[PATCH] dsound: correct the dsound fraglen calculations.
Reece Dunn
msclrhd at googlemail.com
Sun Dec 21 13:43:16 CST 2008
Hi,
Given a timer delay of 10ms, the fragment size is approximately:
fraglen = (nSamplesPerSecond * 10 / 1000) * nBlockAlign
==> fraglen = (nSamplesPerSecond / 100) * nBlockSize
ALSA uses buffers that are powers of 2, so approximate the size for a
given nSamplesPerSecond.
(nSamplesPerSecond / 100) < 120 ==> power of 2 = 128
(nSamplesPerSecond / 100) < 250 ==> power of 2 = 256
(nSamplesPerSecond / 100) < 800 ==> power of 2 = 512
(nSamplesPerSecond / 100) > 800 ==> power of 2 = 1024
The numbers on the right-hand side of the < are where the numbers come
from (e.g. 120 is 12000).
This is not a revert as the previous version was. I have corrected the
26000 to 25000 to prevent under calculating for 25600 <
nSamplesPerSecond < 26000, as well as documenting the above logic for
people looking at this in the future (otherwise it is difficult to
know where the values come from).
I have tested this with Puzzle Quest and Warcraft III, confirming that
these play correctly without stuttering.
- Reece
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-dsound-correct-the-dsound-fraglen-calculations.txt
Url: http://www.winehq.org/pipermail/wine-patches/attachments/20081221/a7c14730/attachment.txt
More information about the wine-patches
mailing list