Routing to usb was rejected due to incorrect card number am: 1e02c88b8f am: 8c80fab3a1
am: e5a89f5fc4
Change-Id: Ie7b1e7971871e49cb1e4ba36bcd834653508f225
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 6126823..72e5c05 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2174,6 +2174,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 +2220,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 +3151,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 {