From c50038542a87a3dc5f6a131d6bd1f3b1d9ac5ac0 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Wed, 16 Feb 2005 16:26:13 +0000 Subject: [PATCH] Some block align cleanups. --- dlls/dsound/mixer.c | 4 ++-- dlls/dsound/primary.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index 75ffb9283bf..d8f17b7fadb 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -388,7 +388,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO len = min(len, temp); } nBlockAlign = dsb->dsound->pwfx->nBlockAlign; - len = len / nBlockAlign * nBlockAlign; /* data alignment */ + len = (len / nBlockAlign) * nBlockAlign; /* data alignment */ if (len == 0) { /* This should only happen if we aren't looping and temp < nBlockAlign */ @@ -502,7 +502,7 @@ static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWOR TRACE("(%p,%ld,%ld)\n",dsb,writepos,len); nBlockAlign = dsb->dsound->pwfx->nBlockAlign; - len = len / nBlockAlign * nBlockAlign; /* data alignment */ + len = (len / nBlockAlign) * nBlockAlign; /* data alignment */ if ((buf = ibuf = DSOUND_tmpbuffer(dsb->dsound, len)) == NULL) return; diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index f46fd72b143..e54b23c6f01 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -38,22 +38,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); void DSOUND_RecalcPrimary(IDirectSoundImpl *This) { - DWORD sw; + DWORD nBlockAlign; TRACE("(%p)\n",This); - sw = This->pwfx->nChannels * (This->pwfx->wBitsPerSample / 8); + nBlockAlign = This->pwfx->nBlockAlign; if (This->hwbuf) { DWORD fraglen; /* let fragment size approximate the timer delay */ - fraglen = (This->pwfx->nSamplesPerSec * DS_TIME_DEL / 1000) * sw; + fraglen = (This->pwfx->nSamplesPerSec * DS_TIME_DEL / 1000) * nBlockAlign; /* reduce fragment size until an integer number of them fits in the buffer */ /* (FIXME: this may or may not be a good idea) */ - while (This->buflen % fraglen) fraglen -= sw; + while (This->buflen % fraglen) fraglen -= nBlockAlign; This->fraglen = fraglen; TRACE("fraglen=%ld\n", This->fraglen); } /* calculate the 10ms write lead */ - This->writelead = (This->pwfx->nSamplesPerSec / 100) * sw; + This->writelead = (This->pwfx->nSamplesPerSec / 100) * nBlockAlign; } static HRESULT DSOUND_PrimaryOpen(IDirectSoundImpl *This) @@ -72,7 +72,7 @@ static HRESULT DSOUND_PrimaryOpen(IDirectSoundImpl *This) else if (This->state == STATE_STOPPING) This->state = STATE_STOPPED; /* use fragments of 10ms (1/100s) each (which should get us within * the documented write cursor lead of 10-15ms) */ - buflen = ((This->pwfx->nAvgBytesPerSec / 100) & ~3) * DS_HEL_FRAGS; + buflen = ((This->pwfx->nSamplesPerSec / 100) * This->pwfx->nBlockAlign) * DS_HEL_FRAGS; TRACE("desired buflen=%ld, old buffer=%p\n", buflen, This->buffer); /* reallocate emulated primary buffer */ -- 2.11.4.GIT