void main_frame::switch_glass(bool on_off) { typedef HRESULT STDAPICALLTYPE DwmExtendFrameIntoClientArea_t(HWND hWnd, _In_ const MARGINS* pMarInset); static DwmExtendFrameIntoClientArea_t* _DwmExtendFrameIntoClientArea = 0; static bool load_attempt_has_been_made = false; if(!_DwmExtendFrameIntoClientArea) { if(load_attempt_has_been_made) return; load_attempt_has_been_made = true; HMODULE hm = LoadLibrary(L"dwmapi.dll"); if( !hm ) return; _DwmExtendFrameIntoClientArea = reinterpret_cast<DwmExtendFrameIntoClientArea_t*>(GetProcAddress(hm,"DwmExtendFrameIntoClientArea")); if( !_DwmExtendFrameIntoClientArea ) return; } _is_glassy = on_off; static MARGINS unlimited_margins = {-1}; static MARGINS zero_margins = {0}; HRESULT hr = _DwmExtendFrameIntoClientArea(get_hwnd(),_is_glassy?&unlimited_margins:&zero_margins); // Extend frame across entire window. assert(SUCCEEDED(hr)); ::SciterSetOption(get_hwnd(),SCITER_TRANSPARENT_WINDOW,_is_glassy); RECT rc; ::GetWindowRect(get_hwnd(), &rc); ::SetWindowPos(get_hwnd(), NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED); }
LRESULT CDTDViewGroup::OnMDIActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { HWND hwndChildDeact = (HWND) wParam; // child being deactivated HWND hwndChildAct = (HWND) lParam; // child being activated HWND hwnd; get_hwnd(&hwnd); BOOL bActivate = (hwnd == hwndChildAct); CComQIPtr<IUIManager> uiManager = gIFrame; if (bActivate) { //CComPtr<IDocumentsClass> documentsClass; //m_pDocument->GetDocumentsClass(&documentsClass); uiManager->ActivateObject(NULL/*documentsClass*/, m_pDocument->GetUnknown()); uiManager->ActivateObject(m_pDocument->GetUnknown(), GetUnknown()); // uiManager->ActivateObject(m_viewGroup->GetUnknown(), GetUnknown()); } CUIMDIChildImpl<CDTDViewGroup>::OnMDIActivate(uMsg, wParam, lParam, bHandled); if (!bActivate) { // uiManager->DeactivateObject(GetUnknown()); uiManager->DeactivateObject(GetUnknown()); uiManager->DeactivateObject(m_pDocument->GetUnknown()); } return 0; }
window::window( UINT creationFlags, RECT frame): _hwnd(NULL) { _hwnd = SAPI()->SciterCreateWindow(creationFlags, (frame.right - frame.left) > 0 ? &frame: NULL,NULL,this,NULL); if( _hwnd ) { add_ref(); setup_callback(); sciter::attach_dom_event_handler(get_hwnd(),this); } }
window::window( UINT creationFlags, RECT frame): _hwnd(NULL) { _hwnd = ::SciterCreateWindow(creationFlags,&frame,&msg_delegate,this,NULL); if( _hwnd ) { add_ref(); setup_callback(); sciter::attach_dom_event_handler(get_hwnd(),this); } }
// 该函数在子线程中被调用 void rpc_request::rpc_signal(void* ctx) { #ifdef WIN32 HWND hWnd = get_hwnd(); if (hWnd != NULL) { // 向窗口句柄发消息,将当前对象的地址发给主线程 ::PostMessage(hWnd, RPC_WIN32_SIG, (WPARAM) ctx, (LPARAM) this); return; } #endif acl_assert(ipc_ != NULL); /* IPC_DAT data; data.req = this; data.ctx = ctx; // 向主线程发送结果 ipc_->send_message(RPC_SIG, &data, sizeof(data)); */ dat_.ctx = ctx; // 向主线程发送结果 ipc_->send_message(RPC_SIG, &dat_, sizeof(RPC_DAT)); }
static void IDirectSoundFullDuplex_tests(void) { HRESULT rc; LPDIRECTSOUNDFULLDUPLEX dsfdo = NULL; DSCBUFFERDESC DSCBufferDesc; DSBUFFERDESC DSBufferDesc; LPDIRECTSOUNDCAPTUREBUFFER8 pDSCBuffer8; LPDIRECTSOUNDBUFFER8 pDSBuffer8; WAVEFORMATEX wfex; trace("Testing IDirectSoundFullDuplex\n"); /* try the COM class factory method of creation with no devices specified */ rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex, (void**)&dsfdo); ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG||rc==CLASS_E_CLASSNOTAVAILABLE, "CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc); if (rc==REGDB_E_CLASSNOTREG) { trace(" Class Not Registered\n"); return; } else if (rc==CLASS_E_CLASSNOTAVAILABLE) { trace(" Class Not Available\n"); return; } if (dsfdo) IDirectSoundFullDuplex_test(dsfdo, FALSE, NULL, NULL); /* try the COM class factory method of creation with default devices * specified */ rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex, (void**)&dsfdo); ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc); if (dsfdo) IDirectSoundFullDuplex_test(dsfdo, FALSE, &DSDEVID_DefaultCapture, &DSDEVID_DefaultPlayback); /* try the COM class factory method of creation with default voice * devices specified */ rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex, (void**)&dsfdo); ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc); if (dsfdo) IDirectSoundFullDuplex_test(dsfdo, FALSE, &DSDEVID_DefaultVoiceCapture, &DSDEVID_DefaultVoicePlayback); /* try the COM class factory method of creation with a bad * IID specified */ rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, &CLSID_DirectSoundPrivate, (void**)&dsfdo); ok(rc==E_NOINTERFACE, "CoCreateInstance(CLSID_DirectSoundFullDuplex,CLSID_DirectSoundPrivate) " "should have failed: 0x%08x\n", rc); ZeroMemory(&wfex, sizeof(wfex)); wfex.wFormatTag = WAVE_FORMAT_PCM; wfex.nChannels = 1; wfex.nSamplesPerSec = 8000; wfex.wBitsPerSample = 16; wfex.nBlockAlign = (wfex.wBitsPerSample * wfex.nChannels) / 8; wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; ZeroMemory(&DSCBufferDesc, sizeof(DSCBufferDesc)); DSCBufferDesc.dwSize = sizeof(DSCBufferDesc); DSCBufferDesc.dwFlags = DSCBCAPS_WAVEMAPPED; DSCBufferDesc.dwBufferBytes = 8192; DSCBufferDesc.lpwfxFormat = &wfex; ZeroMemory(&DSBufferDesc, sizeof(DSBufferDesc)); DSBufferDesc.dwSize = sizeof(DSBufferDesc); DSBufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS; DSBufferDesc.dwBufferBytes = 8192; DSBufferDesc.lpwfxFormat = &wfex; /* try with no device specified */ rc=pDirectSoundFullDuplexCreate(NULL,NULL,&DSCBufferDesc,&DSBufferDesc, get_hwnd(),DSSCL_EXCLUSIVE ,&dsfdo,&pDSCBuffer8, &pDSBuffer8,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL, "DirectSoundFullDuplexCreate(NULL,NULL) failed: %08x\n",rc); if (rc==S_OK && dsfdo) IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL); /* try with default devices specified */ rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultCapture, &DSDEVID_DefaultPlayback,&DSCBufferDesc, &DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,&dsfdo, &pDSCBuffer8,&pDSBuffer8,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL, "DirectSoundFullDuplexCreate(DSDEVID_DefaultCapture," "DSDEVID_DefaultPlayback) failed: %08x\n", rc); if (rc==DS_OK && dsfdo) IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL); /* try with default voice devices specified */ rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultVoiceCapture, &DSDEVID_DefaultVoicePlayback, &DSCBufferDesc,&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE, &dsfdo,&pDSCBuffer8,&pDSBuffer8,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL, "DirectSoundFullDuplexCreate(DSDEVID_DefaultVoiceCapture," "DSDEVID_DefaultVoicePlayback) failed: %08x\n", rc); if (rc==DS_OK && dsfdo) IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL); /* try with bad devices specified */ rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultVoicePlayback, &DSDEVID_DefaultVoiceCapture, &DSCBufferDesc,&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE, &dsfdo,&pDSCBuffer8,&pDSBuffer8,NULL); ok(rc==DSERR_NODRIVER||rc==DSERR_INVALIDCALL, "DirectSoundFullDuplexCreate(DSDEVID_DefaultVoicePlayback," "DSDEVID_DefaultVoiceCapture) should have failed: %08x\n", rc); if (rc==DS_OK && dsfdo) IDirectSoundFullDuplex_Release(dsfdo); }
static HRESULT test_secondary8(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND8 dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; DWORD f; int ref; /* Create the DirectSound object */ rc=pDirectSoundCreate8(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer " "%s\n",DXGetErrorString8(rc)); if (rc==DS_OK && primary!=NULL) { rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL); ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT1; for (f=0;f<NB_FORMATS;f++) { init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], formats[f][2]); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && secondary!=NULL) IDirectSoundBuffer_Release(secondary); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; if (winetest_interactive) { trace(" Testing a secondary buffer at %ldx%dx%d " "with a primary buffer at %ldx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound8_CreateSoundBuffer() failed to create a secondary " "buffer: %s\n",DXGetErrorString8(rc)); if (rc==DS_OK && secondary!=NULL) { test_buffer8(dso,secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } EXIT1: ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound8_Release(dso); ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
/* * Test the primary buffer at different formats while keeping the * secondary buffer at a constant format. */ static HRESULT test_primary_secondary8(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND8 dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx2; int ref; unsigned int f; /* Create the DirectSound object */ rc=pDirectSoundCreate8(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer " "%s\n",DXGetErrorString8(rc)); if (rc==DS_OK && primary!=NULL) { for (f=0;f<NB_FORMATS;f++) { /* We must call SetCooperativeLevel to be allowed to call * SetFormat */ /* DSOUND: Setting DirectSound cooperative level to * DSSCL_PRIORITY */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], formats[f][2]); wfx2=wfx; rc=IDirectSoundBuffer_SetFormat(primary,&wfx); ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat() failed: %s\n", DXGetErrorString8(rc)); /* There is no garantee that SetFormat will actually change the * format to what we asked for. It depends on what the soundcard * supports. So we must re-query the format. */ rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL); ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && (wfx.wFormatTag!=wfx2.wFormatTag || wfx.nSamplesPerSec!=wfx2.nSamplesPerSec || wfx.wBitsPerSample!=wfx2.wBitsPerSample || wfx.nChannels!=wfx2.nChannels)) { trace("Requested primary format tag=0x%04x %ldx%dx%d " "avg.B/s=%ld align=%d\n", wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample, wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign); trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n", wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample, wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx2; if (winetest_interactive) { trace(" Testing a primary buffer at %ldx%dx%d with a " "secondary buffer at %ldx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary " "buffer %s\n",DXGetErrorString8(rc)); if (rc==DS_OK && secondary!=NULL) { test_buffer8(dso,secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound8_Release(dso); ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized, LPCGUID lpGuid) { HRESULT rc; DSCAPS dscaps; int ref; IUnknown * unknown; IDirectSound * ds; IDirectSound8 * ds8; DWORD speaker_config, new_speaker_config; DWORD certified; /* Try to Query for objects */ rc=IDirectSound8_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown); ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IUnknown) failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) IDirectSound8_Release(unknown); rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds); ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound) failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) IDirectSound_Release(ds); rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8); ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound8) " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) IDirectSound8_Release(ds8); if (initialized == FALSE) { /* try unitialized object */ rc=IDirectSound8_GetCaps(dso,0); ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps(NULL) " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_Compact(dso); ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_Compact() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config); ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetSpeakerConfig() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_VerifyCertification(dso, &certified); ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_VerifyCertification() " "should have returned DSERR_UNINITIALIZED, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_Initialize(dso,lpGuid); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL, "IDirectSound8_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=IDirectSound8_Initialize(dso,lpGuid); ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound8_Initialize() " "should have returned DSERR_ALREADYINITIALIZED: %s\n", DXGetErrorString8(rc)); /* DSOUND: Error: Invalid caps buffer */ rc=IDirectSound8_GetCaps(dso,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); ZeroMemory(&dscaps, sizeof(dscaps)); /* DSOUND: Error: Invalid caps buffer */ rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); dscaps.dwSize=sizeof(dscaps); /* DSOUND: Running on a certified driver */ rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc)); rc=IDirectSound8_Compact(dso); ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound8_Compact() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_Compact(dso); ok(rc==DS_OK,"IDirectSound8_Compact() failed: %s\n",DXGetErrorString8(rc)); rc=IDirectSound8_GetSpeakerConfig(dso,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetSpeakerConfig(NULL) " "should have returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config); ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %s\n", DXGetErrorString8(rc)); speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE); rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config); ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) { rc=IDirectSound8_GetSpeakerConfig(dso,&new_speaker_config); ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && speaker_config!=new_speaker_config) trace("IDirectSound8_GetSpeakerConfig() failed to set speaker " "config: expected 0x%08lx, got 0x%08lx\n", speaker_config,new_speaker_config); } rc=IDirectSound8_VerifyCertification(dso, &certified); ok(rc==DS_OK||rc==E_NOTIMPL,"IDirectSound8_VerifyCertification() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound8_Release(dso); ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref); }
static HRESULT test_primary8(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND8 dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx; int ref; /* Create the DirectSound object */ rc=pDirectSoundCreate8(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound8_CreateSoundBuffer(dso,0,0,NULL); ok(rc==DSERR_INVALIDPARAM, "IDirectSound8_CreateSoundBuffer should have returned " "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc)); /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound8_CreateSoundBuffer(dso,0,&primary,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0, "IDirectSound8_CreateSoundBuffer() should have returned " "DSERR_INVALIDPARAM, returned: rc=%s,dsbo=%p\n", DXGetErrorString8(rc),primary); /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,0,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0, "IDirectSound8_CreateSoundBuffer() should have failed: rc=%s," "dsbo=%p\n",DXGetErrorString8(rc),primary); ZeroMemory(&bufdesc, sizeof(bufdesc)); /* DSOUND: Error: Invalid size */ /* DSOUND: Error: Invalid buffer description */ rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0, "IDirectSound8_CreateSoundBuffer() should have failed: rc=%s," "primary=%p\n",DXGetErrorString8(rc),primary); /* We must call SetCooperativeLevel before calling CreateSoundBuffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* Testing the primary buffer */ primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME; bufdesc.lpwfxFormat = &wfx; init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2); rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() should have " "returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && primary!=NULL) IDirectSoundBuffer_Release(primary); primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME; rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL), "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: " "%s\n",DXGetErrorString8(rc)); if (rc==DSERR_CONTROLUNAVAIL) trace(" No Primary\n"); else if (rc==DS_OK && primary!=NULL) { LONG vol; /* Try to create a second primary buffer */ /* DSOUND: Error: The primary buffer already exists. * Any changes made to the buffer description will be ignored. */ rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&second,NULL); ok(rc==DS_OK && second==primary, "IDirectSound8_CreateSoundBuffer() should have returned original " "primary buffer: %s\n",DXGetErrorString8(rc)); ref=IDirectSoundBuffer_Release(second); ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, " "should have 1\n",ref); /* Try to duplicate a primary buffer */ /* DSOUND: Error: Can't duplicate primary buffers */ rc=IDirectSound8_DuplicateSoundBuffer(dso,primary,&third); /* rc=0x88780032 */ ok(rc!=DS_OK,"IDirectSound8_DuplicateSoundBuffer() primary buffer " "should have failed %s\n",DXGetErrorString8(rc)); rc=IDirectSoundBuffer_GetVolume(primary,&vol); ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n", DXGetErrorString8(rc)); if (winetest_interactive) { trace("Playing a 5 seconds reference tone at the current volume.\n"); if (rc==DS_OK) trace("(the current volume is %ld according to DirectSound)\n", vol); trace("All subsequent tones should be identical to this one.\n"); trace("Listen for stutter, changes in pitch, volume, etc.\n"); } test_buffer8(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0); ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound8_Release(dso); ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
bool painter<Derived>::WindowProc(Derived &, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &r) { switch(msg){ case WM_CREATE: { /*if(::IsWindowsVersionOrGreater(6, 2, 0)){ HINSTANCE module = ::LoadLibrary(L"user32.dll"); if(module == nullptr) break; using lpfnSetWindowCompositionAttribute = BOOL(WINAPI *)(HWND, detail::WINDOWCOMPOSITIONATTRIBUTEDATA*); auto SetWindowCompositionAttribute = (lpfnSetWindowCompositionAttribute)::GetProcAddress(module, "SetWindowCompositionAttribute"); if(SetWindowCompositionAttribute == nullptr){ ::FreeLibrary(module); break; } detail::ACCENTPOLICY policy = {3, 0, 0, 0}; detail::WINDOWCOMPOSITIONATTRIBUTEDATA data = {19, &policy, sizeof(policy)}; SetWindowCompositionAttribute(hwnd, &data); ::FreeLibrary(module); }else{ DWM_BLURBEHIND bb = {}; bb.dwFlags = DWM_BB_ENABLE; bb.fEnable = TRUE; ::DwmEnableBlurBehindWindow( get_hwnd(), &bb); htheme = ::OpenThemeData(hwnd, VSCLASS_WINDOW); BOOL b; ::DwmIsCompositionEnabled(&b); aero_glass = b != FALSE; }*/ } break; case WM_DESTROY: ::CloseThemeData(htheme); DestroyResource(); break; case WM_PAINT: if(CreateResource()){ mutex.lock(); paint_params pp = { target }; HWND hwnd = get_hwnd(); RECT rc; ::GetClientRect(hwnd, &rc); PAINTSTRUCT ps; ::BeginPaint(hwnd, &ps); target->BindDC(ps.hdc, &rc); target->BeginDraw(); if(!aero_glass) target->Clear(color(255, 255, 255, 255)); static_cast<Derived*>(this)->draw(pp); if(target->EndDraw() == D2DERR_RECREATE_TARGET){ DestroyResource(); repaint(); } ::EndPaint(hwnd, &ps); mutex.unlock(); }else{ throw std::runtime_error("an error occurred when creating Direct2D resources."); } break; case WM_SIZE: ::InvalidateRect(hwnd, nullptr, FALSE); break; case WM_DWMCOMPOSITIONCHANGED: { BOOL b; ::DwmIsCompositionEnabled(&b); aero_glass = b != FALSE; } break; } return true; }
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; WAVEFORMATEX wfx; int ref; trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule); driver_count++; rc=pDirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL, "DirectSoundCreate() failed: %08x\n",rc); if (rc!=DS_OK) { if (rc==DSERR_NODRIVER) trace(" No Driver\n"); else if (rc == DSERR_ALLOCATED) trace(" Already In Use\n"); else if (rc == E_FAIL) trace(" No Device\n"); goto EXIT; } /* We must call SetCooperativeLevel before calling CreateSoundBuffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT; /* Testing 3D buffers */ primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok((rc==DS_OK&&primary!=NULL) || broken(rc==DSERR_INVALIDPARAM), "IDirectSound_CreateSoundBuffer() failed to " "create a hardware 3D primary buffer: %08x\n",rc); if(rc==DSERR_INVALIDPARAM) { skip("broken driver\n"); goto EXIT; } if (rc==DS_OK&&primary!=NULL) { ZeroMemory(&wfx, sizeof(wfx)); wfx.wFormatTag=WAVE_FORMAT_PCM; wfx.nChannels=1; wfx.wBitsPerSample=16; wfx.nSamplesPerSec=44100; wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8; wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec; bufdesc.lpwfxFormat=&wfx; trace(" Testing a secondary buffer at %dx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */ "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer: %08x\n",rc); if (rc==DS_OK&&secondary!=NULL) { IKsPropertySet * pPropertySet=NULL; rc=IDirectSoundBuffer_QueryInterface(secondary, &IID_IKsPropertySet, (void **)&pPropertySet); /* it's not an error for this to fail */ if(rc==DS_OK) { ULONG ulTypeSupport; trace(" Supports property sets\n"); /* it's not an error for these to fail */ rc=IKsPropertySet_QuerySupport(pPropertySet, &DSPROPSETID_VoiceManager, 0,&ulTypeSupport); if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET| KSPROPERTY_SUPPORT_SET))) trace(" DSPROPSETID_VoiceManager supported\n"); else trace(" DSPROPSETID_VoiceManager not supported\n"); rc=IKsPropertySet_QuerySupport(pPropertySet, &DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport); if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET| KSPROPERTY_SUPPORT_SET))) trace(" DSPROPSETID_EAX20_ListenerProperties " "supported\n"); else trace(" DSPROPSETID_EAX20_ListenerProperties not " "supported\n"); rc=IKsPropertySet_QuerySupport(pPropertySet, &DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport); if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET| KSPROPERTY_SUPPORT_SET))) trace(" DSPROPSETID_EAX20_BufferProperties supported\n"); else trace(" DSPROPSETID_EAX20_BufferProperties not " "supported\n"); rc=IKsPropertySet_QuerySupport(pPropertySet, &DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport); if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET| KSPROPERTY_SUPPORT_SET))) trace(" DSPROPSETID_I3DL2_ListenerProperties " "supported\n"); else trace(" DSPROPSETID_I3DL2_ListenerProperties not " "supported\n"); rc=IKsPropertySet_QuerySupport(pPropertySet, &DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport); if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET| KSPROPERTY_SUPPORT_SET))) trace(" DSPROPSETID_I3DL2_BufferProperties supported\n"); else trace(" DSPROPSETID_I3DL2_BufferProperties not " "supported\n"); rc=IKsPropertySet_QuerySupport(pPropertySet, &DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport); if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET| KSPROPERTY_SUPPORT_SET))) trace(" DSPROPSETID_ZOOMFX_BufferProperties " "supported\n"); else trace(" DSPROPSETID_ZOOMFX_BufferProperties not " "supported\n"); ref=IKsPropertySet_Release(pPropertySet); /* try a few common ones */ ok(ref==0,"IKsPropertySet_Release() secondary has %d " "references, should have 0\n",ref); } else trace(" Doesn't support property sets\n"); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d " "references, should have 0\n",ref); } ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } EXIT: if (dso!=NULL) { ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n", ref); } return TRUE; }
static HRESULT test_frequency(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; DWORD f, r; int ref; int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 96000 }; /* Create the DirectSound object */ rc=pDirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %08x\n",rc); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a primary buffer %08x\n",rc); if (rc==DS_OK && primary!=NULL) { rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL); ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT1; for (f=0;f<sizeof(fmts)/sizeof(fmts[0]);f++) { for (r=0;r<sizeof(rates)/sizeof(rates[0]);r++) { init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits, fmts[f].channels); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY; bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)* BUFFER_LEN/1000,wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; if (winetest_interactive) { trace(" Testing a secondary buffer at %dx%dx%d " "with a primary buffer at %dx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); if (rc==DS_OK && secondary!=NULL) { test_buffer(dso,&secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } } EXIT1: ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
static HRESULT test_secondary(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; DWORD f; int ref; /* Create the DirectSound object */ rc=pDirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %08x\n",rc); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a primary buffer %08x\n",rc); if (rc==DS_OK && primary!=NULL) { rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL); ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT1; for (f=0;f<NB_FORMATS;f++) { WAVEFORMATEXTENSIBLE wfxe; init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], formats[f][2]); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() " "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc); if (rc==DS_OK && secondary!=NULL) IDirectSoundBuffer_Release(secondary); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); if (gotdx8 || wfx.wBitsPerSample <= 16) { if (wfx.wBitsPerSample > 16) ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary) || rc == DS_OK, /* driver dependent? */ "IDirectSound_CreateSoundBuffer() " "should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) " "and NULL, returned: %08x %p\n", rc, secondary); else ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); } else ok(rc==E_INVALIDARG, "Creating %d bpp buffer on dx < 8 returned: %p %08x\n", wfx.wBitsPerSample, secondary, rc); if (!gotdx8) { skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n"); /* Apparently they succeed with bogus values, * which means that older dsound doesn't look at them */ goto no_wfe; } if (secondary) IDirectSoundBuffer_Release(secondary); secondary = NULL; bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe; wfxe.Format = wfx; wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; wfxe.Format.cbSize = 1; wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample; wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL /* 2003 */) && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL || rc==DSERR_INVALIDPARAM) && !secondary) || rc==DS_OK, /* 2003 / 2008 */ "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx); wfxe.SubFormat = GUID_NULL; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL) && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; ++wfxe.Samples.wValidBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } --wfxe.Samples.wValidBitsPerSample; wfxe.Samples.wValidBitsPerSample = 0; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); no_wfe: if (rc==DS_OK && secondary!=NULL) { if (winetest_interactive) { trace(" Testing a secondary buffer at %dx%dx%d " "with a primary buffer at %dx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } test_buffer(dso,&secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0,FALSE,0); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } EXIT1: ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
static void test_COM(void) { IDirectSoundFullDuplex *dsfd = (IDirectSoundFullDuplex*)0xdeadbeef; IDirectSound *ds; IDirectSound8 *ds8; IDirectSoundCapture *dsc; IUnknown *unk, *unk8; IDirectSoundBuffer8 *dsb8; IDirectSoundCaptureBuffer8 *dscb8; DSBUFFERDESC bufdesc; DSCBUFFERDESC cbufdesc; WAVEFORMATEX wfx; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, (IUnknown*)&dsfd, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dsfd); ok(hr == CLASS_E_NOAGGREGATION, "DirectSoundFullDuplex create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dsfd, "dsfd = %p\n", dsfd); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound3DBuffer, (void**)&dsfd); ok(hr == E_NOINTERFACE, "DirectSoundFullDuplex create failed: %08x, expected E_NOINTERFACE\n", hr); /* Different refcount for IDirectSoundFullDuplex and for IUnknown */ hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex, (void**)&dsfd); ok(hr == S_OK, "DirectSoundFullDuplex create failed: %08x, expected S_OK\n", hr); refcount = IDirectSoundFullDuplex_AddRef(dsfd); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); /* Not initialized */ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8, (void**)&ds8); ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectSound8 failed: %08x, expected E_NOINTERFACE\n", hr); hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture, (void**)&dsc); ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectSoundCapture failed: %08x, expected E_NOINTERFACE\n", hr); init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1); ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize = sizeof(bufdesc); bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; bufdesc.lpwfxFormat = &wfx; ZeroMemory(&cbufdesc, sizeof(cbufdesc)); cbufdesc.dwSize = sizeof(cbufdesc); cbufdesc.dwBufferBytes = wfx.nAvgBytesPerSec; cbufdesc.lpwfxFormat = &wfx; hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), DSSCL_EXCLUSIVE, NULL, NULL); ok(hr == E_INVALIDARG, "IDirectSoundFullDuplex_Initialize failed: %08x, expected E_INVALIDARG\n", hr); hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc, get_hwnd(), DSSCL_EXCLUSIVE, &dscb8, &dsb8); if (hr == DSERR_NODRIVER || hr == DSERR_INVALIDCALL) { skip("No driver\n"); return; } ok(hr == S_OK, "IDirectSoundFullDuplex_Initialize failed: %08x\n", hr); /* IDirectSound and IDirectSound8 */ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8, (void**)&ds8); ok(hr == S_OK, "QueryInterface for IID_IDirectSound8 failed: %08x\n", hr); refcount = IDirectSound8_AddRef(ds8); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound, (void**)&ds); ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr); refcount = IDirectSound8_AddRef(ds8); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); refcount = IDirectSound_AddRef(ds); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); hr = IDirectSound8_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); ok(unk == unk8, "Got different IUnknown when QI'ing IDirectSoundFullDuplex and IDirectSound\n"); refcount = IUnknown_AddRef(unk8); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); refcount = IDirectSound_AddRef(ds); ok(refcount == 6, "refcount == %u, expected 6\n", refcount); refcount = IDirectSoundFullDuplex_AddRef(dsfd); ok(refcount == 3, "refcount == %u, expected 3\n", refcount); /* IDirectSoundCapture */ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture, (void**)&dsc); ok(hr == S_OK, "QueryInterface for IID_IDirectSoundCapture failed: %08x\n", hr); refcount = IDirectSoundCapture_AddRef(dsc); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); refcount = IDirectSoundFullDuplex_AddRef(dsfd); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); hr = IDirectSoundCapture_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); ok(unk == unk8, "Got different IUnknown when QI'ing IDirectSoundFullDuplex and IDirectSoundCapture\n"); refcount = IUnknown_AddRef(unk8); ok(refcount == 6, "refcount == %u, expected 6\n", refcount); IDirectSoundBuffer8_Release(dsb8); IDirectSoundCaptureBuffer8_Release(dscb8); while (IDirectSound8_Release(ds8)); while (IDirectSoundCapture_Release(dsc)); while (IDirectSoundFullDuplex_Release(dsfd)); while (IUnknown_Release(unk)); }
static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef) { HRESULT hr; UserData * data = pvRef; IDirectInputDeviceA *pJoystick; DIDATAFORMAT format; DIDEVCAPS caps; DIJOYSTATE2 js; JoystickInfo info; int i, count; ULONG ref; DIDEVICEINSTANCEA inst; DIDEVICEINSTANCE_DX3A inst3; DIPROPDWORD dipw; DIPROPSTRING dps; DIPROPGUIDANDPATH dpg; WCHAR nameBuffer[MAX_PATH]; HWND hWnd = get_hwnd(); char oldstate[248], curstate[248]; ok(data->version > 0x0300, "Joysticks not supported in version 0x%04x\n", data->version); hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, NULL, NULL); ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned " "E_POINTER, returned: %08x\n", hr); hr = IDirectInput_CreateDevice(data->pDI, NULL, &pJoystick, NULL); ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned " "E_POINTER, returned: %08x\n", hr); hr = IDirectInput_CreateDevice(data->pDI, NULL, NULL, NULL); ok(hr==E_POINTER,"IDirectInput_CreateDevice() should have returned " "E_POINTER, returned: %08x\n", hr); hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, &pJoystick, NULL); ok(hr==DI_OK,"IDirectInput_CreateDevice() failed: %08x\n", hr); if (hr!=DI_OK) goto DONE; trace("---- %s ----\n", lpddi->tszProductName); /* Test for joystick ID property */ ZeroMemory(&dipw, sizeof(dipw)); dipw.diph.dwSize = sizeof(DIPROPDWORD); dipw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipw.diph.dwObj = 0; dipw.diph.dwHow = DIPH_DEVICE; hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_JOYSTICKID, &dipw.diph); ok(SUCCEEDED(hr), "IDirectInputDevice_GetProperty() for DIPROP_JOYSTICKID failed\n"); /* Test for INSTANCENAME property */ memset(&dps, 0, sizeof(dps)); dps.diph.dwSize = sizeof(DIPROPSTRING); dps.diph.dwHeaderSize = sizeof(DIPROPHEADER); dps.diph.dwHow = DIPH_DEVICE; hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_INSTANCENAME, &dps.diph); ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_INSTANCENAME failed: %08x\n", hr); /* Test if instance name is the same as present in DIDEVICEINSTANCE */ MultiByteToWideChar(CP_ACP, 0, lpddi->tszInstanceName, -1, nameBuffer, MAX_PATH); ok(!lstrcmpW(nameBuffer, dps.wsz), "DIPROP_INSTANCENAME returned is wrong. Expected: %s Got: %s\n", wine_dbgstr_w(nameBuffer), wine_dbgstr_w(dps.wsz)); /* Test for GUIDPATH properties */ memset(&dpg, 0, sizeof(dpg)); dpg.diph.dwSize = sizeof(DIPROPGUIDANDPATH); dpg.diph.dwHeaderSize = sizeof(DIPROPHEADER); dpg.diph.dwHow = DIPH_DEVICE; hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_GUIDANDPATH, &dpg.diph); todo_wine ok(SUCCEEDED(hr), "IDirectInput_GetProperty() for DIPROP_GUIDANDPATH failed: %08x\n", hr); hr = IDirectInputDevice_SetDataFormat(pJoystick, NULL); ok(hr==E_POINTER,"IDirectInputDevice_SetDataFormat() should have returned " "E_POINTER, returned: %08x\n", hr); ZeroMemory(&format, sizeof(format)); hr = IDirectInputDevice_SetDataFormat(pJoystick, &format); ok(hr==DIERR_INVALIDPARAM,"IDirectInputDevice_SetDataFormat() should have " "returned DIERR_INVALIDPARAM, returned: %08x\n", hr); /* try the default formats */ hr = IDirectInputDevice_SetDataFormat(pJoystick, &c_dfDIJoystick); ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); hr = IDirectInputDevice_SetDataFormat(pJoystick, &c_dfDIJoystick2); ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); /* try an alternate format */ hr = IDirectInputDevice_SetDataFormat(pJoystick, &c_dfDIJoystickTest); ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); hr = IDirectInputDevice_SetDataFormat(pJoystick, &c_dfDIJoystick2); ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); if (hr != DI_OK) goto RELEASE; for (i=0; i<16; i++) { hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, NULL, i); ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %08x\n", i, hr); } for (i=0; i<16; i++) { hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, hWnd, i); ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %08x\n", i, hr); } hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, hWnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND); ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr); /* get capabilities */ hr = IDirectInputDevice_GetCapabilities(pJoystick, NULL); ok(hr==E_POINTER,"IDirectInputDevice_GetCapabilities() " "should have returned E_POINTER, returned: %08x\n", hr); ZeroMemory(&caps, sizeof(caps)); hr = IDirectInputDevice_GetCapabilities(pJoystick, &caps); ok(hr==DIERR_INVALIDPARAM,"IDirectInputDevice_GetCapabilities() " "should have returned DIERR_INVALIDPARAM, returned: %08x\n", hr); caps.dwSize = sizeof(caps); hr = IDirectInputDevice_GetCapabilities(pJoystick, &caps); ok(hr==DI_OK,"IDirectInputDevice_GetCapabilities() failed: %08x\n", hr); ZeroMemory(&info, sizeof(info)); info.pJoystick = pJoystick; /* default min/max limits */ info.lMin = 0; info.lMax = 0xffff; /* enumerate objects */ hr = IDirectInputDevice_EnumObjects(pJoystick, EnumAxes, &info, DIDFT_ALL); ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %08x\n", hr); ok(caps.dwAxes == info.axis, "Number of enumerated axes (%d) doesn't match capabilities (%d)\n", info.axis, caps.dwAxes); ok(caps.dwButtons == info.button, "Number of enumerated buttons (%d) doesn't match capabilities (%d)\n", info.button, caps.dwButtons); ok(caps.dwPOVs == info.pov, "Number of enumerated POVs (%d) doesn't match capabilities (%d)\n", info.pov, caps.dwPOVs); /* Set format and check limits again */ hr = IDirectInputDevice_SetDataFormat(pJoystick, &c_dfDIJoystick2); ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %08x\n", hr); info.lMin = -2000; info.lMax = +2000; info.dZone= 123; hr = IDirectInputDevice_EnumObjects(pJoystick, EnumAxes, &info, DIDFT_ALL); ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %08x\n", hr); hr = IDirectInputDevice_GetDeviceInfo(pJoystick, 0); ok(hr==E_POINTER, "IDirectInputDevice_GetDeviceInfo() " "should have returned E_POINTER, returned: %08x\n", hr); ZeroMemory(&inst, sizeof(inst)); ZeroMemory(&inst3, sizeof(inst3)); hr = IDirectInputDevice_GetDeviceInfo(pJoystick, &inst); ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_GetDeviceInfo() " "should have returned DIERR_INVALIDPARAM, returned: %08x\n", hr); inst.dwSize = sizeof(inst); hr = IDirectInputDevice_GetDeviceInfo(pJoystick, &inst); ok(hr==DI_OK,"IDirectInputDevice_GetDeviceInfo() failed: %08x\n", hr); inst3.dwSize = sizeof(inst3); hr = IDirectInputDevice_GetDeviceInfo(pJoystick, (DIDEVICEINSTANCEA*)&inst3); ok(hr==DI_OK,"IDirectInputDevice_GetDeviceInfo() failed: %08x\n", hr); hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %08x\n", hr); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); if (hr != DI_OK) goto RELEASE; hr = IDirectInputDevice_Acquire(pJoystick); ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have returned S_FALSE, got: %08x\n", hr); if (info.pov < 4) { hr = IDirectInputDevice_GetDeviceState(pJoystick, sizeof(DIJOYSTATE2), &js); ok(hr == DI_OK, "IDirectInputDevice_GetDeviceState() failed: %08x\n", hr); ok(js.rgdwPOV[3] == -1, "Default for unassigned POV should be -1 not: %d\n", js.rgdwPOV[3]); } if (caps.dwFlags & DIDC_FORCEFEEDBACK) { DWORD axes[2] = {DIJOFS_X, DIJOFS_Y}; LONG direction[2] = {0, 0}; DICONSTANTFORCE force = {0}; DIEFFECT eff; LPDIRECTINPUTEFFECT effect = NULL; LONG cnt1, cnt2; HWND real_hWnd; HINSTANCE hInstance = GetModuleHandleW(NULL); DIPROPDWORD dip_gain_set, dip_gain_get; trace("Testing force-feedback\n"); memset(&eff, 0, sizeof(eff)); eff.dwSize = sizeof(eff); eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; eff.dwDuration = INFINITE; eff.dwGain = DI_FFNOMINALMAX; eff.dwTriggerButton = DIEB_NOTRIGGER; eff.cAxes = sizeof(axes) / sizeof(axes[0]); eff.rgdwAxes = axes; eff.rglDirection = direction; eff.cbTypeSpecificParams = sizeof(force); eff.lpvTypeSpecificParams = &force; /* Sending effects to joystick requires * calling IDirectInputEffect_Initialize, which requires * having exclusive access to the device, which requires * - not having acquired the joystick when calling * IDirectInputDevice_SetCooperativeLevel * - a visible window */ real_hWnd = CreateWindowExA(0, "EDIT", "Test text", 0, 10, 10, 300, 300, NULL, NULL, hInstance, NULL); ok(real_hWnd!=0,"CreateWindowExA failed: %p\n", real_hWnd); ShowWindow(real_hWnd, SW_SHOW); hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, real_hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND); ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); cnt1 = get_refcount((IUnknown*)pJoystick); hr = IDirectInputDevice2_CreateEffect((IDirectInputDevice2A*)pJoystick, &GUID_ConstantForce, &eff, &effect, NULL); ok(hr == DI_OK, "IDirectInputDevice_CreateEffect() failed: %08x\n", hr); cnt2 = get_refcount((IUnknown*)pJoystick); ok(cnt1 == cnt2, "Ref count is wrong %d != %d\n", cnt1, cnt2); if (effect) { DWORD effect_status; struct DIPROPDWORD diprop_word; GUID guid = {0}; hr = IDirectInputEffect_Initialize(effect, hInstance, data->version, &GUID_ConstantForce); ok(hr==DI_OK,"IDirectInputEffect_Initialize failed: %08x\n", hr); hr = IDirectInputEffect_SetParameters(effect, &eff, DIEP_AXES | DIEP_DIRECTION | DIEP_TYPESPECIFICPARAMS); ok(hr==DI_OK,"IDirectInputEffect_SetParameters failed: %08x\n", hr); if (hr==DI_OK) { /* Test that upload, unacquire, acquire still permits updating * uploaded effect. */ hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); hr = IDirectInputEffect_SetParameters(effect, &eff, DIEP_GAIN); ok(hr==DI_OK,"IDirectInputEffect_SetParameters failed: %08x\n", hr); } /* Check effect status. * State: initially stopped * start * State: started * unacquire, acquire, download * State: stopped * start * State: started * * Shows that: * - effects are stopped after Unacquire + Acquire * - effects are preserved (Download + Start doesn't complain * about incomplete effect) */ hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status); ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr); ok(effect_status==0,"IDirectInputEffect_GetEffectStatus() reported effect as started\n"); hr = IDirectInputEffect_SetParameters(effect, &eff, DIEP_START); ok(hr==DI_OK,"IDirectInputEffect_SetParameters failed: %08x\n", hr); hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status); ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr); todo_wine ok(effect_status!=0,"IDirectInputEffect_GetEffectStatus() reported effect as stopped\n"); hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); hr = IDirectInputEffect_Download(effect); ok(hr==DI_OK,"IDirectInputEffect_Download() failed: %08x\n", hr); hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status); ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr); ok(effect_status==0,"IDirectInputEffect_GetEffectStatus() reported effect as started\n"); hr = IDirectInputEffect_Start(effect, 1, 0); ok(hr==DI_OK,"IDirectInputEffect_Start() failed: %08x\n", hr); hr = IDirectInputEffect_GetEffectStatus(effect, &effect_status); ok(hr==DI_OK,"IDirectInputEffect_GetEffectStatus() failed: %08x\n", hr); todo_wine ok(effect_status!=0,"IDirectInputEffect_GetEffectStatus() reported effect as stopped\n"); hr = IDirectInputEffect_GetEffectGuid(effect, &guid); ok(hr==DI_OK,"IDirectInputEffect_GetEffectGuid() failed: %08x\n", hr); ok(IsEqualGUID(&GUID_ConstantForce, &guid), "Wrong guid returned\n"); /* Check autocenter status * State: initially stopped * enable * State: enabled * acquire * State: enabled * unacquire * State: enabled * * IDirectInputDevice2_SetProperty(DIPROP_AUTOCENTER) can only be * executed when the device is released. * * If Executed interactively, user can feel that autocenter is * only disabled when the joystick is acquired. */ diprop_word.diph.dwSize = sizeof(diprop_word); diprop_word.diph.dwHeaderSize = sizeof(diprop_word.diph); diprop_word.diph.dwObj = 0; diprop_word.diph.dwHow = DIPH_DEVICE; hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph); ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr); ok(diprop_word.dwData==DIPROPAUTOCENTER_ON,"IDirectInputDevice2_GetProperty() reported autocenter as disabled\n"); diprop_word.dwData = DIPROPAUTOCENTER_OFF; hr = IDirectInputDevice2_SetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph); ok(hr==DI_OK,"IDirectInputDevice2_SetProperty() failed: %08x\n", hr); hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph); ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr); ok(diprop_word.dwData==DIPROPAUTOCENTER_OFF,"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n"); if (winetest_interactive) { trace("Acquiring in 2s, autocenter will be disabled.\n"); Sleep(2000); } hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); if (winetest_interactive) trace("Acquired.\n"); hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph); ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr); ok(diprop_word.dwData==DIPROPAUTOCENTER_OFF,"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n"); if (winetest_interactive) { trace("Releasing in 2s, autocenter will be re-enabled.\n"); Sleep(2000); } hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); if (winetest_interactive) trace("Released\n"); hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph); ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr); ok(diprop_word.dwData==DIPROPAUTOCENTER_OFF,"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n"); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); hr = IDirectInputDevice2_GetProperty(pJoystick, DIPROP_AUTOCENTER, &diprop_word.diph); ok(hr==DI_OK,"IDirectInputDevice2_GetProperty() failed: %08x\n", hr); /* Device gain (DIPROP_FFGAIN). * From MSDN: * 0..10000 range, otherwise DIERR_INVALIDPARAM. * Can be changed even if device is acquired. * Difference found by tests: * <0 is refused, >10000 is accepted */ dip_gain_set.diph.dwSize = sizeof(DIPROPDWORD); dip_gain_set.diph.dwHeaderSize = sizeof(DIPROPHEADER); dip_gain_set.diph.dwObj = 0; dip_gain_set.diph.dwHow = DIPH_DEVICE; dip_gain_set.dwData = 10000; dip_gain_get.diph.dwSize = sizeof(DIPROPDWORD); dip_gain_get.diph.dwHeaderSize = sizeof(DIPROPHEADER); dip_gain_get.diph.dwObj = 0; dip_gain_get.diph.dwHow = DIPH_DEVICE; dip_gain_get.dwData = 0; /* Test device is acquisition (non)impact. */ hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr == DI_OK, "IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %08x\n", hr); dip_gain_set.dwData = 1; hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph); ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr); hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph); ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr); ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); dip_gain_set.dwData = 2; hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph); ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr); hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph); ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr); ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData); /* Test range and internal clamping. */ dip_gain_set.dwData = -1; hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph); todo_wine ok(hr==DIERR_INVALIDPARAM, "IDirectInputDevice_SetProperty() should have returned %08x: %08x\n", DIERR_INVALIDPARAM, hr); dip_gain_set.dwData = 0; hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph); ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr); hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph); ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr); ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData); dip_gain_set.dwData = 10000; hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph); ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr); hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph); ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr); ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData); /* WARNING: This call succeeds, on the contrary of what is stated on MSDN. */ dip_gain_set.dwData = 10001; hr = IDirectInputDevice_SetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_set.diph); ok(hr==DI_OK, "IDirectInputDevice_SetProperty() failed: %08x\n", hr); hr = IDirectInputDevice_GetProperty(pJoystick, DIPROP_FFGAIN, &dip_gain_get.diph); ok(hr==DI_OK, "IDirectInputDevice_GetProperty() failed: %08x\n", hr); ok(dip_gain_get.dwData==dip_gain_set.dwData, "Gain not updated: %i\n", dip_gain_get.dwData); ref = IUnknown_Release(effect); ok(ref == 0, "IDirectInputDevice_Release() reference count = %d\n", ref); } cnt1 = get_refcount((IUnknown*)pJoystick); ok(cnt1 == cnt2, "Ref count is wrong %d != %d\n", cnt1, cnt2); /* Before destroying the window, release joystick to revert to * non-exclusive, background cooperative level. */ hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); hr = IDirectInputDevice_SetCooperativeLevel(pJoystick, hWnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND); ok(hr==DI_OK,"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n", hr); DestroyWindow (real_hWnd); hr = IDirectInputDevice_Acquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Acquire() failed: %08x\n", hr); } if (winetest_interactive) { trace("You have 30 seconds to test all axes, sliders, POVs and buttons\n"); count = 300; } else count = 1; trace("\n"); oldstate[0]='\0'; for (i = 0; i < count; i++) { hr = IDirectInputDevice_GetDeviceState(pJoystick, sizeof(DIJOYSTATE2), &js); ok(hr==DI_OK,"IDirectInputDevice_GetDeviceState() failed: %08x\n", hr); if (hr != DI_OK) break; sprintf(curstate, "X%5d Y%5d Z%5d Rx%5d Ry%5d Rz%5d " "S0%5d S1%5d POV0%5d POV1%5d POV2%5d POV3%5d " "B %d %d %d %d %d %d %d %d %d %d %d %d\n", js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz, js.rglSlider[0], js.rglSlider[1], js.rgdwPOV[0], js.rgdwPOV[1], js.rgdwPOV[2], js.rgdwPOV[3], js.rgbButtons[0]>>7, js.rgbButtons[1]>>7, js.rgbButtons[2]>>7, js.rgbButtons[3]>>7, js.rgbButtons[4]>>7, js.rgbButtons[5]>>7, js.rgbButtons[6]>>7, js.rgbButtons[7]>>7, js.rgbButtons[8]>>7, js.rgbButtons[9]>>7, js.rgbButtons[10]>>7, js.rgbButtons[11]>>7); if (strcmp(oldstate, curstate) != 0) { trace("%s\n", curstate); strcpy(oldstate, curstate); } Sleep(100); } trace("\n"); hr = IDirectInputDevice_Unacquire(pJoystick); ok(hr==DI_OK,"IDirectInputDevice_Unacquire() failed: %08x\n", hr); RELEASE: ref = IDirectInputDevice_Release(pJoystick); ok(ref==0,"IDirectInputDevice_Release() reference count = %d\n", ref); DONE: return DIENUM_CONTINUE; }
static HRESULT test_secondary8(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND8 dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; DWORD f, tag; int ref; /* Create the DirectSound object */ rc=pDirectSoundCreate8(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate8() failed: %08x\n",rc); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound8_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer " "%08x\n",rc); if (rc==DS_OK && primary!=NULL) { rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL); ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT1; for (f=0;f<NB_FORMATS;f++) { for (tag=0;tag<NB_TAGS;tag++) { WAVEFORMATEXTENSIBLE wfxe; /* if float, we only want to test 32-bit */ if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32)) continue; init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1], formats[f][2]); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() " "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc); if (rc==DS_OK && secondary!=NULL) IDirectSoundBuffer_Release(secondary); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); if (wfx.wBitsPerSample != 8 && wfx.wBitsPerSample != 16) ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary) || rc == DS_OK, /* driver dependent? */ "IDirectSound_CreateSoundBuffer() " "should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) " "and NULL, returned: %08x %p\n", rc, secondary); else ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary " "buffer %08x\n",rc); if (secondary) IDirectSoundBuffer_Release(secondary); secondary = NULL; bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe; wfxe.Format = wfx; wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); wfxe.Format.cbSize = 1; wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample; wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL /* 2003 */) && !secondary) || rc==DS_OK /* driver dependent? */, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx); wfxe.SubFormat = GUID_NULL; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL) && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL || rc==E_INVALIDARG) && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) + 1; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL /* 2003 */) && !secondary) || rc==DS_OK /* driver dependent? */, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx); ++wfxe.Samples.wValidBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } --wfxe.Samples.wValidBitsPerSample; wfxe.Samples.wValidBitsPerSample = 0; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary " "buffer %08x\n",rc); if (rc==DS_OK && secondary!=NULL) { if (winetest_interactive) { trace(" Testing a secondary buffer at %dx%dx%d (fmt=%d) " "with a primary buffer at %dx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag], wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } } EXIT1: ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc); EXIT: ref=IDirectSound8_Release(dso); ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }