Commit c5003854 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Some block align cleanups.

parent 3988d9c5
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment