ALSA: usb: Handle unplug during multiple devices
Rahul Mittal [Wed, 16 Oct 2013 06:04:26 +0000 (11:04 +0530)]
Set usb_audio switch state to DISCONNECTED only if
the device with active audio (i.e. the one which was
plugged-in earliest) is unplugged. Hence, unplugging
other devices won't disturb active audio.

Bug 1368093

Change-Id: I461c58cf15b20220fa627634423b6e23112ad64b
Signed-off-by: Rahul Mittal <rmittal@nvidia.com>
Reviewed-on: http://git-master/r/299797
Reviewed-by: Scott Peterson <speterson@nvidia.com>
GVS: Gerrit_Virtual_Submit

sound/usb/card.c

index 080ae81..e0c0e25 100644 (file)
@@ -604,6 +604,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
 {
        struct snd_card *card;
        struct list_head *p, *n;
+       int i;
 
        if (chip == (void *)-1L)
                return;
@@ -617,7 +618,12 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
        chip->num_interfaces--;
 
 #ifdef CONFIG_SWITCH
-       switch_set_state(&usb_switch_dev, STATE_DISCONNECTED);
+       for (i = 0; i < chip->index; i++) {
+               if (usb_chip[i])
+                       break;
+       }
+       if (i == chip->index)
+               switch_set_state(&usb_switch_dev, STATE_DISCONNECTED);
 #endif
 
        if (chip->num_interfaces <= 0) {