Treat WAVE_MAPPER as a real device and performs all tests on it.

Added 16000Hz because win9x hardware spec requires it.
This commit is contained in:
Robert Reif 2004-06-04 17:58:00 +00:00 committed by Alexandre Julliard
parent a7e8f6f3a2
commit 7bd78fe59a
3 changed files with 304 additions and 260 deletions

View File

@ -72,7 +72,7 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
(!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) && !(pcaps->dwFormats & format)) || (!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) && !(pcaps->dwFormats & format)) ||
(rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)), (rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
"waveInOpen: device=%d format=%ldx%2dx%d flags=%lx(%s) rc=%s\n",device, "waveInOpen: device=%s format=%ldx%2dx%d flags=%lx(%s) rc=%s\n",dev_name(device),
pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,CALLBACK_EVENT|flags, pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,CALLBACK_EVENT|flags,
wave_open_flags(CALLBACK_EVENT|flags),wave_in_error(rc)); wave_open_flags(CALLBACK_EVENT|flags),wave_in_error(rc));
if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
@ -80,8 +80,8 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
trace(" Reason: The device lists this format as supported in it's capabilities but opening it failed.\n"); trace(" Reason: The device lists this format as supported in it's capabilities but opening it failed.\n");
if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
!(pcaps->dwFormats & format)) !(pcaps->dwFormats & format))
trace("waveInOpen: device=%d format=%ldx%2dx%d %s rc=%s failed but format not supported so OK.\n", trace("waveInOpen: device=%s format=%ldx%2dx%d %s rc=%s failed but format not supported so OK.\n",
device, pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels, dev_name(device), pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,
flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" : flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc)); flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
if (rc!=MMSYSERR_NOERROR) { if (rc!=MMSYSERR_NOERROR) {
@ -107,7 +107,7 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
frag.lpNext=0; frag.lpNext=0;
rc=waveInPrepareHeader(win, &frag, sizeof(frag)); rc=waveInPrepareHeader(win, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR, "waveInPrepareHeader: device=%d rc=%s\n",device,wave_in_error(rc)); ok(rc==MMSYSERR_NOERROR, "waveInPrepareHeader: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
ok(frag.dwFlags&WHDR_PREPARED,"waveInPrepareHeader: prepared flag not set\n"); ok(frag.dwFlags&WHDR_PREPARED,"waveInPrepareHeader: prepared flag not set\n");
if (winetest_interactive && rc==MMSYSERR_NOERROR) { if (winetest_interactive && rc==MMSYSERR_NOERROR) {
@ -116,10 +116,10 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" : flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" :
flags & WAVE_MAPPED ? "WAVE_MAPPED" : ""); flags & WAVE_MAPPED ? "WAVE_MAPPED" : "");
rc=waveInAddBuffer(win, &frag, sizeof(frag)); rc=waveInAddBuffer(win, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR,"waveInAddBuffer: device=%d rc=%s\n",device,wave_in_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveInAddBuffer: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
rc=waveInStart(win); rc=waveInStart(win);
ok(rc==MMSYSERR_NOERROR,"waveInStart: device=%d rc=%s\n",device,wave_in_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveInStart: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
res = WaitForSingleObject(hevent,1200); res = WaitForSingleObject(hevent,1200);
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n"); ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n");
@ -130,30 +130,30 @@ static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format,
if (res!=WAIT_OBJECT_0) { if (res!=WAIT_OBJECT_0) {
rc=waveInStop(win); rc=waveInStop(win);
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveInStop: device=%d rc=%s\n",device,wave_in_error(rc)); "waveInStop: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
} }
} }
rc=waveInUnprepareHeader(win, &frag, sizeof(frag)); rc=waveInUnprepareHeader(win, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveInUnprepareHeader: device=%d rc=%s\n",device,wave_in_error(rc)); "waveInUnprepareHeader: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
rc=waveInClose(win); rc=waveInClose(win);
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveInClose: device=%d rc=%s\n",device,wave_in_error(rc)); "waveInClose: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
res=WaitForSingleObject(hevent,1000); res=WaitForSingleObject(hevent,1000);
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n"); ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n");
free(frag.lpData); free(frag.lpData);
CloseHandle(hevent); CloseHandle(hevent);
} }
static void wave_in_tests() static void wave_in_test_device(int device)
{ {
WAVEINCAPS caps; WAVEINCAPS caps;
WAVEFORMATEX format,oformat; WAVEFORMATEX format,oformat;
HWAVEIN win; HWAVEIN win;
MMRESULT rc; MMRESULT rc;
UINT ndev,d,f; UINT f;
WCHAR * wname; WCHAR * wname;
CHAR * name; CHAR * name;
DWORD size; DWORD size;
@ -166,6 +166,126 @@ static void wave_in_tests()
GetSystemInfo(&sSysInfo); GetSystemInfo(&sSysInfo);
dwPageSize = sSysInfo.dwPageSize; dwPageSize = sSysInfo.dwPageSize;
rc=waveInGetDevCapsA(device,&caps,sizeof(caps));
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
"waveInGetDevCapsA: failed to get capabilities of device %s: rc=%s\n",dev_name(device),wave_in_error(rc));
if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
return;
name=NULL;
rc=waveInMessage((HWAVEIN)device, DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0);
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
"waveInMessage: failed to get interface size for device: %s rc=%s\n",dev_name(device),wave_in_error(rc));
if (rc==MMSYSERR_NOERROR) {
wname = (WCHAR *)malloc(size);
rc=waveInMessage((HWAVEIN)device, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wname, size);
ok(rc==MMSYSERR_NOERROR,"waveInMessage: failed to get interface name for device: %s rc=%s\n",dev_name(device),wave_in_error(rc));
ok(lstrlenW(wname)+1==size/sizeof(WCHAR),"got an incorrect size: %ld instead of %d\n",size,(lstrlenW(wname)+1)*sizeof(WCHAR));
if (rc==MMSYSERR_NOERROR) {
name = malloc(size/sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, wname, size/sizeof(WCHAR), name, size/sizeof(WCHAR), NULL, NULL);
}
free(wname);
} else if (rc==MMSYSERR_NOTSUPPORTED) {
name=strdup("not supported");
}
trace(" %s: \"%s\" (%s) %d.%d (%d:%d): channels=%d formats=%05lx\n",
dev_name(device),caps.szPname,(name?name:"failed"),caps.vDriverVersion >> 8,
caps.vDriverVersion & 0xff,
caps.wMid,caps.wPid,
caps.wChannels,caps.dwFormats);
free(name);
for (f=0;f<NB_WIN_FORMATS;f++) {
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=win_formats[f][3];
format.wBitsPerSample=win_formats[f][2];
format.nSamplesPerSec=win_formats[f][1];
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_in_test_deviceIn(device,&format,win_formats[f][0],0, &caps);
wave_in_test_deviceIn(device,&format,win_formats[f][0],WAVE_FORMAT_DIRECT, &caps);
if (device != WAVE_MAPPER)
wave_in_test_deviceIn(device,&format,win_formats[f][0],WAVE_MAPPED, &caps);
}
/* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */
twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
if (twoPages) {
res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS, &flOldProtect);
ok(res, "Failed to set memory access on second page\n");
if (res) {
LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize - sizeof(PCMWAVEFORMAT));
pwfx->wFormatTag=WAVE_FORMAT_PCM;
pwfx->nChannels=1;
pwfx->wBitsPerSample=8;
pwfx->nSamplesPerSec=22050;
pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,0, &caps);
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT, &caps);
if (device != WAVE_MAPPER)
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED, &caps);
}
VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
}
/* Try invalid formats to test error handling */
trace("Testing invalid format: 11 bits per sample\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2;
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,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
"waveInOpen: opening the device in 11 bit mode should fail %s: rc=%s\n",dev_name(device),wave_in_error(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);
}
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,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
"waveInOpen: opening the device with 2 MHz sample rate should fail %s: rc=%s\n",dev_name(device),wave_in_error(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);
}
}
static void wave_in_tests()
{
WAVEINCAPS caps;
WAVEFORMATEX format;
HWAVEIN win;
MMRESULT rc;
UINT ndev,d;
ndev=waveInGetNumDevs(); ndev=waveInGetNumDevs();
trace("found %d WaveIn devices\n",ndev); trace("found %d WaveIn devices\n",ndev);
@ -192,116 +312,11 @@ static void wave_in_tests()
ok(rc==MMSYSERR_BADDEVICEID, ok(rc==MMSYSERR_BADDEVICEID,
"waveInOpen: MMSYSERR_BADDEVICEID expected, got %s\n",wave_in_error(rc)); "waveInOpen: MMSYSERR_BADDEVICEID expected, got %s\n",wave_in_error(rc));
for (d=0;d<ndev;d++) { for (d=0;d<ndev;d++)
rc=waveInGetDevCapsA(d,&caps,sizeof(caps)); wave_in_test_device(d);
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
"waveInGetDevCapsA: failed to get capabilities of device %d: rc=%s\n",d,wave_in_error(rc));
if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
continue;
name=NULL; if (ndev>0)
rc=waveInMessage((HWAVEIN)d, DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0); wave_in_test_device(WAVE_MAPPER);
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
"waveInMessage: failed to get interface size for device: %d rc=%s\n",d,wave_in_error(rc));
if (rc==MMSYSERR_NOERROR) {
wname = (WCHAR *)malloc(size);
rc=waveInMessage((HWAVEIN)d, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wname, size);
ok(rc==MMSYSERR_NOERROR,"waveInMessage: failed to get interface name for device: %d rc=%s\n",d,wave_in_error(rc));
ok(lstrlenW(wname)+1==size/sizeof(WCHAR),"got an incorrect size: %ld instead of %d\n",size,(lstrlenW(wname)+1)*sizeof(WCHAR));
if (rc==MMSYSERR_NOERROR) {
name = malloc(size/sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, wname, size/sizeof(WCHAR), name, size/sizeof(WCHAR), NULL, NULL);
}
free(wname);
} else if (rc==MMSYSERR_NOTSUPPORTED) {
name=strdup("not supported");
}
trace(" %d: \"%s\" (%s) %d.%d (%d:%d): channels=%d formats=%05lx\n",
d,caps.szPname,(name?name:"failed"),caps.vDriverVersion >> 8,
caps.vDriverVersion & 0xff,
caps.wMid,caps.wPid,
caps.wChannels,caps.dwFormats);
free(name);
for (f=0;f<NB_WIN_FORMATS;f++) {
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=win_formats[f][3];
format.wBitsPerSample=win_formats[f][2];
format.nSamplesPerSec=win_formats[f][1];
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_in_test_deviceIn(d,&format,win_formats[f][0],0, &caps);
wave_in_test_deviceIn(d,&format,win_formats[f][0],WAVE_FORMAT_DIRECT, &caps);
wave_in_test_deviceIn(d,&format,win_formats[f][0],WAVE_MAPPED, &caps);
}
/* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */
twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
if (twoPages) {
res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS, &flOldProtect);
ok(res, "Failed to set memory access on second page\n");
if (res) {
LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize - sizeof(PCMWAVEFORMAT));
pwfx->wFormatTag=WAVE_FORMAT_PCM;
pwfx->nChannels=1;
pwfx->wBitsPerSample=8;
pwfx->nSamplesPerSec=22050;
pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
wave_in_test_deviceIn(d,pwfx,WAVE_FORMAT_2M08,0, &caps);
wave_in_test_deviceIn(d,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT, &caps);
wave_in_test_deviceIn(d,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED, &caps);
}
VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
}
/* Try invalid formats to test error handling */
trace("Testing invalid format: 11 bits per sample\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2;
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 || rc==MMSYSERR_INVALPARAM,
"waveInOpen: opening the device in 11 bit mode should fail %d: rc=%s\n",d,wave_in_error(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);
}
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 || rc==MMSYSERR_INVALPARAM,
"waveInOpen: opening the device with 2 MHz sample rate should fail %d: rc=%s\n",d,wave_in_error(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);
}
}
} }
START_TEST(capture) START_TEST(capture)

