Commit 57eb95a2 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dmusic: Simplify the creation of a DirectMusicBuffer object.

Also lock/unlock the module only on creation/destruction of the object.
parent 19b6c4cf
......@@ -57,8 +57,6 @@ static ULONG WINAPI IDirectMusicBufferImpl_AddRef(LPDIRECTMUSICBUFFER iface)
TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule();
return ref;
}
......@@ -72,9 +70,8 @@ static ULONG WINAPI IDirectMusicBufferImpl_Release(LPDIRECTMUSICBUFFER iface)
if (!ref) {
HeapFree(GetProcessHeap(), 0, This->data);
HeapFree(GetProcessHeap(), 0, This);
}
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment