Пример #1
0
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 port_caps;
    IDirectMusicPort* new_port = NULL;
    HRESULT hr;
    GUID default_port;
    const GUID *request_port = rclsid_port;

    TRACE("(%p)->(%s, %p, %p, %p)\n", This, debugstr_dmguid(rclsid_port), port_params, port, unkouter);

    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;
}
Пример #2
0
static HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwPChannel, IDirectMusicPort** ppPort, DWORD* pdwGroup, DWORD* pdwMChannel) {
	IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface;
	DMUS_PORTPARAMS8 dmusportparams;
	GUID def;

	FIXME("(%p, %d, %p, %p, %p): stub\n", This, dwPChannel, ppPort, pdwGroup, pdwMChannel);

	dmusportparams.dwSize = sizeof(DMUS_PORTPARAMS8);
	dmusportparams.dwValidParams = 0;
	IDirectMusic8_GetDefaultPort(This->pDirectMusic, &def);
	IDirectMusic8_CreatePort(This->pDirectMusic, &def, &dmusportparams, ppPort, NULL);

	return S_OK;
}
Пример #3
0
static HRESULT WINAPI IDirectMusicPerformance8Impl_PChannelInfo(IDirectMusicPerformance8 *iface,
        DWORD PChannel, IDirectMusicPort **port, DWORD *group, DWORD *MChannel)
{
    IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
    DMUS_PORTPARAMS8 port_params;
    GUID default_port;

    FIXME("(%p)->(%d, %p, %p, %p): stub\n", This, PChannel, port, group, MChannel);

    port_params.dwSize = sizeof(DMUS_PORTPARAMS8);
    port_params.dwValidParams = 0;
    IDirectMusic8_GetDefaultPort(This->pDirectMusic, &default_port);
    IDirectMusic8_CreatePort(This->pDirectMusic, &default_port, &port_params, port, NULL);

    return S_OK;
}
Пример #4
0
static HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort(IDirectMusicPerformance8 *iface,
        IDirectMusicPort *pPort)
{
        IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
	HRESULT hr = E_FAIL;

	FIXME("(%p, %p): stub\n", This, pPort);
	if (!This->pDirectMusic || !This->pDirectSound) return DMUS_E_NOT_INIT;
	if (NULL == pPort) {
	  GUID port_guid;
	  IDirectMusicPort* pDefaultPort = NULL;
	  DMUS_PORTPARAMS params;
	  int i, j;
	  hr = IDirectMusic8_GetDefaultPort(This->pDirectMusic, &port_guid);
	  if (FAILED(hr)) return hr;
	  ZeroMemory(&params, sizeof(params)); 
	  params.dwSize = sizeof(params);
	  params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_SHARE;
	  params.dwChannelGroups = 1;
	  params.fShare = TRUE;
	  hr = IDirectMusic8_CreatePort(This->pDirectMusic, &port_guid, &params, &pDefaultPort, NULL);
	  if (FAILED(hr)) return hr;
	  hr = IDirectMusicPort_Activate(pDefaultPort, TRUE);
	  if (FAILED(hr)) { IDirectMusicPort_Release(pDefaultPort); return hr; }
	  j = 0;
	  for (i = 0; i < 16; ++i) {
	    if (NULL == This->PChannel[i].port) {
	      This->PChannel[i].port = pPort; 
	      This->PChannel[i].group = 0; 
	      This->PChannel[i].channel = j; /* FIXME: should this be assigned? */
	      j++;
	    }
	  }
	} else {
	  IDirectMusicPort_AddRef(pPort);	  
	}
	/**
	 * We should remember added Ports (for example using a list)
	 * and control if Port is registered for each api who use ports
	 */
	return S_OK;
}