From: Giovanni Mascellani gmascellani@codeweavers.com
This is effectively dead code, because if the buffer's state is STARTING it gets changed to PLAYING just before calling DSOUND_MixOne(). It has been like that since 6e8c8c28ebbdc15292612b7b6657e44ce8c5040f (17 years ago), mere months after the lead-in logic was introduced in 36e90546298e8c096926330dd75f4e373a415171.
I don't know whether that code does something useful. It was introduced in a monster 390+ 310- commit whose commit message doesn't say much, and the comment near the code only mentions "more fluid pointer advancement", which I have no idea of what it means. But the fact that it was effectively dead for 95% of its existence and nobody every complained seems to suggest that we can get rid of it. --- dlls/dsound/buffer.c | 5 ++--- dlls/dsound/dsound_private.h | 4 ++-- dlls/dsound/mixer.c | 17 +---------------- 3 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index b39c5db035d..c0fe0cc1fd6 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -317,7 +317,6 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Play(IDirectSoundBuffer8 *iface, DW
This->playflags = flags; if (This->state == STATE_STOPPED) { - This->leadin = TRUE; This->state = STATE_STARTING; }
@@ -1073,8 +1072,8 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds }
if (dsbd->dwBufferBytes % dsbd->lpwfxFormat->nBlockAlign) - dsb->buflen = dsbd->dwBufferBytes + - (dsbd->lpwfxFormat->nBlockAlign - + dsb->buflen = dsbd->dwBufferBytes + + (dsbd->lpwfxFormat->nBlockAlign - (dsbd->dwBufferBytes % dsbd->lpwfxFormat->nBlockAlign)); else dsb->buflen = dsbd->dwBufferBytes; diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index 28bba6cd64e..132af52880c 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -140,7 +140,7 @@ struct IDirectSoundBufferImpl SRWLOCK lock; PWAVEFORMATEX pwfx; BufferMemory* buffer; - DWORD playflags,state,leadin; + DWORD playflags,state; DWORD writelead,maxwritelead,buflen; DWORD freq; DSVOLUMEPAN volpan; @@ -242,7 +242,7 @@ DWORD CALLBACK DSOUND_mixthread(void *ptr); void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
/* capture.c */ - + HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv); HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv); HRESULT IDirectSoundCaptureImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BOOL has_dsc8); diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index bf88e94eafd..6a96f4b10f0 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -573,22 +573,7 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, float *mix_buffer, DWORD DWORD primary_done = 0;
TRACE("(%p, frames=%ld)\n",dsb,frames); - TRACE("looping=%ld, leadin=%ld\n", dsb->playflags, dsb->leadin); - - /* If leading in, only mix about 20 ms, and 'skip' mixing the rest, for more fluid pointer advancement */ - /* FIXME: Is this needed? */ - if (dsb->leadin && dsb->state == STATE_STARTING) { - if (frames > 2 * dsb->device->frag_frames) { - primary_done = frames - 2 * dsb->device->frag_frames; - frames = 2 * dsb->device->frag_frames; - dsb->sec_mixpos += primary_done * - dsb->pwfx->nBlockAlign * dsb->freqAdjustNum / dsb->freqAdjustDen; - } - } - - dsb->leadin = FALSE; - - TRACE("frames (primary) = %li\n", frames); + TRACE("looping=%ld\n", dsb->playflags);
/* First try to mix to the end of the buffer if possible * Theoretically it would allow for better optimization
From: Giovanni Mascellani gmascellani@codeweavers.com
Similarly to the previous commit, the state can never be STARTING at that place. --- dlls/dsound/mixer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index 6a96f4b10f0..552e11fc361 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -548,8 +548,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, float *mix_buffer, }
/* check for notification positions */ - if (dsb->dsbd.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY && - dsb->state != STATE_STARTING) { + if (dsb->dsbd.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY) { INT ilen = DSOUND_BufPtrDiff(dsb->buflen, dsb->sec_mixpos, oldpos); DSOUND_CheckEvent(dsb, oldpos, ilen); }
This merge request was approved by Huw Davies.