summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongwei Wang <hwwang@google.com>2018-03-29 14:27:51 -0700
committerHongwei Wang <hwwang@google.com>2018-04-03 17:16:37 -0700
commit6f315dbfb2288f1c309367efe70bec1628841207 (patch)
treebb510d479daeceb54bc75bb022fb952dbe8f98e6
parent2d5d7ed29b9f77c2ffebc7199331ab72d8d3427b (diff)
downloadcar-6f315dbfb2288f1c309367efe70bec1628841207.tar.gz
Adds audio patch test
audio_hw.c is formatted via clang-format and more debug information for audio patch is added Bug: 77147937 Test: releaseAudioPatch(createAudioPatch(String, int, int)) Change-Id: I5cb02557cc5df31a3d33337905601630c5bd525e
-rw-r--r--emulator/audio/audio_policy_configuration.xml30
-rw-r--r--emulator/audio/driver/audio_hw.c20
2 files changed, 50 insertions, 0 deletions
diff --git a/emulator/audio/audio_policy_configuration.xml b/emulator/audio/audio_policy_configuration.xml
index 2bc3172..30d20f0 100644
--- a/emulator/audio/audio_policy_configuration.xml
+++ b/emulator/audio/audio_policy_configuration.xml
@@ -60,6 +60,8 @@
<item>bus6_notification_out</item>
<item>bus7_system_sound_out</item>
<item>bus0_mic1_in</item>
+ <!-- Test input device port for audio patch -->
+ <item>bus1_audio_patch_test_in</item>
</attachedDevices>
<defaultOutputDevice>bus0_media_out</defaultOutputDevice>
<mixPorts>
@@ -116,6 +118,15 @@
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
+ <!--
+ Test mixport for audio patch,
+ this needs to be present to work around the framework limitation
+ -->
+ <mixPort name="mixport_audio_patch_in" role="sink">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="48000"
+ channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
+ </mixPort>
</mixPorts>
<devicePorts>
<devicePort tagName="bus0_media_out" role="sink" type="AUDIO_DEVICE_OUT_BUS"
@@ -194,6 +205,20 @@
address="bus0_mic1_in">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
+ <gains>
+ <gain name="" mode="AUDIO_GAIN_MODE_JOINT"
+ minValueMB="-8400" maxValueMB="4000" defaultValueMB="0" stepValueMB="100"/>
+ </gains>
+ </devicePort>
+ <!-- Test input device ports for audio patch -->
+ <devicePort tagName="bus1_audio_patch_test_in" type="AUDIO_DEVICE_IN_BUS" role="source"
+ address="bus1_audio_patch_test_in">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
+ <gains>
+ <gain name="" mode="AUDIO_GAIN_MODE_JOINT"
+ minValueMB="-8400" maxValueMB="4000" defaultValueMB="0" stepValueMB="100"/>
+ </gains>
</devicePort>
</devicePorts>
<!-- route declaration, i.e. list all available sources for a given sink -->
@@ -207,6 +232,11 @@
<route type="mix" sink="bus6_notification_out" sources="mixport_bus6_notification_out"/>
<route type="mix" sink="bus7_system_sound_out" sources="mixport_bus7_system_sound_out"/>
<route type="mix" sink="mixport_bus0_mic1_in" sources="bus0_mic1_in"/>
+ <!--
+ Listed source device ports will be routed to desired sinks via audio patch,
+ this route needs to be present to work around framework limitation for now
+ -->
+ <route type="mix" sink="mixport_audio_patch_in" sources="bus1_audio_patch_test_in"/>
</routes>
</module>
diff --git a/emulator/audio/driver/audio_hw.c b/emulator/audio/driver/audio_hw.c
index 24294ca..83d4858 100644
--- a/emulator/audio/driver/audio_hw.c
+++ b/emulator/audio/driver/audio_hw.c
@@ -1360,11 +1360,31 @@ static int adev_create_audio_patch(struct audio_hw_device *dev,
unsigned int num_sinks,
const struct audio_port_config *sinks,
audio_patch_handle_t *handle) {
+ // Logging only, no real work is done here
+ for (int i = 0; i < num_sources; i++) {
+ ALOGD("%s: source[%d] type=%d address=%s", __func__, i, sources[i].type,
+ sources[i].type == AUDIO_PORT_TYPE_DEVICE
+ ? sources[i].ext.device.address
+ : "");
+ }
+ for (int i = 0; i < num_sinks; i++) {
+ ALOGD("%s: sink[%d] type=%d address=%s", __func__, i, sinks[i].type,
+ sinks[i].type == AUDIO_PORT_TYPE_DEVICE ? sinks[i].ext.device.address
+ : "N/A");
+ }
+ if (num_sources == 1 && num_sinks == 1 &&
+ sources[0].type == AUDIO_PORT_TYPE_DEVICE &&
+ sinks[0].type == AUDIO_PORT_TYPE_DEVICE) {
+ // The same audio_patch_handle_t will be passed to release_audio_patch
+ *handle = 42;
+ ALOGD("%s: handle: %d", __func__, *handle);
+ }
return 0;
}
static int adev_release_audio_patch(struct audio_hw_device *dev,
audio_patch_handle_t handle) {
+ ALOGD("%s: handle: %d", __func__, handle);
return 0;
}