Commit ed4327ee authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmusic: Move constructor parameter checks to class factory.

parent 54ed994a
......@@ -520,31 +520,22 @@ static const IPersistStreamVtbl persiststream_vtbl = {
unimpl_IPersistStream_GetSizeMax
};
HRESULT DMUSIC_CreateDirectMusicCollectionImpl(REFIID lpcGUID, void **ppobj, IUnknown *pUnkOuter)
HRESULT collection_create(IUnknown **ret_iface)
{
IDirectMusicCollectionImpl* obj;
HRESULT hr;
*ppobj = NULL;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
obj = calloc(1, sizeof(IDirectMusicCollectionImpl));
if (!obj)
return E_OUTOFMEMORY;
obj->IDirectMusicCollection_iface.lpVtbl = &DirectMusicCollection_Collection_Vtbl;
obj->ref = 1;
dmobject_init(&obj->dmobj, &CLSID_DirectMusicCollection,
(IUnknown*)&obj->IDirectMusicCollection_iface);
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
list_init (&obj->Instruments);
IDirectMusicCollectionImpl *obj;
hr = IDirectMusicCollection_QueryInterface(&obj->IDirectMusicCollection_iface, lpcGUID, ppobj);
IDirectMusicCollection_Release(&obj->IDirectMusicCollection_iface);
return hr;
*ret_iface = NULL;
if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDirectMusicCollection_iface.lpVtbl = &DirectMusicCollection_Collection_Vtbl;
obj->ref = 1;
dmobject_init(&obj->dmobj, &CLSID_DirectMusicCollection,
(IUnknown *)&obj->IDirectMusicCollection_iface);
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
list_init(&obj->Instruments);
TRACE("Created DirectMusicCollection %p\n", obj);
*ret_iface = (IUnknown *)&obj->IDirectMusicCollection_iface;
return S_OK;
}
......@@ -577,22 +577,15 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
object->num_system_ports = nb_ports;
}
/* For ClassFactory */
HRESULT DMUSIC_CreateDirectMusicImpl(REFIID riid, void **ret_iface, IUnknown *unkouter)
HRESULT music_create(IUnknown **ret_iface)
{
IDirectMusic8Impl *dmusic;
HRESULT ret;
TRACE("(%s, %p, %p)\n", debugstr_guid(riid), ret_iface, unkouter);
TRACE("(%p)\n", ret_iface);
*ret_iface = NULL;
if (unkouter)
return CLASS_E_NOAGGREGATION;
dmusic = calloc(1, sizeof(IDirectMusic8Impl));
if (!dmusic)
return E_OUTOFMEMORY;
if (!(dmusic = calloc(1, sizeof(*dmusic)))) return E_OUTOFMEMORY;
dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
dmusic->ref = 1;
ret = master_clock_create(&dmusic->master_clock);
......@@ -603,8 +596,7 @@ HRESULT DMUSIC_CreateDirectMusicImpl(REFIID riid, void **ret_iface, IUnknown *un
create_system_ports_list(dmusic);
ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
IDirectMusic8_Release(&dmusic->IDirectMusic8_iface);
return ret;
TRACE("Created DirectMusic %p\n", dmusic);
*ret_iface = (IUnknown *)&dmusic->IDirectMusic8_iface;
return S_OK;
}
......@@ -41,7 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
typedef struct {
IClassFactory IClassFactory_iface;
HRESULT (*fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
HRESULT (*create_instance)(IUnknown **ret_iface);
} IClassFactoryImpl;
/******************************************************************
......@@ -82,14 +82,23 @@ static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
return 1; /* non-heap based object */
}
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
REFIID riid, void **ppv)
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *unk_outer, REFIID riid, void **ret_iface)
{
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
IUnknown *object;
HRESULT hr;
TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
TRACE("(%p, %s, %p)\n", unk_outer, debugstr_dmguid(riid), ret_iface);
return This->fnCreateInstance(riid, ppv, pUnkOuter);
*ret_iface = NULL;
if (unk_outer) return CLASS_E_NOAGGREGATION;
if (SUCCEEDED(hr = This->create_instance(&object)))
{
hr = IUnknown_QueryInterface(object, riid, ret_iface);
IUnknown_Release(object);
}
return hr;
}
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
......@@ -106,9 +115,8 @@ static const IClassFactoryVtbl classfactory_vtbl = {
ClassFactory_LockServer
};
static IClassFactoryImpl DirectMusic_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicImpl};
static IClassFactoryImpl Collection_CF = {{&classfactory_vtbl},
DMUSIC_CreateDirectMusicCollectionImpl};
static IClassFactoryImpl DirectMusic_CF = {{&classfactory_vtbl}, music_create};
static IClassFactoryImpl Collection_CF = {{&classfactory_vtbl}, collection_create};
......
......@@ -91,8 +91,8 @@ typedef struct instrument_articulation {
*/
/* CLSID */
extern HRESULT DMUSIC_CreateDirectMusicImpl(REFIID riid, void **ret_iface, IUnknown *pUnkOuter);
extern HRESULT DMUSIC_CreateDirectMusicCollectionImpl(REFIID riid, void **ppobj, IUnknown *pUnkOuter);
extern HRESULT music_create(IUnknown **ret_iface);
extern HRESULT collection_create(IUnknown **ret_iface);
/* Internal */
extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface);
......
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