From: Takashi Iwai Subject: Re: Is there a function I can call from my ISR to tell ALSA to abort playback? Date: Fri, 16 Nov 2007 11:49:56 +0100 Message-ID: References: <473B5D83.2020408@freescale.com> <473C5F26.2050807@freescale.com> <473CABDE.7000205@freescale.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 7BCA1103866 for ; Fri, 16 Nov 2007 11:50:08 +0100 (CET) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Jaroslav Kysela Cc: alsa-devel@alsa-project.org, Timur Tabi List-Id: alsa-devel@alsa-project.org At Fri, 16 Nov 2007 11:41:51 +0100 (CET), Jaroslav Kysela wrote: > > On Fri, 16 Nov 2007, Takashi Iwai wrote: > > > At Thu, 15 Nov 2007 14:28:14 -0600, > > Timur Tabi wrote: > > > > > > Takashi Iwai wrote: > > > > At Thu, 15 Nov 2007 09:00:54 -0600, > > > > Timur Tabi wrote: > > > >> Jaroslav Kysela wrote: > > > >> > > > >>> Yes, call snd_pcm_stop() function. The call must be protected with > > > >>> snd_pcm_stream_lock... See to i2c/other/ak4117.c for an example. > > > >> That code calls snd_pcm_stop() from a timer, not an ISR. Do I need the call to > > > >> wake_up() as well? > > > > > > > > snd_pcm_stop() can be called from ISR, too (e.g. > > > > snd_pcm_period_elapsed() may call snd_pcm_stop() when XRUN occurs). > > > > You only need to protect it via snd_pcm_stream_lock*(). > > > > > > It doesn't seem to do much. Here's the function I wrote: > > > > > > 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_DRAINING); > > > > You passed a wrong state. Usually snd_pcm_stop() passes either > > SNDRV_PCM_STATE_SETUP (for post-draining) or SNDRV_PCM_STATE_XRUN (for > > errors). > > > > > wake_up(&substream->runtime->sleep); > > > } > > > snd_pcm_stream_unlock_irqrestore(substream, flags); > > > } > > > > This wake_up is superfluous. Now I understand your question in the > > last mail... > > I'm not sure if the wake call is superfluous, if driver ends to call > elapsed callbacks, there is no way to wakeup process when it sleeps > somewhere. I think that code might be covered with a nice macro with a > name like 'snd_pcm_hw_stopped()' or so. But wake_up() is already in snd_pcm_post_stop(). How can this second call help? thanks, Takashi