Restore the 2 MHz sample rate test and fix the winealsa driver for

reasonable limits.
This commit is contained in:
Robert Reif 2004-04-27 23:28:46 +00:00 committed by Alexandre Julliard
parent 74f583ed19
commit 7c80f993d2
2 changed files with 50 additions and 7 deletions

View File

@ -324,12 +324,12 @@ static void wave_out_tests()
} }
} }
/* Try an invalid format to test error handling */ /* Try invalid formats to test error handling */
trace("Testing invalid format\n"); trace("Testing invalid format: 11 bits per sample\n");
format.wFormatTag=WAVE_FORMAT_PCM; format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2; format.nChannels=2;
format.wBitsPerSample=11; format.wBitsPerSample=11;
format.nSamplesPerSec=8000; format.nSamplesPerSec=22050;
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0; format.cbSize=0;
@ -345,6 +345,27 @@ static void wave_out_tests()
oformat.nChannels); oformat.nChannels);
waveOutClose(wout); waveOutClose(wout);
} }
trace("Testing invalid format: 2 MHz sample rate\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2;
format.wBitsPerSample=16;
format.nSamplesPerSec=2000000;
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 2 MHz sample rate should fail %d: rc=%d\n",d,rc);
if (rc==MMSYSERR_NOERROR) {
trace(" got %ldx%2dx%d for %ldx%2dx%d\n",
format.nSamplesPerSec, format.wBitsPerSample,
format.nChannels,
oformat.nSamplesPerSec, oformat.wBitsPerSample,
oformat.nChannels);
waveOutClose(wout);
}
} }
} }
@ -525,12 +546,12 @@ static void wave_in_tests()
} }
} }
/* Try an invalid format to test error handling */ /* Try invalid formats to test error handling */
trace("Testing invalid format\n"); trace("Testing invalid format: 11 bits per sample\n");
format.wFormatTag=WAVE_FORMAT_PCM; format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2; format.nChannels=2;
format.wBitsPerSample=11; format.wBitsPerSample=11;
format.nSamplesPerSec=8000; format.nSamplesPerSec=22050;
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8; format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign; format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0; format.cbSize=0;
@ -546,6 +567,27 @@ static void wave_in_tests()
oformat.nChannels); oformat.nChannels);
waveInClose(win); waveInClose(win);
} }
trace("Testing invalid format: 2 MHz sample rate\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2;
format.wBitsPerSample=16;
format.nSamplesPerSec=2000000;
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 with 2 MHz sample rate should fail %d: rc=%d\n",d,rc);
if (rc==MMSYSERR_NOERROR) {
trace(" got %ldx%2dx%d for %ldx%2dx%d\n",
format.nSamplesPerSec, format.wBitsPerSample,
format.nChannels,
oformat.nSamplesPerSec, oformat.wBitsPerSample,
oformat.nChannels);
waveInClose(win);
}
} }
} }

View File

@ -1438,7 +1438,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
/* only PCM format is supported so far... */ /* only PCM format is supported so far... */
if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM || if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM ||
lpDesc->lpFormat->nChannels == 0 || lpDesc->lpFormat->nChannels == 0 ||
lpDesc->lpFormat->nSamplesPerSec == 0 || lpDesc->lpFormat->nSamplesPerSec < DSBFREQUENCY_MIN ||
lpDesc->lpFormat->nSamplesPerSec > DSBFREQUENCY_MAX ||
(lpDesc->lpFormat->wBitsPerSample!=8 && lpDesc->lpFormat->wBitsPerSample!=16)) { (lpDesc->lpFormat->wBitsPerSample!=8 && lpDesc->lpFormat->wBitsPerSample!=16)) {
WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%ld !\n", WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%ld !\n",
lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels, lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,