Commit af5423ef authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

dsound: Forcibly lock buffers to be mixed.

parent 43790cf3
...@@ -664,7 +664,6 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi ...@@ -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 * writepos = the current safe-to-write position in the primary buffer
* mixlen = the maximum amount to mix into the primary buffer * mixlen = the maximum amount to mix into the primary buffer
* (beyond the current writepos) * (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 * recover = true if the sound device may have been reset and the write
* position in the device buffer changed * position in the device buffer changed
* all_stopped = reports back if all buffers have stopped * all_stopped = reports back if all buffers have stopped
...@@ -672,12 +671,11 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi ...@@ -672,12 +671,11 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi
* Returns: the length beyond the writepos that was mixed to. * 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; INT i, len;
DWORD minlen = 0; DWORD minlen = 0;
IDirectSoundBufferImpl *dsb; IDirectSoundBufferImpl *dsb;
BOOL gotall = TRUE;
/* unless we find a running buffer, all have stopped */ /* unless we find a running buffer, all have stopped */
*all_stopped = TRUE; *all_stopped = TRUE;
...@@ -690,11 +688,7 @@ static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos ...@@ -690,11 +688,7 @@ static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos
if (dsb->buflen && dsb->state && !dsb->hwbuf) { if (dsb->buflen && dsb->state && !dsb->hwbuf) {
TRACE("Checking %p, mixlen=%d\n", dsb, mixlen); TRACE("Checking %p, mixlen=%d\n", dsb, mixlen);
if (!RtlAcquireResourceShared(&dsb->lock, mustlock)) RtlAcquireResourceShared(&dsb->lock, TRUE);
{
gotall = FALSE;
continue;
}
/* if buffer is stopping it is stopped now */ /* if buffer is stopping it is stopped now */
if (dsb->state == STATE_STOPPING) { if (dsb->state == STATE_STOPPING) {
dsb->state = STATE_STOPPED; dsb->state = STATE_STOPPED;
...@@ -726,7 +720,6 @@ static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos ...@@ -726,7 +720,6 @@ static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos
} }
TRACE("Mixed at least %d from all buffers\n", minlen); TRACE("Mixed at least %d from all buffers\n", minlen);
if (!gotall) return 0;
return minlen; return minlen;
} }
...@@ -814,7 +807,6 @@ static void DSOUND_PerformMix(DirectSoundDevice *device) ...@@ -814,7 +807,6 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
DWORD playpos, writepos, writelead, maxq, frag, prebuff_max, prebuff_left, size1, size2, mixplaypos, mixplaypos2; DWORD playpos, writepos, writelead, maxq, frag, prebuff_max, prebuff_left, size1, size2, mixplaypos, mixplaypos2;
LPVOID buf1, buf2; LPVOID buf1, buf2;
BOOL lock = (device->hwbuf && !(device->drvdesc.dwFlags & DSDDESC_DONTNEEDPRIMARYLOCK)); BOOL lock = (device->hwbuf && !(device->drvdesc.dwFlags & DSDDESC_DONTNEEDPRIMARYLOCK));
BOOL mustlock = FALSE;
int nfiller; int nfiller;
/* the sound of silence */ /* the sound of silence */
...@@ -897,15 +889,11 @@ static void DSOUND_PerformMix(DirectSoundDevice *device) ...@@ -897,15 +889,11 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
TRACE("prebuff_left = %d, prebuff_max = %dx%d=%d, writelead=%d\n", TRACE("prebuff_left = %d, prebuff_max = %dx%d=%d, writelead=%d\n",
prebuff_left, device->prebuf, device->fraglen, prebuff_max, writelead); 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) if (lock)
IDsDriverBuffer_Lock(device->hwbuf, &buf1, &size1, &buf2, &size2, writepos, maxq, 0); IDsDriverBuffer_Lock(device->hwbuf, &buf1, &size1, &buf2, &size2, writepos, maxq, 0);
/* do the mixing */ /* 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) if (frag + writepos > device->buflen)
{ {
......
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