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

Commit 5bbd8eda authored by Andy Hung's avatar Andy Hung
Browse files

AudioStreamOut: Align with AudioStreamIn

Currenty the MixerThread bypasses AudioStreamOut::getPresentationPosition so
inaccuracy in handling is avoided.  Fix this to work for the linear PCM
case.

Test: atest AudioTrackTest (with and without AudioStreamOut usage)
Bug: 326134469
Merged-In: I630d1e79bd591e6ce5e99ccec1df094e989be2f1
Change-Id: I630d1e79bd591e6ce5e99ccec1df094e989be2f1
parent 0c5d37c0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -99,15 +99,15 @@ status_t AudioStreamOut::getPresentationPosition(uint64_t *frames, struct timesp
        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_OUTPUT_FLAG_DIRECT) == AUDIO_OUTPUT_FLAG_DIRECT) {
        // For DirectTrack reset timestamp to 0 on standby.
        const uint64_t adjustedPosition = (halPosition <= mFramesWrittenAtStandby) ?
                0 : (halPosition - mFramesWrittenAtStandby);
        // Scale from HAL sample rate to application rate.
        *frames = adjustedPosition / mRateMultiplier;
    } else {
        // For offloaded MP3 and other compressed formats.
        // For offloaded MP3 and other compressed formats, and linear PCM.
        *frames = halPosition;
    }