2002-11-05 00:47:49 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for winmm functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 Francois Gouget
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-04-03 00:38:42 +02:00
|
|
|
#include <stdio.h>
|
2003-01-03 23:32:47 +01:00
|
|
|
#include <stdlib.h>
|
2002-12-16 23:12:32 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2002-11-05 00:47:49 +01:00
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-11-05 00:47:49 +01:00
|
|
|
#include "winbase.h"
|
2003-10-28 01:15:16 +01:00
|
|
|
#include "winnls.h"
|
2002-12-16 23:12:32 +01:00
|
|
|
#include "mmsystem.h"
|
2003-10-28 01:15:16 +01:00
|
|
|
#include "mmddk.h"
|
2002-11-05 00:47:49 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that in most of this test we may get MMSYSERR_BADDEVICEID errors
|
|
|
|
* at about any time if the user starts another application that uses the
|
|
|
|
* sound device. So we should not report these as test failures.
|
2003-01-02 18:52:05 +01:00
|
|
|
*
|
|
|
|
* This test can play a test tone. But this only makes sense if someone
|
2002-12-16 23:12:32 +01:00
|
|
|
* is going to carefully listen to it, and would only bother everyone else.
|
2003-01-02 18:52:05 +01:00
|
|
|
* So this is only done if the test is being run in interactive mode.
|
2002-12-16 23:12:32 +01:00
|
|
|
*/
|
|
|
|
|
2003-01-21 00:28:50 +01:00
|
|
|
#ifndef WAVE_FORMAT_48M08
|
|
|
|
#define WAVE_FORMAT_48M08 0x00001000 /* 48 kHz, Mono, 8-bit */
|
|
|
|
#define WAVE_FORMAT_48S08 0x00002000 /* 48 kHz, Stereo, 8-bit */
|
|
|
|
#define WAVE_FORMAT_48M16 0x00004000 /* 48 kHz, Mono, 16-bit */
|
|
|
|
#define WAVE_FORMAT_48S16 0x00008000 /* 48 kHz, Stereo, 16-bit */
|
|
|
|
#define WAVE_FORMAT_96M08 0x00010000 /* 96 kHz, Mono, 8-bit */
|
|
|
|
#define WAVE_FORMAT_96S08 0x00020000 /* 96 kHz, Stereo, 8-bit */
|
|
|
|
#define WAVE_FORMAT_96M16 0x00040000 /* 96 kHz, Mono, 16-bit */
|
|
|
|
#define WAVE_FORMAT_96S16 0x00080000 /* 96 kHz, Stereo, 16-bit */
|
|
|
|
#endif
|
|
|
|
|
2002-12-16 23:12:32 +01:00
|
|
|
static const unsigned int win_formats[][4]={
|
|
|
|
{WAVE_FORMAT_1M08, 11025, 8, 1},
|
|
|
|
{WAVE_FORMAT_1S08, 11025, 8, 2},
|
|
|
|
{WAVE_FORMAT_1M16, 11025, 16, 1},
|
|
|
|
{WAVE_FORMAT_1S16, 11025, 16, 2},
|
|
|
|
{WAVE_FORMAT_2M08, 22050, 8, 1},
|
|
|
|
{WAVE_FORMAT_2S08, 22050, 8, 2},
|
|
|
|
{WAVE_FORMAT_2M16, 22050, 16, 1},
|
|
|
|
{WAVE_FORMAT_2S16, 22050, 16, 2},
|
|
|
|
{WAVE_FORMAT_4M08, 44100, 8, 1},
|
|
|
|
{WAVE_FORMAT_4S08, 44100, 8, 2},
|
|
|
|
{WAVE_FORMAT_4M16, 44100, 16, 1},
|
|
|
|
{WAVE_FORMAT_4S16, 44100, 16, 2},
|
|
|
|
{WAVE_FORMAT_48M08, 48000, 8, 1},
|
|
|
|
{WAVE_FORMAT_48S08, 48000, 8, 2},
|
|
|
|
{WAVE_FORMAT_48M16, 48000, 16, 1},
|
|
|
|
{WAVE_FORMAT_48S16, 48000, 16, 2},
|
|
|
|
{WAVE_FORMAT_96M08, 96000, 8, 1},
|
|
|
|
{WAVE_FORMAT_96S08, 96000, 8, 2},
|
|
|
|
{WAVE_FORMAT_96M16, 96000, 16, 1},
|
|
|
|
{WAVE_FORMAT_96S16, 96000, 16, 2}
|
2002-11-05 00:47:49 +01:00
|
|
|
};
|
2002-12-16 23:12:32 +01:00
|
|
|
#define NB_WIN_FORMATS (sizeof(win_formats)/sizeof(*win_formats))
|
|
|
|
|
|
|
|
#define PI 3.14159265358979323846
|
|
|
|
static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int nb_samples;
|
|
|
|
char* buf;
|
|
|
|
char* b;
|
|
|
|
|
|
|
|
nb_samples=(int)(duration*wfx->nSamplesPerSec);
|
|
|
|
*size=nb_samples*wfx->nBlockAlign;
|
|
|
|
b=buf=malloc(*size);
|
|
|
|
for (i=0;i<nb_samples;i++) {
|
|
|
|
double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
|
|
|
|
if (wfx->wBitsPerSample==8) {
|
|
|
|
unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
|
|
|
|
*b++=sample;
|
|
|
|
if (wfx->nChannels==2)
|
|
|
|
*b++=sample;
|
|
|
|
} else {
|
|
|
|
signed short sample=(signed short)((double)32767.5*y-0.5);
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=sample >> 8;
|
|
|
|
b+=2;
|
|
|
|
if (wfx->nChannels==2) {
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=sample >> 8;
|
|
|
|
b+=2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2003-04-03 00:38:42 +02:00
|
|
|
static const char * wave_out_error(MMRESULT error)
|
|
|
|
{
|
|
|
|
static char msg[1024];
|
|
|
|
MMRESULT rc;
|
|
|
|
|
|
|
|
rc = waveOutGetErrorText(error, msg, sizeof(msg));
|
|
|
|
if (rc != MMSYSERR_NOERROR)
|
2004-03-27 21:42:57 +01:00
|
|
|
sprintf(msg, "waveOutGetErrorText(%x) failed with error %x", error, rc);
|
2003-04-03 00:38:42 +02:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2004-05-13 21:41:53 +02:00
|
|
|
static const char * mmsys_error(DWORD error)
|
|
|
|
{
|
|
|
|
static char unknown[32];
|
|
|
|
switch (error) {
|
|
|
|
case MMSYSERR_NOERROR: return "MMSYSERR_NOERROR";
|
|
|
|
case MMSYSERR_ERROR: return "MMSYSERR_ERROR";
|
|
|
|
case MMSYSERR_BADDEVICEID: return "MMSYSERR_BADDEVICEID";
|
|
|
|
case MMSYSERR_NOTENABLED: return "MMSYSERR_NOTENABLED";
|
|
|
|
case MMSYSERR_ALLOCATED: return "MMSYSERR_ALLOCATED";
|
|
|
|
case MMSYSERR_INVALHANDLE: return "MMSYSERR_INVALHANDLE";
|
|
|
|
case MMSYSERR_NODRIVER: return "MMSYSERR_NODRIVER";
|
|
|
|
case MMSYSERR_NOMEM: return "MMSYSERR_NOMEM";
|
|
|
|
case MMSYSERR_NOTSUPPORTED: return "MMSYSERR_NOTSUPPORTED";
|
|
|
|
case MMSYSERR_BADERRNUM: return "MMSYSERR_BADERRNUM";
|
|
|
|
case MMSYSERR_INVALFLAG: return "MMSYSERR_INVALFLAG";
|
|
|
|
case MMSYSERR_INVALPARAM: return "MMSYSERR_INVALPARAM";
|
|
|
|
}
|
|
|
|
sprintf(unknown, "Unknown(0x%08lx)", error);
|
|
|
|
return unknown;
|
|
|
|
}
|
|
|
|
|
2003-04-03 00:38:42 +02:00
|
|
|
static const char * wave_open_flags(DWORD flags)
|
|
|
|
{
|
|
|
|
static char msg[1024];
|
|
|
|
int first = TRUE;
|
|
|
|
msg[0] = 0;
|
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_EVENT) {
|
2004-03-27 21:42:57 +01:00
|
|
|
strcat(msg, "CALLBACK_EVENT");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "CALLBACK_FUNCTION");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_NULL) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "CALLBACK_NULL");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "CALLBACK_THREAD");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "CALLBACK_WINDOW");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & WAVE_ALLOWSYNC) == WAVE_ALLOWSYNC) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "WAVE_ALLOWSYNC");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & WAVE_FORMAT_DIRECT) == WAVE_FORMAT_DIRECT) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "WAVE_FORMAT_DIRECT");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & WAVE_FORMAT_QUERY) == WAVE_FORMAT_QUERY) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "WAVE_FORMAT_QUERY");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if ((flags & WAVE_MAPPED) == WAVE_MAPPED) {
|
2004-03-27 21:42:57 +01:00
|
|
|
if (!first) strcat(msg, "|");
|
|
|
|
strcat(msg, "WAVE_MAPPED");
|
2003-04-03 00:38:42 +02:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2004-05-14 06:54:54 +02:00
|
|
|
static const char * wave_out_caps(DWORD dwSupport)
|
|
|
|
{
|
|
|
|
#define ADD_FLAG(f) if (dwSupport & f) strcat(msg, " " #f)
|
|
|
|
static char msg[256];
|
|
|
|
msg[0] = 0;
|
|
|
|
|
|
|
|
ADD_FLAG(WAVECAPS_PITCH);
|
|
|
|
ADD_FLAG(WAVECAPS_PLAYBACKRATE);
|
|
|
|
ADD_FLAG(WAVECAPS_VOLUME);
|
|
|
|
ADD_FLAG(WAVECAPS_LRVOLUME);
|
|
|
|
ADD_FLAG(WAVECAPS_SYNC);
|
|
|
|
ADD_FLAG(WAVECAPS_SAMPLEACCURATE);
|
|
|
|
|
|
|
|
return msg[0] ? msg + 1 : "";
|
|
|
|
#undef FLAG
|
|
|
|
}
|
|
|
|
|
2003-11-11 22:56:21 +01:00
|
|
|
static void wave_out_test_deviceOut(int device, int format, DWORD flags, LPWAVEOUTCAPS pcaps)
|
2002-12-16 23:12:32 +01:00
|
|
|
{
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
HWAVEOUT wout;
|
|
|
|
HANDLE hevent;
|
|
|
|
WAVEHDR frag;
|
|
|
|
MMRESULT rc;
|
|
|
|
DWORD volume;
|
|
|
|
|
|
|
|
hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
|
|
|
|
ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError());
|
|
|
|
if (hevent==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wfx.wFormatTag=WAVE_FORMAT_PCM;
|
|
|
|
wfx.nChannels=win_formats[format][3];
|
|
|
|
wfx.wBitsPerSample=win_formats[format][2];
|
|
|
|
wfx.nSamplesPerSec=win_formats[format][1];
|
|
|
|
wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
|
|
|
|
wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
|
|
|
|
wfx.cbSize=0;
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2002-12-16 23:12:32 +01:00
|
|
|
wout=NULL;
|
|
|
|
rc=waveOutOpen(&wout,device,&wfx,(DWORD)hevent,0,CALLBACK_EVENT|flags);
|
|
|
|
/* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
|
2003-11-11 22:56:21 +01:00
|
|
|
(rc==WAVERR_BADFORMAT && (flags & WAVE_FORMAT_DIRECT) && (pcaps->dwFormats & win_formats[format][0])) ||
|
2002-12-16 23:12:32 +01:00
|
|
|
(rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
|
2003-09-11 04:52:19 +02:00
|
|
|
"waveOutOpen: device=%d format=%ldx%2dx%d flags=%lx(%s) rc=%d(%s)\n",device,
|
2003-04-03 00:38:42 +02:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,CALLBACK_EVENT|flags,
|
|
|
|
wave_open_flags(CALLBACK_EVENT|flags),rc,wave_out_error(rc));
|
2002-12-16 23:12:32 +01:00
|
|
|
if (rc!=MMSYSERR_NOERROR) {
|
|
|
|
CloseHandle(hevent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(wfx.nChannels==win_formats[format][3] &&
|
|
|
|
wfx.wBitsPerSample==win_formats[format][2] &&
|
|
|
|
wfx.nSamplesPerSec==win_formats[format][1],
|
|
|
|
"got the wrong format: %ldx%2dx%d instead of %dx%2dx%d\n",
|
|
|
|
wfx.nSamplesPerSec, wfx.wBitsPerSample,
|
|
|
|
wfx.nChannels, win_formats[format][1], win_formats[format][2],
|
|
|
|
win_formats[format][3]);
|
|
|
|
|
|
|
|
frag.lpData=wave_generate_la(&wfx,1.0,&frag.dwBufferLength);
|
|
|
|
frag.dwFlags=0;
|
|
|
|
frag.dwLoops=0;
|
|
|
|
|
|
|
|
rc=waveOutGetVolume(wout,&volume);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutGetVolume: device=%d rc=%d\n",device,rc);
|
|
|
|
|
|
|
|
rc=waveOutPrepareHeader(wout, &frag, sizeof(frag));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutPrepareHeader: device=%d rc=%d\n",device,rc);
|
|
|
|
|
2003-01-02 18:52:05 +01:00
|
|
|
if (winetest_interactive && rc==MMSYSERR_NOERROR) {
|
2002-12-16 23:12:32 +01:00
|
|
|
trace("Playing 440Hz LA at %ldx%2dx%d %04lx\n",
|
|
|
|
wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels,flags);
|
|
|
|
rc=waveOutSetVolume(wout,0x20002000);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%d rc=%d\n",device,rc);
|
|
|
|
WaitForSingleObject(hevent,INFINITE);
|
|
|
|
|
|
|
|
rc=waveOutWrite(wout, &frag, sizeof(frag));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutWrite: device=%d rc=%d\n",device,rc);
|
|
|
|
WaitForSingleObject(hevent,INFINITE);
|
|
|
|
|
|
|
|
rc=waveOutSetVolume(wout,volume);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%d rc=%d\n",device,rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutUnprepareHeader: device=%d rc=%d\n",device,rc);
|
|
|
|
free(frag.lpData);
|
|
|
|
|
|
|
|
CloseHandle(hevent);
|
|
|
|
waveOutClose(wout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wave_out_tests()
|
2002-11-05 00:47:49 +01:00
|
|
|
{
|
|
|
|
WAVEOUTCAPS caps;
|
2003-04-03 00:38:42 +02:00
|
|
|
WAVEFORMATEX format, oformat;
|
2002-11-05 00:47:49 +01:00
|
|
|
HWAVEOUT wout;
|
|
|
|
MMRESULT rc;
|
|
|
|
UINT ndev,d,f;
|
2003-10-28 01:15:16 +01:00
|
|
|
WCHAR * wname;
|
2004-04-27 01:30:26 +02:00
|
|
|
CHAR * name;
|
|
|
|
DWORD size;
|
2002-11-05 00:47:49 +01:00
|
|
|
|
|
|
|
ndev=waveOutGetNumDevs();
|
2002-12-12 23:23:15 +01:00
|
|
|
trace("found %d WaveOut devices\n",ndev);
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2002-12-15 02:11:41 +01:00
|
|
|
rc=waveOutGetDevCapsA(ndev+1,&caps,sizeof(caps));
|
|
|
|
ok(rc==MMSYSERR_BADDEVICEID,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutGetDevCapsA: MMSYSERR_BADDEVICEID expected, got %s\n",mmsys_error(rc));
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2004-04-28 05:50:36 +02:00
|
|
|
rc=waveOutGetDevCapsA(WAVE_MAPPER,&caps,sizeof(caps));
|
2004-04-30 06:14:58 +02:00
|
|
|
if (ndev>0)
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutGetDevCapsA: MMSYSERR_NOERROR expected, got %s\n",mmsys_error(rc));
|
2004-04-30 06:14:58 +02:00
|
|
|
else
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
|
|
|
|
"waveOutGetDevCapsA: MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER expected, got %s\n",mmsys_error(rc));
|
2004-04-27 01:30:26 +02:00
|
|
|
|
2002-11-05 00:47:49 +01:00
|
|
|
format.wFormatTag=WAVE_FORMAT_PCM;
|
|
|
|
format.nChannels=2;
|
|
|
|
format.wBitsPerSample=16;
|
|
|
|
format.nSamplesPerSec=44100;
|
|
|
|
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
|
|
|
|
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
|
|
|
|
format.cbSize=0;
|
|
|
|
rc=waveOutOpen(&wout,ndev+1,&format,0,0,CALLBACK_NULL);
|
|
|
|
ok(rc==MMSYSERR_BADDEVICEID,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutOpen: MMSYSERR_BADDEVICEID expected, got %s\n",mmsys_error(rc));
|
2002-11-05 00:47:49 +01:00
|
|
|
|
|
|
|
for (d=0;d<ndev;d++) {
|
|
|
|
rc=waveOutGetDevCapsA(d,&caps,sizeof(caps));
|
2002-12-12 23:23:15 +01:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutGetDevCapsA: failed to get capabilities of device %d: rc=%s\n",d,mmsys_error(rc));
|
2002-12-12 23:23:15 +01:00
|
|
|
if (rc==MMSYSERR_BADDEVICEID)
|
2002-11-05 00:47:49 +01:00
|
|
|
continue;
|
|
|
|
|
2004-04-27 01:30:26 +02:00
|
|
|
name=NULL;
|
2004-03-27 21:42:57 +01:00
|
|
|
rc=waveOutMessage((HWAVEOUT)d, DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0);
|
2004-04-27 01:30:26 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutMessage: failed to get interface size for device: %d rc=%s\n",d,mmsys_error(rc));
|
2004-03-27 21:42:57 +01:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
wname = (WCHAR *)malloc(size);
|
2003-10-28 01:15:16 +01:00
|
|
|
rc=waveOutMessage((HWAVEOUT)d, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wname, size);
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutMessage: failed to get interface name for device: %d rc=%s\n",d,mmsys_error(rc));
|
2004-04-27 01:30:26 +02:00
|
|
|
ok(lstrlenW(wname)+1==size/sizeof(WCHAR),"got an incorrect size: %ld instead of %d\n",size,(lstrlenW(wname)+1)*sizeof(WCHAR));
|
2004-03-27 21:42:57 +01:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
name = malloc(size/sizeof(WCHAR));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, wname, size/sizeof(WCHAR), name, size/sizeof(WCHAR), NULL, NULL);
|
|
|
|
}
|
2004-04-27 01:30:26 +02:00
|
|
|
free(wname);
|
|
|
|
}
|
2004-05-13 21:41:53 +02:00
|
|
|
else if (rc==MMSYSERR_NOTSUPPORTED) {
|
2004-04-27 01:30:26 +02:00
|
|
|
name=strdup("not supported");
|
2004-03-27 21:42:57 +01:00
|
|
|
}
|
2003-10-28 01:15:16 +01:00
|
|
|
|
2004-05-14 06:54:54 +02:00
|
|
|
trace(" %d: \"%s\" (%s) %d.%d (%d:%d): channels=%d formats=%05lx support=%04lx(%s)\n",
|
2004-04-27 01:30:26 +02:00
|
|
|
d,caps.szPname,(name?name:"failed"),caps.vDriverVersion >> 8,
|
2002-12-12 23:23:15 +01:00
|
|
|
caps.vDriverVersion & 0xff,
|
|
|
|
caps.wMid,caps.wPid,
|
2004-05-14 06:54:54 +02:00
|
|
|
caps.wChannels,caps.dwFormats,caps.dwSupport,wave_out_caps(caps.dwSupport));
|
2004-04-27 01:30:26 +02:00
|
|
|
free(name);
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2002-12-16 23:12:32 +01:00
|
|
|
for (f=0;f<NB_WIN_FORMATS;f++) {
|
|
|
|
if (caps.dwFormats & win_formats[f][0]) {
|
2003-11-11 22:56:21 +01:00
|
|
|
wave_out_test_deviceOut(d,f,0,&caps);
|
|
|
|
wave_out_test_deviceOut(d,f,WAVE_FORMAT_DIRECT,&caps);
|
2002-12-12 23:23:15 +01:00
|
|
|
}
|
2002-11-05 00:47:49 +01:00
|
|
|
}
|
|
|
|
|
2004-04-28 01:28:46 +02:00
|
|
|
/* Try invalid formats to test error handling */
|
|
|
|
trace("Testing invalid format: 11 bits per sample\n");
|
2002-11-05 00:47:49 +01:00
|
|
|
format.wFormatTag=WAVE_FORMAT_PCM;
|
|
|
|
format.nChannels=2;
|
2004-04-27 01:30:26 +02:00
|
|
|
format.wBitsPerSample=11;
|
2004-04-28 01:28:46 +02:00
|
|
|
format.nSamplesPerSec=22050;
|
2002-11-05 00:47:49 +01:00
|
|
|
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
|
|
|
|
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
|
|
|
|
format.cbSize=0;
|
2004-03-27 21:42:57 +01:00
|
|
|
oformat=format;
|
2003-04-03 00:38:42 +02:00
|
|
|
rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
2004-04-28 05:50:36 +02:00
|
|
|
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutOpen: opening the device in 11 bits mode should fail %d: rc=%s\n",d,mmsys_error(rc));
|
2002-11-05 00:47:49 +01:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2003-04-03 00:38:42 +02:00
|
|
|
trace(" got %ldx%2dx%d for %ldx%2dx%d\n",
|
2002-12-12 23:23:15 +01:00
|
|
|
format.nSamplesPerSec, format.wBitsPerSample,
|
|
|
|
format.nChannels,
|
2003-04-03 00:38:42 +02:00
|
|
|
oformat.nSamplesPerSec, oformat.wBitsPerSample,
|
|
|
|
oformat.nChannels);
|
2002-11-05 00:47:49 +01:00
|
|
|
waveOutClose(wout);
|
|
|
|
}
|
2004-04-28 01:28:46 +02:00
|
|
|
|
|
|
|
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);
|
2004-04-28 05:50:36 +02:00
|
|
|
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveOutOpen: opening the device at 2 MHz sample rate should fail %d: rc=%s\n",d,mmsys_error(rc));
|
2004-04-28 01:28:46 +02:00
|
|
|
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);
|
|
|
|
}
|
2002-11-05 00:47:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-03 00:38:42 +02:00
|
|
|
static const char * wave_in_error(MMRESULT error)
|
|
|
|
{
|
|
|
|
static char msg[1024];
|
|
|
|
MMRESULT rc;
|
|
|
|
|
|
|
|
rc = waveInGetErrorText(error, msg, sizeof(msg));
|
|
|
|
if (rc != MMSYSERR_NOERROR)
|
2004-03-27 21:42:57 +01:00
|
|
|
sprintf(msg, "waveInGetErrorText(%x) failed with error %x", error, rc);
|
2003-04-03 00:38:42 +02:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2003-11-11 22:56:21 +01:00
|
|
|
static void wave_in_test_deviceIn(int device, int format, DWORD flags, LPWAVEINCAPS pcaps)
|
2003-03-04 23:15:39 +01:00
|
|
|
{
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
HWAVEIN win;
|
|
|
|
HANDLE hevent;
|
|
|
|
WAVEHDR frag;
|
|
|
|
MMRESULT rc;
|
2003-11-11 01:25:50 +01:00
|
|
|
DWORD res;
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
|
|
|
|
ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError());
|
|
|
|
if (hevent==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wfx.wFormatTag=WAVE_FORMAT_PCM;
|
|
|
|
wfx.nChannels=win_formats[format][3];
|
|
|
|
wfx.wBitsPerSample=win_formats[format][2];
|
|
|
|
wfx.nSamplesPerSec=win_formats[format][1];
|
|
|
|
wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
|
|
|
|
wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
|
|
|
|
wfx.cbSize=0;
|
|
|
|
|
|
|
|
win=NULL;
|
|
|
|
rc=waveInOpen(&win,device,&wfx,(DWORD)hevent,0,CALLBACK_EVENT|flags);
|
|
|
|
/* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
|
2003-11-11 22:56:21 +01:00
|
|
|
(rc==WAVERR_BADFORMAT && (flags & WAVE_FORMAT_DIRECT) && (pcaps->dwFormats & win_formats[format][0])) ||
|
2003-03-04 23:15:39 +01:00
|
|
|
(rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
|
2003-09-11 04:52:19 +02:00
|
|
|
"waveInOpen: device=%d format=%ldx%2dx%d flags=%lx(%s) rc=%d(%s)\n",device,
|
2003-04-03 00:38:42 +02:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,CALLBACK_EVENT|flags,
|
|
|
|
wave_open_flags(CALLBACK_EVENT|flags),rc,wave_in_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
if (rc!=MMSYSERR_NOERROR) {
|
|
|
|
CloseHandle(hevent);
|
|
|
|
return;
|
|
|
|
}
|
2003-11-11 01:25:50 +01:00
|
|
|
res=WaitForSingleObject(hevent,1000);
|
|
|
|
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for open\n");
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
ok(wfx.nChannels==win_formats[format][3] &&
|
|
|
|
wfx.wBitsPerSample==win_formats[format][2] &&
|
|
|
|
wfx.nSamplesPerSec==win_formats[format][1],
|
|
|
|
"got the wrong format: %ldx%2dx%d instead of %dx%2dx%d\n",
|
|
|
|
wfx.nSamplesPerSec, wfx.wBitsPerSample,
|
|
|
|
wfx.nChannels, win_formats[format][1], win_formats[format][2],
|
|
|
|
win_formats[format][3]);
|
|
|
|
|
|
|
|
frag.lpData=malloc(wfx.nAvgBytesPerSec);
|
|
|
|
frag.dwBufferLength=wfx.nAvgBytesPerSec;
|
2003-11-11 22:56:21 +01:00
|
|
|
frag.dwBytesRecorded=0;
|
|
|
|
frag.dwUser=0;
|
2003-03-04 23:15:39 +01:00
|
|
|
frag.dwFlags=0;
|
|
|
|
frag.dwLoops=0;
|
2003-11-11 22:56:21 +01:00
|
|
|
frag.lpNext=0;
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
rc=waveInPrepareHeader(win, &frag, sizeof(frag));
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR, "waveInPrepareHeader: device=%d rc=%s(%s)\n",device,mmsys_error(rc),wave_in_error(rc));
|
2003-11-11 22:56:21 +01:00
|
|
|
ok(frag.dwFlags&WHDR_PREPARED,"waveInPrepareHeader: prepared flag not set\n");
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
if (winetest_interactive && rc==MMSYSERR_NOERROR) {
|
|
|
|
trace("Recording at %ldx%2dx%d %04lx\n",
|
|
|
|
wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels,flags);
|
|
|
|
|
2004-03-27 21:42:57 +01:00
|
|
|
rc=waveInAddBuffer(win, &frag, sizeof(frag));
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInAddBuffer: device=%d rc=%s(%s)\n",device,mmsys_error(rc),wave_in_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
rc=waveInStart(win);
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInStart: device=%d rc=%s(%s)\n",device,mmsys_error(rc),wave_in_error(rc));
|
2004-03-27 21:42:57 +01:00
|
|
|
|
2003-11-11 01:25:50 +01:00
|
|
|
res = WaitForSingleObject(hevent,1200);
|
|
|
|
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n");
|
2004-03-27 21:42:57 +01:00
|
|
|
ok(frag.dwFlags&WHDR_DONE,"WHDR_DONE not set in frag.dwFlags\n");
|
2003-11-11 01:25:50 +01:00
|
|
|
ok(frag.dwBytesRecorded==wfx.nAvgBytesPerSec,"frag.dwBytesRecorded=%ld, should=%ld\n",
|
2004-03-27 21:42:57 +01:00
|
|
|
frag.dwBytesRecorded,wfx.nAvgBytesPerSec);
|
|
|
|
/* stop playing on error */
|
|
|
|
if (res!=WAIT_OBJECT_0) {
|
|
|
|
rc=waveInStop(win);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInStop: device=%d rc=%s(%s)\n",device,mmsys_error(rc),wave_in_error(rc));
|
2004-03-27 21:42:57 +01:00
|
|
|
}
|
2003-03-04 23:15:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
rc=waveInUnprepareHeader(win, &frag, sizeof(frag));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInUnprepareHeader: device=%d rc=%s(%s)\n",device,mmsys_error(rc),wave_in_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
|
2003-11-11 01:25:50 +01:00
|
|
|
waveInClose(win);
|
|
|
|
res=WaitForSingleObject(hevent,1000);
|
|
|
|
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n");
|
2003-03-04 23:15:39 +01:00
|
|
|
free(frag.lpData);
|
|
|
|
CloseHandle(hevent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wave_in_tests()
|
|
|
|
{
|
|
|
|
WAVEINCAPS caps;
|
2003-04-03 00:38:42 +02:00
|
|
|
WAVEFORMATEX format,oformat;
|
2003-03-04 23:15:39 +01:00
|
|
|
HWAVEIN win;
|
|
|
|
MMRESULT rc;
|
|
|
|
UINT ndev,d,f;
|
2003-10-28 01:15:16 +01:00
|
|
|
WCHAR * wname;
|
2004-04-27 01:30:26 +02:00
|
|
|
CHAR * name;
|
|
|
|
DWORD size;
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
ndev=waveInGetNumDevs();
|
|
|
|
trace("found %d WaveIn devices\n",ndev);
|
|
|
|
|
|
|
|
rc=waveInGetDevCapsA(ndev+1,&caps,sizeof(caps));
|
|
|
|
ok(rc==MMSYSERR_BADDEVICEID,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInGetDevCapsA: MMSYSERR_BADDEVICEID expected, got %s(%s)\n",mmsys_error(rc),wave_in_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
|
2004-04-28 05:50:36 +02:00
|
|
|
rc=waveInGetDevCapsA(WAVE_MAPPER,&caps,sizeof(caps));
|
2004-04-30 06:14:58 +02:00
|
|
|
if (ndev>0)
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInGetDevCapsA: MMSYSERR_NOERROR expected, got %s\n",mmsys_error(rc));
|
2004-04-30 06:14:58 +02:00
|
|
|
else
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || MMSYSERR_NODRIVER,
|
|
|
|
"waveInGetDevCapsA: MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER expected, got %s\n",mmsys_error(rc));
|
2004-04-27 01:30:26 +02:00
|
|
|
|
2003-03-04 23:15:39 +01:00
|
|
|
format.wFormatTag=WAVE_FORMAT_PCM;
|
|
|
|
format.nChannels=2;
|
|
|
|
format.wBitsPerSample=16;
|
|
|
|
format.nSamplesPerSec=44100;
|
|
|
|
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
|
|
|
|
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
|
|
|
|
format.cbSize=0;
|
|
|
|
rc=waveInOpen(&win,ndev+1,&format,0,0,CALLBACK_NULL);
|
|
|
|
ok(rc==MMSYSERR_BADDEVICEID,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInOpen: MMSYSERR_BADDEVICEID expected, got %s(%s)\n",mmsys_error(rc),wave_in_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
for (d=0;d<ndev;d++) {
|
|
|
|
rc=waveInGetDevCapsA(d,&caps,sizeof(caps));
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInGetDevCapsA: failed to get capabilities of device %d: rc=%s(%s)\n",d,mmsys_error(rc),wave_in_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
if (rc==MMSYSERR_BADDEVICEID)
|
|
|
|
continue;
|
|
|
|
|
2004-04-27 01:30:26 +02:00
|
|
|
name=NULL;
|
2004-03-27 21:42:57 +01:00
|
|
|
rc=waveInMessage((HWAVEIN)d, DRV_QUERYDEVICEINTERFACESIZE, (DWORD_PTR)&size, 0);
|
2004-04-27 01:30:26 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInMessage: failed to get interface size for device: %d rc=%s(%s)\n",d,mmsys_error(rc),wave_in_error(rc));
|
2004-03-27 21:42:57 +01:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
wname = (WCHAR *)malloc(size);
|
2003-10-28 01:15:16 +01:00
|
|
|
rc=waveInMessage((HWAVEIN)d, DRV_QUERYDEVICEINTERFACE, (DWORD_PTR)wname, size);
|
2004-05-13 21:41:53 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInMessage: failed to get interface name for device: %d rc=%s(%s)\n",d,mmsys_error(rc),wave_in_error(rc));
|
2004-04-27 01:30:26 +02:00
|
|
|
ok(lstrlenW(wname)+1==size/sizeof(WCHAR),"got an incorrect size: %ld instead of %d\n",size,(lstrlenW(wname)+1)*sizeof(WCHAR));
|
2004-03-27 21:42:57 +01:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
name = malloc(size/sizeof(WCHAR));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, wname, size/sizeof(WCHAR), name, size/sizeof(WCHAR), NULL, NULL);
|
|
|
|
}
|
2004-04-27 01:30:26 +02:00
|
|
|
free(wname);
|
|
|
|
}
|
2004-05-13 21:41:53 +02:00
|
|
|
else if (rc==MMSYSERR_NOTSUPPORTED) {
|
2004-04-27 01:30:26 +02:00
|
|
|
name=strdup("not supported");
|
2004-03-27 21:42:57 +01:00
|
|
|
}
|
2003-10-28 01:15:16 +01:00
|
|
|
|
|
|
|
trace(" %d: \"%s\" (%s) %d.%d (%d:%d): channels=%d formats=%05lx\n",
|
2004-04-27 01:30:26 +02:00
|
|
|
d,caps.szPname,(name?name:"failed"),caps.vDriverVersion >> 8,
|
2003-03-04 23:15:39 +01:00
|
|
|
caps.vDriverVersion & 0xff,
|
|
|
|
caps.wMid,caps.wPid,
|
|
|
|
caps.wChannels,caps.dwFormats);
|
2004-04-27 01:30:26 +02:00
|
|
|
free(name);
|
2003-03-04 23:15:39 +01:00
|
|
|
|
|
|
|
for (f=0;f<NB_WIN_FORMATS;f++) {
|
|
|
|
if (caps.dwFormats & win_formats[f][0]) {
|
2003-11-11 22:56:21 +01:00
|
|
|
wave_in_test_deviceIn(d,f,0, &caps);
|
|
|
|
wave_in_test_deviceIn(d,f,WAVE_FORMAT_DIRECT, &caps);
|
2003-03-04 23:15:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-28 01:28:46 +02:00
|
|
|
/* Try invalid formats to test error handling */
|
|
|
|
trace("Testing invalid format: 11 bits per sample\n");
|
2003-03-04 23:15:39 +01:00
|
|
|
format.wFormatTag=WAVE_FORMAT_PCM;
|
|
|
|
format.nChannels=2;
|
2004-04-27 01:30:26 +02:00
|
|
|
format.wBitsPerSample=11;
|
2004-04-28 01:28:46 +02:00
|
|
|
format.nSamplesPerSec=22050;
|
2003-03-04 23:15:39 +01:00
|
|
|
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
|
|
|
|
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
|
|
|
|
format.cbSize=0;
|
2004-03-27 21:42:57 +01:00
|
|
|
oformat=format;
|
2003-04-03 00:38:42 +02:00
|
|
|
rc=waveInOpen(&win,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
2004-04-28 05:50:36 +02:00
|
|
|
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInOpen: opening the device in 11 bit mode should fail %d: rc=%s\n",d,mmsys_error(rc));
|
2003-03-04 23:15:39 +01:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2003-04-03 00:38:42 +02:00
|
|
|
trace(" got %ldx%2dx%d for %ldx%2dx%d\n",
|
2003-03-04 23:15:39 +01:00
|
|
|
format.nSamplesPerSec, format.wBitsPerSample,
|
|
|
|
format.nChannels,
|
2003-04-03 00:38:42 +02:00
|
|
|
oformat.nSamplesPerSec, oformat.wBitsPerSample,
|
|
|
|
oformat.nChannels);
|
2003-03-04 23:15:39 +01:00
|
|
|
waveInClose(win);
|
|
|
|
}
|
2004-04-28 01:28:46 +02:00
|
|
|
|
|
|
|
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);
|
2004-04-28 05:50:36 +02:00
|
|
|
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
2004-05-13 21:41:53 +02:00
|
|
|
"waveInOpen: opening the device with 2 MHz sample rate should fail %d: rc=%s\n",d,mmsys_error(rc));
|
2004-04-28 01:28:46 +02:00
|
|
|
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);
|
|
|
|
}
|
2003-03-04 23:15:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-05 00:47:49 +01:00
|
|
|
START_TEST(wave)
|
|
|
|
{
|
|
|
|
wave_out_tests();
|
2003-03-04 23:15:39 +01:00
|
|
|
wave_in_tests();
|
2002-11-05 00:47:49 +01:00
|
|
|
}
|