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

This commit is contained in:
Christian Costa 2012-09-17 22:31:58 +02:00 committed by Alexandre Julliard
parent 7c83bd84fd
commit 142c527b4b
1 changed files with 48 additions and 45 deletions

View File

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