📄 ds3d8.c
字号:
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(DSSCL_NORMAL) " "failed: %s\n",DXGetErrorString8(rc)); } if (play) { play_state_t state; DS3DLISTENER listener_param; LPDIRECTSOUND3DBUFFER buffer=NULL; DS3DBUFFER buffer_param; DWORD start_time,now; if (winetest_interactive) { trace(" Playing %g second 440Hz tone at %ldx%dx%d\n", duration, wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels); } if (is_primary) { /* We must call SetCooperativeLevel to be allowed to call Lock */ /* DSOUND: Setting DirectSound cooperative level to * DSSCL_WRITEPRIMARY */ rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(), DSSCL_WRITEPRIMARY); ok(rc==DS_OK, "IDirectSound8_SetCooperativeLevel(DSSCL_WRITEPRIMARY) failed: " "%s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return; } if (buffer3d) { LPDIRECTSOUNDBUFFER temp_buffer; rc=IDirectSoundBuffer_QueryInterface(dsbo,&IID_IDirectSound3DBuffer, (LPVOID *)&buffer); ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) return; /* check the COM interface */ rc=IDirectSoundBuffer_QueryInterface(dsbo, &IID_IDirectSoundBuffer, (LPVOID *)&temp_buffer); ok(rc==DS_OK && temp_buffer!=NULL, "IDirectSoundBuffer_QueryInterface() failed: %s\n", DXGetErrorString8(rc)); ok(temp_buffer==dsbo,"COM interface broken: %p != %p\n", temp_buffer,dsbo); ref=IDirectSoundBuffer_Release(temp_buffer); ok(ref==1,"IDirectSoundBuffer_Release() has %d references, " "should have 1\n",ref); temp_buffer=NULL; rc=IDirectSound3DBuffer_QueryInterface(dsbo, &IID_IDirectSoundBuffer, (LPVOID *)&temp_buffer); ok(rc==DS_OK && temp_buffer!=NULL, "IDirectSound3DBuffer_QueryInterface() failed: %s\n", DXGetErrorString8(rc)); ok(temp_buffer==dsbo,"COM interface broken: %p != %p\n", temp_buffer,dsbo); ref=IDirectSoundBuffer_Release(temp_buffer); ok(ref==1,"IDirectSoundBuffer_Release() has %d references, " "should have 1\n",ref);#if 0 /* FIXME: this works on windows */ ref=IDirectSoundBuffer_Release(dsbo); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); rc=IDirectSound3DBuffer_QueryInterface(buffer, &IID_IDirectSoundBuffer, (LPVOID *)&dsbo); ok(rc==DS_OK && dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() " "failed: %s\n",DXGetErrorString8(rc),#endif /* DSOUND: Error: Invalid buffer */ rc=IDirectSound3DBuffer_GetAllParameters(buffer,0); ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() " "failed: %s\n",DXGetErrorString8(rc)); ZeroMemory(&buffer_param, sizeof(buffer_param)); /* DSOUND: Error: Invalid buffer */ rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param); ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() " "failed: %s\n",DXGetErrorString8(rc)); buffer_param.dwSize=sizeof(buffer_param); rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param); ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %s\n", DXGetErrorString8(rc)); } if (set_volume) { if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) { LONG val; rc=IDirectSoundBuffer_GetVolume(dsbo,&val); ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSoundBuffer_SetVolume(dsbo,volume); ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %s\n", DXGetErrorString8(rc)); } else { /* DSOUND: Error: Buffer does not have CTRLVOLUME */ rc=IDirectSoundBuffer_GetVolume(dsbo,&volume); ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() " "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n", DXGetErrorString8(rc)); } } if (set_pan) { if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) { LONG val; rc=IDirectSoundBuffer_GetPan(dsbo,&val); ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSoundBuffer_SetPan(dsbo,pan); ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %s\n", DXGetErrorString8(rc)); } else { /* DSOUND: Error: Buffer does not have CTRLPAN */ rc=IDirectSoundBuffer_GetPan(dsbo,&pan); ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() " "should have returned DSERR_CONTROLUNAVAIL, returned: %s\n", DXGetErrorString8(rc)); } } state.wave=wave_generate_la(&wfx,duration,&state.wave_len); state.dsbo=dsbo; state.wfx=&wfx; state.buffer_size=dsbcaps.dwBufferBytes; state.played=state.written=state.offset=0; buffer_refill8(&state,state.buffer_size); rc=IDirectSoundBuffer_Play(dsbo,0,0,DSBPLAY_LOOPING); ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %s\n", DXGetErrorString8(rc)); rc=IDirectSoundBuffer_GetStatus(dsbo,&status); ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %s\n", DXGetErrorString8(rc)); ok(status==(DSBSTATUS_PLAYING|DSBSTATUS_LOOPING), "GetStatus: bad status: %lx\n",status); if (listener) { ZeroMemory(&listener_param,sizeof(listener_param)); listener_param.dwSize=sizeof(listener_param); rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param); ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() " "failed: %s\n",DXGetErrorString8(rc)); if (move_listener) { listener_param.vPosition.x = -5.0; listener_param.vVelocity.x = 10.0/duration; } rc=IDirectSound3DListener_SetAllParameters(listener, &listener_param, DS3D_IMMEDIATE); ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %s\n", DXGetErrorString8(rc)); } if (buffer3d) { if (move_sound) { buffer_param.vPosition.x = 100.0; buffer_param.vVelocity.x = -200.0/duration; } buffer_param.flMinDistance = 10; rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param, DS3D_IMMEDIATE); ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n", DXGetErrorString8(rc)); } start_time=GetTickCount(); while (buffer_service8(&state)) { WaitForSingleObject(GetCurrentProcess(),TIME_SLICE); now=GetTickCount(); if (listener && move_listener) { listener_param.vPosition.x = -5.0+10.0*(now-start_time)/ 1000/duration; if (winetest_debug>2) trace("listener position=%g\n",listener_param.vPosition.x); rc=IDirectSound3DListener_SetPosition(listener, listener_param.vPosition.x,listener_param.vPosition.y, listener_param.vPosition.z,DS3D_IMMEDIATE); ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: " "%s\n",DXGetErrorString8(rc)); } if (buffer3d && move_sound) { buffer_param.vPosition.x = 100-200.0*(now-start_time)/ 1000/duration; if (winetest_debug>2) trace("sound position=%g\n",buffer_param.vPosition.x); rc=IDirectSound3DBuffer_SetPosition(buffer, buffer_param.vPosition.x,buffer_param.vPosition.y, buffer_param.vPosition.z,DS3D_IMMEDIATE); ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %s\n", DXGetErrorString8(rc)); } } /* Check the sound duration was within 10% of the expected value */ now=GetTickCount(); ok(fabs(1000*duration-now+start_time)<=100*duration, "The sound played for %ld ms instead of %g ms\n", now-start_time,1000*duration); free(state.wave); if (is_primary) { /* 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)); } if (buffer3d) { ref=IDirectSound3DBuffer_Release(buffer); ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, " "should have 0\n",ref); } }}static HRESULT test_secondary8(LPGUID lpGuid, int play, int has_3d, int has_3dbuffer, int has_listener, int has_duplicate, int move_listener, int move_sound){ HRESULT rc; LPDIRECTSOUND8 dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; LPDIRECTSOUND3DLISTENER listener=NULL; DSBUFFERDESC bufdesc; WAVEFORMATEX wfx, wfx1; int ref; /* 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; /* 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(DSSCL_PRIORITY) failed: " "%s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; if (has_3d) bufdesc.dwFlags|=DSBCAPS_CTRL3D; else bufdesc.dwFlags|=(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 %sprimary buffer: " "%s\n",has_3d?"3D ":"", DXGetErrorString8(rc)); if (rc == DSERR_CONTROLUNAVAIL) trace(" No Primary\n"); else 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; if (has_listener) { rc=IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSound3DListener, (void **)&listener); ok(rc==DS_OK && listener!=NULL, "IDirectSoundBuffer_QueryInterface() failed to get a 3D "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -