From: John Lindgren <john.lindgren@tds.net>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] alsa-lib: snd_pcm_delay and friends do not account for a write being currently in progress
Date: Thu, 03 Jun 2010 10:00:48 -0400 [thread overview]
Message-ID: <1275573648.1415.6.camel@satellite> (raw)
In-Reply-To: <4C074E63.90508@ladisch.de>
Thanks for your reply.
On Thu, 2010-06-03 at 08:40 +0200, Clemens Ladisch wrote:
> John Lindgren wrote:
> > In a multi-threaded application it is possible for snd_pcm_delay or an
> > equivalent function to be called by one thread while another is sitting
> > in snd_pcm_writei.
>
> Alsa-lib is not thread safe. In theory, you are not even allowed to
> call snd_pcm_delay while another function on the same PCM device has not
> yet returned.
>From http://alsa-project.org/main/index.php/Main_Page:
ALSA has the following significant features:
...
SMP and thread-safe design.
So, that's a big lie?
> ...
> > On the application side, the playback time counter will be calculated
> > during this time as 0.5 seconds written to ALSA
>
> This is wrong; as long as the write call has not returned, you do not
> know how much has been written (and when an error occurs, writing can
> stop before).
>
> To keep track of the actual amount of data written, use non-blocking
> mode and in a loop, write as much as possible in one call, then update
> your write counter, then wait for some more free space in the buffer
> with poll().
Would it work to simply call snd_pcm_wait?
John Lindgren
next prev parent reply other threads:[~2010-06-03 14:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-02 21:29 [PATCH] alsa-lib: snd_pcm_delay and friends do not account for a write being currently in progress John Lindgren
2010-06-03 6:40 ` Clemens Ladisch
2010-06-03 14:00 ` John Lindgren [this message]
2010-06-03 14:48 ` Clemens Ladisch
2010-06-03 16:16 ` John Lindgren
2010-06-03 17:03 ` Clemens Ladisch
2010-06-03 17:51 ` John Lindgren
2010-06-03 14:40 ` [PATCH] " James Courtier-Dutton
2010-06-03 16:10 ` John Lindgren
2010-06-03 16:34 ` James Courtier-Dutton
2010-06-03 18:06 ` John Lindgren
2010-06-03 17:40 ` VDR User
2010-06-03 18:08 ` John Lindgren
2010-06-04 6:50 ` Clemens Ladisch
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=1275573648.1415.6.camel@satellite \
--to=john.lindgren@tds.net \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.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;
as well as URLs for NNTP newsgroup(s).