Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mads Kiilerich <mads@kiilerich.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel <alsa-devel@alsa-project.org>
Subject: Re: handling of underrunning snd_pcm_writei
Date: Thu, 12 Nov 2009 15:01:15 +0100	[thread overview]
Message-ID: <4AFC152B.7090409@kiilerich.com> (raw)
In-Reply-To: <4AFBFB39.8050500@kiilerich.com>

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.

Any idea?

/Mads

  reply	other threads:[~2009-11-12 14:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 16:50 handling of underrunning snd_pcm_writei Mads Kiilerich
2009-11-11 18:12 ` Mads Kiilerich
2009-11-12  7:12 ` Takashi Iwai
2009-11-12 12:10   ` Mads Kiilerich
2009-11-12 14:01     ` Mads Kiilerich [this message]
2009-11-14 13:03       ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AFC152B.7090409@kiilerich.com \
    --to=mads@kiilerich.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox