Select the highest sampling rate if the requested is higher than default

Currently, when selecting output, the sample rate will only be
considered if the output sample rate is higher than the requested. In
this CL, the highest sampling rate will be selected if the requested
sampling rate is higher than default.

Bug: 232062000
Test: atest AudioTrackTest
Change-Id: I40391fe3c8f73ff28e519f5b187adb5717e45235
Merged-In: I40391fe3c8f73ff28e519f5b187adb5717e45235
(cherry picked from commit b12a6da58b69e13e9bc793e530cb055059bace78)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 744609f..3f0de54 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1868,7 +1868,8 @@
     //    (see b/200293124, the incorrect selection of AUDIO_OUTPUT_FLAG_VOIP_RX).
     // 3: the output supporting the exact channel mask
     // 4: the output with a higher channel count than requested
-    // 5: the output with a higher sampling rate than requested
+    // 5: the output with the highest sampling rate if the requested sample rate is
+    //    greater than default sampling rate
     // 6: the output with the highest number of requested performance flags
     // 7: the output with the bit depth the closest to the requested one
     // 8: the primary output
@@ -1928,8 +1929,7 @@
         }
 
         // sampling rate match
-        if (samplingRate > SAMPLE_RATE_HZ_DEFAULT &&
-                samplingRate <= outputDesc->getSamplingRate()) {
+        if (samplingRate > SAMPLE_RATE_HZ_DEFAULT) {
             currentMatchCriteria[4] = outputDesc->getSamplingRate();
         }