From 0c4ec8a1ccc352e15e447c927cb146cb000075c2 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 5 Sep 2007 13:54:33 +0200 Subject: [PATCH] dsound: Fix overshot calculations. --- dlls/dsound/primary.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index f358aec2eb1..ce2f9431184 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -173,7 +173,7 @@ static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device) buflen = ds_hel_buflen; else /* In case we move from hw accelerated to waveout */ buflen = device->buflen; - buflen -= ds_hel_buflen % device->pwfx->nBlockAlign; + buflen -= buflen % device->pwfx->nBlockAlign; TRACE("desired buflen=%d, old buffer=%p\n", buflen, device->buffer); @@ -223,11 +223,13 @@ static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device) } } - overshot = device->buflen % device->helfrags; + overshot = device->buflen % device->fraglen; /* sanity */ if(overshot) { - WARN("helfrags (%d x %d) doesn't fit entirely in buflen (%d) overshot: %d\n", device->helfrags, device->fraglen, device->buflen, overshot); + overshot -= overshot % device->pwfx->nBlockAlign; + if (overshot) + WARN("helfrags (%d x %d) doesn't fit entirely in buflen (%d) overshot: %d\n", device->helfrags, device->fraglen, device->buflen, overshot); device->pwave[device->helfrags - 1].dwBufferLength += overshot; }