do apps need to care for xfer_align ???
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines · Paul Davis
Quoted 21 lines · Guilhem Tardy
Quoted 5 lines
Hi all,
While trying to understand
snd_pcm_lib_write1(), I found thatruntime->xfer_alignis set toperiod_sizeinpcm_native.c, but wonder if itis
Quoted 3 lines
just a default?
Paul Davis' example (at http://www.op.net/~pbd/alsa-audio.html#playex) doesn
't
Quoted 1 line
check for a particular transfer size, and my card supports playout of less t
han
Quoted 1 line
160 samples (i.e. the period size). Thus, I set to try playing out 512 bytes
at
Quoted 1 line
a time (i.e. 2048 samples of 2-bit ADPCM), which does NOT come to a multiple
of
Quoted 1 line
period size. The result is that only 1920 samples are played, and my app thi
nks
Quoted 2 lines
an error has occured.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Is it a general requirement for apps to send only audio in multiple of the period size?
Nope, applications might modify
xfer_alignto satisfy their requirements.jaroslav, since even i don't understand what
xfer_alignis for, or even have an answer to the actual question, it might be good for you to expand on this a little.
It's software only limit for read/write transfers. The direct transfers (mmap) don't take care about this limit. The idea is to avoid using very small transfer chunks which are inefficient. Application might change this value from 1 (no control) to buffer_size (in samples), but values bigger than period_size hasn't any sense anyway.
The default value for xfer_align is period_size.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
SuSE Linux http://www.suse.com
ALSA project http://www.alsa-project.org
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
Quoted 7 lines
It's software only limit for read/write transfers. The direct transfers (mmap) don't take care about this limit. The idea is to avoid using very small transfer chunks which are inefficient. Application might change this value from 1 (no control) to
buffer_size(in samples), but values bigger thanperiod_sizehasn't any sense anyway.The default value for
xfer_alignisperiod_size.
Since 'xfer_align' must be equal or greater than 'min_align', how can we get this value through the library?
Thanks,
Guilhem.
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
Quoted 10 lines · Guilhem Tardy
Quoted 7 lines
It's software only limit for read/write transfers. The direct transfers (mmap) don't take care about this limit. The idea is to avoid using very small transfer chunks which are inefficient. Application might change this value from 1 (no control) to
buffer_size(in samples), but values bigger thanperiod_sizehasn't any sense anyway.The default value for
xfer_alignisperiod_size.Since '
xfer_align' must be equal or greater than 'min_align', how can we get this value through the library?
The physical size of xfer_align * frame_size_in_bits must be multiple by 8, of course. Adding bit copying in the kernel or library will cause a lot of overhead.
I've added this function to library:
snd_pcm_sframes_t snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params)
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project http://www.alsa-project.org
SuSE Linux http://www.suse.com
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
Jaroslav,
I am working on a conferencing application, and need to deal with audio packets of various sizes (in sample).
Quoted 5 lines
Quoted 5 lines
It's software only limit for read/write transfers. The direct transfers (mmap) don't take care about this limit. The idea is to avoid using very small transfer chunks which are inefficient. Application might change this value from 1 (no control) to
buffer_size(in samples), but values bigger thanperiod_sizehasn't any sense anyway.
The application writer who chooses to send audio in chunks of any size then must (and can) also set xfer_align to 1. Which is what I would do to avoid having:
1) audio systematically dropped at the end of each chunk, and
2) writei() return a value different from the number of frames passed to it
(which is usually treated as an error)
Quoted 3 lines
The physical size of
xfer_align*frame_size_in_bitsmust be multiple by 8, of course. Adding bit copying in the kernel or library will cause a lot of overhead.
Agreed.
To me, this only means that period_size must be a multiple of min_align. Any number of samples given to write1() in alsa-kernel/core/pcm_lib.c should be supported already by the current code, except for the xfer_align check at the top of the function.
Quoted 4 lines
I've added this function to library:
snd_pcm_sframes_tsnd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params)
That certainly is helpful, thank you.
Regards,
Guilhem.
__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390