From: Colin Guthrie <gmane@colin.guthr.ie>
To: alsa-devel@alsa-project.org
Subject: Re: What does snd_pcm_delay() actually return?
Date: Wed, 11 Jun 2008 21:24:20 +0100 [thread overview]
Message-ID: <g2pc9p$16h$1@ger.gmane.org> (raw)
In-Reply-To: <s5h1w333o7r.wl%tiwai@suse.de>
Takashi Iwai wrote:
> At Mon, 9 Jun 2008 21:02:25 +0200,
> Lennart Poettering wrote:
>> Takashi, Jaroslav,
>>
>> could you please explain what exactly snd_pcm_delay() returns?
>>
>> Some applications (such as WINE) assume it is the time that would pass
>> until we reach an underrun if we would stop writing any further data
>> to the PCM device.
>>
>> Other applications (such as most media players) use it for time
>> synchronisation. i.e. assume that it is the time that passes until a
>> sample I write to a PCM device now would take to be played.
>
> As James already pointed, the correct answer is the latter.
> In the driver implementation level, snd_pcm_delay() simply returns the
> difference between appl_ptr and hw_ptr. It means how many samples are
> ahead on the buffer from the point currently being played.
>
> However, if you stop feeding samples now, snd_pcm_delay() returns the
> least time XRUN occurs. So the first understanding isn't 100% wrong.
snip
> The implementation of snd_pcm_delay() (at least in the driver level)
> purely depends on the accuracy of PCM pointer callback of each
> driver. So, if the driver returns more accurate hw_ptr via pointer
> callback, you'll get more accurate value of snd_pcm_delay(). In the
> worst case, it may be bigger up to one period size than the real
> delay.
I could be wrong here as I'm only going on discussions I've had with
wine folks rather than poking at the code myself (I did look a while
back but I've forgotten it all now!).
AFAIK, the way Wine uses snd_pcm_delay() is to check when a sample is
fully played. e.g. they wait for the function to return 0. I think this
was done due to the docs specifically say that it is the "difference
between appl_ptr and hw_ptr" so it makes sense to assume this will
return 0 when there is nothing waiting to be played. I would strongly
recommend that you remove the implementation detail from the (supposedly
high level) docs.
Given this clarification can this bug please be closed as invalid?
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3943
In the mean time, can you suggest how the wine code can check to see if
there is any data waiting to be played (e.g. things are idle) so that
they can refactor their use of snd_pcm_delay()?
Col
Disclaimer: Any wine person, please feel free to correct me if I'd
misunderstood things!
next prev parent reply other threads:[~2008-06-11 20:24 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-09 19:02 What does snd_pcm_delay() actually return? Lennart Poettering
2008-06-10 14:01 ` RafałMużyło
2008-06-10 14:36 ` James Courtier-Dutton
2008-06-11 16:56 ` Takashi Iwai
2008-06-11 20:24 ` Colin Guthrie [this message]
2008-06-11 21:40 ` Tomas Carnecky
2008-06-12 10:25 ` Takashi Iwai
2008-06-12 11:51 ` Colin Guthrie
2008-06-12 12:08 ` Takashi Iwai
2008-06-12 21:00 ` Lennart Poettering
2008-06-13 6:22 ` Takashi Iwai
2008-06-12 20:52 ` Lennart Poettering
2008-06-13 6:13 ` Takashi Iwai
2008-06-13 13:51 ` Lennart Poettering
2008-06-13 13:55 ` Jaroslav Kysela
2008-06-13 14:29 ` Lennart Poettering
2008-06-13 6:59 ` Takashi Iwai
2008-06-13 8:14 ` Jaroslav Kysela
2008-06-13 10:14 ` James Courtier-Dutton
2008-06-13 12:44 ` Colin Guthrie
2008-06-13 13:06 ` Jaroslav Kysela
2008-06-13 14:48 ` Lennart Poettering
2008-06-13 15:02 ` Jaroslav Kysela
2008-06-13 15:42 ` Takashi Iwai
2008-06-17 0:53 ` Eliot Blennerhassett
2008-06-13 14:38 ` Lennart Poettering
2008-06-13 15:27 ` Takashi Iwai
2008-06-13 15:44 ` Jaroslav Kysela
2008-06-13 15:59 ` Takashi Iwai
2008-06-13 16:20 ` Jaroslav Kysela
2008-06-13 16:38 ` Takashi Iwai
2008-06-13 16:48 ` Takashi Iwai
2008-06-13 19:55 ` James Courtier-Dutton
2008-06-16 12:07 ` Jaroslav Kysela
2008-06-19 17:59 ` Lennart Poettering
2008-06-13 19:59 ` James Courtier-Dutton
2008-06-13 14:25 ` Lennart Poettering
2008-06-13 15:55 ` Takashi Iwai
2008-06-13 16:11 ` Jaroslav Kysela
2008-06-13 16:26 ` Takashi Iwai
2008-06-13 16:47 ` Jaroslav Kysela
2008-06-13 16:52 ` Takashi Iwai
2008-06-13 17:37 ` Jaroslav Kysela
2008-06-13 18:23 ` Takashi Iwai
2008-06-13 18:48 ` Lennart Poettering
2008-06-13 18:43 ` Lennart Poettering
2008-06-13 18:29 ` Lennart Poettering
2008-06-13 18:46 ` Takashi Iwai
2008-06-13 19:01 ` Lennart Poettering
2008-06-13 19:05 ` Takashi Iwai
2008-06-13 18:22 ` Lennart Poettering
2008-06-13 18:32 ` Takashi Iwai
2008-06-14 9:51 ` James Courtier-Dutton
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='g2pc9p$16h$1@ger.gmane.org' \
--to=gmane@colin.guthr.ie \
--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.