dmusic: Pass only the needed stuff to the DMPort create functions.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2017-05-10 14:44:01 +02:00 committed by Alexandre Julliard
parent 36a88d2841
commit e8873b75af
3 changed files with 30 additions and 22 deletions

View File

@ -153,7 +153,7 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSI
for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) { for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &port_caps); i++) {
if (IsEqualCLSID(request_port, &port_caps.guidPort)) { 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)) { if (FAILED(hr)) {
*port = NULL; *port = NULL;
return hr; return hr;
@ -379,7 +379,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
/* Fill midi mapper port info */ /* Fill midi mapper port info */
port->device = MIDI_MAPPER; port->device = MIDI_MAPPER;
port->create = DMUSIC_CreateMidiOutPortImpl; port->create = midi_out_port_create;
midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out)); midiOutGetDevCapsW(MIDI_MAPPER, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname); strcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated); strcatW(port->caps.wszDescription, emulated);
@ -391,7 +391,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
for (i = 0; i < nb_midi_out; i++) for (i = 0; i < nb_midi_out; i++)
{ {
port->device = i; port->device = i;
port->create = DMUSIC_CreateMidiOutPortImpl; port->create = midi_out_port_create;
midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out)); midiOutGetDevCapsW(i, &caps_out, sizeof(caps_out));
strcpyW(port->caps.wszDescription, caps_out.szPname); strcpyW(port->caps.wszDescription, caps_out.szPname);
strcatW(port->caps.wszDescription, emulated); strcatW(port->caps.wszDescription, emulated);
@ -404,7 +404,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
for (i = 0; i < nb_midi_in; i++) for (i = 0; i < nb_midi_in; i++)
{ {
port->device = i; port->device = i;
port->create = DMUSIC_CreateMidiInPortImpl; port->create = midi_in_port_create;
midiInGetDevCapsW(i, &caps_in, sizeof(caps_in)); midiInGetDevCapsW(i, &caps_in, sizeof(caps_in));
strcpyW(port->caps.wszDescription, caps_in.szPname); strcpyW(port->caps.wszDescription, caps_in.szPname);
strcatW(port->caps.wszDescription, emulated); strcatW(port->caps.wszDescription, emulated);
@ -414,7 +414,7 @@ static void create_system_ports_list(IDirectMusic8Impl* object)
} }
/* Fill synth port info */ /* 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); hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth8, (void**)&synth);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {

View File

@ -71,7 +71,8 @@ typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
typedef struct port_info { typedef struct port_info {
DMUS_PORTCAPS caps; 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; ULONG device;
} port_info; } port_info;
@ -157,9 +158,12 @@ struct IDirectMusicDownloadImpl {
}; };
/** Internal factory */ /** 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 synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN; DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) 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 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 * IReferenceClockImpl implementation structure

View File

@ -30,6 +30,7 @@ typedef struct SynthPortImpl {
IDirectMusicThru IDirectMusicThru_iface; IDirectMusicThru IDirectMusicThru_iface;
IKsControl IKsControl_iface; IKsControl IKsControl_iface;
LONG ref; LONG ref;
IDirectMusic8Impl *parent;
IDirectSound *pDirectSound; IDirectSound *pDirectSound;
IReferenceClock *pLatencyClock; IReferenceClock *pLatencyClock;
IDirectMusicSynth *synth; IDirectMusicSynth *synth;
@ -763,16 +764,16 @@ static const IKsControlVtbl ikscontrol_vtbl = {
IKsControlImpl_KsEvent 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; SynthPortImpl *obj;
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
int i; int i;
TRACE("(%s, %p, %p, %p, %p, %d)\n", debugstr_guid(guid), object, unkouter, port_params, TRACE("(%p, %p, %p)\n", port_params, port_caps, port);
port_caps, device);
*object = NULL; *port = NULL;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl)); obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl));
if (!obj) if (!obj)
@ -782,7 +783,8 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou
obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl; obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl;
obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl; obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl;
obj->IKsControl_iface.lpVtbl = &ikscontrol_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->fActive = FALSE;
obj->params = *port_params; obj->params = *port_params;
obj->caps = *port_caps; obj->caps = *port_caps;
@ -839,8 +841,10 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou
} }
} }
if (SUCCEEDED(hr)) if (SUCCEEDED(hr)) {
return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, guid, object); *port = &obj->IDirectMusicPort_iface;
return S_OK;
}
if (obj->synth) if (obj->synth)
IDirectMusicSynth_Release(obj->synth); IDirectMusicSynth_Release(obj->synth);
@ -853,18 +857,18 @@ HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkou
return hr; 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, FIXME("(%p, %p, %p): stub\n", port_params, port_caps, port);
port_caps, device);
return E_NOTIMPL; 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, FIXME("(%p, %p, %p): stub\n", port_params, port_caps, port);
port_caps, device);
return E_NOTIMPL; return E_NOTIMPL;
} }