release-request-7f84484c-eec6-4577-8d5a-55079be4f3c5-for-git_oc-mr1-release-4262309 snap-temp-L02100000091441105
Change-Id: Iac308175409c7f7fb1764a0765c5f6e7f4b35224
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index d7b9dc9..561f4a5 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1793,6 +1793,15 @@
/* Must be called after removing the usecase from list */
if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)
check_and_set_hdmi_channels(adev, DEFAULT_HDMI_OUT_CHANNELS);
+ else if (out->devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) {
+ struct listnode *node;
+ struct audio_usecase *usecase;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if (usecase->devices & AUDIO_DEVICE_OUT_SPEAKER)
+ select_devices(adev, usecase->id);
+ }
+ }
ALOGV("%s: exit: status(%d)", __func__, ret);
return ret;
@@ -2174,6 +2183,15 @@
return out == adev->primary_output || out == adev->voice_tx_output;
}
+static int get_alive_usb_card(struct str_parms* parms) {
+ int card;
+ if ((str_parms_get_int(parms, "card", &card) >= 0) &&
+ !audio_extn_usb_alive(card)) {
+ return card;
+ }
+ return -ENODEV;
+}
+
static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
{
struct stream_out *out = (struct stream_out *)stream;
@@ -2211,9 +2229,11 @@
// Workaround: If routing to an non existing usb device, fail gracefully
// The routing request will otherwise block during 10 second
- if (audio_is_usb_out_device(new_dev) && !audio_extn_usb_alive(adev->snd_card)) {
- ALOGW("out_set_parameters() ignoring rerouting to non existing USB card %d",
- adev->snd_card);
+ int card;
+ if (audio_is_usb_out_device(new_dev) &&
+ (card = get_alive_usb_card(parms)) >= 0) {
+
+ ALOGW("out_set_parameters() ignoring rerouting to non existing USB card %d", card);
pthread_mutex_unlock(&adev->lock);
pthread_mutex_unlock(&out->lock);
status = -ENOSYS;
@@ -3140,9 +3160,11 @@
// Workaround: If routing to an non existing usb device, fail gracefully
// The routing request will otherwise block during 10 second
- if (audio_is_usb_in_device(val) && !audio_extn_usb_alive(adev->snd_card)) {
- ALOGW("in_set_parameters() ignoring rerouting to non existing USB card %d",
- adev->snd_card);
+ int card;
+ if (audio_is_usb_in_device(val) &&
+ (card = get_alive_usb_card(parms)) >= 0) {
+
+ ALOGW("in_set_parameters() ignoring rerouting to non existing USB card %d", card);
status = -ENOSYS;
} else {