Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c13b7cf2 authored by Andy Hung's avatar Andy Hung
Browse files

AudioRecord: Fix capture timestamp after standby

Fix AudioStreamIn getCapturePosition handling since it
is also used for linear PCM.

Test: atest AudioRecordTest
Bug: 308526758
Change-Id: Ia07e1ef0b15e7dace1dca882e7ab75df09706c9c
parent 11481c90
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -56,15 +56,15 @@ status_t AudioStreamIn::getCapturePosition(int64_t* frames, int64_t* time)
        return status;
    }

    // Adjust for standby using HAL rate frames.
    // Only apply this correction if the HAL is getting PCM frames.
    if (mHalFormatHasProportionalFrames) {
    if (mHalFormatHasProportionalFrames &&
            (flags & AUDIO_INPUT_FLAG_DIRECT) == AUDIO_INPUT_FLAG_DIRECT) {
        // For DirectRecord reset timestamp to 0 on standby.
        const uint64_t adjustedPosition = (halPosition <= mFramesReadAtStandby) ?
                0 : (halPosition - mFramesReadAtStandby);
        // Scale from HAL sample rate to application rate.
        *frames = adjustedPosition / mRateMultiplier;
    } else {
        // For compressed formats.
        // For compressed formats and linear PCM.
        *frames = halPosition;
    }