From: Takashi Iwai Subject: Re: How to report error in _pointer function? Date: Wed, 30 Jul 2008 18:12:43 +0200 Message-ID: References: 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 mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 6620B24335 for ; Wed, 30 Jul 2008 18:12:43 +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: Timur Tabi Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Wed, 30 Jul 2008 10:56:31 -0500, Timur Tabi wrote: > > In my driver, I can detect in the _pointer callback function whether > or not the DMA engine has actually started. Sometimes, when I have a > programming error, the DMA will not start, so my _pointer function > calculates a crazy value for the current position. The number it > returns causes ALSA to go haywire (see my post titled, "underrun!!! > (at least 1786051083.613 ms long)". > > What is the best way to handle this? Is there a way I can tell ALSA, > "hey, this is really screwed up, just abort playback and return an > error to the app"? You can return SNDRV_PCM_POS_XRUN from the pointer callback (with kernel messages if you like). Then the PCM stream is stopped and the status is changed to SND_PCM_STATUS_XRUN. Further access will result in -EPIPE. I guess this doesn't fully satisfy your demand, but maybe better than now :) We'd need a mechanism to pass a proper error code if other critical error code must be passed. Takashi