Reece Dunn : dsound: Correct the dsound fraglen calculations.
Alexandre Julliard
julliard at winehq.org
Mon Dec 22 10:19:53 CST 2008
Module: wine
Branch: master
Commit: ce06de420874b9983324508f8257a580fee341ca
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ce06de420874b9983324508f8257a580fee341ca
Author: Reece Dunn <msclrhd at googlemail.com>
Date: Mon Dec 22 13:33:43 2008 +0000
dsound: Correct the dsound fraglen calculations.
---
dlls/dsound/primary.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 661cd8c..5812f00 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -46,19 +46,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
*/
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 <= 26000)
- fraglen /= 2;
+ if (nSamplesPerSec <= 12800)
+ return 128 * nBlockAlign;
- if (nSamplesPerSec <= 10000)
- fraglen /= 2;
+ if (nSamplesPerSec <= 25600)
+ return 256 * nBlockAlign;
- if (nSamplesPerSec >= 80000)
- fraglen *= 2;
+ if (nSamplesPerSec <= 51200)
+ return 512 * nBlockAlign;
- return fraglen;
+ return 1024 * nBlockAlign;
}
static void DSOUND_RecalcPrimary(DirectSoundDevice *device)
More information about the wine-cvs
mailing list