dmusic: Simplify the creation of a DirectMusicBuffer object.
Also lock/unlock the module only on creation/destruction of the object.
This commit is contained in:
parent
19b6c4cfc7
commit
57eb95a2ea
|
@ -57,8 +57,6 @@ static ULONG WINAPI IDirectMusicBufferImpl_AddRef(LPDIRECTMUSICBUFFER iface)
|
||||||
|
|
||||||
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
||||||
|
|
||||||
DMUSIC_LockModule();
|
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,10 +70,9 @@ static ULONG WINAPI IDirectMusicBufferImpl_Release(LPDIRECTMUSICBUFFER iface)
|
||||||
if (!ref) {
|
if (!ref) {
|
||||||
HeapFree(GetProcessHeap(), 0, This->data);
|
HeapFree(GetProcessHeap(), 0, This->data);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
DMUSIC_UnlockModule();
|
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +276,6 @@ static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
|
||||||
HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
|
HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
|
||||||
{
|
{
|
||||||
IDirectMusicBufferImpl* dmbuffer;
|
IDirectMusicBufferImpl* dmbuffer;
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", desc, ret_iface);
|
TRACE("(%p, %p)\n", desc, ret_iface);
|
||||||
|
|
||||||
|
@ -290,7 +286,7 @@ HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_i
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
dmbuffer->IDirectMusicBuffer_iface.lpVtbl = &DirectMusicBuffer_Vtbl;
|
dmbuffer->IDirectMusicBuffer_iface.lpVtbl = &DirectMusicBuffer_Vtbl;
|
||||||
dmbuffer->ref = 0; /* Will be inited by QueryInterface */
|
dmbuffer->ref = 1;
|
||||||
|
|
||||||
if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
|
if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
|
||||||
dmbuffer->format = KSDATAFORMAT_SUBTYPE_MIDI;
|
dmbuffer->format = KSDATAFORMAT_SUBTYPE_MIDI;
|
||||||
|
@ -304,12 +300,8 @@ HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_i
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
|
DMUSIC_LockModule();
|
||||||
if (FAILED(hr))
|
*ret_iface = &dmbuffer->IDirectMusicBuffer_iface;
|
||||||
{
|
|
||||||
HeapFree(GetProcessHeap(), 0, dmbuffer->data);
|
|
||||||
HeapFree(GetProcessHeap(), 0, dmbuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hr;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue