All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mads Kiilerich <mads@kiilerich.com>
To: alsa-devel <alsa-devel@alsa-project.org>
Subject: handling of underrunning snd_pcm_writei
Date: Wed, 11 Nov 2009 17:50:12 +0100	[thread overview]
Message-ID: <4AFAEB44.60104@kiilerich.com> (raw)

Hi,

I AM trying to convert an internal app from oss to alsa and is trying to 
grok the alsa API and the examples I can find.

I would like to ask some questions to avoid guessing and making wrong 
assumptions. Feel free to redirect me to where I should have found the 
answer myself.

http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gf13067c0ebde29118ca05af76e5b17a9 
says about snd_pcm_writei:

> Returns: a positive number of frames actually written otherwise a negative error code
> ...
> Return values:
> ...
> -EPIPE 	an underrun occurred
> ...
> The count of bytes can be less only if a signal or underrun occurred.

So what is returned in case of underrun? Error code or count of bytes?

Should snd_pcm_recover always be used to get the byte count after 
-EPIPE? snd_pcm_recover is neither mentioned in the link above nor in 
http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html , so I don't feel 
confident about that.

And is it measured in "positive number of frames actually written" or 
"count of bytes"?

It surprises me that snd_pcm_writei shows non-blocking behaviour in case 
of underruns and don't use all the offered data. I would guess that it 
either blocked and enjoyed the data it finally got, or that it gave an 
error and didn't take any data at all. But if this is how it is, then 
... that is how it is ;-)

/Mads

using
alsa-lib-1.0.21-3.fc11.i586
alsa-plugins-pulseaudio-1.0.21-2.fc11.i586

             reply	other threads:[~2009-11-11 16:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 16:50 Mads Kiilerich [this message]
2009-11-11 18:12 ` handling of underrunning snd_pcm_writei Mads Kiilerich
2009-11-12  7:12 ` Takashi Iwai
2009-11-12 12:10   ` Mads Kiilerich
2009-11-12 14:01     ` Mads Kiilerich
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=4AFAEB44.60104@kiilerich.com \
    --to=mads@kiilerich.com \
    --cc=alsa-devel@alsa-project.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.