Michael Stefaniuc : dmusic: Simplify the creation of a DirectMusicBuffer object.

Alexandre Julliard julliard at winehq.org
Wed Jun 11 13:36:23 CDT 2014


Module: wine
Branch: master
Commit: 57eb95a2ea19d555435a5ab0eaa1976426d8c1cd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=57eb95a2ea19d555435a5ab0eaa1976426d8c1cd

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Sat May 31 19:18:55 2014 +0200

dmusic: Simplify the creation of a DirectMusicBuffer object.

Also lock/unlock the module only on creation/destruction of the object.

---

 dlls/dmusic/buffer.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/dlls/dmusic/buffer.c b/dlls/dmusic/buffer.c
index 35cbd88..bd0ad1a 100644
--- a/dlls/dmusic/buffer.c
+++ b/dlls/dmusic/buffer.c
@@ -57,8 +57,6 @@ static ULONG WINAPI IDirectMusicBufferImpl_AddRef(LPDIRECTMUSICBUFFER iface)
 
     TRACE("(%p)->(): new ref = %u\n", iface, ref);
 
-    DMUSIC_LockModule();
-
     return ref;
 }
 
@@ -72,10 +70,9 @@ static ULONG WINAPI IDirectMusicBufferImpl_Release(LPDIRECTMUSICBUFFER iface)
     if (!ref) {
         HeapFree(GetProcessHeap(), 0, This->data);
         HeapFree(GetProcessHeap(), 0, This);
+        DMUSIC_UnlockModule();
     }
 
-    DMUSIC_UnlockModule();
-
     return ref;
 }
 
@@ -279,7 +276,6 @@ static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
 HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
 {
     IDirectMusicBufferImpl* dmbuffer;
-    HRESULT hr;
 
     TRACE("(%p, %p)\n", desc, ret_iface);
 
@@ -290,7 +286,7 @@ HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_i
         return E_OUTOFMEMORY;
 
     dmbuffer->IDirectMusicBuffer_iface.lpVtbl = &DirectMusicBuffer_Vtbl;
-    dmbuffer->ref = 0; /* Will be inited by QueryInterface */
+    dmbuffer->ref = 1;
 
     if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
         dmbuffer->format = KSDATAFORMAT_SUBTYPE_MIDI;
@@ -304,12 +300,8 @@ HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_i
         return E_OUTOFMEMORY;
     }
 
-    hr = IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
-    if (FAILED(hr))
-    {
-        HeapFree(GetProcessHeap(), 0, dmbuffer->data);
-        HeapFree(GetProcessHeap(), 0, dmbuffer);
-    }
+    DMUSIC_LockModule();
+    *ret_iface = &dmbuffer->IDirectMusicBuffer_iface;
 
-    return hr;
+    return S_OK;
 }




More information about the wine-cvs mailing list