View File

@ -75,6 +75,15 @@ static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
return buf; return buf;
} }
const char * dev_name(int device)
{
static char name[16];
if (device == WAVE_MAPPER)
return "WAVE_MAPPER";
sprintf(name, "%d", device);
return name;
}
const char* mmsys_error(MMRESULT error) const char* mmsys_error(MMRESULT error)
{ {
#define ERR_TO_STR(dev) case dev: return #dev #define ERR_TO_STR(dev) case dev: return #dev
@ -193,7 +202,7 @@ static void check_position(int device, HWAVEOUT wout, double duration, LPWAVEFOR
mmtime.wType = TIME_BYTES; mmtime.wType = TIME_BYTES;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime)); rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition: device=%d rc=%s\n",device,wave_out_error(rc)); "waveOutGetPosition: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_BYTES) if (mmtime.wType == TIME_BYTES)
ok(mmtime.u.cb==duration*pwfx->nAvgBytesPerSec, ok(mmtime.u.cb==duration*pwfx->nAvgBytesPerSec,
"waveOutGetPosition returned %ld bytes, should be %ld\n", "waveOutGetPosition returned %ld bytes, should be %ld\n",
@ -202,7 +211,7 @@ static void check_position(int device, HWAVEOUT wout, double duration, LPWAVEFOR
mmtime.wType = TIME_SAMPLES; mmtime.wType = TIME_SAMPLES;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime)); rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition: device=%d rc=%s\n",device,wave_out_error(rc)); "waveOutGetPosition: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_SAMPLES) if (mmtime.wType == TIME_SAMPLES)
ok(mmtime.u.sample==duration*pwfx->nSamplesPerSec, ok(mmtime.u.sample==duration*pwfx->nSamplesPerSec,
"waveOutGetPosition returned %ld samples, should be %ld\n", "waveOutGetPosition returned %ld samples, should be %ld\n",
@ -211,7 +220,7 @@ static void check_position(int device, HWAVEOUT wout, double duration, LPWAVEFOR
mmtime.wType = TIME_MS; mmtime.wType = TIME_MS;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime)); rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition: device=%d rc=%s\n",device,wave_out_error(rc)); "waveOutGetPosition: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_MS) if (mmtime.wType == TIME_MS)
ok(mmtime.u.ms==(DWORD)(duration*1000), ok(mmtime.u.ms==(DWORD)(duration*1000),
"waveOutGetPosition returned %ld ms, should be %ld\n", "waveOutGetPosition returned %ld ms, should be %ld\n",
@ -220,7 +229,7 @@ static void check_position(int device, HWAVEOUT wout, double duration, LPWAVEFOR
mmtime.wType = TIME_SMPTE; mmtime.wType = TIME_SMPTE;
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime)); rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveOutGetPosition: device=%d rc=%s\n",device,wave_out_error(rc)); "waveOutGetPosition: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
if (mmtime.wType == TIME_SMPTE) if (mmtime.wType == TIME_SMPTE)
ok(mmtime.u.smpte.hour==(BYTE)(floor(duration/(60*60))) && ok(mmtime.u.smpte.hour==(BYTE)(floor(duration/(60*60))) &&
mmtime.u.smpte.min==(BYTE)(fmod(floor(duration/60), 60)) && mmtime.u.smpte.min==(BYTE)(fmod(floor(duration/60), 60)) &&
@ -261,7 +270,7 @@ static void wave_out_test_deviceOut(int device, double duration, LPWAVEFORMATEX
((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
(!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) && !(pcaps->dwFormats & format)) || (!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) && !(pcaps->dwFormats & format)) ||
(rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)), (rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
"waveOutOpen: device=%d format=%ldx%2dx%d flags=%lx(%s) rc=%s\n",device, "waveOutOpen: device=%s format=%ldx%2dx%d flags=%lx(%s) rc=%s\n",dev_name(device),
pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,CALLBACK_EVENT|flags, pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,CALLBACK_EVENT|flags,
wave_open_flags(CALLBACK_EVENT|flags),wave_out_error(rc)); wave_open_flags(CALLBACK_EVENT|flags),wave_out_error(rc));
if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
@ -269,8 +278,8 @@ static void wave_out_test_deviceOut(int device, double duration, LPWAVEFORMATEX
trace(" Reason: The device lists this format as supported in it's capabilities but opening it failed.\n"); trace(" Reason: The device lists this format as supported in it's capabilities but opening it failed.\n");
if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) && if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
!(pcaps->dwFormats & format)) !(pcaps->dwFormats & format))
trace("waveOutOpen: device=%d format=%ldx%2dx%d %s rc=%s failed but format not supported so OK.\n", trace("waveOutOpen: device=%s format=%ldx%2dx%d %s rc=%s failed but format not supported so OK.\n",
device, pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels, dev_name(device), pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,
flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" : flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc)); flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
if (rc!=MMSYSERR_NOERROR) { if (rc!=MMSYSERR_NOERROR) {
@ -290,11 +299,11 @@ static void wave_out_test_deviceOut(int device, double duration, LPWAVEFORMATEX
frag.dwLoops=0; frag.dwLoops=0;
rc=waveOutGetVolume(wout,&volume); rc=waveOutGetVolume(wout,&volume);
ok(rc==MMSYSERR_NOERROR,"waveOutGetVolume: device=%d rc=%s\n",device,wave_out_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveOutGetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
rc=waveOutPrepareHeader(wout, &frag, sizeof(frag)); rc=waveOutPrepareHeader(wout, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveOutPrepareHeader: device=%d rc=%s\n",device,wave_out_error(rc)); "waveOutPrepareHeader: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
if (winetest_interactive && rc==MMSYSERR_NOERROR) { if (winetest_interactive && rc==MMSYSERR_NOERROR) {
trace("Playing %g second 440Hz tone at %5ldx%2dx%d %s\n",duration, trace("Playing %g second 440Hz tone at %5ldx%2dx%d %s\n",duration,
@ -302,36 +311,36 @@ static void wave_out_test_deviceOut(int device, double duration, LPWAVEFORMATEX
flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" : flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" :
flags & WAVE_MAPPED ? "WAVE_MAPPED" : ""); flags & WAVE_MAPPED ? "WAVE_MAPPED" : "");
rc=waveOutSetVolume(wout,0x20002000); rc=waveOutSetVolume(wout,0x20002000);
ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%d rc=%s\n",device,wave_out_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
WaitForSingleObject(hevent,INFINITE); WaitForSingleObject(hevent,INFINITE);
rc=waveOutWrite(wout, &frag, sizeof(frag)); rc=waveOutWrite(wout, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR,"waveOutWrite: device=%d rc=%s\n",device,wave_out_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveOutWrite: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
WaitForSingleObject(hevent,INFINITE); WaitForSingleObject(hevent,INFINITE);
rc=waveOutSetVolume(wout,volume); rc=waveOutSetVolume(wout,volume);
ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%d rc=%s\n",device,wave_out_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
check_position(device, wout, duration, pwfx); check_position(device, wout, duration, pwfx);
} }
rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag)); rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveOutUnprepareHeader: device=%d rc=%s\n",device,wave_out_error(rc)); "waveOutUnprepareHeader: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
free(frag.lpData); free(frag.lpData);
CloseHandle(hevent); CloseHandle(hevent);
rc=waveOutClose(wout); rc=waveOutClose(wout);
ok(rc==MMSYSERR_NOERROR,"waveOutClose: device=%d rc=%s\n",device,wave_out_error(rc)); ok(rc==MMSYSERR_NOERROR,"waveOutClose: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
} }
static void wave_out_tests() static void wave_out_test_device(int device)
{ {
WAVEOUTCAPS caps; WAVEOUTCAPS caps;
WAVEFORMATEX format, oformat; WAVEFORMATEX format, oformat;
HWAVEOUT wout; HWAVEOUT wout;
MMRESULT rc; MMRESULT rc;
UINT ndev,d,f; UINT f;
WCHAR * wname; WCHAR * wname;
CHAR * name; CHAR * name;
DWORD size; DWORD size;
@ -344,6 +353,141 @@ static void wave_out_tests()
GetSystemInfo(&sSysInfo); GetSystemInfo(&sSysInfo);
dwPageSize = sSysInfo.dwPageSize; dwPageSize = sSysInfo.dwPageSize;
rc=waveOutGetDevCapsA(device,&caps,sizeof(caps));
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
"waveOutGetDevCapsA: failed to get capabilities of device %d: rc=%s\n",device,wave_out_error(rc));
if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
return;
name=NULL;
rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0);
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
"waveOutMessage: failed to get interface size for device: %d rc=%s\n",device,wave_out_error(rc));
if (rc==MMSYSERR_NOERROR) {
wname = (WCHAR *)malloc(size);
rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wname, size);
ok(rc==MMSYSERR_NOERROR,"waveOutMessage: failed to get interface name for device: %d rc=%s\n",device,wave_out_error(rc));
ok(lstrlenW(wname)+1==size/sizeof(WCHAR),"got an incorrect size: %ld instead of %d\n",size,(lstrlenW(wname)+1)*sizeof(WCHAR));
if (rc==MMSYSERR_NOERROR) {
name = malloc(size/sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, wname, size/sizeof(WCHAR), name, size/sizeof(WCHAR), NULL, NULL);
}
free(wname);
}
else if (rc==MMSYSERR_NOTSUPPORTED) {
name=strdup("not supported");
}
trace(" %d: \"%s\" (%s) %d.%d (%d:%d): channels=%d formats=%05lx support=%04lx(%s)\n",
device,caps.szPname,(name?name:"failed"),caps.vDriverVersion >> 8,
caps.vDriverVersion & 0xff,
caps.wMid,caps.wPid,
caps.wChannels,caps.dwFormats,caps.dwSupport,wave_out_caps(caps.dwSupport));
free(name);
if (winetest_interactive && (device != WAVE_MAPPER))
{
trace("Playing a 5 seconds reference tone.\n");
trace("All subsequent tones should be identical to this one.\n");
trace("Listen for stutter, changes in pitch, volume, etc.\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=1;
format.wBitsPerSample=8;
format.nSamplesPerSec=22050;
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_out_test_deviceOut(device,5.0,&format,WAVE_FORMAT_2M08,0,&caps);
}
for (f=0;f<NB_WIN_FORMATS;f++) {
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=win_formats[f][3];
format.wBitsPerSample=win_formats[f][2];
format.nSamplesPerSec=win_formats[f][1];
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],0,&caps);
wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],WAVE_FORMAT_DIRECT,&caps);
if (device != WAVE_MAPPER)
wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],WAVE_MAPPED,&caps);
}
/* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */
twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
if (twoPages) {
res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS, &flOldProtect);
ok(res, "Failed to set memory access on second page\n");
if (res) {
LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize - sizeof(PCMWAVEFORMAT));
pwfx->wFormatTag=WAVE_FORMAT_PCM;
pwfx->nChannels=1;
pwfx->wBitsPerSample=8;
pwfx->nSamplesPerSec=22050;
pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,0,&caps);
wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT,&caps);
if (device != WAVE_MAPPER)
wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED,&caps);
}
VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
}
/* Try invalid formats to test error handling */
trace("Testing invalid format: 11 bits per sample\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2;
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,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
"waveOutOpen: opening the device in 11 bits mode should fail %d: rc=%s\n",device,wave_out_error(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);
}
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,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
"waveOutOpen: opening the device at 2 MHz sample rate should fail %d: rc=%s\n",device,wave_out_error(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);
}
}
static void wave_out_tests()
{
WAVEOUTCAPS caps;
WAVEFORMATEX format;
HWAVEOUT wout;
MMRESULT rc;
UINT ndev,d;
ndev=waveOutGetNumDevs(); ndev=waveOutGetNumDevs();
trace("found %d WaveOut devices\n",ndev); trace("found %d WaveOut devices\n",ndev);
@ -370,131 +514,11 @@ static void wave_out_tests()
ok(rc==MMSYSERR_BADDEVICEID, ok(rc==MMSYSERR_BADDEVICEID,
"waveOutOpen: MMSYSERR_BADDEVICEID expected, got %s\n",mmsys_error(rc)); "waveOutOpen: MMSYSERR_BADDEVICEID expected, got %s\n",mmsys_error(rc));
for (d=0;d<ndev;d++) { for (d=0;d<ndev;d++)
rc=waveOutGetDevCapsA(d,&caps,sizeof(caps)); wave_out_test_device(d);
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
"waveOutGetDevCapsA: failed to get capabilities of device %d: rc=%s\n",d,wave_out_error(rc));
if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
continue;
name=NULL; if (ndev>0)
rc=waveOutMessage((HWAVEOUT)d, DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0); wave_out_test_device(WAVE_MAPPER);
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
"waveOutMessage: failed to get interface size for device: %d rc=%s\n",d,wave_out_error(rc));
if (rc==MMSYSERR_NOERROR) {
wname = (WCHAR *)malloc(size);
rc=waveOutMessage((HWAVEOUT)d, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wname, size);
ok(rc==MMSYSERR_NOERROR,"waveOutMessage: failed to get interface name for device: %d rc=%s\n",d,wave_out_error(rc));
ok(lstrlenW(wname)+1==size/sizeof(WCHAR),"got an incorrect size: %ld instead of %d\n",size,(lstrlenW(wname)+1)*sizeof(WCHAR));
if (rc==MMSYSERR_NOERROR) {
name = malloc(size/sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, wname, size/sizeof(WCHAR), name, size/sizeof(WCHAR), NULL, NULL);
}
free(wname);
}
else if (rc==MMSYSERR_NOTSUPPORTED) {
name=strdup("not supported");
}
trace(" %d: \"%s\" (%s) %d.%d (%d:%d): channels=%d formats=%05lx support=%04lx(%s)\n",
d,caps.szPname,(name?name:"failed"),caps.vDriverVersion >> 8,
caps.vDriverVersion & 0xff,
caps.wMid,caps.wPid,
caps.wChannels,caps.dwFormats,caps.dwSupport,wave_out_caps(caps.dwSupport));
free(name);
if (winetest_interactive)
{
trace("Playing a 5 seconds reference tone.\n");
trace("All subsequent tones should be identical to this one.\n");
trace("Listen for stutter, changes in pitch, volume, etc.\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=1;
format.wBitsPerSample=8;
format.nSamplesPerSec=22050;
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_out_test_deviceOut(d,5.0,&format,WAVE_FORMAT_2M08,0,&caps);
}
for (f=0;f<NB_WIN_FORMATS;f++) {
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=win_formats[f][3];
format.wBitsPerSample=win_formats[f][2];
format.nSamplesPerSec=win_formats[f][1];
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
format.cbSize=0;
wave_out_test_deviceOut(d,1.0,&format,win_formats[f][0],0,&caps);
wave_out_test_deviceOut(d,1.0,&format,win_formats[f][0],WAVE_FORMAT_DIRECT,&caps);
wave_out_test_deviceOut(d,1.0,&format,win_formats[f][0],WAVE_MAPPED,&caps);
}
/* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */
twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
if (twoPages) {
res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS, &flOldProtect);
ok(res, "Failed to set memory access on second page\n");
if (res) {
LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize - sizeof(PCMWAVEFORMAT));
pwfx->wFormatTag=WAVE_FORMAT_PCM;
pwfx->nChannels=1;
pwfx->wBitsPerSample=8;
pwfx->nSamplesPerSec=22050;
pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
wave_out_test_deviceOut(d,1.0,pwfx,WAVE_FORMAT_2M08,0,&caps);
wave_out_test_deviceOut(d,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT,&caps);
wave_out_test_deviceOut(d,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED,&caps);
}
VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
}
/* Try invalid formats to test error handling */
trace("Testing invalid format: 11 bits per sample\n");
format.wFormatTag=WAVE_FORMAT_PCM;
format.nChannels=2;
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 || rc==MMSYSERR_INVALPARAM,
"waveOutOpen: opening the device in 11 bits mode should fail %d: rc=%s\n",d,wave_out_error(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);
}
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 || rc==MMSYSERR_INVALPARAM,
"waveOutOpen: opening the device at 2 MHz sample rate should fail %d: rc=%s\n",d,wave_out_error(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);
}
}
} }
START_TEST(wave) START_TEST(wave)

