예제 #1
0
/* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */
static HRESULT WINAPI IDirectMusicPerformance8Impl_Init(IDirectMusicPerformance8 *iface,
        IDirectMusic **ppDirectMusic, IDirectSound *pDirectSound, HWND hWnd)
{
        IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);

	FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p)\n", This, ppDirectMusic, pDirectSound, hWnd);
 	if (This->pDirectMusic || This->pDirectSound)
	  return DMUS_E_ALREADY_INITED;
	
	if (NULL == hWnd) {
	  hWnd = GetForegroundWindow();
	}

	if (NULL != pDirectSound) {
	  This->pDirectSound = pDirectSound;
	  IDirectSound_AddRef(This->pDirectSound);
	} else {
	  DirectSoundCreate8(NULL, (LPDIRECTSOUND8*) &This->pDirectSound, NULL);
	  if (!This->pDirectSound) return DSERR_NODRIVER;

	  if (NULL != hWnd) {
	    IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);
	  } else {
	    /* how to get the ForeGround window handle ? */
            /*IDirectSound8_SetCooperativeLevel(This->pDirectSound, hWnd, DSSCL_PRIORITY);*/
	  }
	}

	if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
          /* app creates its own dmusic object and gives it to performance */
	  This->pDirectMusic = (IDirectMusic8*) *ppDirectMusic;
	  IDirectMusic8_AddRef(This->pDirectMusic);
	} else {
        HRESULT hr;
        /* App enables the performance to initialize itself and needs a pointer to object */
        hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, (void**)&This->pDirectMusic);
        if (FAILED(hr))
            return hr;
        if (ppDirectMusic) {
            *ppDirectMusic = (LPDIRECTMUSIC)This->pDirectMusic;
            IDirectMusic8_AddRef((LPDIRECTMUSIC8)*ppDirectMusic);
        }
    }

    return S_OK;
}
예제 #2
0
파일: dmusic.c 프로젝트: Dimillian/wine
/* IDirectMusic8Impl IUnknown part: */
static HRESULT WINAPI IDirectMusic8Impl_QueryInterface(LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ret_iface)
{
    IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface);

    TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);

    if (IsEqualIID (riid, &IID_IUnknown) ||
        IsEqualIID (riid, &IID_IDirectMusic) ||
        IsEqualIID (riid, &IID_IDirectMusic2) ||
        IsEqualIID (riid, &IID_IDirectMusic8))
    {
        IDirectMusic8_AddRef(iface);
        *ret_iface = iface;
        return S_OK;
    }

    *ret_iface = NULL;

    WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);

    return E_NOINTERFACE;
}