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

dmsynth: Move constructor parameter checks to class factory.

parent 8ee23728
......@@ -27,7 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
typedef struct {
IClassFactory IClassFactory_iface;
HRESULT (*fnCreateInstance)(REFIID riid, void **ppv);
HRESULT (*create_instance)(IUnknown **ret_iface);
} IClassFactoryImpl;
/******************************************************************
......@@ -68,17 +68,24 @@ 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);
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
*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 This->fnCreateInstance(riid, ppv);
return hr;
}
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
......@@ -95,9 +102,8 @@ static const IClassFactoryVtbl classfactory_vtbl = {
ClassFactory_LockServer
};
static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicSynthImpl};
static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl},
DMUSIC_CreateDirectMusicSynthSinkImpl};
static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, synth_create};
static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl}, synth_sink_create};
/******************************************************************
......
......@@ -43,8 +43,8 @@
/*****************************************************************************
* ClassFactory
*/
extern HRESULT DMUSIC_CreateDirectMusicSynthImpl(REFIID riid, void **ppobj);
extern HRESULT DMUSIC_CreateDirectMusicSynthSinkImpl(REFIID riid, void **ppobj);
extern HRESULT synth_create(IUnknown **ret_iface);
extern HRESULT synth_sink_create(IUnknown **ret_iface);
/*****************************************************************************
* Misc.
......
......@@ -737,19 +737,18 @@ static const IKsControlVtbl synth_control_vtbl =
synth_control_KsEvent,
};
HRESULT DMUSIC_CreateDirectMusicSynthImpl(REFIID riid, void **ppobj)
HRESULT synth_create(IUnknown **ret_iface)
{
struct synth *obj;
HRESULT hr;
TRACE("(%s, %p)\n", debugstr_guid(riid), ppobj);
TRACE("(%p)\n", ret_iface);
*ppobj = NULL;
*ret_iface = NULL;
if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDirectMusicSynth8_iface.lpVtbl = &synth_vtbl;
obj->IKsControl_iface.lpVtbl = &synth_control_vtbl;
obj->ref = 1;
/* fill in caps */
obj->caps.dwSize = sizeof(DMUS_PORTCAPS);
obj->caps.dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
obj->caps.guidPort = CLSID_DirectMusicSynth;
......@@ -762,8 +761,7 @@ HRESULT DMUSIC_CreateDirectMusicSynthImpl(REFIID riid, void **ppobj)
obj->caps.dwEffectFlags = DMUS_EFFECT_REVERB;
lstrcpyW(obj->caps.wszDescription, L"Microsoft Synthesizer");
hr = IDirectMusicSynth8_QueryInterface(&obj->IDirectMusicSynth8_iface, riid, ppobj);
IDirectMusicSynth8_Release(&obj->IDirectMusicSynth8_iface);
return hr;
TRACE("Created DirectMusicSynth %p\n", obj);
*ret_iface = (IUnknown *)&obj->IDirectMusicSynth8_iface;
return S_OK;
}
......@@ -371,29 +371,27 @@ static const IKsControlVtbl synth_sink_control =
synth_sink_control_KsEvent,
};
HRESULT DMUSIC_CreateDirectMusicSynthSinkImpl(REFIID riid, void **ret_iface)
HRESULT synth_sink_create(IUnknown **ret_iface)
{
struct synth_sink *obj;
HRESULT hr;
TRACE("(%s, %p)\n", debugstr_guid(riid), ret_iface);
TRACE("(%p)\n", ret_iface);
*ret_iface = NULL;
if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDirectMusicSynthSink_iface.lpVtbl = &synth_sink_vtbl;
obj->IKsControl_iface.lpVtbl = &synth_sink_control;
obj->ref = 1;
hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&obj->latency_clock);
hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (void **)&obj->latency_clock);
if (FAILED(hr))
{
free(obj);
return hr;
}
hr = IDirectMusicSynthSink_QueryInterface(&obj->IDirectMusicSynthSink_iface, riid, ret_iface);
IDirectMusicSynthSink_Release(&obj->IDirectMusicSynthSink_iface);
return hr;
TRACE("Created DirectMusicSynthSink %p\n", obj);
*ret_iface = (IUnknown *)&obj->IDirectMusicSynthSink_iface;
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