ALSA: line6: Sync PCM stop at disconnect
authorTakashi Iwai <tiwai@suse.de>
Mon, 19 Jan 2015 15:15:54 +0000 (16:15 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 20 Jan 2015 07:18:44 +0000 (08:18 +0100)
Call line6_pcm_disconnect() at disconnect to make sure that all URBs
are cleared.  Also reduce the superfluous snd_pcm_stop() calls from
the function (and remove the unused function) since the streams are
guaranteed to be stopped at this point via snd_card_disconnect().

Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/line6/driver.c
sound/usb/line6/pcm.c

index f222d9ffeca5bb8d26d7c346187a90d19c91b898..1193d16396a0731983083d7cf5c0fa9a02b6d428 100644 (file)
@@ -670,6 +670,8 @@ void line6_disconnect(struct usb_interface *interface)
                dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n");
 
        snd_card_disconnect(line6->card);
+       if (line6->line6pcm)
+               line6_pcm_disconnect(line6->line6pcm);
        if (line6->disconnect)
                line6->disconnect(interface);
 
index 39034c7681dafd15416f45b920b912ac7e253434..08fa9753a68084954b88af1a1890dab52acd719e 100644 (file)
@@ -379,30 +379,13 @@ static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret)
 }
 
 /*
-       Stop substream if still running.
-*/
-static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
-{
-       if (substream->runtime && snd_pcm_running(substream)) {
-               snd_pcm_stream_lock_irq(substream);
-               snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
-               snd_pcm_stream_unlock_irq(substream);
-       }
-}
-
-/*
-       Stop PCM stream.
+       Sync with PCM stream stops.
 */
 void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm)
 {
-       pcm_disconnect_substream(get_substream
-                                (line6pcm, SNDRV_PCM_STREAM_CAPTURE));
-       pcm_disconnect_substream(get_substream
-                                (line6pcm, SNDRV_PCM_STREAM_PLAYBACK));
        line6_unlink_wait_clear_audio_out_urbs(line6pcm);
        line6_unlink_wait_clear_audio_in_urbs(line6pcm);
 }
-EXPORT_SYMBOL_GPL(line6_pcm_disconnect);
 
 /*
        Create and register the PCM device and mixer entries.