dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
dev->dmasound.bufsize, dev->dmasound.blocks);
spin_unlock(&dev->slock);
- snd_pcm_stream_lock(dev->dmasound.substream);
- snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock(dev->dmasound.substream);
+ snd_pcm_stop_xrun(dev->dmasound.substream);
return;
}
int snd_pcm_start(struct snd_pcm_substream *substream);
int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
int snd_pcm_drain_done(struct snd_pcm_substream *substream);
+int snd_pcm_stop_xrun(struct snd_pcm_substream *substream);
#ifdef CONFIG_PM
int snd_pcm_suspend(struct snd_pcm_substream *substream);
int snd_pcm_suspend_all(struct snd_pcm *pcm);
} else {
printk(KERN_ERR "DMA error on channel %d (DCSR=%#x)\n",
dma_ch, dcsr);
- snd_pcm_stream_lock(substream);
- snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock(substream);
+ snd_pcm_stop_xrun(substream);
}
}
EXPORT_SYMBOL(pxa2xx_pcm_dma_irq);
SNDRV_PCM_STATE_SETUP);
}
+/**
+ * snd_pcm_stop_xrun - stop the running streams as XRUN
+ * @substream: the PCM substream instance
+ * @state: PCM state after stopping the stream
+ *
+ * This stops the given running substream (and all linked substreams) as XRUN.
+ * Unlike snd_pcm_stop(), this function takes the substream lock by itself.
+ *
+ * Return: Zero if successful, or a negative error code.
+ */
+int snd_pcm_stop_xrun(struct snd_pcm_substream *substream)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ snd_pcm_stream_lock_irqsave(substream, flags);
+ if (snd_pcm_running(substream))
+ ret = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+ snd_pcm_stream_unlock_irqrestore(substream, flags);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_pcm_stop_xrun);
+
/*
* pause callbacks
*/
struct snd_pcm_substream *pcm;
pcm = ACCESS_ONCE(s->pcm);
- if (pcm) {
- snd_pcm_stream_lock_irq(pcm);
- if (snd_pcm_running(pcm))
- snd_pcm_stop(pcm, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irq(pcm);
- }
+ if (pcm)
+ snd_pcm_stop_xrun(pcm);
}
EXPORT_SYMBOL(amdtp_stream_pcm_abort);
static void isight_pcm_abort(struct isight *isight)
{
- unsigned long flags;
-
- if (ACCESS_ONCE(isight->pcm_active)) {
- snd_pcm_stream_lock_irqsave(isight->pcm, flags);
- if (snd_pcm_running(isight->pcm))
- snd_pcm_stop(isight->pcm, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(isight->pcm, flags);
- }
+ if (ACCESS_ONCE(isight->pcm_active))
+ snd_pcm_stop_xrun(isight->pcm);
}
static void isight_dropped_samples(struct isight *isight, unsigned int total)
s->number);
ds->drained_count++;
if (ds->drained_count > 20) {
- unsigned long flags;
- snd_pcm_stream_lock_irqsave(s, flags);
- snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(s, flags);
+ snd_pcm_stop_xrun(s);
continue;
}
} else {
if (! dma->substream || ! dma->running)
return;
dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
- snd_pcm_stream_lock(dma->substream);
- snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock(dma->substream);
+ snd_pcm_stop_xrun(dma->substream);
}
/*
if (! dma->substream || ! dma->running)
return;
dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
- snd_pcm_stream_lock(dma->substream);
- snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock(dma->substream);
+ snd_pcm_stop_xrun(dma->substream);
}
/*
/* stop RX and capture: will be enabled again at restart */
ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable);
- snd_pcm_stream_lock(substream);
- snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock(substream);
+ snd_pcm_stop_xrun(substream);
/* now drain RHR and read status to remove xrun condition */
ssc_readx(prtd->ssc->regs, SSC_RHR);
*/
static void fsl_dma_abort_stream(struct snd_pcm_substream *substream)
{
- unsigned long flags;
-
- snd_pcm_stream_lock_irqsave(substream, flags);
-
- if (snd_pcm_running(substream))
- snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
-
- snd_pcm_stream_unlock_irqrestore(substream, flags);
+ snd_pcm_stop_xrun(substream);
}
/**
void usb6fire_pcm_abort(struct sfire_chip *chip)
{
struct pcm_runtime *rt = chip->pcm;
- unsigned long flags;
int i;
if (rt) {
rt->panic = true;
- if (rt->playback.instance) {
- snd_pcm_stream_lock_irqsave(rt->playback.instance, flags);
- snd_pcm_stop(rt->playback.instance,
- SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags);
- }
+ if (rt->playback.instance)
+ snd_pcm_stop_xrun(rt->playback.instance);
- if (rt->capture.instance) {
- snd_pcm_stream_lock_irqsave(rt->capture.instance, flags);
- snd_pcm_stop(rt->capture.instance,
- SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags);
- }
+ if (rt->capture.instance)
+ snd_pcm_stop_xrun(rt->capture.instance);
for (i = 0; i < PCM_N_URBS; i++) {
usb_poison_urb(&rt->in_urbs[i].instance);
usb_audio_err(ep->chip, "cannot submit urb (err = %d)\n", err);
if (ep->data_subs && ep->data_subs->pcm_substream) {
substream = ep->data_subs->pcm_substream;
- snd_pcm_stream_lock_irqsave(substream, flags);
- snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(substream, flags);
+ snd_pcm_stop_xrun(substream);
}
exit_clear:
static void abort_alsa_capture(struct ua101 *ua)
{
- unsigned long flags;
-
- if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) {
- snd_pcm_stream_lock_irqsave(ua->capture.substream, flags);
- snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(ua->capture.substream, flags);
- }
+ if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states))
+ snd_pcm_stop_xrun(ua->capture.substream);
}
static void abort_alsa_playback(struct ua101 *ua)
{
- unsigned long flags;
-
- if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) {
- snd_pcm_stream_lock_irqsave(ua->playback.substream, flags);
- snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(ua->playback.substream, flags);
- }
+ if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states))
+ snd_pcm_stop_xrun(ua->playback.substream);
}
static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream,
for (s = 0; s < 4; s++) {
struct snd_usX2Y_substream *subs = usX2Y->subs[s];
if (subs) {
- if (atomic_read(&subs->state) >= state_PRERUNNING) {
- unsigned long flags;
-
- snd_pcm_stream_lock_irqsave(subs->pcm_substream, flags);
- snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(subs->pcm_substream, flags);
- }
+ if (atomic_read(&subs->state) >= state_PRERUNNING)
+ snd_pcm_stop_xrun(subs->pcm_substream);
for (u = 0; u < NRURBS; u++) {
struct urb *urb = subs->urb[u];
if (NULL != urb)