aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-11-07 11:08:28 -0500
committerTakashi Iwai <tiwai@suse.de>2014-11-09 12:20:40 -0500
commit1fb8510cdb5b7befe8a59f533c7fc12ef0dac73e (patch)
treeb44569425ea7683d02893cfd145081a11d7677f1 /sound/usb
parent31584ed18c073176a7ad96ddbfd09765e21e813d (diff)
ALSA: pcm: Add snd_pcm_stop_xrun() helper
Add a new helper function snd_pcm_stop_xrun() to the standard sequnce lock/snd_pcm_stop(XRUN)/unlock by a single call, and replace the existing open codes with this helper. The function checks the PCM running state to prevent setting the wrong state, too, for more safety. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/6fire/pcm.c17
-rw-r--r--sound/usb/endpoint.c4
-rw-r--r--sound/usb/misc/ua101.c18
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c9
4 files changed, 11 insertions, 37 deletions
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index ba40489b2de4..36f4115eb1cd 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -679,25 +679,16 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
679void usb6fire_pcm_abort(struct sfire_chip *chip) 679void usb6fire_pcm_abort(struct sfire_chip *chip)
680{ 680{
681 struct pcm_runtime *rt = chip->pcm; 681 struct pcm_runtime *rt = chip->pcm;
682 unsigned long flags;
683 int i; 682 int i;
684 683
685 if (rt) { 684 if (rt) {
686 rt->panic = true; 685 rt->panic = true;
687 686
688 if (rt->playback.instance) { 687 if (rt->playback.instance)
689 snd_pcm_stream_lock_irqsave(rt->playback.instance, flags); 688 snd_pcm_stop_xrun(rt->playback.instance);
690 snd_pcm_stop(rt->playback.instance,
691 SNDRV_PCM_STATE_XRUN);
692 snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags);
693 }
694 689
695 if (rt->capture.instance) { 690 if (rt->capture.instance)
696 snd_pcm_stream_lock_irqsave(rt->capture.instance, flags); 691 snd_pcm_stop_xrun(rt->capture.instance);
697 snd_pcm_stop(rt->capture.instance,
698 SNDRV_PCM_STATE_XRUN);
699 snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags);
700 }
701 692
702 for (i = 0; i < PCM_N_URBS; i++) { 693 for (i = 0; i < PCM_N_URBS; i++) {
703 usb_poison_urb(&rt->in_urbs[i].instance); 694 usb_poison_urb(&rt->in_urbs[i].instance);
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index a4679913b0aa..03b074419964 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -391,9 +391,7 @@ static void snd_complete_urb(struct urb *urb)
391 usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err); 391 usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err);
392 if (ep->data_subs && ep->data_subs->pcm_substream) { 392 if (ep->data_subs && ep->data_subs->pcm_substream) {
393 substream = ep->data_subs->pcm_substream; 393 substream = ep->data_subs->pcm_substream;
394 snd_pcm_stream_lock_irqsave(substream, flags); 394 snd_pcm_stop_xrun(substream);
395 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
396 snd_pcm_stream_unlock_irqrestore(substream, flags);
397 } 395 }
398 396
399exit_clear: 397exit_clear:
diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
index a1bab149df4d..9581089c28c5 100644
--- a/sound/usb/misc/ua101.c
+++ b/sound/usb/misc/ua101.c
@@ -613,24 +613,14 @@ static int start_usb_playback(struct ua101 *ua)
613 613
614static void abort_alsa_capture(struct ua101 *ua) 614static void abort_alsa_capture(struct ua101 *ua)
615{ 615{
616 unsigned long flags; 616 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states))
617 617 snd_pcm_stop_xrun(ua->capture.substream);
618 if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) {
619 snd_pcm_stream_lock_irqsave(ua->capture.substream, flags);
620 snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN);
621 snd_pcm_stream_unlock_irqrestore(ua->capture.substream, flags);
622 }
623} 618}
624 619
625static void abort_alsa_playback(struct ua101 *ua) 620static void abort_alsa_playback(struct ua101 *ua)
626{ 621{
627 unsigned long flags; 622 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states))
628 623 snd_pcm_stop_xrun(ua->playback.substream);
629 if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) {
630 snd_pcm_stream_lock_irqsave(ua->playback.substream, flags);
631 snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN);
632 snd_pcm_stream_unlock_irqrestore(ua->playback.substream, flags);
633 }
634} 624}
635 625
636static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, 626static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream,
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index a63330dd1407..61d5dc2a3421 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -272,13 +272,8 @@ static void usX2Y_clients_stop(struct usX2Ydev *usX2Y)
272 for (s = 0; s < 4; s++) { 272 for (s = 0; s < 4; s++) {
273 struct snd_usX2Y_substream *subs = usX2Y->subs[s]; 273 struct snd_usX2Y_substream *subs = usX2Y->subs[s];
274 if (subs) { 274 if (subs) {
275 if (atomic_read(&subs->state) >= state_PRERUNNING) { 275 if (atomic_read(&subs->state) >= state_PRERUNNING)
276 unsigned long flags; 276 snd_pcm_stop_xrun(subs->pcm_substream);
277
278 snd_pcm_stream_lock_irqsave(subs->pcm_substream, flags);
279 snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN);
280 snd_pcm_stream_unlock_irqrestore(subs->pcm_substream, flags);
281 }
282 for (u = 0; u < NRURBS; u++) { 277 for (u = 0; u < NRURBS; u++) {
283 struct urb *urb = subs->urb[u]; 278 struct urb *urb = subs->urb[u];
284 if (NULL != urb) 279 if (NULL != urb)