📄 ds3d8.c
字号:
"listener %s\n",DXGetErrorString8(rc));
ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
if (rc==DS_OK && listener!=NULL) {
DS3DLISTENER listener_param;
ZeroMemory(&listener_param,sizeof(listener_param));
/* DSOUND: Error: Invalid buffer */
rc=IDirectSound3DListener_GetAllParameters(listener,0);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound3dListener_GetAllParameters() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid buffer */
rc=IDirectSound3DListener_GetAllParameters(listener,
&listener_param);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound3dListener_GetAllParameters() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
listener_param.dwSize=sizeof(listener_param);
rc=IDirectSound3DListener_GetAllParameters(listener,
&listener_param);
ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
"failed: %s\n",DXGetErrorString8(rc));
}
else
goto EXIT;
}
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
if (has_3d)
bufdesc.dwFlags|=DSBCAPS_CTRL3D;
else
bufdesc.dwFlags|=
(DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
if (has_3d) {
/* a stereo 3D buffer should fail */
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound8_CreateSoundBuffer(secondary) should have "
"returned DSERR_INVALIDPARAM, returned %s\n",
DXGetErrorString8(rc));
if (secondary)
ref=IDirectSoundBuffer_Release(secondary);
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
}
if (winetest_interactive) {
trace(" Testing a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d "
"with a primary buffer at %ldx%dx%d\n",
has_3dbuffer?"3D ":"",
has_duplicate?"duplicated ":"",
listener!=NULL||move_sound?"with ":"",
move_listener?"moving ":"",
listener!=NULL?"listener ":"",
listener&&move_sound?"and moving sound ":move_sound?
"moving sound ":"",
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 %s%ssecondary buffer %s%s%s%sat %ldx%dx%d (%s): %s\n",
has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",
listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",
listener!=NULL?"listener ":"",
listener&&move_sound?"and moving sound ":move_sound?
"moving sound ":"",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
if (!has_3d) {
LONG refvol,vol,refpan,pan;
/* Check the initial secondary buffer's volume and pan */
rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
ok(vol==0,"wrong volume for a new secondary buffer: %ld\n",vol);
rc=IDirectSoundBuffer_GetPan(secondary,&pan);
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
ok(pan==0,"wrong pan for a new secondary buffer: %ld\n",pan);
/* Check that changing the secondary buffer's volume and pan
* does not impact the primary buffer's volume and pan
*/
rc=IDirectSoundBuffer_GetVolume(primary,&refvol);
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "
"%s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_GetPan(primary,&refpan);
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: "
"%s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_SetVolume(secondary,-1000);
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
ok(vol==-1000,"secondary: wrong volume %ld instead of -1000\n",
vol);
rc=IDirectSoundBuffer_SetPan(secondary,-1000);
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_GetPan(secondary,&pan);
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
ok(pan==-1000,"secondary: wrong pan %ld instead of -1000\n",
pan);
rc=IDirectSoundBuffer_GetVolume(primary,&vol);
ok(rc==DS_OK,"IDirectSoundBuffer_`GetVolume(primary) failed: i"
"%s\n",DXGetErrorString8(rc));
ok(vol==refvol,"The primary volume changed from %ld to %ld\n",
refvol,vol);
rc=IDirectSoundBuffer_GetPan(primary,&pan);
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: "
"%s\n",DXGetErrorString8(rc));
ok(pan==refpan,"The primary pan changed from %ld to %ld\n",
refpan,pan);
rc=IDirectSoundBuffer_SetVolume(secondary,0);
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
rc=IDirectSoundBuffer_SetPan(secondary,0);
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "
"%s\n",DXGetErrorString8(rc));
}
if (has_duplicate) {
LPDIRECTSOUNDBUFFER duplicated=NULL;
/* DSOUND: Error: Invalid source buffer */
rc=IDirectSound8_DuplicateSoundBuffer(dso,0,0);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound8_DuplicateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* DSOUND: Error: Invalid dest buffer */
rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,0);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound8_DuplicateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* DSOUND: Error: Invalid source buffer */
rc=IDirectSound8_DuplicateSoundBuffer(dso,0,&duplicated);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound8_DuplicateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
duplicated=NULL;
rc=IDirectSound8_DuplicateSoundBuffer(dso,secondary,
&duplicated);
ok(rc==DS_OK && duplicated!=NULL,
"IDirectSound8_DuplicateSoundBuffer() failed to duplicate "
"a secondary buffer: %s\n",DXGetErrorString8(rc));
if (rc==DS_OK && duplicated!=NULL) {
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
"references, should have 0\n",ref);
secondary=duplicated;
}
}
if (rc==DS_OK && secondary!=NULL) {
double duration;
duration=(move_listener || move_sound?4.0:1.0);
test_buffer8(dso,secondary,0,FALSE,0,FALSE,0,
winetest_interactive,duration,has_3dbuffer,
listener,move_listener,move_sound);
ref=IDirectSoundBuffer_Release(secondary);
ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "
"should have 0\n",has_duplicate?"duplicated":"secondary",
ref);
}
}
}
EXIT1:
if (has_listener) {
ref=IDirectSound3DListener_Release(listener);
ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
"references, should have 0\n",ref);
} else {
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(DSSCL_NORMAL) 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 HRESULT test_for_driver8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
int ref;
/* Create the DirectSound object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
"DirectSoundCreate8() failed: %s\n",DXGetErrorString8(rc));
if (rc!=DS_OK)
return rc;
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 HRESULT test_primary8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
LPDIRECTSOUNDBUFFER primary=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
int ref, i;
/* Create the DirectSound object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER,"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 calling CreateSoundBuffer */
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) 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|DSBCAPS_CTRLPAN;
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) {
test_buffer8(dso,primary,1,TRUE,0,TRUE,0,winetest_interactive &&
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
if (winetest_interactive) {
LONG volume,pan;
volume = DSBVOLUME_MAX;
for (i = 0; i < 6; i++) {
test_buffer8(dso,primary,1,TRUE,volume,TRUE,0,
winetest_interactive &&
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -