From: Raymond Yau <superquad.vortex2@gmail.com>
To: alsa-devel@alsa-project.org
Subject: Re: semantics of SNDRV_PCM_INFO_BATCH (was: Re: safe support for rewind in ALSA)
Date: Tue, 23 Feb 2010 15:02:35 +0800 [thread overview]
Message-ID: <4f3252891002222302i6c65b672l40ff7a781ef824b8@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1002221958390.3327@ecabase.localdomain>
2010/2/23 Kai Vehmanen <kvehmanen@eca.cx>
> Hi,
>
> On Sun, 21 Feb 2010, Lennart Poettering wrote:
>
> But you can query the SNDRV_PCM_INFO_BATCH flag (it's set by e.g. the USB
>>> driver) and adjust your hrtimer-based application's logic based on that
>>>
>>
It is not easy to calculate the correct wake up time if the function is a
stepping function since you must keep track of the elasped time instead of
relying on the hw ptr positon
> [...]
>
>> This mean that the wake up time cannot be calculated using as number of
>>>> sample/rate since the fuction is not linear especially when using max
>>>> buffer
>>>> size , min period --> max period size is much greater than the watermark
>>>>
>>>
>>> Yep, that's what SNDRV_PCM_INFO_BATCH flag warns you about.
>>>
>>
>> Hmm, could you elaborate a little about SNDRV_PCM_INFO_BATCH? What
>> exactly does that mean in general and especially for the timer based
>> audio scheduling?
>>
>> I am currently not making use of this, but should I?
>>
>
> I'm also looking at this topic from an application developer perspective,
> so I can only provide you my interpretation of reading current ALSA code,
> but here goes.
>
> I'll also add Eliot (who asked about the same thing, in
> http://mailman.alsa-project.org/pipermail/alsa-devel/2010-February/025262.html) to the cc, and also Takashi, who git-annotate reveals has made most recent
> PCM_INFO_BATCH related changes to linux/sound/core/pcm_lib.c. ;)
>
> Anyway, SNDRV_PCM_INFO_BATCH is set by following drivers:
> - isa/msnd
> - pcii/bt87x
> - pci/korg1212
> - pcmcia/pdaudiocf
> - soc/au1x
> - soc/fsl (mpc52xx/8610)
> - sparc/dbri
> - usbaudio
>
How about cs46xx ?
>
> Common to all these drivers is that audio samples are moved to/from the
> ALSA ringbuffer, in bursts, to an intermediary block of memory, and from
> there to/from the codec. And most importantly, pointer callback is based on
> last ack'ed burst. IOW, hw_ptr jumps in bursts with these drivers and
> granularity of hw_ptr is more coarse (affecting snd_pcm_avail(),
> snd_pcm_delay() and so forth).
>
> Now the existing documentation for the flag (and user-space
> snd_pcm_hw_params_is_batch() API) is rather brief as you've noted, and AFAIK
> very few apps use these, so I'm not sure, how much we as app developers
> should rely on these semantics (and to the fact that future drivers will use
> the BATCH flag in a similar way).
>
> But anyways, the fact remains that snd_pcm_hw_params_is_batch() exists, and
> based on a review of current (2.6.33-rc) drivers, majority/all of the
> drivers use the flag in the same way.
>
> So for apps like PA, snd_pcm_hw_params_is_batch() is a hint that app should
> not rewind closer to hw_ptr than period-size. It also hints that hw_ptr
> granularity is more coarse, which might be useful in setting sane defaults
> for buffer watermarks and such.
>
> PS Eliot: I didn't respond to your original mail, as I don't really
> have even good reading-the-code interpretations for the others.
> SNDRV_PCM_INFO_BLOCK_TRANSFER/snd_pcm_hw_params_is_block_transfer()
> is set by many, many drivers, but I'm not sure what the
> semantics really are (why cs4281 does not set the flag, while
> ens1370 sets it for instance). Then again SNDRV_PCM_INFO_BLOCK_DOUBLE
> seems very close to BATCH flag, but drivers setting DOUBLE (basicly
> just rme9652), _do_ support accurate pointer/hw_ptr reporting, so
> there is a difference.
>
next prev parent reply other threads:[~2010-02-23 7:02 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-01 17:20 safe support for rewind in ALSA pl bossart
2010-02-01 18:00 ` Jaroslav Kysela
2010-02-01 22:40 ` pl bossart
2010-02-03 2:20 ` Raymond Yau
2010-02-03 18:03 ` Kai Vehmanen
2010-02-03 20:52 ` Kai Vehmanen
2010-02-03 22:57 ` pl bossart
2010-02-08 1:22 ` Raymond Yau
2010-02-02 2:53 ` Raymond Yau
2010-02-06 11:59 ` Raymond Yau
2010-02-17 15:30 ` Lennart Poettering
2010-02-18 1:31 ` Raymond Yau
2010-02-18 2:33 ` Lennart Poettering
2010-02-18 3:21 ` Raymond Yau
2010-02-01 18:01 ` Mark Brown
2010-02-01 18:05 ` Jaroslav Kysela
2010-02-01 21:28 ` Kai Vehmanen
2010-02-01 21:54 ` Kai Vehmanen
2010-02-08 22:59 ` Raymond Yau
2010-02-09 20:54 ` Kai Vehmanen
2010-02-10 13:19 ` Raymond Yau
2010-02-10 13:36 ` Clemens Ladisch
2010-02-11 6:52 ` Raymond Yau
2010-02-11 7:20 ` Clemens Ladisch
2010-02-11 7:27 ` Jaroslav Kysela
2010-02-15 3:03 ` Raymond Yau
2010-02-17 15:46 ` Lennart Poettering
2010-02-21 10:35 ` Kai Vehmanen
2010-02-22 9:07 ` Raymond Yau
[not found] ` <20100221203500.GH31800@tango.0pointer.de>
2010-02-22 19:15 ` semantics of SNDRV_PCM_INFO_BATCH (was: Re: safe support for rewind in ALSA) Kai Vehmanen
2010-02-23 7:02 ` Raymond Yau [this message]
2010-02-23 2:37 ` safe support for rewind in ALSA Raymond Yau
2010-02-23 2:44 ` Raymond Yau
2010-02-17 15:42 ` Lennart Poettering
2010-02-21 10:06 ` Kai Vehmanen
[not found] ` <20100221202144.GG31800@tango.0pointer.de>
2010-05-04 2:31 ` Raymond Yau
2010-02-17 15:39 ` Lennart Poettering
2010-02-17 15:36 ` Lennart Poettering
2010-02-17 15:35 ` Lennart Poettering
2010-02-01 22:10 ` Kai Vehmanen
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=4f3252891002222302i6c65b672l40ff7a781ef824b8@mail.gmail.com \
--to=superquad.vortex2@gmail.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 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).