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

Commit 53c13f52 authored by Satya Krishna Pindiproli's avatar Satya Krishna Pindiproli Committed by Steve Kondik
Browse files

audioflinger: update multiplier logic to calculate frameCount

If the value of the multiplier used in calculating
mNormalFrameCount is odd, it is rounded off to a higher even value.

This results in an increase of mNormalFrameCount and thereby
the latency which is not expected.

Do not prefer an even multiplier and let the value remain as is
even if it is odd.

CRs-Fixed: 931454
Change-Id: Ia60d87d01caef6f45998bffeafc3d6a24f7c7fb4
parent a58a4799
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -2185,6 +2185,7 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l()
            kUseFastMixer == FastMixer_Dynamic)) {
        size_t minNormalFrameCount = (kMinNormalSinkBufferSizeMs * mSampleRate) / 1000;
        size_t maxNormalFrameCount = (kMaxNormalSinkBufferSizeMs * mSampleRate) / 1000;

        // round up minimum and round down maximum to nearest 16 frames to satisfy AudioMixer
        minNormalFrameCount = (minNormalFrameCount + 15) & ~15;
        maxNormalFrameCount = maxNormalFrameCount & ~15;
@@ -2200,19 +2201,6 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l()
            } else {
                multiplier = (double) maxNormalFrameCount / (double) mFrameCount;
            }
        } else {
            // prefer an even multiplier, for compatibility with doubling of fast tracks due to HAL
            // SRC (it would be unusual for the normal sink buffer size to not be a multiple of fast
            // track, but we sometimes have to do this to satisfy the maximum frame count
            // constraint)
            // FIXME this rounding up should not be done if no HAL SRC
            uint32_t truncMult = (uint32_t) multiplier;
            if ((truncMult & 1)) {
                if ((truncMult + 1) * mFrameCount <= maxNormalFrameCount) {
                    ++truncMult;
                }
            }
            multiplier = (double) truncMult;
        }
    }
    mNormalFrameCount = multiplier * mFrameCount;