From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Subject: Re: How to report error in _pointer function? Date: Fri, 08 Aug 2008 17:26:11 -0500 Message-ID: <489CC803.9030408@freescale.com> References: <489A1D9E.7040709@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from de01egw02.freescale.net (de01egw02.freescale.net [192.88.165.103]) by alsa0.perex.cz (Postfix) with ESMTP id 55E8A24B4E for ; Sat, 9 Aug 2008 00:26:16 +0200 (CEST) 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: Takashi Iwai Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org Takashi Iwai wrote: > So, the PCM status is properly changed to XRUN as expected. From the > driver perspective, everything must be fine. I've been debugging aplay. The main loop is function pcm_write(). It calls writei_func() which returns -EPIPE. This causes aplay to jump to xrun(), which attempts to recover. This is not what I want. I don't want to return overrun/underrun. I want to return failure. Returning XRUN is wrong. Instead, I need to take a look at this code I have: 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); It's the call to snd_pcm_stop() that I don't like. There doesn't appear to be a SNDRV_PCM_STATE_xxx state that makes sense. This function should eventually bring me to snd_pcm_pre_stop(). But this function returns -EBADFD because the current state is RUNNING and not OPEN. Because it returns an error, snd_pcm_do_stop() is never called. This doesn't make any sense to me. Why should I be able to stop a stream only if it's open but not running? If it's open, but not running, then there's nothing to stop! Can you explain the restriction in snd_pcm_pre_stop()? -- Timur Tabi Linux kernel developer at Freescale