Zebediah Figura : dsound: Use an SRW lock for buffer_list_lock.

Alexandre Julliard julliard at winehq.org
Mon Feb 3 15:06:07 CST 2020


Module: wine
Branch: master
Commit: 13087008437d80542123fc3087cbef85f636a50a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=13087008437d80542123fc3087cbef85f636a50a

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Feb  3 09:02:17 2020 -0600

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 at gmail.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dsound/buffer.c         |  4 ++--
 dlls/dsound/dsound.c         | 15 +++++++--------
 dlls/dsound/dsound_private.h |  2 +-
 dlls/dsound/mixer.c          |  4 ++--
 dlls/dsound/primary.c        |  4 ++--
 5 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index f600652914..d585a7605e 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -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;
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index 8e2b839fe8..e7ab7922bb 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -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;
 }
 
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 930c3e92ec..5605bded90 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -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;
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index 05ca99b5df..c1bd3273f5 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -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;
 }
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 852ec51b7f..8d42fe0ed9 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -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;




More information about the wine-cvs mailing list