[DSOUND] block align cleanups
Robert Reif
reif at earthlink.net
Tue Feb 15 21:31:19 CST 2005
Some block align cleanups.
-------------- next part --------------
Index: dlls/dsound/mixer.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/mixer.c,v
retrieving revision 1.30
diff -u -p -r1.30 mixer.c
--- dlls/dsound/mixer.c 10 Feb 2005 17:10:54 -0000 1.30
+++ dlls/dsound/mixer.c 16 Feb 2005 03:01:56 -0000
@@ -388,7 +388,7 @@ static DWORD DSOUND_MixInBuffer(IDirectS
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(IDirectSo
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;
Index: dlls/dsound/primary.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/primary.c,v
retrieving revision 1.42
diff -u -p -r1.42 primary.c
--- dlls/dsound/primary.c 11 Feb 2005 11:49:05 -0000 1.42
+++ dlls/dsound/primary.c 16 Feb 2005 03:01:56 -0000
@@ -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(IDirec
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 */
More information about the wine-patches
mailing list