[DSOUND] primary buffer lock fix
Robert Reif
reif at earthlink.net
Sat Jan 22 14:49:09 CST 2005
Don't allow other threads to access the primary buffer while the format
is being changed.
-------------- next part --------------
Index: dlls/dsound/primary.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/primary.c,v
retrieving revision 1.37
diff -p -u -r1.37 primary.c
--- dlls/dsound/primary.c 23 Dec 2004 18:41:06 -0000 1.37
+++ dlls/dsound/primary.c 22 Jan 2005 20:41:14 -0000
@@ -360,6 +360,7 @@ static HRESULT WINAPI PrimaryBufferImpl_
/* **** */
RtlAcquireResourceExclusive(&(dsound->buffer_list_lock), TRUE);
+ EnterCriticalSection(&(dsound->mixlock));
if (wfex->wFormatTag == WAVE_FORMAT_PCM) {
alloc_size = sizeof(WAVEFORMATEX);
@@ -387,14 +388,12 @@ static HRESULT WINAPI PrimaryBufferImpl_
if (err == DS_OK) {
err = DSOUND_PrimaryOpen(dsound);
if (err != DS_OK) {
- WARN("DSOUND_PrimaryOpen failed\n");
- RtlReleaseResource(&(dsound->buffer_list_lock));
- return err;
+ WARN("DSOUND_PrimaryOpen failed\n");
+ goto done;
}
} else {
WARN("waveOutOpen failed\n");
- RtlReleaseResource(&(dsound->buffer_list_lock));
- return err;
+ goto done;
}
} else if (dsound->hwbuf) {
err = IDsDriverBuffer_SetFormat(dsound->hwbuf, dsound->pwfx);
@@ -407,15 +406,13 @@ static HRESULT WINAPI PrimaryBufferImpl_
(LPVOID)&(dsound->hwbuf));
if (err != DS_OK) {
WARN("IDsDriver_CreateSoundBuffer failed\n");
- RtlReleaseResource(&(dsound->buffer_list_lock));
- return err;
+ goto done;
}
if (dsound->state == STATE_PLAYING) dsound->state = STATE_STARTING;
else if (dsound->state == STATE_STOPPING) dsound->state = STATE_STOPPED;
} else {
WARN("IDsDriverBuffer_SetFormat failed\n");
- RtlReleaseResource(&(dsound->buffer_list_lock));
- return err;
+ goto done;
}
/* FIXME: should we set err back to DS_OK in all cases ? */
}
@@ -435,6 +432,8 @@ static HRESULT WINAPI PrimaryBufferImpl_
}
}
+done:
+ LeaveCriticalSection(&(dsound->mixlock));
RtlReleaseResource(&(dsound->buffer_list_lock));
/* **** */
More information about the wine-patches
mailing list