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

Commit f1bc7f9c authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Fix timestretch AV sync

am: 3da7f05a

Change-Id: I77bc91b812c67ecbdb5d301b4d3928797d80649c
parents afcd6783 3da7f05a
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -474,18 +474,18 @@ void TimestretchBufferProvider::processFrames(void *dstBuffer, size_t *dstFrames
    ALOGV("processFrames(%zu %zu)  remaining(%zu)", *dstFrames, *srcFrames, mRemaining);
    // Note dstFrames is the required number of frames.

    if (!mAudioPlaybackRateValid) {
        //fallback mode
        // Ensure consumption from src is as expected.
        // TODO: add logic to track "very accurate" consumption related to speed, original sampling
        // rate, actual frames processed.

        const size_t targetSrc = *dstFrames * mPlaybackRate.mSpeed;
        if (*srcFrames < targetSrc) { // limit dst frames to that possible
            *dstFrames = *srcFrames / mPlaybackRate.mSpeed;
        } else if (*srcFrames > targetSrc + 1) {
            *srcFrames = targetSrc + 1;
        }

    if (!mAudioPlaybackRateValid) {
        //fallback mode
        if (*dstFrames > 0) {
            switch(mPlaybackRate.mFallbackMode) {
            case AUDIO_TIMESTRETCH_FALLBACK_CUT_REPEAT: