diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-11-07 11:08:28 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-11-09 12:20:40 -0500 |
commit | 1fb8510cdb5b7befe8a59f533c7fc12ef0dac73e (patch) | |
tree | b44569425ea7683d02893cfd145081a11d7677f1 /sound/usb/misc/ua101.c | |
parent | 31584ed18c073176a7ad96ddbfd09765e21e813d (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/misc/ua101.c')
-rw-r--r-- | sound/usb/misc/ua101.c | 18 |
1 files changed, 4 insertions, 14 deletions
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 | ||
614 | static void abort_alsa_capture(struct ua101 *ua) | 614 | static 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 | ||
625 | static void abort_alsa_playback(struct ua101 *ua) | 620 | static 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 | ||
636 | static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, | 626 | static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, |