dsound: Use an SRW lock for buffer_list_lock.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48408
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Zebediah Figura 2020-02-03 09:02:17 -06:00 committed by Alexandre Julliard
parent 729c9eab58
commit 1308700843
5 changed files with 14 additions and 15 deletions

View File

@ -643,7 +643,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock(IDirectSoundBuffer8 *iface,
if (x1 || x2)
{
RtlAcquireResourceShared(&This->device->buffer_list_lock, TRUE);
AcquireSRWLockShared(&This->device->buffer_list_lock);
LIST_FOR_EACH_ENTRY(iter, &This->buffer->buffers, IDirectSoundBufferImpl, entry )
{
RtlAcquireResourceShared(&iter->lock, TRUE);
@ -664,7 +664,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock(IDirectSoundBuffer8 *iface,
}
RtlReleaseResource(&iter->lock);
}
RtlReleaseResource(&This->device->buffer_list_lock);
ReleaseSRWLockShared(&This->device->buffer_list_lock);
}
return hres;

View File

@ -181,7 +181,7 @@ static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice)
InitializeCriticalSection(&(device->mixlock));
device->mixlock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DirectSoundDevice.mixlock");
RtlInitializeResource(&(device->buffer_list_lock));
InitializeSRWLock(&device->buffer_list_lock);
*ppDevice = device;
@ -238,7 +238,6 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
HeapFree(GetProcessHeap(), 0, device->tmp_buffer);
HeapFree(GetProcessHeap(), 0, device->cp_buffer);
HeapFree(GetProcessHeap(), 0, device->buffer);
RtlDeleteResource(&device->buffer_list_lock);
device->mixlock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&device->mixlock);
HeapFree(GetProcessHeap(),0,device);
@ -612,7 +611,7 @@ HRESULT DirectSoundDevice_AddBuffer(
TRACE("(%p, %p)\n", device, pDSB);
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
AcquireSRWLockExclusive(&device->buffer_list_lock);
if (device->buffers)
newbuffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
@ -629,7 +628,7 @@ HRESULT DirectSoundDevice_AddBuffer(
hr = DSERR_OUTOFMEMORY;
}
RtlReleaseResource(&(device->buffer_list_lock));
ReleaseSRWLockExclusive(&device->buffer_list_lock);
return hr;
}
@ -644,7 +643,7 @@ void DirectSoundDevice_RemoveBuffer(DirectSoundDevice * device, IDirectSoundBuff
TRACE("(%p, %p)\n", device, pDSB);
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
AcquireSRWLockExclusive(&device->buffer_list_lock);
if (device->nrofbuffers == 1) {
assert(device->buffers[0] == pDSB);
@ -662,7 +661,7 @@ void DirectSoundDevice_RemoveBuffer(DirectSoundDevice * device, IDirectSoundBuff
device->nrofbuffers--;
TRACE("buffer count is now %d\n", device->nrofbuffers);
RtlReleaseResource(&(device->buffer_list_lock));
ReleaseSRWLockExclusive(&device->buffer_list_lock);
}
/*******************************************************************************
@ -869,14 +868,14 @@ static HRESULT WINAPI IDirectSound8Impl_SetCooperativeLevel(IDirectSound8 *iface
level==DSSCL_PRIORITY ? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
}
RtlAcquireResourceExclusive(&device->buffer_list_lock, TRUE);
AcquireSRWLockExclusive(&device->buffer_list_lock);
EnterCriticalSection(&device->mixlock);
if ((level == DSSCL_WRITEPRIMARY) != (device->priolevel == DSSCL_WRITEPRIMARY))
hr = DSOUND_ReopenDevice(device, level == DSSCL_WRITEPRIMARY);
if (SUCCEEDED(hr))
device->priolevel = level;
LeaveCriticalSection(&device->mixlock);
RtlReleaseResource(&device->buffer_list_lock);
ReleaseSRWLockExclusive(&device->buffer_list_lock);
return hr;
}

View File

@ -80,7 +80,7 @@ struct DirectSoundDevice
DWORD writelead, buflen, ac_frames, frag_frames, playpos, pad, stopped;
int nrofbuffers;
IDirectSoundBufferImpl** buffers;
RTL_RWLOCK buffer_list_lock;
SRWLOCK buffer_list_lock;
CRITICAL_SECTION mixlock;
IDirectSoundBufferImpl *primary;
DWORD speaker_config;

View File

@ -767,9 +767,9 @@ DWORD CALLBACK DSOUND_mixthread(void *p)
if (!dev->ref)
break;
RtlAcquireResourceShared(&(dev->buffer_list_lock), TRUE);
AcquireSRWLockShared(&dev->buffer_list_lock);
DSOUND_PerformMix(dev);
RtlReleaseResource(&(dev->buffer_list_lock));
ReleaseSRWLockShared(&dev->buffer_list_lock);
}
return 0;
}

View File

@ -472,7 +472,7 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passe
}
/* **** */
RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
AcquireSRWLockExclusive(&device->buffer_list_lock);
EnterCriticalSection(&(device->mixlock));
if (device->priolevel == DSSCL_WRITEPRIMARY) {
@ -508,7 +508,7 @@ HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX passe
out:
LeaveCriticalSection(&(device->mixlock));
RtlReleaseResource(&(device->buffer_list_lock));
ReleaseSRWLockExclusive(&device->buffer_list_lock);
/* **** */
return err;