Module: wine Branch: master Commit: d6dc41c2efca6084e3e10619acf8758a273ec86c URL: https://gitlab.winehq.org/wine/wine/-/commit/d6dc41c2efca6084e3e10619acf8758...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Sep 4 10:56:55 2023 +0200
dmusic: Simplify and cleanup IDirectMusicInstrument constructor.
---
dlls/dmusic/collection.c | 2 +- dlls/dmusic/dmusic_private.h | 3 ++- dlls/dmusic/instrument.c | 28 +++++++++++----------------- 3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index 19fc48ce555..1331efbd05d 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -377,7 +377,7 @@ static HRESULT WINAPI collection_stream_Load(IPersistStream *iface, DMUS_PRIVATE_INSTRUMENTENTRY *new_instrument = calloc(1, sizeof(DMUS_PRIVATE_INSTRUMENTENTRY)); TRACE_(dmfile)(": instrument list\n"); /* Only way to create this one... even M$ does it discretely */ - DMUSIC_CreateDirectMusicInstrumentImpl(&IID_IDirectMusicInstrument, (void**)&new_instrument->pInstrument, NULL); + instrument_create(&new_instrument->pInstrument); { IDirectMusicInstrumentImpl *instrument = impl_from_IDirectMusicInstrument(new_instrument->pInstrument); /* Store offset and length, they will be needed when loading the instrument */ diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h index 003bbbb6544..05738c1fcf1 100644 --- a/dlls/dmusic/dmusic_private.h +++ b/dlls/dmusic/dmusic_private.h @@ -97,10 +97,11 @@ extern HRESULT collection_create(IUnknown **ret_iface); /* Internal */ extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface); extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter); -extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface);
+extern HRESULT instrument_create(IDirectMusicInstrument **ret_iface); + /***************************************************************************** * IDirectMusic8Impl implementation structure */ diff --git a/dlls/dmusic/instrument.c b/dlls/dmusic/instrument.c index 767c4419225..3d4d7478be6 100644 --- a/dlls/dmusic/instrument.c +++ b/dlls/dmusic/instrument.c @@ -119,24 +119,18 @@ static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl = IDirectMusicInstrumentImpl_SetPatch };
-/* for ClassFactory */ -HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) { - IDirectMusicInstrumentImpl* dminst; - HRESULT hr; - - dminst = calloc(1, sizeof(IDirectMusicInstrumentImpl)); - if (NULL == dminst) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } - dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl; - dminst->ref = 1; - - hr = IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, - ppobj); - IDirectMusicInstrument_Release(&dminst->IDirectMusicInstrument_iface); +HRESULT instrument_create(IDirectMusicInstrument **ret_iface) +{ + IDirectMusicInstrumentImpl *dminst;
- return hr; + *ret_iface = NULL; + if (!(dminst = calloc(1, sizeof(*dminst)))) return E_OUTOFMEMORY; + dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl; + dminst->ref = 1; + + TRACE("Created DirectMusicInstrument %p\n", dminst); + *ret_iface = &dminst->IDirectMusicInstrument_iface; + return S_OK; }
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)