[PATCH] dsound: correct the dsound fraglen calculations. [try 2]
msclrhd at googlemail.com
Sun Dec 21 15:23:30 CST 2008
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
(nSamplesPerSecond / 100) < 120 ==> power of 2 = 128
(nSamplesPerSecond / 100) < 260 ==> 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 using the numbers from
the original code before this bug occurred (the ones that apparently
fix the current audio issues that people are reporting). As can be
seen, there are two issues:
* the first is with the value 26000, which means that 256 is picked
for 25600 <
nSamplesPerSec < 26000, instead of 512 - this was picked up in my
* the second is with the value 80000, which means that 512 is
picked for 51200 < nSamplesPerSec < 80000, instead of 1024 - this was
not picked up in my previous patch.
To make things clearer, as well as documenting the reasoning behind
the calculations, I have restructured them into a more logical order
and used the exact (power of 2) * 100 values instead of approximations
to them to prevent any approximation errors.
I have tested this with Puzzle Quest and Warcraft III, confirming that
these play correctly without stuttering.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the wine-patches