Use returned config to retry opening MMAP stream when fails.

When opening MMAP stream, it may fail at the first try as the requested
configuration may not match what the HAL supports. The audio policy
manager knows all the information that the HAL supports. In that case,
when it fails at the first try, audio policy manager is able to return
the supported configurations. After getting the supported
configuration, the aaudio service can retry opening MMAP stream with the
supported configuration.

Bug: 226190094
Test: atest AAudioTests AudioTrackTest AudioRecordTest
Test: atest DirectAudioProfilesForAttributesTest
Change-Id: Id6ccae3e26d7ffc8fe4c3c7babe825a08d22aa78
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index a68f63e..7f0fc1f 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -597,6 +597,11 @@
                                             (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_MMAP_NOIRQ |
                                                     AUDIO_OUTPUT_FLAG_DIRECT),
                                             deviceId, &portId, &secondaryOutputs, &isSpatialized);
+        if (ret != NO_ERROR) {
+            config->sample_rate = fullConfig.sample_rate;
+            config->channel_mask = fullConfig.channel_mask;
+            config->format = fullConfig.format;
+        }
         ALOGW_IF(!secondaryOutputs.empty(),
                  "%s does not support secondary outputs, ignoring them", __func__);
     } else {