2004-05-20 03:39:47 +02:00
|
|
|
/*
|
|
|
|
* Test winmm sound capture in each sound format
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-05-20 03:39:47 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "mmsystem.h"
|
2004-08-19 03:13:58 +02:00
|
|
|
#define NOBITMAP
|
|
|
|
#include "mmreg.h"
|
|
|
|
|
|
|
|
extern GUID KSDATAFORMAT_SUBTYPE_PCM;
|
2004-08-30 20:36:06 +02:00
|
|
|
extern GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
|
2004-05-20 03:39:47 +02:00
|
|
|
|
|
|
|
#include "winmm_test.h"
|
|
|
|
|
|
|
|
static const char * wave_in_error(MMRESULT error)
|
|
|
|
{
|
|
|
|
static char msg[1024];
|
2004-05-21 22:53:45 +02:00
|
|
|
static char long_msg[1100];
|
2004-05-20 03:39:47 +02:00
|
|
|
MMRESULT rc;
|
|
|
|
|
|
|
|
rc = waveInGetErrorText(error, msg, sizeof(msg));
|
|
|
|
if (rc != MMSYSERR_NOERROR)
|
2004-05-21 22:53:45 +02:00
|
|
|
sprintf(long_msg, "waveInGetErrorText(%x) failed with error %x", error, rc);
|
|
|
|
else
|
|
|
|
sprintf(long_msg, "%s(%s)", mmsys_error(error), msg);
|
|
|
|
return long_msg;
|
2004-05-20 03:39:47 +02:00
|
|
|
}
|
|
|
|
|
2005-04-11 14:49:22 +02:00
|
|
|
static void check_position(int device, HWAVEIN win, DWORD bytes,
|
|
|
|
LPWAVEFORMATEX pwfx )
|
|
|
|
{
|
|
|
|
MMTIME mmtime;
|
|
|
|
DWORD samples;
|
|
|
|
double duration;
|
|
|
|
MMRESULT rc;
|
|
|
|
DWORD returned;
|
|
|
|
|
|
|
|
samples=bytes/(pwfx->wBitsPerSample/8*pwfx->nChannels);
|
|
|
|
duration=((double)samples)/pwfx->nSamplesPerSec;
|
|
|
|
|
|
|
|
mmtime.wType = TIME_BYTES;
|
|
|
|
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (mmtime.wType != TIME_BYTES && winetest_debug > 1)
|
|
|
|
trace("waveInGetPosition(%s): TIME_BYTES not supported, returned %s\n",
|
|
|
|
dev_name(device),wave_time_format(mmtime.wType));
|
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(returned == bytes, "waveInGetPosition(%s): returned %d bytes, "
|
|
|
|
"should be %d\n", dev_name(device), returned, bytes);
|
2005-04-11 14:49:22 +02:00
|
|
|
|
|
|
|
mmtime.wType = TIME_SAMPLES;
|
|
|
|
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (mmtime.wType != TIME_SAMPLES && winetest_debug > 1)
|
|
|
|
trace("waveInGetPosition(%s): TIME_SAMPLES not supported, "
|
|
|
|
"returned %s\n",dev_name(device),wave_time_format(mmtime.wType));
|
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(returned == bytes, "waveInGetPosition(%s): returned %d samples, "
|
|
|
|
"should be %d\n", dev_name(device), bytes_to_samples(returned, pwfx),
|
2005-04-11 14:49:22 +02:00
|
|
|
bytes_to_samples(bytes, pwfx));
|
|
|
|
|
|
|
|
mmtime.wType = TIME_MS;
|
|
|
|
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (mmtime.wType != TIME_MS && winetest_debug > 1)
|
|
|
|
trace("waveInGetPosition(%s): TIME_MS not supported, returned %s\n",
|
|
|
|
dev_name(device), wave_time_format(mmtime.wType));
|
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(returned == bytes, "waveInGetPosition(%s): returned %d ms, "
|
|
|
|
"should be %d\n", dev_name(device), bytes_to_ms(returned, pwfx),
|
2005-04-11 14:49:22 +02:00
|
|
|
bytes_to_ms(bytes, pwfx));
|
|
|
|
|
|
|
|
mmtime.wType = TIME_SMPTE;
|
|
|
|
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (mmtime.wType != TIME_SMPTE && winetest_debug > 1)
|
|
|
|
trace("waveInGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
|
|
|
|
dev_name(device),wave_time_format(mmtime.wType));
|
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
|
|
|
ok(returned == bytes, "waveInGetPosition(%s): SMPTE test failed\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
mmtime.wType = TIME_MIDI;
|
|
|
|
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (mmtime.wType != TIME_MIDI && winetest_debug > 1)
|
|
|
|
trace("waveInGetPosition(%s): TIME_MIDI not supported, returned %s\n",
|
|
|
|
dev_name(device),wave_time_format(mmtime.wType));
|
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
|
|
|
ok(returned == bytes, "waveInGetPosition(%s): MIDI test failed\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
mmtime.wType = TIME_TICKS;
|
|
|
|
rc=waveInGetPosition(win, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveInGetPosition(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (mmtime.wType != TIME_TICKS && winetest_debug > 1)
|
|
|
|
trace("waveInGetPosition(%s): TIME_TICKS not supported, returned %s\n",
|
|
|
|
dev_name(device),wave_time_format(mmtime.wType));
|
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
|
|
|
ok(returned == bytes, "waveInGetPosition(%s): TICKS test failed\n",
|
|
|
|
dev_name(device));
|
|
|
|
}
|
|
|
|
|
2004-05-27 22:00:26 +02:00
|
|
|
static void wave_in_test_deviceIn(int device, LPWAVEFORMATEX pwfx, DWORD format, DWORD flags, LPWAVEINCAPS pcaps)
|
2004-05-20 03:39:47 +02:00
|
|
|
{
|
|
|
|
HWAVEIN win;
|
|
|
|
HANDLE hevent;
|
|
|
|
WAVEHDR frag;
|
|
|
|
MMRESULT rc;
|
|
|
|
DWORD res;
|
2004-05-27 22:00:26 +02:00
|
|
|
WORD nChannels = pwfx->nChannels;
|
|
|
|
WORD wBitsPerSample = pwfx->wBitsPerSample;
|
|
|
|
DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
|
2004-05-20 03:39:47 +02:00
|
|
|
|
|
|
|
hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(hevent!=NULL,"CreateEvent(): error=%d\n",GetLastError());
|
2004-05-20 03:39:47 +02:00
|
|
|
if (hevent==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
win=NULL;
|
2004-05-27 22:00:26 +02:00
|
|
|
rc=waveInOpen(&win,device,pwfx,(DWORD)hevent,0,CALLBACK_EVENT|flags);
|
2004-05-20 03:39:47 +02:00
|
|
|
/* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
|
2004-08-19 03:13:58 +02:00
|
|
|
rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER ||
|
|
|
|
rc==MMSYSERR_ALLOCATED ||
|
2004-05-27 22:00:26 +02:00
|
|
|
((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
|
|
|
|
(flags & WAVE_FORMAT_DIRECT) && !(pcaps->dwFormats & format)) ||
|
|
|
|
((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
|
2004-08-19 03:13:58 +02:00
|
|
|
(!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) &&
|
|
|
|
!(pcaps->dwFormats & format)) ||
|
2004-05-20 03:39:47 +02:00
|
|
|
(rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
|
2006-11-12 21:06:57 +01:00
|
|
|
"waveInOpen(%s): format=%dx%2dx%d flags=%lx(%s) rc=%s\n",
|
2004-08-19 03:13:58 +02:00
|
|
|
dev_name(device),pwfx->nSamplesPerSec,pwfx->wBitsPerSample,
|
|
|
|
pwfx->nChannels,CALLBACK_EVENT|flags,
|
2004-05-21 22:53:45 +02:00
|
|
|
wave_open_flags(CALLBACK_EVENT|flags),wave_in_error(rc));
|
2004-05-27 22:00:26 +02:00
|
|
|
if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
|
|
|
|
(flags & WAVE_FORMAT_DIRECT) && (pcaps->dwFormats & format))
|
2004-08-19 03:13:58 +02:00
|
|
|
trace(" Reason: The device lists this format as supported in it's "
|
|
|
|
"capabilities but opening it failed.\n");
|
2004-05-27 22:00:26 +02:00
|
|
|
if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
|
|
|
|
!(pcaps->dwFormats & format))
|
2006-11-12 21:06:57 +01:00
|
|
|
trace("waveInOpen(%s): format=%dx%2dx%d %s rc=%s failed but format "
|
2004-08-19 03:13:58 +02:00
|
|
|
"not supported so OK.\n",dev_name(device),pwfx->nSamplesPerSec,
|
|
|
|
pwfx->wBitsPerSample,pwfx->nChannels,
|
2004-05-27 22:00:26 +02:00
|
|
|
flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
|
|
|
|
flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
if (rc!=MMSYSERR_NOERROR) {
|
|
|
|
CloseHandle(hevent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
res=WaitForSingleObject(hevent,1000);
|
|
|
|
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for open\n");
|
|
|
|
|
2004-05-27 22:00:26 +02:00
|
|
|
ok(pwfx->nChannels==nChannels &&
|
|
|
|
pwfx->wBitsPerSample==wBitsPerSample &&
|
|
|
|
pwfx->nSamplesPerSec==nSamplesPerSec,
|
2006-11-12 21:06:57 +01:00
|
|
|
"got the wrong format: %dx%2dx%d instead of %dx%2dx%d\n",
|
2004-05-27 22:00:26 +02:00
|
|
|
pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
|
|
|
|
pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels);
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2005-04-11 14:49:22 +02:00
|
|
|
/* Check that the position is 0 at start */
|
|
|
|
check_position(device, win, 0, pwfx);
|
|
|
|
|
2004-05-27 22:00:26 +02:00
|
|
|
frag.lpData=malloc(pwfx->nAvgBytesPerSec);
|
|
|
|
frag.dwBufferLength=pwfx->nAvgBytesPerSec;
|
2004-05-20 03:39:47 +02:00
|
|
|
frag.dwBytesRecorded=0;
|
|
|
|
frag.dwUser=0;
|
|
|
|
frag.dwFlags=0;
|
|
|
|
frag.dwLoops=0;
|
|
|
|
frag.lpNext=0;
|
|
|
|
|
|
|
|
rc=waveInPrepareHeader(win, &frag, sizeof(frag));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR, "waveInPrepareHeader(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
|
|
|
ok(frag.dwFlags&WHDR_PREPARED,"waveInPrepareHeader(%s): prepared flag "
|
|
|
|
"not set\n",dev_name(device));
|
2004-05-20 03:39:47 +02:00
|
|
|
|
|
|
|
if (winetest_interactive && rc==MMSYSERR_NOERROR) {
|
2006-11-12 21:06:57 +01:00
|
|
|
trace("Recording for 1 second at %5dx%2dx%d %s %s\n",
|
2004-05-27 22:00:26 +02:00
|
|
|
pwfx->nSamplesPerSec, pwfx->wBitsPerSample,pwfx->nChannels,
|
2004-08-19 03:13:58 +02:00
|
|
|
get_format_str(pwfx->wFormatTag),
|
2004-05-27 22:00:26 +02:00
|
|
|
flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" :
|
|
|
|
flags & WAVE_MAPPED ? "WAVE_MAPPED" : "");
|
2004-05-20 03:39:47 +02:00
|
|
|
rc=waveInAddBuffer(win, &frag, sizeof(frag));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInAddBuffer(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2005-04-11 14:49:22 +02:00
|
|
|
/* Check that the position is 0 at start */
|
|
|
|
check_position(device, win, 0, pwfx);
|
|
|
|
|
2004-05-20 03:39:47 +02:00
|
|
|
rc=waveInStart(win);
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInStart(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
|
|
|
|
res = WaitForSingleObject(hevent,1200);
|
|
|
|
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n");
|
|
|
|
ok(frag.dwFlags&WHDR_DONE,"WHDR_DONE not set in frag.dwFlags\n");
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(frag.dwBytesRecorded==pwfx->nAvgBytesPerSec,
|
2006-11-12 21:06:57 +01:00
|
|
|
"frag.dwBytesRecorded=%d, should=%d\n",
|
2004-05-27 22:00:26 +02:00
|
|
|
frag.dwBytesRecorded,pwfx->nAvgBytesPerSec);
|
2005-04-11 14:49:22 +02:00
|
|
|
|
2004-05-20 03:39:47 +02:00
|
|
|
/* stop playing on error */
|
|
|
|
if (res!=WAIT_OBJECT_0) {
|
|
|
|
rc=waveInStop(win);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInStop(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc=waveInUnprepareHeader(win, &frag, sizeof(frag));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInUnprepareHeader(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2004-05-27 22:00:26 +02:00
|
|
|
rc=waveInClose(win);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInClose(%s): rc=%s\n",dev_name(device),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
res=WaitForSingleObject(hevent,1000);
|
|
|
|
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n");
|
2004-08-03 00:29:02 +02:00
|
|
|
|
|
|
|
if (winetest_interactive)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Now play back what we recorded
|
|
|
|
*/
|
|
|
|
HWAVEOUT wout;
|
|
|
|
|
|
|
|
trace("Playing back recorded sound\n");
|
|
|
|
rc=waveOutOpen(&wout,WAVE_MAPPER,pwfx,(DWORD)hevent,0,CALLBACK_EVENT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
|
2004-08-19 03:13:58 +02:00
|
|
|
rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER ||
|
|
|
|
rc==MMSYSERR_ALLOCATED ||
|
2004-08-03 00:29:02 +02:00
|
|
|
((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
|
|
|
|
!(pcaps->dwFormats & format)),
|
2006-11-12 21:06:57 +01:00
|
|
|
"waveOutOpen(%s) format=%dx%2dx%d flags=%lx(%s) rc=%s\n",
|
2004-08-19 03:13:58 +02:00
|
|
|
dev_name(device),pwfx->nSamplesPerSec,pwfx->wBitsPerSample,
|
|
|
|
pwfx->nChannels,CALLBACK_EVENT|flags,
|
2004-08-03 00:29:02 +02:00
|
|
|
wave_open_flags(CALLBACK_EVENT),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
rc=waveOutPrepareHeader(wout, &frag, sizeof(frag));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutPrepareHeader(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-08-03 00:29:02 +02:00
|
|
|
|
|
|
|
if (rc==MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(hevent,INFINITE);
|
|
|
|
rc=waveOutWrite(wout, &frag, sizeof(frag));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-08-03 00:29:02 +02:00
|
|
|
WaitForSingleObject(hevent,INFINITE);
|
|
|
|
|
|
|
|
rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutUnprepareHeader(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-08-03 00:29:02 +02:00
|
|
|
}
|
|
|
|
rc=waveOutClose(wout);
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-08-03 00:29:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
trace("Unable to play back the recorded sound\n");
|
|
|
|
}
|
|
|
|
|
2004-05-20 03:39:47 +02:00
|
|
|
free(frag.lpData);
|
|
|
|
CloseHandle(hevent);
|
|
|
|
}
|
|
|
|
|
2004-06-04 19:58:00 +02:00
|
|
|
static void wave_in_test_device(int device)
|
2004-05-20 03:39:47 +02:00
|
|
|
{
|
2004-07-23 21:05:49 +02:00
|
|
|
WAVEINCAPSA capsA;
|
|
|
|
WAVEINCAPSW capsW;
|
2004-05-20 03:39:47 +02:00
|
|
|
WAVEFORMATEX format,oformat;
|
2004-08-19 03:13:58 +02:00
|
|
|
WAVEFORMATEXTENSIBLE wfex;
|
2004-05-20 03:39:47 +02:00
|
|
|
HWAVEIN win;
|
|
|
|
MMRESULT rc;
|
2004-06-04 19:58:00 +02:00
|
|
|
UINT f;
|
2004-07-23 21:05:49 +02:00
|
|
|
WCHAR * nameW;
|
|
|
|
CHAR * nameA;
|
2004-05-20 03:39:47 +02:00
|
|
|
DWORD size;
|
2004-05-27 22:00:26 +02:00
|
|
|
DWORD dwPageSize;
|
|
|
|
BYTE * twoPages;
|
|
|
|
SYSTEM_INFO sSysInfo;
|
|
|
|
DWORD flOldProtect;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
GetSystemInfo(&sSysInfo);
|
|
|
|
dwPageSize = sSysInfo.dwPageSize;
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2004-07-23 21:05:49 +02:00
|
|
|
rc=waveInGetDevCapsA(device,&capsA,sizeof(capsA));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
|
|
|
|
rc==MMSYSERR_NODRIVER,
|
|
|
|
"waveInGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
|
|
|
|
return;
|
|
|
|
|
2004-07-23 21:05:49 +02:00
|
|
|
rc=waveInGetDevCapsW(device,&capsW,sizeof(capsW));
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_in_error(rc));
|
2004-07-23 21:05:49 +02:00
|
|
|
|
|
|
|
rc=waveInGetDevCapsA(device,0,sizeof(capsA));
|
2004-06-14 19:54:45 +02:00
|
|
|
ok(rc==MMSYSERR_INVALPARAM,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-06-14 19:54:45 +02:00
|
|
|
|
2004-07-23 21:05:49 +02:00
|
|
|
rc=waveInGetDevCapsW(device,0,sizeof(capsW));
|
|
|
|
ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_in_error(rc));
|
2004-07-23 21:05:49 +02:00
|
|
|
|
2004-06-14 19:54:45 +02:00
|
|
|
#if 0 /* FIXME: this works on windows but crashes wine */
|
2004-07-23 21:05:49 +02:00
|
|
|
rc=waveInGetDevCapsA(device,1,sizeof(capsA));
|
2004-06-14 19:54:45 +02:00
|
|
|
ok(rc==MMSYSERR_INVALPARAM,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-07-23 21:05:49 +02:00
|
|
|
|
|
|
|
rc=waveInGetDevCapsW(device,1,sizeof(capsW));
|
|
|
|
ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_in_error(rc));
|
2004-06-14 19:54:45 +02:00
|
|
|
#endif
|
|
|
|
|
2004-07-23 21:05:49 +02:00
|
|
|
rc=waveInGetDevCapsA(device,&capsA,4);
|
2004-06-14 19:54:45 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-06-14 19:54:45 +02:00
|
|
|
|
2004-07-23 21:05:49 +02:00
|
|
|
rc=waveInGetDevCapsW(device,&capsW,4);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_in_error(rc));
|
2004-07-23 21:05:49 +02:00
|
|
|
|
|
|
|
nameA=NULL;
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveInMessage((HWAVEIN)device, DRV_QUERYDEVICEINTERFACESIZE,
|
|
|
|
(DWORD_PTR)&size, 0);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM ||
|
|
|
|
rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveInMessage(%s): failed to get interface size: rc=%s\n",
|
|
|
|
dev_name(device),wave_in_error(rc));
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2004-07-23 21:05:49 +02:00
|
|
|
nameW = (WCHAR *)malloc(size);
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveInMessage((HWAVEIN)device, DRV_QUERYDEVICEINTERFACE,
|
|
|
|
(DWORD_PTR)nameW, size);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveInMessage(%s): failed to get interface "
|
|
|
|
"name: rc=%s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
ok(lstrlenW(nameW)+1==size/sizeof(WCHAR),
|
2006-11-12 21:06:57 +01:00
|
|
|
"got an incorrect size %d\n", size);
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2004-07-23 21:05:49 +02:00
|
|
|
nameA = malloc(size/sizeof(WCHAR));
|
2004-08-19 03:13:58 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, nameW, size/sizeof(WCHAR),
|
|
|
|
nameA, size/sizeof(WCHAR), NULL, NULL);
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
2004-07-23 21:05:49 +02:00
|
|
|
free(nameW);
|
2004-06-04 19:58:00 +02:00
|
|
|
} else if (rc==MMSYSERR_NOTSUPPORTED) {
|
2004-07-23 21:05:49 +02:00
|
|
|
nameA=strdup("not supported");
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device),capsA.szPname,
|
|
|
|
(nameA?nameA:"failed"),capsA.vDriverVersion >> 8,
|
|
|
|
capsA.vDriverVersion & 0xff,capsA.wMid,capsA.wPid);
|
2006-11-12 21:06:57 +01:00
|
|
|
trace(" channels=%d formats=%05x\n",
|
2004-07-23 21:05:49 +02:00
|
|
|
capsA.wChannels,capsA.dwFormats);
|
2004-06-04 19:58:00 +02:00
|
|
|
|
2004-07-23 21:05:49 +02:00
|
|
|
free(nameA);
|
2004-06-04 19:58:00 +02:00
|
|
|
|
|
|
|
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;
|
2004-07-23 21:05:49 +02:00
|
|
|
wave_in_test_deviceIn(device,&format,win_formats[f][0],0, &capsA);
|
2005-04-11 14:49:22 +02:00
|
|
|
if (device != WAVE_MAPPER) {
|
|
|
|
wave_in_test_deviceIn(device,&format,win_formats[f][0],
|
|
|
|
WAVE_FORMAT_DIRECT, &capsA);
|
2004-08-19 03:13:58 +02:00
|
|
|
wave_in_test_deviceIn(device,&format,win_formats[f][0],
|
|
|
|
WAVE_MAPPED, &capsA);
|
2005-04-11 14:49:22 +02:00
|
|
|
}
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
|
2004-08-26 02:31:20 +02:00
|
|
|
/* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
|
2004-08-19 03:13:58 +02:00
|
|
|
* checking */
|
|
|
|
twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
2004-06-04 19:58:00 +02:00
|
|
|
ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
|
|
|
|
if (twoPages) {
|
2004-08-19 03:13:58 +02:00
|
|
|
res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS,
|
|
|
|
&flOldProtect);
|
2004-06-04 19:58:00 +02:00
|
|
|
ok(res, "Failed to set memory access on second page\n");
|
|
|
|
if (res) {
|
2004-08-19 03:13:58 +02:00
|
|
|
LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize -
|
|
|
|
sizeof(PCMWAVEFORMAT));
|
2004-06-04 19:58:00 +02:00
|
|
|
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;
|
2004-07-23 21:05:49 +02:00
|
|
|
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,0, &capsA);
|
2005-04-11 14:49:22 +02:00
|
|
|
if (device != WAVE_MAPPER) {
|
|
|
|
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
WAVE_FORMAT_DIRECT, &capsA);
|
2004-08-19 03:13:58 +02:00
|
|
|
wave_in_test_deviceIn(device,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
WAVE_MAPPED, &capsA);
|
2005-04-11 14:49:22 +02:00
|
|
|
}
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
|
|
|
|
}
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
/* Testing invalid format: 2 MHz sample rate */
|
2004-06-04 19:58:00 +02:00
|
|
|
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);
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG ||
|
|
|
|
rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): opening the device with 2 MHz sample rate should fail: "
|
|
|
|
" rc=%s\n",dev_name(device),wave_in_error(rc));
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2006-11-12 21:06:57 +01:00
|
|
|
trace(" got %dx%2dx%d for %dx%2dx%d\n",
|
2004-06-04 19:58:00 +02:00
|
|
|
format.nSamplesPerSec, format.wBitsPerSample,
|
|
|
|
format.nChannels,
|
|
|
|
oformat.nSamplesPerSec, oformat.wBitsPerSample,
|
|
|
|
oformat.nChannels);
|
|
|
|
waveInClose(win);
|
|
|
|
}
|
2004-08-19 03:13:58 +02:00
|
|
|
|
|
|
|
/* test non PCM formats */
|
|
|
|
format.wFormatTag=WAVE_FORMAT_MULAW;
|
|
|
|
format.nChannels=1;
|
|
|
|
format.wBitsPerSample=8;
|
|
|
|
format.nSamplesPerSec=8000;
|
|
|
|
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
|
|
|
|
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
|
|
|
|
format.cbSize=0;
|
|
|
|
rc=waveInOpen(&win,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&format,0,0,&capsA);
|
|
|
|
} else
|
|
|
|
trace("waveInOpen(%s): WAVE_FORMAT_MULAW not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
format.wFormatTag=WAVE_FORMAT_ADPCM;
|
|
|
|
format.nChannels=2;
|
|
|
|
format.wBitsPerSample=4;
|
|
|
|
format.nSamplesPerSec=22050;
|
|
|
|
format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
|
|
|
|
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
|
|
|
|
format.cbSize=0;
|
|
|
|
rc=waveInOpen(&win,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&format,0,0,&capsA);
|
|
|
|
} else
|
|
|
|
trace("waveInOpen(%s): WAVE_FORMAT_ADPCM not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
/* test if WAVEFORMATEXTENSIBLE supported */
|
|
|
|
wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
wfex.Format.nChannels=2;
|
|
|
|
wfex.Format.wBitsPerSample=16;
|
|
|
|
wfex.Format.nSamplesPerSec=22050;
|
|
|
|
wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc=waveInOpen(&win,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&wfex.Format,0,0,&capsA);
|
|
|
|
} else
|
|
|
|
trace("waveInOpen(%s): WAVE_FORMAT_EXTENSIBLE not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
/* test if 4 channels supported */
|
|
|
|
wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
wfex.Format.nChannels=4;
|
|
|
|
wfex.Format.wBitsPerSample=16;
|
|
|
|
wfex.Format.nSamplesPerSec=22050;
|
|
|
|
wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc=waveInOpen(&win,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&wfex.Format,0,0,&capsA);
|
|
|
|
} else
|
|
|
|
trace("waveInOpen(%s): 4 channels not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
/* test if 6 channels supported */
|
|
|
|
wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
wfex.Format.nChannels=6;
|
|
|
|
wfex.Format.wBitsPerSample=16;
|
|
|
|
wfex.Format.nSamplesPerSec=22050;
|
|
|
|
wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc=waveInOpen(&win,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&wfex.Format,0,0,&capsA);
|
|
|
|
} else
|
|
|
|
trace("waveInOpen(%s): 6 channels not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
#if 0 /* ALSA doesn't like this */
|
|
|
|
/* test if 24 bit samples supported */
|
|
|
|
wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
wfex.Format.nChannels=2;
|
|
|
|
wfex.Format.wBitsPerSample=24;
|
|
|
|
wfex.Format.nSamplesPerSec=22050;
|
|
|
|
wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc=waveInOpen(&win,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&wfex.Format,0,0,&capsA);
|
|
|
|
} else
|
2004-08-30 20:36:06 +02:00
|
|
|
trace("waveInOpen(%s): 24 bit samples not supported\n",
|
2004-08-19 03:13:58 +02:00
|
|
|
dev_name(device));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* test if 32 bit samples supported */
|
|
|
|
wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
wfex.Format.nChannels=2;
|
|
|
|
wfex.Format.wBitsPerSample=32;
|
|
|
|
wfex.Format.nSamplesPerSec=22050;
|
|
|
|
wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc=waveInOpen(&win,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&wfex.Format,0,0,&capsA);
|
|
|
|
} else
|
2004-08-30 20:36:06 +02:00
|
|
|
trace("waveInOpen(%s): 32 bit samples not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
/* test if 32 bit float samples supported */
|
|
|
|
wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
wfex.Format.nChannels=2;
|
|
|
|
wfex.Format.wBitsPerSample=32;
|
|
|
|
wfex.Format.nSamplesPerSec=22050;
|
|
|
|
wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
|
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
|
|
|
|
rc=waveInOpen(&win,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveInOpen(%s): returned: %s\n",dev_name(device),wave_in_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveInClose(win);
|
|
|
|
wave_in_test_deviceIn(device,&wfex.Format,0,0,&capsA);
|
|
|
|
} else
|
|
|
|
trace("waveInOpen(%s): 32 bit float samples not supported\n",
|
2004-08-19 03:13:58 +02:00
|
|
|
dev_name(device));
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
|
2005-06-21 22:53:13 +02:00
|
|
|
static void wave_in_tests(void)
|
2004-06-04 19:58:00 +02:00
|
|
|
{
|
2004-08-19 03:13:58 +02:00
|
|
|
WAVEINCAPSA capsA;
|
|
|
|
WAVEINCAPSW capsW;
|
2004-06-04 19:58:00 +02:00
|
|
|
WAVEFORMATEX format;
|
|
|
|
HWAVEIN win;
|
|
|
|
MMRESULT rc;
|
|
|
|
UINT ndev,d;
|
|
|
|
|
2004-05-20 03:39:47 +02:00
|
|
|
ndev=waveInGetNumDevs();
|
|
|
|
trace("found %d WaveIn devices\n",ndev);
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveInGetDevCapsA(ndev+1,&capsA,sizeof(capsA));
|
|
|
|
ok(rc==MMSYSERR_BADDEVICEID,
|
|
|
|
"waveInGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
|
|
|
|
dev_name(ndev+1),wave_in_error(rc));
|
|
|
|
|
|
|
|
rc=waveInGetDevCapsA(WAVE_MAPPER,&capsA,sizeof(capsA));
|
|
|
|
if (ndev>0)
|
2004-10-25 23:46:12 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NODRIVER,
|
|
|
|
"waveInGetDevCapsA(%s): MMSYSERR_NOERROR or MMSYSERR_NODRIVER "
|
|
|
|
"expected, got %s\n",dev_name(WAVE_MAPPER),wave_in_error(rc));
|
2004-08-19 03:13:58 +02:00
|
|
|
else
|
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
|
|
|
|
"waveInGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
|
2004-10-25 23:46:12 +02:00
|
|
|
"expected, got %s\n",dev_name(WAVE_MAPPER),wave_in_error(rc));
|
2004-08-19 03:13:58 +02:00
|
|
|
|
|
|
|
rc=waveInGetDevCapsW(ndev+1,&capsW,sizeof(capsW));
|
2004-10-19 01:14:54 +02:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(ndev+1),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveInGetDevCapsW(WAVE_MAPPER,&capsW,sizeof(capsW));
|
2004-05-20 03:39:47 +02:00
|
|
|
if (ndev>0)
|
2004-10-25 23:46:12 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NODRIVER ||
|
|
|
|
rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NODRIVER or "
|
|
|
|
"MMSYSERR_NOTSUPPORTED expected, got %s\n",
|
|
|
|
dev_name(ndev+1),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
else
|
2004-11-03 23:13:44 +01:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER ||
|
|
|
|
rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveInGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER or"
|
|
|
|
"MMSYSERR_NOTSUPPORTED expected, got %s\n",
|
|
|
|
dev_name(ndev+1),wave_in_error(rc));
|
2004-05-20 03:39:47 +02: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-08-19 03:13:58 +02:00
|
|
|
"waveInOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
|
|
|
|
dev_name(ndev+1),wave_in_error(rc));
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2004-06-04 19:58:00 +02:00
|
|
|
for (d=0;d<ndev;d++)
|
|
|
|
wave_in_test_device(d);
|
2004-05-20 03:39:47 +02:00
|
|
|
|
2004-06-04 19:58:00 +02:00
|
|
|
if (ndev>0)
|
|
|
|
wave_in_test_device(WAVE_MAPPER);
|
2004-05-20 03:39:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(capture)
|
|
|
|
{
|
|
|
|
wave_in_tests();
|
|
|
|
}
|