View File

@ -32,6 +32,10 @@ static const unsigned int win_formats[][4] = {
{0, 8000, 8, 2}, {0, 8000, 8, 2},
{0, 8000, 16, 1}, {0, 8000, 16, 1},
{0, 8000, 16, 2}, {0, 8000, 16, 2},
{0, 16000, 8, 1},
{0, 16000, 8, 2},
{0, 16000, 16, 1},
{0, 16000, 16, 2},
{0, 12000, 16, 2}, {0, 12000, 16, 2},
{WAVE_FORMAT_1M08, 11025, 8, 1}, {WAVE_FORMAT_1M08, 11025, 8, 1},
{WAVE_FORMAT_1S08, 11025, 8, 2}, {WAVE_FORMAT_1S08, 11025, 8, 2},
@ -56,5 +60,6 @@ static const unsigned int win_formats[][4] = {
}; };
#define NB_WIN_FORMATS (sizeof(win_formats)/sizeof(*win_formats)) #define NB_WIN_FORMATS (sizeof(win_formats)/sizeof(*win_formats))
extern const char* dev_name(int);
extern const char* wave_open_flags(DWORD); extern const char* wave_open_flags(DWORD);
extern const char* mmsys_error(MMRESULT); extern const char* mmsys_error(MMRESULT);