summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongwei Wang <hwwang@google.com>2018-06-07 10:04:53 -0700
committerHongwei Wang <hwwang@google.com>2018-06-13 15:07:26 -0700
commitda23d848426881ef2275e37389f0ad21d9eecf0e (patch)
tree8796d9333bd6283e73444cfcb7a2fad1c88d367a
parent6f3ae29a9d8be05b812cbfde5b04c15d9356bf4d (diff)
downloaddevice_generic_car-da23d848426881ef2275e37389f0ad21d9eecf0e.tar.gz
device_generic_car-da23d848426881ef2275e37389f0ad21d9eecf0e.tar.bz2
device_generic_car-da23d848426881ef2275e37389f0ad21d9eecf0e.zip
Adds broadcast radio 2.0 default HAL to car emulator
Also, uses broadcast radio to better demonstrate audio patch as an end-to-end case. We can further surface pseudo broadcast radio audio stream. Bug: 110166790 Test: launch radio app in gcar_emu_x86-userdebug Change-Id: I3871e7ef5408a7ae15ea35c80176dc0d00dae200
-rw-r--r--common/car.mk2
-rw-r--r--common/manifest.xml4
-rw-r--r--emulator/audio/audio_policy_configuration.xml36
-rw-r--r--emulator/audio/driver/audio_hw.c8
-rw-r--r--emulator/audio/driver/audio_hw.h7
-rw-r--r--emulator/hal/car_emulator_manifest.xml9
6 files changed, 27 insertions, 39 deletions
diff --git a/common/car.mk b/common/car.mk
index 27860b3..871d828 100644
--- a/common/car.mk
+++ b/common/car.mk
@@ -16,6 +16,7 @@
# Auto modules
PRODUCT_PACKAGES += \
+ android.hardware.broadcastradio@2.0-service \
android.hardware.automotive.vehicle@2.0-service
# Emulator configuration
@@ -41,6 +42,7 @@ PRODUCT_COPY_FILES += \
# Vendor Interface Manifest
PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.broadcastradio.xml:system/etc/permissions/android.hardware.broadcastradio.xml \
device/generic/car/common/manifest.xml:$(TARGET_COPY_OUT_VENDOR)/manifest.xml
PRODUCT_PROPERTY_OVERRIDES += \
diff --git a/common/manifest.xml b/common/manifest.xml
index f27e715..bfe0d2b 100644
--- a/common/manifest.xml
+++ b/common/manifest.xml
@@ -108,9 +108,9 @@
<hal format="hidl">
<name>android.hardware.broadcastradio</name>
<transport>hwbinder</transport>
- <version>1.0</version>
+ <version>2.0</version>
<interface>
- <name>IBroadcastRadioFactory</name>
+ <name>IBroadcastRadio</name>
<instance>default</instance>
</interface>
</hal>
diff --git a/emulator/audio/audio_policy_configuration.xml b/emulator/audio/audio_policy_configuration.xml
index eb1d453..44e4666 100644
--- a/emulator/audio/audio_policy_configuration.xml
+++ b/emulator/audio/audio_policy_configuration.xml
@@ -61,9 +61,7 @@
<item>bus7_system_sound_out</item>
<item>Built-In Mic</item>
<item>Built-In Back Mic</item>
- <item>bus0_mic1_in</item>
- <!-- Test input device port for audio patch -->
- <item>bus1_audio_patch_test_in</item>
+ <item>FM Tuner</item>
</attachedDevices>
<defaultOutputDevice>bus0_media_out</defaultOutputDevice>
<mixPorts>
@@ -120,16 +118,7 @@
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
</mixPort>
- <mixPort name="mixport_bus0_mic1_in" role="sink">
- <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
- 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">
+ <mixPort name="mixport_tuner0" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
@@ -218,18 +207,8 @@
samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
</devicePort>
- <devicePort tagName="bus0_mic1_in" type="AUDIO_DEVICE_IN_BUS" role="source"
- 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="-3200" maxValueMB="600" 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">
+ <devicePort tagName="FM Tuner" type="AUDIO_DEVICE_IN_FM_TUNER" role="source"
+ address="tuner0">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_STEREO"/>
<gains>
@@ -249,12 +228,7 @@
<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="primary input" sources="Built-In Mic,Built-In Back Mic"/>
- <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"/>
+ <route type="mix" sink="mixport_tuner0" sources="FM Tuner"/>
</routes>
</module>
diff --git a/emulator/audio/driver/audio_hw.c b/emulator/audio/driver/audio_hw.c
index 807cc15..1c17683 100644
--- a/emulator/audio/driver/audio_hw.c
+++ b/emulator/audio/driver/audio_hw.c
@@ -1237,7 +1237,7 @@ 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
+ struct generic_audio_device *audio_dev = (struct generic_audio_device *)dev;
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
@@ -1252,8 +1252,10 @@ static int adev_create_audio_patch(struct audio_hw_device *dev,
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;
+ pthread_mutex_lock(&audio_dev->lock);
+ audio_dev->last_patch_id += 1;
+ pthread_mutex_unlock(&audio_dev->lock);
+ *handle = audio_dev->last_patch_id;
ALOGD("%s: handle: %d", __func__, *handle);
}
return 0;
diff --git a/emulator/audio/driver/audio_hw.h b/emulator/audio/driver/audio_hw.h
index 41217ad..21eda66 100644
--- a/emulator/audio/driver/audio_hw.h
+++ b/emulator/audio/driver/audio_hw.h
@@ -28,9 +28,10 @@
struct generic_audio_device {
struct audio_hw_device device; // Constant after init
pthread_mutex_t lock;
- bool master_mute; // Proteced by this->lock
- bool mic_mute; // Proteced by this->lock
- struct mixer *mixer; // Proteced by this->lock
+ unsigned int last_patch_id; // Protected by this->lock
+ bool master_mute; // Protected by this->lock
+ bool mic_mute; // Protected by this->lock
+ struct mixer *mixer; // Protected by this->lock
Hashmap *out_bus_stream_map; // Extended field. Constant after init
};
diff --git a/emulator/hal/car_emulator_manifest.xml b/emulator/hal/car_emulator_manifest.xml
index 0e09a8f..9ab23f7 100644
--- a/emulator/hal/car_emulator_manifest.xml
+++ b/emulator/hal/car_emulator_manifest.xml
@@ -199,6 +199,15 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="hidl">
+ <name>android.hardware.broadcastradio</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IBroadcastRadio</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<sepolicy>
<version>10000.0</version>
</sepolicy>