SetFormat will not set the primary buffer to the requested format if that format is not supported by the sound card. Wemust deal with that condition and prepare the wave signal accordingly.
Changelog:
Francois Gouget <fgouget@codeweavers.com>
* dlls/dsound/tests/dsound.c
SetFormat may not change the primary buffer format as requested. Dump the effective format and prepare the tone signal accordingly.
Play tones from the secondary buffers at -3dB rather than -12dB.
Always print the volume the tone is going to be played at.
Remove the gamedev URL.
--
Francois Gouget
fgouget@codeweavers.com
Index: dlls/dsound/tests/dsound.c =================================================================== RCS file: /home/wine/wine/dlls/dsound/tests/dsound.c,v retrieving revision 1.3 diff -u -r1.3 dsound.c --- dlls/dsound/tests/dsound.c 2 Jan 2003 23:08:57 -0000 1.3 +++ dlls/dsound/tests/dsound.c 14 Jan 2003 09:14:02 -0000 @@ -24,7 +24,6 @@ #include "wine/test.h" #include "dsound.h" -/* http://www.gamedev.net/reference/articles/article710.asp */ /* The time slice determines how often we will service the buffer and the * buffer will be four time slices long @@ -252,8 +251,8 @@ ok(rc==DS_OK,"GetFormat failed: 0x%lx\n",rc); if (rc==DS_OK) { trace(" 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); + wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample, + wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign); } rc=IDirectSoundBuffer_GetFrequency(dsbo,&freq); @@ -277,20 +276,18 @@ init_format(&wfx2,11025,16,2); rc=IDirectSoundBuffer_SetFormat(dsbo,&wfx2); ok(rc==DS_OK,"SetFormat failed: 0x%lx\n",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(dsbo,&wfx,sizeof(wfx),NULL); ok(rc==DS_OK,"GetFormat failed: 0x%lx\n",rc); if (rc==DS_OK) { - ok(wfx.wFormatTag==wfx2.wFormatTag && - wfx.nChannels==wfx2.nChannels && - wfx.wBitsPerSample==wfx2.wBitsPerSample && - wfx.nSamplesPerSec==wfx2.nSamplesPerSec && - wfx.nBlockAlign==wfx2.nBlockAlign && - wfx.nAvgBytesPerSec==wfx2.nAvgBytesPerSec, - "SetFormat did not work right: 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); - } + trace(" 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 */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); @@ -318,13 +317,15 @@ if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) { rc=IDirectSoundBuffer_GetVolume(dsbo,&volume); ok(rc==DS_OK,"GetVolume failed: 0x%lx\n",rc); - if (rc==DS_OK) { - trace(" volume=%ld\n",volume); - } - rc=IDirectSoundBuffer_SetVolume(dsbo,-1200); + rc=IDirectSoundBuffer_SetVolume(dsbo,-300); ok(rc==DS_OK,"SetVolume failed: 0x%lx\n",rc); } + rc=IDirectSoundBuffer_GetVolume(dsbo,&volume); + ok(rc==DS_OK,"GetVolume failed: 0x%lx\n",rc); + if (rc==DS_OK) { + trace(" volume=%ld\n",volume); + } state.wave=wave_generate_la(&wfx,((double)TONE_DURATION)/1000,&state.wave_len);