Francois Gouget wrote:
On Sun, 25 Apr 2004, Robert Reif wrote:
Francois Gouget wrote:
Some Windows sound drivers allow wild frequencies such as the 2MHz one.
Is this a windows driver bug? Is the test really valid and it's just finding a real bug in the windows driver for that specific sound card?
I know it makes the test fail on bad windows drivers but is that bad?
It might be a buggy sound driver or it may siomply be that Windows does not specify the behavior. After all it's always possible to remap a 2MHz sampling rate to 44.1kHz...
So in doubt it seems best to just remove that test. Or currently just modify it to check for invalid bits per sample values in the hope it's a more robust test. If not we could also remove the test altogether.
How about something like this:
Adds test for illegal bits per sample. Fixes format printing.
Since we are opening the device in WAVE_FORMAT_DIRECT mode, the wave mapper is not involved so it should fail unless the hardware really supports 2MHz (which is highly unlikely).
Index: dlls/winmm/tests/wave.c =================================================================== RCS file: /home/wine/wine/dlls/winmm/tests/wave.c,v retrieving revision 1.16 diff -u -r1.16 wave.c --- dlls/winmm/tests/wave.c 27 Mar 2004 20:42:57 -0000 1.16 +++ dlls/winmm/tests/wave.c 26 Apr 2004 00:18:45 -0000 @@ -312,7 +312,7 @@ }
/* Try an invalid format to test error handling */ - trace("Testing invalid 2MHz format\n"); + trace("Testing invalid format: 2MHz sample rate\n"); format.wFormatTag=WAVE_FORMAT_PCM; format.nChannels=2; format.wBitsPerSample=16; @@ -322,7 +322,7 @@ format.cbSize=0; oformat=format; rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT); - ok(rc==WAVERR_BADFORMAT, + ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG, "waveOutOpen: opening the device at 2MHz should fail %d: rc=%d\n",d,rc); if (rc==MMSYSERR_NOERROR) { trace(" got %ldx%2dx%d for %ldx%2dx%d\n", @@ -333,22 +333,25 @@ waveOutClose(wout); }
+ /* try an unsupported bit size */ + trace("Testing invalid format: 11 bits per sample\n"); format.wFormatTag=WAVE_FORMAT_PCM; format.nChannels=2; - format.wBitsPerSample=16; - format.nSamplesPerSec=2000000; /* 2MHz! */ + format.wBitsPerSample=11; + format.nSamplesPerSec=22050; format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.cbSize=0; + oformat=format; rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT); ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG, - "waveOutOpen: opening the device at 2MHz should fail %d: rc=%d\n",d,rc); + "waveOutOpen: opening the device in 11 bit mode should fail %d: rc=%d\n",d,rc); if (rc==MMSYSERR_NOERROR) { - trace(" got %ldx%2dx%d for %dx%2dx%d\n", + trace(" got %ldx%2dx%d for %ldx%2dx%d\n", format.nSamplesPerSec, format.wBitsPerSample, format.nChannels, - win_formats[f][1], win_formats[f][2], - win_formats[f][3]); + oformat.nSamplesPerSec, oformat.wBitsPerSample, + oformat.nChannels); waveOutClose(wout); } } @@ -519,7 +522,7 @@ }
/* Try an invalid format to test error handling */ - trace("Testing invalid 2MHz format\n"); + trace("Testing invalid format: 2MHz sample rate\n"); format.wFormatTag=WAVE_FORMAT_PCM; format.nChannels=2; format.wBitsPerSample=16; @@ -529,7 +532,7 @@ format.cbSize=0; oformat=format; rc=waveInOpen(&win,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT); - ok(rc==WAVERR_BADFORMAT, + ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG, "waveInOpen: opening the device at 2MHz should fail %d: rc=%d\n",d,rc); if (rc==MMSYSERR_NOERROR) { trace(" got %ldx%2dx%d for %ldx%2dx%d\n", @@ -540,22 +543,25 @@ waveInClose(win); }
+ /* try an unsupported bit size */ + trace("Testing invalid format: 11 bits per sample\n"); format.wFormatTag=WAVE_FORMAT_PCM; format.nChannels=2; - format.wBitsPerSample=16; - format.nSamplesPerSec=2000000; /* 2MHz! */ + format.wBitsPerSample=11; + format.nSamplesPerSec=22050; format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.cbSize=0; + oformat=format; rc=waveInOpen(&win,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT); ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG, - "waveInOpen: opening the device at 2MHz should fail %d: rc=%d\n",d,rc); + "waveInOpen: opening the device in 11 bit mode should fail %d: rc=%d\n",d,rc); if (rc==MMSYSERR_NOERROR) { - trace(" got %ldx%2dx%d for %dx%2dx%d\n", + trace(" got %ldx%2dx%d for %ldx%2dx%d\n", format.nSamplesPerSec, format.wBitsPerSample, format.nChannels, - win_formats[f][1], win_formats[f][2], - win_formats[f][3]); + oformat.nSamplesPerSec, oformat.wBitsPerSample, + oformat.nChannels); waveInClose(win); } } }