[BUG] Fails to find a profile for AudioSource for Direct Output
When trying to start an audio source expected to be routed on a Direct
Output, it fails on identifying the matching profile due to wrong
channel mask.
The channel mask is taken from the source port configuration, which
is an input device. Thus, it fails to apply to identify a sink profile.
Bug: 238058094
Test: adb shell ./data/nativetest/AudioPolicyEmulatorTests/AudioPolicyEmulatorTests --gtest_filter=*AudioSourceBridgingTest.UsingAudioSourceAPI/4
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Change-Id: I6c460ea765b5eb8ec26e56547e8262beb347f2b2
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 2c5a61f..0135183 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -4519,7 +4519,11 @@
audio_attributes_t resultAttr;
audio_config_t config = AUDIO_CONFIG_INITIALIZER;
config.sample_rate = sourceDesc->config().sample_rate;
- config.channel_mask = sourceDesc->config().channel_mask;
+ audio_channel_mask_t sourceMask = sourceDesc->config().channel_mask;
+ config.channel_mask =
+ (audio_channel_mask_get_representation(sourceMask)
+ == AUDIO_CHANNEL_REPRESENTATION_INDEX) ? sourceMask
+ : audio_channel_mask_in_to_out(sourceMask);
config.format = sourceDesc->config().format;
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE;
audio_port_handle_t selectedDeviceId = AUDIO_PORT_HANDLE_NONE;