[DSOUND] block align cleanup
Robert Reif
reif at earthlink.net
Fri Feb 25 10:54:58 CST 2005
Use nBlockAlign rather than calculating it.
Add a buffer length alignment error message.
-------------- next part --------------
Index: dlls/dsound/mixer.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/mixer.c,v
retrieving revision 1.31
diff -u -p -r1.31 mixer.c
--- dlls/dsound/mixer.c 16 Feb 2005 16:26:13 -0000 1.31
+++ dlls/dsound/mixer.c 25 Feb 2005 16:48:29 -0000
@@ -91,12 +91,10 @@ void DSOUND_AmpFactorToVolPan(PDSVOLUMEP
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb)
{
- DWORD sw;
TRACE("(%p)\n",dsb);
- sw = dsb->pwfx->nChannels * (dsb->pwfx->wBitsPerSample / 8);
/* calculate the 10ms write lead */
- dsb->writelead = (dsb->freq / 100) * sw;
+ dsb->writelead = (dsb->freq / 100) * dsb->pwfx->nBlockAlign;
}
void DSOUND_CheckEvent(IDirectSoundBufferImpl *dsb, int len)
@@ -374,7 +372,7 @@ static LPBYTE DSOUND_tmpbuffer(IDirectSo
static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD fraglen)
{
- INT i, len, ilen, field, nBlockAlign, todo;
+ INT i, len, ilen, field, todo;
BYTE *buf, *ibuf;
TRACE("(%p,%ld,%ld)\n",dsb,writepos,fraglen);
@@ -387,8 +385,12 @@ static DWORD DSOUND_MixInBuffer(IDirectS
dsb->nAvgBytesPerSec);
len = min(len, temp);
}
- nBlockAlign = dsb->dsound->pwfx->nBlockAlign;
- len = (len / nBlockAlign) * nBlockAlign; /* data alignment */
+
+ if (len % dsb->dsound->pwfx->nBlockAlign) {
+ INT nBlockAlign = dsb->dsound->pwfx->nBlockAlign;
+ len = (len / nBlockAlign) * nBlockAlign; /* data alignment */
+ ERR("length not a multiple of block size, len = %d, block size = %d\n", len, nBlockAlign);
+ }
if (len == 0) {
/* This should only happen if we aren't looping and temp < nBlockAlign */
@@ -495,14 +497,17 @@ static DWORD DSOUND_MixInBuffer(IDirectS
static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD len)
{
- INT ilen, field, nBlockAlign;
+ INT ilen, field;
UINT i, todo;
BYTE *buf, *ibuf;
TRACE("(%p,%ld,%ld)\n",dsb,writepos,len);
- nBlockAlign = dsb->dsound->pwfx->nBlockAlign;
- len = (len / nBlockAlign) * nBlockAlign; /* data alignment */
+ if (len % dsb->dsound->pwfx->nBlockAlign) {
+ INT nBlockAlign = dsb->dsound->pwfx->nBlockAlign;
+ len = (len / nBlockAlign) * nBlockAlign; /* data alignment */
+ ERR("length not a multiple of block size, len = %ld, block size = %d\n", len, nBlockAlign);
+ }
if ((buf = ibuf = DSOUND_tmpbuffer(dsb->dsound, len)) == NULL)
return;
More information about the wine-patches
mailing list