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

Commit 9b70ca24 authored by Robert Wu's avatar Robert Wu
Browse files

AAudio: Avoid scaling capacity with sample rate

When the apps using AAudio explicitly set the capacity, AAudio should
try its best to respect this capacity set.

This includes streams with sample rate conversion.

This CL prescales capacity by (deviceSampleRate / sampleRate) so that
when the capacity is scaled by (sampleRate / deviceSampleRate), it
will work as intended.

Bug: 382715299
Bug: 382390990
Test: atest AAudioTests
Test: OboeTester Test Glitches
Flag: EXEMPT bugfix
Change-Id: I427aef8364bb50fe7858aedc27ed7a9834f0940c
parent 55d0ea49
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -134,7 +134,12 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) {
    request.getConfiguration().setInputPreset(getInputPreset());
    request.getConfiguration().setPrivacySensitive(isPrivacySensitive());

    request.getConfiguration().setBufferCapacity(builder.getBufferCapacity());
    // When sample rate conversion is needed, we use the device sample rate instead of the
    // requested sample rate to scale the capacity in configureDataInformation().
    // Thus, we should scale the capacity here to cancel out the (sampleRate / deviceSampleRate)
    // scaling there.
    request.getConfiguration().setBufferCapacity(builder.getBufferCapacity()
            * 48000 / getSampleRate());

    mServiceStreamHandleInfo = mServiceInterface.openStream(request, configurationOutput);
    if (getServiceHandle() < 0