//open the dsound interface. static BOOL setupSoundPlay(VOID) { HWND hwnd; HRESULT hr; hwnd = frameGetWinHandle(); hr =DirectSoundCreate(NULL, &lpDirectSound, NULL); // create dsound object if (hr != DS_OK) { DBPRINTF(("NETPLAY Failed to create dsound interface.\n")); return (FALSE); } hr =IDirectSound_SetCooperativeLevel(lpDirectSound, hwnd, DSSCL_PRIORITY); // Set coop level if (hr != DS_OK) { DBPRINTF(("NETPLAY Failed to create playback buffer..\n")); return (FALSE); } IDirectSound_Compact(lpDirectSound); // compact things return (TRUE); }
static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized, LPCGUID lpGuid) { HRESULT rc; DSCAPS dscaps; int ref; IUnknown * unknown; IDirectSound * ds; IDirectSound8 * ds8; DWORD speaker_config, new_speaker_config; /* Try to Query for objects */ rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown); ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IUnknown) failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) IDirectSound_Release(unknown); rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds); ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound) failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) IDirectSound_Release(ds); rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8); ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) " "should have failed: %s\n",DXGetErrorString8(rc)); if (rc==DS_OK) IDirectSound8_Release(ds8); if (initialized == FALSE) { /* try unitialized object */ rc=IDirectSound_GetCaps(dso,0); ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps(NULL) " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_Compact(dso); ok(rc==DSERR_UNINITIALIZED,"IDirectSound_Compact() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config); ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetSpeakerConfig() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_Initialize(dso,lpGuid); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL, "IDirectSound_Initialize() failed: %s\n",DXGetErrorString8(rc)); if (rc==DSERR_NODRIVER) { trace(" No Driver\n"); goto EXIT; } else if (rc==E_FAIL) { trace(" No Device\n"); goto EXIT; } else if (rc==DSERR_ALLOCATED) { trace(" Already In Use\n"); goto EXIT; } } rc=IDirectSound_Initialize(dso,lpGuid); ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound_Initialize() " "should have returned DSERR_ALREADYINITIALIZED: %s\n", DXGetErrorString8(rc)); /* DSOUND: Error: Invalid caps buffer */ rc=IDirectSound_GetCaps(dso,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps(NULL) " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); ZeroMemory(&dscaps, sizeof(dscaps)); /* DSOUND: Error: Invalid caps buffer */ rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps() " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); dscaps.dwSize=sizeof(dscaps); /* DSOUND: Running on a certified driver */ rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc)); rc=IDirectSound_Compact(dso); ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound_Compact() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_Compact(dso); ok(rc==DS_OK,"IDirectSound_Compact() failed: %s\n",DXGetErrorString8(rc)); rc=IDirectSound_GetSpeakerConfig(dso,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetSpeakerConfig(NULL) " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config); ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n", DXGetErrorString8(rc)); speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE); rc=IDirectSound_SetSpeakerConfig(dso,speaker_config); ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) { rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config); ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && speaker_config!=new_speaker_config) trace("IDirectSound_GetSpeakerConfig() failed to set speaker " "config: expected 0x%08lx, got 0x%08lx\n", speaker_config,new_speaker_config); } EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); }