[PATCH 4/6] dmusic: Pass only the needed stuff to the DMPort create functions
Michael Stefaniuc
mstefani at winehq.org
Wed May 10 07:44:01 CDT 2017
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/dmusic/dmusic.c | 10 +++++-----
dlls/dmusic/dmusic_private.h | 12 ++++++++----
dlls/dmusic/port.c | 30 +++++++++++++++++-------------
3 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c
index d5e57af..83daafd 100644
--- a/dlls/dmusic/dmusic.c
+++ b/dlls/dmusic/dmusic.c
@@ -153,7 +153,7 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSI
for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) {
if (IsEqualCLSID(request_port, &port_caps.guidPort)) {
- hr = This->system_ports[i].create(&IID_IDirectMusicPort, (LPVOID*)&new_port, (LPUNKNOWN)This, port_params, &port_caps, This->system_ports[i].device);
+ hr = This->system_ports[i].create(This, port_params, &port_caps, &new_port);
if (FAILED(hr)) {
*port = NULL;
return hr;
@@ -377,7 +377,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
/* Fill midi mapper port info */
port->device = MIDI_MAPPER;
- port->create = DMUSIC_CreateMidiOutPortImpl;
+ port->create = midi_out_port_create;
midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated);
@@ -389,7 +389,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
for (i = 0; i < nb_midi_out; i++)
{
port->device = i;
- port->create = DMUSIC_CreateMidiOutPortImpl;
+ port->create = midi_out_port_create;
midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated);
@@ -402,7 +402,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
for (i = 0; i < nb_midi_in; i++)
{
port->device = i;
- port->create = DMUSIC_CreateMidiInPortImpl;
+ port->create = midi_in_port_create;
midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
strcpyW(port->caps.wszDescription, caps_in.szPname);
strcatW(port->caps.wszDescription, emulated);
@@ -412,7 +412,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
}
/* Fill synth port info */
- port->create = DMUSIC_CreateSynthPortImpl;
+ port->create = synth_port_create;
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
if (SUCCEEDED(hr))
{
diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h
index a470989..053d24f 100644
--- a/dlls/dmusic/dmusic_private.h
+++ b/dlls/dmusic/dmusic_private.h
@@ -71,7 +71,8 @@ typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
typedef struct port_info {
DMUS_PORTCAPS caps;
- HRESULT (*create)(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device);
+ HRESULT (*create)(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port);
ULONG device;
} port_info;
@@ -157,9 +158,12 @@ struct IDirectMusicDownloadImpl {
};
/** Internal factory */
-extern HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
-extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
-extern HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
+extern HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN;
+extern HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN;
+extern HRESULT midi_in_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN;
/*****************************************************************************
* IReferenceClockImpl implementation structure
diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c
index 07da1ae..577fb0a 100644
--- a/dlls/dmusic/port.c
+++ b/dlls/dmusic/port.c
@@ -30,6 +30,7 @@ typedef struct SynthPortImpl {
IDirectMusicThru IDirectMusicThru_iface;
IKsControl IKsControl_iface;
LONG ref;
+ IDirectMusic8Impl *parent;
IDirectSound *pDirectSound;
IReferenceClock *pLatencyClock;
IDirectMusicSynth *synth;
@@ -763,16 +764,16 @@ static const IKsControlVtbl ikscontrol_vtbl = {
IKsControlImpl_KsEvent
};
-HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port)
{
SynthPortImpl *obj;
HRESULT hr = E_FAIL;
int i;
- TRACE("(%s, %p, %p, %p, %p, %d)\n", debugstr_guid(guid), object, unkouter, port_params,
- port_caps, device);
+ TRACE("(%p, %p, %p)\n", port_params, port_caps, port);
- *object = NULL;
+ *port = NULL;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl));
if (!obj)
@@ -782,7 +783,8 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou
obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl;
obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl;
obj->IKsControl_iface.lpVtbl = &ikscontrol_vtbl;
- obj->ref = 0; /* Will be inited by QueryInterface */
+ obj->ref = 1;
+ obj->parent = parent;
obj->fActive = FALSE;
obj->params = *port_params;
obj->caps = *port_caps;
@@ -839,8 +841,10 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou
}
}
- if (SUCCEEDED(hr))
- return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, guid, object);
+ if (SUCCEEDED(hr)) {
+ *port = &obj->IDirectMusicPort_iface;
+ return S_OK;
+ }
if (obj->synth)
IDirectMusicSynth_Release(obj->synth);
@@ -853,18 +857,18 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou
return hr;
}
-HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port)
{
- TRACE("(%s, %p, %p, %p, %p, %d): stub\n", debugstr_guid(guid), object, unkouter, port_params,
- port_caps, device);
+ FIXME("(%p, %p, %p): stub\n", port_params, port_caps, port);
return E_NOTIMPL;
}
-HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
+HRESULT midi_in_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
+ DMUS_PORTCAPS *port_caps, IDirectMusicPort **port)
{
- TRACE("(%s, %p, %p, %p, %p, %d): stub\n", debugstr_guid(guid), object, unkouter, port_params,
- port_caps, device);
+ FIXME("(%p, %p, %p): stub\n", port_params, port_caps, port);
return E_NOTIMPL;
}
--
2.9.3
More information about the wine-patches
mailing list