Blend MMAP streams for accessibility

There is an accessibility feature called Mono audio. This feature
allows stereo audio to be blended into mono audio.

Currently, this feature works perfectly in most scenarios. However,
this feature is not used when MMAP is enabled. This cl fixes MMAP
scenarios.

Bug: 69635707
Test: Tested on Bramble and MMAP through the following six scenarios:
1. MMAP Exclusive Mono Audio Enabled
2. MMAP Shared Mono Audio Enabled
3. No MMAP Mono Audio Enabled
4. MMAP Exclusive Mono Audio Disabled
5. MMAP Shared Mono Audio Disabled
6. No MMAP Mono Audio Disabled
You can enable Mono Audio from Settings -> Accessibility -> Audio
adjustment -> Mono audio
With OboeTester playing a different frequency on each ear, this seems
to work as expected.
atest test_flowgraph

Change-Id: I2688f06cc8c6ef0f2965845e65e2582f3cc9788e
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index 89d42bf..1b8e224 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -27,6 +27,7 @@
 #include <aaudio/AAudio.h>
 #include <cutils/properties.h>
 
+#include <media/AudioParameter.h>
 #include <media/AudioSystem.h>
 #include <media/MediaMetricsItem.h>
 #include <utils/Trace.h>
@@ -270,6 +271,15 @@
         mCallbackBuffer = std::make_unique<uint8_t[]>(callbackBufferSize);
     }
 
+    // Exclusive output streams should combine channels when mono audio adjustment
+    // is enabled.
+    if ((getDirection() == AAUDIO_DIRECTION_OUTPUT) &&
+        (getSharingMode() == AAUDIO_SHARING_MODE_EXCLUSIVE)) {
+        bool isMasterMono = false;
+        android::AudioSystem::getMasterMono(&isMasterMono);
+        setRequireMonoBlend(isMasterMono);
+    }
+
     // For debugging and analyzing the distribution of MMAP timestamps.
     // For OUTPUT, use a NEGATIVE offset to move the CPU writes further BEFORE the HW reads.
     // For INPUT, use a POSITIVE offset to move the CPU reads further AFTER the HW writes.