dsound.c
来自「Wine-20031016」· C语言 代码 · 共 1,079 行 · 第 1/3 页
C
1,079 行
trace(" DirectSound Caps: flags=0x%08lx secondary min=%ld max=%ld\n", dscaps.dwFlags,dscaps.dwMinSecondarySampleRate, dscaps.dwMaxSecondarySampleRate); } rc=IDirectSound_GetSpeakerConfig(dso,0); ok(rc==DSERR_INVALIDPARAM,"GetSpeakerConfig should have failed: 0x%lx\n",rc); rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config); ok(rc==DS_OK,"GetSpeakerConfig failed: 0x%lx\n",rc); if (rc==DS_OK) { trace(" DirectSound SpeakerConfig: 0x%08lx\n", speaker_config); } speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,DSSPEAKER_GEOMETRY_WIDE); rc=IDirectSound_SetSpeakerConfig(dso,speaker_config); ok(rc==DS_OK,"SetSpeakerConfig failed: 0x%lx\n",rc); if (rc==DS_OK) { rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config); ok(rc==DS_OK,"GetSpeakerConfig failed: 0x%lx\n",rc); if (rc==DS_OK) ok(speaker_config==new_speaker_config,"SetSpeakerConfig failed to set speaker config: expected 0x%08lx, got 0x%08lx\n", speaker_config,new_speaker_config); } /* Release the DirectSound object */ ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; #if 0 /* FIXME: this works on windows */ /* Create a DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\n",rc); if (rc==DS_OK) { LPDIRECTSOUND dso1=NULL; /* Create a second DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso1,NULL); ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\n",rc); if (rc==DS_OK) { /* Release the second DirectSound object */ ref=IDirectSound_Release(dso1); ok(ref==0,"IDirectSound_Release has %d references, should have 0\n",ref); ok(dso!=dso1,"DirectSound objects should be unique: dso=0x%08lx,dso1=0x%08lx\n",(DWORD)dso,(DWORD)dso1); } /* Release the first DirectSound object */ ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; } else return rc;#endif return DS_OK;}static HRESULT test_primary(LPGUID lpGuid){ HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; int ref, i; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\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,"GetCaps failed: 0x%lx\n",rc); if (rc!=DS_OK) goto EXIT; /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound_CreateSoundBuffer(dso,0,0,NULL); ok(rc==DSERR_INVALIDPARAM,"CreateSoundBuffer should have failed: 0x%lx\n",rc); /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound_CreateSoundBuffer(dso,0,&primary,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0,"CreateSoundBuffer should have failed: rc=0x%lx,dsbo=0x%lx\n",rc,(DWORD)primary); /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,0,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0,"CreateSoundBuffer should have failed: rc=0x%lx,dsbo=0x%lx\n",rc,(DWORD)primary); ZeroMemory(&bufdesc, sizeof(bufdesc)); /* DSOUND: Error: Invalid size */ /* DSOUND: Error: Invalid buffer description */ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0,"CreateSoundBuffer should have failed: rc=0x%lx,primary=0x%lx\n",rc,(DWORD)primary); /* 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,"SetCooperativeLevel failed: 0x%lx\n",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|DSBCAPS_CTRLPAN; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK&&primary!=NULL,"CreateSoundBuffer failed to create a primary buffer: 0x%lx\n",rc); if (rc==DS_OK&&primary!=NULL) { /* 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=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&second,NULL); ok(rc==DS_OK&&second==primary,"CreateSoundBuffer should have returned original primary buffer: 0x%lx\n",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=IDirectSound_DuplicateSoundBuffer(dso,primary,&third); /* rc=0x88780032 */ ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer primary buffer should have failed 0x%lx\n",rc); test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),0,0,0,0); test_buffer(dso,primary,1,TRUE,0,TRUE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),0,0,0,0); if (winetest_interactive) { LONG volume = DSBVOLUME_MAX; for (i = 0; i < 6; i++) { test_buffer(dso,primary,1,TRUE,volume,TRUE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),0,0,0,0); volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40); } if (winetest_interactive) { LONG pan = DSBPAN_LEFT; for (i = 0; i < 7; i++) { test_buffer(dso,primary,1,TRUE,0,TRUE,pan,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),0,0,0,0); pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6); } } } 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,"SetCooperativeLevel failed: 0x%lx\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_primary_3d(LPGUID lpGuid){ HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; int ref; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\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,"GetCaps failed: 0x%lx\n",rc); if (rc!=DS_OK) 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,"SetCooperativeLevel failed: 0x%lx\n",rc); if (rc!=DS_OK) goto EXIT; primary=NULL; 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,"CreateSoundBuffer failed to create a primary buffer: 0x%lx\n",rc); if (rc==DS_OK&&primary!=NULL) { ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref); primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK&&primary!=NULL,"CreateSoundBuffer failed to create a 3D primary buffer: 0x%lx\n",rc); if (rc==DS_OK&&primary!=NULL) { test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),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=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"SetCooperativeLevel failed: 0x%lx\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_primary_3d_with_listener(LPGUID lpGuid){ HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; int ref; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\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,"GetCaps failed: 0x%lx\n",rc); if (rc!=DS_OK) 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,"SetCooperativeLevel failed: 0x%lx\n",rc); if (rc!=DS_OK) goto EXIT; primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK&&primary!=NULL,"CreateSoundBuffer failed to create a 3D primary buffer 0x%lx\n",rc); if (rc==DS_OK&&primary!=NULL) { LPDIRECTSOUND3DLISTENER listener=NULL; rc=IDirectSoundBuffer_QueryInterface(primary,&IID_IDirectSound3DListener,(void **)&listener); ok(rc==DS_OK&&listener!=NULL,"IDirectSoundBuffer_QueryInterface failed to get a 3D listener 0x%lx\n",rc); if (rc==DS_OK&&listener!=NULL) { LPDIRECTSOUNDBUFFER temp_buffer=NULL; /* Checking the COM interface */ rc=IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer); ok(rc==DS_OK&&temp_buffer!=NULL,"IDirectSoundBuffer_QueryInterface failed: 0x%lx\n",rc); ok(temp_buffer==primary,"COM interface broken: 0x%08lx != 0x%08lx\n",(DWORD)temp_buffer,(DWORD)primary); if(rc==DS_OK&&temp_buffer!=NULL) { ref=IDirectSoundBuffer_Release(temp_buffer); ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref); temp_buffer=NULL; rc=IDirectSound3DListener_QueryInterface(listener, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer); ok(rc==DS_OK&&temp_buffer!=NULL,"IDirectSoundBuffer_QueryInterface failed: 0x%lx\n",rc); ok(temp_buffer==primary,"COM interface broken: 0x%08lx != 0x%08lx\n",(DWORD)temp_buffer,(DWORD)primary); ref=IDirectSoundBuffer_Release(temp_buffer); ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref); /* Testing the buffer */ test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),0,listener,0,0); } /* Testing the reference counting */ ref=IDirectSound3DListener_Release(listener); ok(ref==0,"IDirectSound3DListener_Release listener has %d references, should have 0\n",ref); } /* Testing the reference counting */ ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref); }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 BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext){ HRESULT rc; trace("Testing %s - %s\n",lpcstrDescription,lpcstrModule); rc=test_dsound(lpGuid); ok(rc==DS_OK,"DirectSound test failed\n"); trace(" Testing the primary buffer\n"); rc=test_primary(lpGuid); ok(rc==DS_OK,"Primary Buffer test failed\n"); trace(" Testing 3D primary buffer\n"); rc=test_primary_3d(lpGuid); ok(rc==DS_OK,"3D Primary Buffer test failed\n"); trace(" Testing 3D primary buffer with listener\n"); rc=test_primary_3d_with_listener(lpGuid); ok(rc==DS_OK,"3D Primary Buffer with listener test failed\n"); /* Testing secondary buffers */ test_secondary(lpGuid,winetest_interactive,0,0,0,0,0,0); test_secondary(lpGuid,winetest_interactive,0,0,0,1,0,0); /* Testing 3D secondary buffers */ test_secondary(lpGuid,winetest_interactive,1,0,0,0,0,0); test_secondary(lpGuid,winetest_interactive,1,1,0,0,0,0); test_secondary(lpGuid,winetest_interactive,1,1,0,1,0,0); test_secondary(lpGuid,winetest_interactive,1,0,1,0,0,0); test_secondary(lpGuid,winetest_interactive,1,0,1,1,0,0); test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,0); test_secondary(lpGuid,winetest_interactive,1,1,1,1,0,0); test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,0); test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,1); test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,1); return 1;}static void dsound_tests(){ HRESULT rc; rc=DirectSoundEnumerateA(&dsenum_callback,NULL); ok(rc==DS_OK,"DirectSoundEnumerate failed: %ld\n",rc);}START_TEST(dsound){ dsound_tests();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?