Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jan 2012 22:22:33 +0200
From:      Alexander Motin <mav@FreeBSD.org>
To:        freebsd-multimedia@freebsd.org
Subject:   [RFC] Soft sound buffer size smaller then hard buffer size
Message-ID:  <4F1F1309.3090300@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F1F1309.3090300>