[PATCH 2/2] dsound: Remove the now obsolete IDirectSoundBufferImpl_Destroy().
Michael Stefaniuc
mstefani at redhat.de
Thu Jan 19 17:53:51 CST 2012
---
Somebody familiar with the locking in dsound please have a look at
this.
The patch does keep the current semantic when in use secondary
buffers get destroyed on device destruction. Which is a safe thing to
do so short before the freeze; especially as dsound is well designed
and the application never abuse any implementation detail and
(non-existent) bugs of it...
But the search&replaced comment seems fishy as secondarybuffer_destroy
doesn't do any locking nor did the IDirectSoundBufferImpl_Destroy do
one when I started with the COM cleanup of the sound buffer objects.
bye
michael
dlls/dsound/buffer.c | 19 +++++--------------
dlls/dsound/dsound.c | 4 ++--
dlls/dsound/dsound_private.h | 2 --
3 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 18af3f9..0e1d319 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -964,6 +964,11 @@ HRESULT IDirectSoundBufferImpl_Create(
void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
{
+ ULONG ref = InterlockedIncrement(&This->numIfaces);
+
+ if (ref > 1)
+ WARN("Destroyng buffer with %u in use interfaces\n", ref - 1);
+
DirectSoundDevice_RemoveBuffer(This->device, This);
RtlDeleteResource(&This->lock);
@@ -981,20 +986,6 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
TRACE("(%p) released\n", This);
}
-HRESULT IDirectSoundBufferImpl_Destroy(
- IDirectSoundBufferImpl *pdsb)
-{
- TRACE("(%p)\n",pdsb);
-
- /* This keeps the *_Destroy functions from possibly deleting
- * this object until it is ready to be deleted */
- InterlockedIncrement(&pdsb->numIfaces);
-
- secondarybuffer_destroy(pdsb);
-
- return S_OK;
-}
-
HRESULT IDirectSoundBufferImpl_Duplicate(
DirectSoundDevice *device,
IDirectSoundBufferImpl **ppdsb,
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index b3475ad..305bfeb0 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -1244,7 +1244,7 @@ ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
/* The kill event should have allowed the timer process to expire
* but try to grab the lock just in case. Can't hold lock because
- * IDirectSoundBufferImpl_Destroy also grabs the lock */
+ * secondarybuffer_destroy also grabs the lock */
RtlAcquireResourceShared(&(device->buffer_list_lock), TRUE);
RtlReleaseResource(&(device->buffer_list_lock));
@@ -1256,7 +1256,7 @@ ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
if (device->buffers) {
WARN("%d secondary buffers not released\n", device->nrofbuffers);
for( i=0;i<device->nrofbuffers;i++)
- IDirectSoundBufferImpl_Destroy(device->buffers[i]);
+ secondarybuffer_destroy(device->buffers[i]);
}
if (device->primary) {
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 10bd281..a7209ca 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -199,8 +199,6 @@ HRESULT IDirectSoundBufferImpl_Create(
DirectSoundDevice *device,
IDirectSoundBufferImpl **ppdsb,
LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
-HRESULT IDirectSoundBufferImpl_Destroy(
- IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
HRESULT IDirectSoundBufferImpl_Duplicate(
DirectSoundDevice *device,
IDirectSoundBufferImpl **ppdsb,
--
1.7.4.4
More information about the wine-patches
mailing list