dsound: Correct the dsound fraglen calculations.
This commit is contained in:
parent
f9e0e5198f
commit
ce06de4208
|
@ -46,19 +46,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
||||||
*/
|
*/
|
||||||
DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign)
|
DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign)
|
||||||
{
|
{
|
||||||
DWORD fraglen = 256 * nBlockAlign;
|
/* Given a timer delay of 10ms, the fragment size is approximately:
|
||||||
|
* fraglen = (nSamplesPerSec * 10 / 1000) * nBlockAlign
|
||||||
|
* ==> fraglen = (nSamplesPerSec / 100) * nBlockSize
|
||||||
|
*
|
||||||
|
* ALSA uses buffers that are powers of 2. Because of this, fraglen
|
||||||
|
* is rounded up to the nearest power of 2:
|
||||||
|
*/
|
||||||
|
|
||||||
/* Compensate for only being roughly accurate */
|
if (nSamplesPerSec <= 12800)
|
||||||
if (nSamplesPerSec <= 26000)
|
return 128 * nBlockAlign;
|
||||||
fraglen /= 2;
|
|
||||||
|
|
||||||
if (nSamplesPerSec <= 10000)
|
if (nSamplesPerSec <= 25600)
|
||||||
fraglen /= 2;
|
return 256 * nBlockAlign;
|
||||||
|
|
||||||
if (nSamplesPerSec >= 80000)
|
if (nSamplesPerSec <= 51200)
|
||||||
fraglen *= 2;
|
return 512 * nBlockAlign;
|
||||||
|
|
||||||
return fraglen;
|
return 1024 * nBlockAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DSOUND_RecalcPrimary(DirectSoundDevice *device)
|
static void DSOUND_RecalcPrimary(DirectSoundDevice *device)
|
||||||
|
|
Loading…
Reference in New Issue