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

Commit 67c12fe4 authored by Richard Folke Tullberg's avatar Richard Folke Tullberg Committed by Edward Savage-Jones
Browse files

HiRes: Check mixport samplerates

Samplerate will check the delta between mixport and content.
It will weigh higher the closer the delta between mixport
and content is. If content has higher samplerate than mixport
allows, the highest samplerate will be chosen.

Bug: 303085342
Test: atest AudioTrackTest
Change-Id: If6956bd8b1113e2f211f24071c43e888eae1cbb0
parent bd98dc51
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2086,7 +2086,14 @@ audio_io_handle_t AudioPolicyManager::selectOutput(const SortedVector<audio_io_h

        // sampling rate match
        if (samplingRate > SAMPLE_RATE_HZ_DEFAULT) {
            currentMatchCriteria[4] = outputDesc->getSamplingRate();
            int diff;  // avoid unsigned integer overflow.
            __builtin_sub_overflow(outputDesc->getSamplingRate(), samplingRate, &diff);

            // prefer the closest output sampling rate greater than or equal to target
            // if none exists, prefer the closest output sampling rate less than target.
            //
            // criteria is offset to make non-negative.
            currentMatchCriteria[4] = diff >= 0 ? -diff + 200'000'000 : diff + 100'000'000;
        }

        // performance flags match