[RFC] Soft sound buffer size smaller then hard buffer size
Alexander Motin
mav at FreeBSD.org
Tue Jan 24 20:22:40 UTC 2012
Hi.
I was reported about some sound cards that have fixed 64K buffer with 2K
or 8K block sizes. Experimenting with the sound(4) code I've noticed
that while it automatically tuning buffer sizes, it almost never sets
soft buffer size less then hard buffer size and it always tries to keep
all playback buffers full. On the mentioned cards that makes sound(4)
set both soft and hard buffers to 64K and results in playback latency at
44100/16/2 of about 800ms!
To improve that situation, I've made a patch that allows to set soft
buffer size down to just two blocks of the hard buffer and to not write
more then that size ahead to the hardware buffer. As result of that
change I was able to reduce full practically measured record-playback
loop delay in those conditions down to only about 115ms with theoretical
playback latency of only about 50ms!
Patch works fine for both vchans and direct cases. In both cases
sound(4) tries to follow hw.snd.latency_profile and hw.snd.latency
values and application-requested buffer size as much as limitation of
two hardware blocks allows.
The patch can be found here:
http://people.freebsd.org/~mav/sound.latency.patch
Can somebody review this and tell me whether is this correct?
Thank you!
--
Alexander Motin
More information about the freebsd-multimedia
mailing list