Commit 142c527b authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

dmusic: Use system ports list to create port in CreatePort and rename params.

parent 7c83bd84
......@@ -117,59 +117,62 @@ static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer(LPDIRECTMUSIC8 iface,
return DMUSIC_CreateDirectMusicBufferImpl(buffer_desc, (LPVOID)buffer);
}
static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsid_port, LPDMUS_PORTPARAMS port_params, LPDIRECTMUSICPORT* port, LPUNKNOWN unkouter)
{
IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
int i;
DMUS_PORTCAPS PortCaps;
IDirectMusicPort* pNewPort = NULL;
HRESULT hr;
GUID default_port;
const GUID *request_port = rclsidPort;
TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_dmguid(rclsidPort), pPortParams, ppPort, pUnkOuter);
if (TRACE_ON(dmusic))
dump_DMUS_PORTPARAMS(pPortParams);
if (!rclsidPort)
return E_POINTER;
if (!pPortParams)
return E_INVALIDARG;
if (!ppPort)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
if (TRACE_ON(dmusic))
dump_DMUS_PORTPARAMS(pPortParams);
ZeroMemory(&PortCaps, sizeof(DMUS_PORTCAPS));
PortCaps.dwSize = sizeof(DMUS_PORTCAPS);
if(IsEqualGUID(request_port, &GUID_NULL)){
hr = IDirectMusic8_GetDefaultPort(iface, &default_port);
if(FAILED(hr))
return hr;
request_port = &default_port;
}
IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);
int i;
DMUS_PORTCAPS port_caps;
IDirectMusicPort* new_port = NULL;
HRESULT hr;
GUID default_port;
const GUID *request_port = rclsid_port;
for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &PortCaps); i++) {
if (IsEqualCLSID (request_port, &PortCaps.guidPort)) {
hr = DMUSIC_CreateDirectMusicPortImpl(&IID_IDirectMusicPort, (LPVOID*) &pNewPort, (LPUNKNOWN) This, pPortParams, &PortCaps, 0);
if (FAILED(hr)) {
*ppPort = NULL;
return hr;
}
This->nrofports++;
if (!This->ppPorts) This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
else This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
This->ppPorts[This->nrofports - 1] = pNewPort;
*ppPort = pNewPort;
return S_OK;
}
}
return E_NOINTERFACE;
TRACE("(%p)->(%s, %p, %p, %p)\n", This, debugstr_dmguid(rclsid_port), port_params, port, unkouter);
if (TRACE_ON(dmusic))
dump_DMUS_PORTPARAMS(port_params);
if (!rclsid_port)
return E_POINTER;
if (!port_params)
return E_INVALIDARG;
if (!port)
return E_POINTER;
if (unkouter)
return CLASS_E_NOAGGREGATION;
if (TRACE_ON(dmusic))
dump_DMUS_PORTPARAMS(port_params);
ZeroMemory(&port_caps, sizeof(DMUS_PORTCAPS));
port_caps.dwSize = sizeof(DMUS_PORTCAPS);
if (IsEqualGUID(request_port, &GUID_NULL)) {
hr = IDirectMusic8_GetDefaultPort(iface, &default_port);
if(FAILED(hr))
return hr;
request_port = &default_port;
}
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);
if (FAILED(hr)) {
*port = NULL;
return hr;
}
This->nrofports++;
if (!This->ppPorts)
This->ppPorts = HeapAlloc(GetProcessHeap(), 0, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
else
This->ppPorts = HeapReAlloc(GetProcessHeap(), 0, This->ppPorts, sizeof(LPDIRECTMUSICPORT) * This->nrofports);
This->ppPorts[This->nrofports - 1] = new_port;
*port = new_port;
return S_OK;
}
}
return E_NOINTERFACE;
}
static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DWORD index, LPDMUS_CLOCKINFO clock_info)
......
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