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

Commit 1e7bc668 authored by Glenn Kasten's avatar Glenn Kasten Committed by Android (Google) Code Review
Browse files

Merge "Fix underruns when sample rate != native sample rate"

parents 4b58d70b bb6f0a0b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -861,8 +861,10 @@ status_t AudioTrack::createTrack_l(

        // Ensure that buffer depth covers at least audio hardware latency
        uint32_t minBufCount = afLatency / ((1000 * afFrameCount)/afSampleRate);
        if (minBufCount < 2) {
            minBufCount = 2;
        ALOGV("afFrameCount=%d, minBufCount=%d, afSampleRate=%u, afLatency=%d",
                afFrameCount, minBufCount, afSampleRate, afLatency);
        if (minBufCount <= 2) {
            minBufCount = sampleRate == afSampleRate ? 2 : 3;
        }

        size_t minFrameCount = (afFrameCount*sampleRate*minBufCount)/afSampleRate;