Module: wine Branch: master Commit: af5423ef5761545b4177f45be5bbcbbcab6afba1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=af5423ef5761545b4177f45be5...
Author: Maarten Lankhorst m.b.lankhorst@gmail.com Date: Fri Feb 11 01:21:05 2011 +0100
dsound: Forcibly lock buffers to be mixed.
---
dlls/dsound/mixer.c | 18 +++--------------- 1 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index e08cbca..6647e4a 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -664,7 +664,6 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi * writepos = the current safe-to-write position in the primary buffer * mixlen = the maximum amount to mix into the primary buffer * (beyond the current writepos) - * mustlock = Do we have to fight for lock because we otherwise risk an underrun? * recover = true if the sound device may have been reset and the write * position in the device buffer changed * all_stopped = reports back if all buffers have stopped @@ -672,12 +671,11 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi * Returns: the length beyond the writepos that was mixed to. */
-static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos, DWORD mixlen, BOOL mustlock, BOOL recover, BOOL *all_stopped) +static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos, DWORD mixlen, BOOL recover, BOOL *all_stopped) { INT i, len; DWORD minlen = 0; IDirectSoundBufferImpl *dsb; - BOOL gotall = TRUE;
/* unless we find a running buffer, all have stopped */ *all_stopped = TRUE; @@ -690,11 +688,7 @@ static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos
if (dsb->buflen && dsb->state && !dsb->hwbuf) { TRACE("Checking %p, mixlen=%d\n", dsb, mixlen); - if (!RtlAcquireResourceShared(&dsb->lock, mustlock)) - { - gotall = FALSE; - continue; - } + RtlAcquireResourceShared(&dsb->lock, TRUE); /* if buffer is stopping it is stopped now */ if (dsb->state == STATE_STOPPING) { dsb->state = STATE_STOPPED; @@ -726,7 +720,6 @@ static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos }
TRACE("Mixed at least %d from all buffers\n", minlen); - if (!gotall) return 0; return minlen; }
@@ -814,7 +807,6 @@ static void DSOUND_PerformMix(DirectSoundDevice *device) DWORD playpos, writepos, writelead, maxq, frag, prebuff_max, prebuff_left, size1, size2, mixplaypos, mixplaypos2; LPVOID buf1, buf2; BOOL lock = (device->hwbuf && !(device->drvdesc.dwFlags & DSDDESC_DONTNEEDPRIMARYLOCK)); - BOOL mustlock = FALSE; int nfiller;
/* the sound of silence */ @@ -897,15 +889,11 @@ static void DSOUND_PerformMix(DirectSoundDevice *device) TRACE("prebuff_left = %d, prebuff_max = %dx%d=%d, writelead=%d\n", prebuff_left, device->prebuf, device->fraglen, prebuff_max, writelead);
- /* Do we risk an 'underrun' if we don't advance pointer? */ - if (writelead/device->fraglen <= ds_snd_queue_min || recover) - mustlock = TRUE; - if (lock) IDsDriverBuffer_Lock(device->hwbuf, &buf1, &size1, &buf2, &size2, writepos, maxq, 0);
/* do the mixing */ - frag = DSOUND_MixToPrimary(device, writepos, maxq, mustlock, recover, &all_stopped); + frag = DSOUND_MixToPrimary(device, writepos, maxq, recover, &all_stopped);
if (frag + writepos > device->buflen) {