From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: handling of underrunning snd_pcm_writei Date: Sat, 14 Nov 2009 14:03:43 +0100 Message-ID: References: <4AFAEB44.60104@kiilerich.com> <4AFBFB39.8050500@kiilerich.com> <4AFC152B.7090409@kiilerich.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 (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 0889E103844 for ; Sat, 14 Nov 2009 14:03:44 +0100 (CET) In-Reply-To: <4AFC152B.7090409@kiilerich.com> 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: Mads Kiilerich Cc: alsa-devel List-Id: alsa-devel@alsa-project.org At Thu, 12 Nov 2009 15:01:15 +0100, Mads Kiilerich wrote: > > On 11/12/2009 01:10 PM, Mads Kiilerich wrote: > > On 11/12/2009 08:12 AM, Takashi Iwai wrote: > >> Yes, snd_pcm_recover() is *recommended*. You can write the recovery > >> routine by yourself. The function isn't referred here just because > >> it's relatively new. Better to be documented, indeed. > > > > Thanks a lot for you answer, Takashi. That was very helpful. > > > > But when I hack pcm_min.c to log the state at the beginning of the loop > > and then enforces an underrun by pausing the program then it sometimes > > locks up: > > > > $ ./pcm_min > > state 2 SND_PCM_STATE_PREPARED > > state 2 SND_PCM_STATE_PREPARED > > Short write (expected 16384, wrote 7616) > > state 3 SND_PCM_STATE_RUNNING > > state 3 SND_PCM_STATE_RUNNING > > state 3 SND_PCM_STATE_RUNNING > > state 3 SND_PCM_STATE_RUNNING > > [ctrl-s ... waiting for silence ... ctrl q] > > ALSA lib pcm.c:7234:(snd_pcm_recover) underrun occured > > state 2 SND_PCM_STATE_PREPARED > > state 2 SND_PCM_STATE_PREPARED > > state 3 SND_PCM_STATE_RUNNING > > [hanging in snd_pcm_writei] > > > > It seems like pcm_min.cs use of snd_pcm_recover isn't enough to recover > > fully? The playback never gets started again, so the async writes in > > PREPARED succeeds, but the first blocking write hangs waiting forever? > > What is missing? > > It seems like the lockup always happens in SND_PCM_STATE_RUNNING after > snd_pcm_avail_update has reported values > 9000. Usually it returns < 8000. Hm, not now, as I've been too busy for other things. Will take a look at this issue later. thanks, Takashi