2002-11-05 00:47:49 +01:00
|
|
|
/*
|
2004-05-20 03:39:47 +02:00
|
|
|
* Test winmm sound playback in each sound format
|
2002-11-05 00:47:49 +01:00
|
|
|
*
|
|
|
|
* 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
|
2002-11-05 00:47:49 +01:00
|
|
|
*/
|
|
|
|
|
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"
|
2006-05-07 23:06:04 +02:00
|
|
|
#include "winuser.h"
|
2003-10-28 01:15:16 +01:00
|
|
|
#include "winnls.h"
|
2002-12-16 23:12:32 +01:00
|
|
|
#include "mmsystem.h"
|
2004-08-16 23:10:04 +02:00
|
|
|
#define NOBITMAP
|
2011-10-04 15:24:27 +02:00
|
|
|
#include "mmddk.h"
|
2004-08-16 23:10:04 +02:00
|
|
|
#include "mmreg.h"
|
|
|
|
#include "ks.h"
|
|
|
|
#include "ksguid.h"
|
|
|
|
#include "ksmedia.h"
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2004-05-20 03:39:47 +02:00
|
|
|
#include "winmm_test.h"
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2011-07-18 18:19:35 +02:00
|
|
|
static DWORD g_tid;
|
|
|
|
|
2008-08-18 23:56:56 +02:00
|
|
|
static void test_multiple_waveopens(void)
|
|
|
|
{
|
|
|
|
HWAVEOUT handle1, handle2;
|
|
|
|
MMRESULT ret;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
|
|
|
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
wfx.nChannels = 1;
|
|
|
|
wfx.nSamplesPerSec = 11025;
|
|
|
|
wfx.nBlockAlign = 1;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
wfx.wBitsPerSample = 8;
|
|
|
|
wfx.cbSize = 0;
|
|
|
|
|
|
|
|
ret = waveOutOpen(&handle1, 0, &wfx, 0, 0, 0);
|
|
|
|
if (ret != MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
skip("Could not do the duplicate waveopen test\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = waveOutOpen(&handle2, 0, &wfx, 0, 0, 0);
|
2009-10-16 11:10:09 +02:00
|
|
|
/* Modern Windows allows for wave-out devices to be opened multiple times.
|
|
|
|
* Some Wine audio drivers allow that and some don't. To avoid false alarms
|
|
|
|
* for those that do, don't "todo_wine ok(...)" on success.
|
2008-08-18 23:56:56 +02:00
|
|
|
*/
|
2009-10-16 11:10:09 +02:00
|
|
|
if (ret != MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
todo_wine ok(ret == MMSYSERR_NOERROR || broken(ret == MMSYSERR_ALLOCATED), /* winME */
|
|
|
|
"second waveOutOpen returns: %x\n", ret);
|
|
|
|
}
|
|
|
|
else
|
2008-08-18 23:56:56 +02:00
|
|
|
waveOutClose(handle2);
|
|
|
|
|
|
|
|
waveOutClose(handle1);
|
|
|
|
}
|
|
|
|
|
2004-05-20 03:39:47 +02: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.
|
|
|
|
*
|
|
|
|
* This test can play a test tone. But this only makes sense if someone
|
|
|
|
* is going to carefully listen to it, and would only bother everyone else.
|
|
|
|
* So this is only done if the test is being run in interactive mode.
|
|
|
|
*/
|
2002-12-16 23:12:32 +01:00
|
|
|
|
|
|
|
#define PI 3.14159265358979323846
|
|
|
|
static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
|
|
|
|
{
|
2004-08-19 03:13:58 +02:00
|
|
|
int i,j;
|
2002-12-16 23:12:32 +01:00
|
|
|
int nb_samples;
|
|
|
|
char* buf;
|
|
|
|
char* b;
|
2004-08-30 20:36:06 +02:00
|
|
|
WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE*)wfx;
|
2002-12-16 23:12:32 +01:00
|
|
|
|
|
|
|
nb_samples=(int)(duration*wfx->nSamplesPerSec);
|
|
|
|
*size=nb_samples*wfx->nBlockAlign;
|
2007-06-26 01:05:56 +02:00
|
|
|
b=buf=HeapAlloc(GetProcessHeap(), 0, *size);
|
2002-12-16 23:12:32 +01:00
|
|
|
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));
|
2004-08-19 03:13:58 +02:00
|
|
|
for (j = 0; j < wfx->nChannels; j++)
|
|
|
|
*b++=sample;
|
|
|
|
} else if (wfx->wBitsPerSample==16) {
|
2002-12-16 23:12:32 +01:00
|
|
|
signed short sample=(signed short)((double)32767.5*y-0.5);
|
2004-08-19 03:13:58 +02:00
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
2002-12-16 23:12:32 +01:00
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=sample >> 8;
|
|
|
|
b+=2;
|
|
|
|
}
|
2004-08-19 03:13:58 +02:00
|
|
|
} else if (wfx->wBitsPerSample==24) {
|
|
|
|
signed int sample=(signed int)(((double)0x7fffff+0.5)*y-0.5);
|
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=(sample >> 8) & 0xff;
|
|
|
|
b[2]=(sample >> 16) & 0xff;
|
|
|
|
b+=3;
|
|
|
|
}
|
2004-08-30 20:36:06 +02:00
|
|
|
} else if ((wfx->wBitsPerSample==32) && ((wfx->wFormatTag == WAVE_FORMAT_PCM) ||
|
2004-10-26 23:18:27 +02:00
|
|
|
((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
|
2004-08-30 20:36:06 +02:00
|
|
|
IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)))) {
|
2004-08-19 03:13:58 +02:00
|
|
|
signed int sample=(signed int)(((double)0x7fffffff+0.5)*y-0.5);
|
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=(sample >> 8) & 0xff;
|
|
|
|
b[2]=(sample >> 16) & 0xff;
|
|
|
|
b[3]=(sample >> 24) & 0xff;
|
|
|
|
b+=4;
|
|
|
|
}
|
2004-10-26 23:18:27 +02:00
|
|
|
} else if ((wfx->wBitsPerSample==32) && (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
|
2004-08-30 20:36:06 +02:00
|
|
|
IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
|
|
|
|
union { float f; char c[4]; } sample;
|
2005-02-16 18:52:35 +01:00
|
|
|
sample.f=(float)y;
|
2004-08-30 20:36:06 +02:00
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=sample.c[0];
|
|
|
|
b[1]=sample.c[1];
|
|
|
|
b[2]=sample.c[2];
|
|
|
|
b[3]=sample.c[3];
|
|
|
|
b+=4;
|
|
|
|
}
|
2002-12-16 23:12:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2004-10-26 23:18:27 +02:00
|
|
|
static char* wave_generate_silence(WAVEFORMATEX* wfx, double duration, DWORD* size)
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
int nb_samples;
|
|
|
|
char* buf;
|
|
|
|
char* b;
|
|
|
|
WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE*)wfx;
|
|
|
|
|
|
|
|
nb_samples=(int)(duration*wfx->nSamplesPerSec);
|
|
|
|
*size=nb_samples*wfx->nBlockAlign;
|
2007-06-26 01:05:56 +02:00
|
|
|
b=buf=HeapAlloc(GetProcessHeap(), 0, *size);
|
2004-10-26 23:18:27 +02:00
|
|
|
for (i=0;i<nb_samples;i++) {
|
|
|
|
if (wfx->wBitsPerSample==8) {
|
|
|
|
for (j = 0; j < wfx->nChannels; j++)
|
|
|
|
*b++=128;
|
|
|
|
} else if (wfx->wBitsPerSample==16) {
|
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=0;
|
|
|
|
b[1]=0;
|
|
|
|
b+=2;
|
|
|
|
}
|
|
|
|
} else if (wfx->wBitsPerSample==24) {
|
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=0;
|
|
|
|
b[1]=0;
|
|
|
|
b[2]=0;
|
|
|
|
b+=3;
|
|
|
|
}
|
|
|
|
} else if ((wfx->wBitsPerSample==32) && ((wfx->wFormatTag == WAVE_FORMAT_PCM) ||
|
|
|
|
((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
|
|
|
|
IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)))) {
|
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=0;
|
|
|
|
b[1]=0;
|
|
|
|
b[2]=0;
|
|
|
|
b[3]=0;
|
|
|
|
b+=4;
|
|
|
|
}
|
|
|
|
} else if ((wfx->wBitsPerSample==32) && (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
|
|
|
|
IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
|
|
|
|
union { float f; char c[4]; } sample;
|
|
|
|
sample.f=0;
|
|
|
|
for (j = 0; j < wfx->nChannels; j++) {
|
|
|
|
b[0]=sample.c[0];
|
|
|
|
b[1]=sample.c[1];
|
|
|
|
b[2]=sample.c[2];
|
|
|
|
b[3]=sample.c[3];
|
|
|
|
b+=4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2004-06-04 19:58:00 +02:00
|
|
|
const char * dev_name(int device)
|
|
|
|
{
|
|
|
|
static char name[16];
|
|
|
|
if (device == WAVE_MAPPER)
|
|
|
|
return "WAVE_MAPPER";
|
|
|
|
sprintf(name, "%d", device);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2004-05-21 22:53:45 +02:00
|
|
|
const char* mmsys_error(MMRESULT error)
|
|
|
|
{
|
2004-05-27 22:00:26 +02:00
|
|
|
#define ERR_TO_STR(dev) case dev: return #dev
|
2004-05-21 22:53:45 +02:00
|
|
|
static char unknown[32];
|
|
|
|
switch (error) {
|
2004-05-27 22:00:26 +02:00
|
|
|
ERR_TO_STR(MMSYSERR_NOERROR);
|
|
|
|
ERR_TO_STR(MMSYSERR_ERROR);
|
|
|
|
ERR_TO_STR(MMSYSERR_BADDEVICEID);
|
|
|
|
ERR_TO_STR(MMSYSERR_NOTENABLED);
|
|
|
|
ERR_TO_STR(MMSYSERR_ALLOCATED);
|
|
|
|
ERR_TO_STR(MMSYSERR_INVALHANDLE);
|
|
|
|
ERR_TO_STR(MMSYSERR_NODRIVER);
|
|
|
|
ERR_TO_STR(MMSYSERR_NOMEM);
|
|
|
|
ERR_TO_STR(MMSYSERR_NOTSUPPORTED);
|
|
|
|
ERR_TO_STR(MMSYSERR_BADERRNUM);
|
|
|
|
ERR_TO_STR(MMSYSERR_INVALFLAG);
|
|
|
|
ERR_TO_STR(MMSYSERR_INVALPARAM);
|
|
|
|
ERR_TO_STR(WAVERR_BADFORMAT);
|
|
|
|
ERR_TO_STR(WAVERR_STILLPLAYING);
|
|
|
|
ERR_TO_STR(WAVERR_UNPREPARED);
|
|
|
|
ERR_TO_STR(WAVERR_SYNC);
|
2004-08-16 23:10:04 +02:00
|
|
|
ERR_TO_STR(MIDIERR_UNPREPARED);
|
|
|
|
ERR_TO_STR(MIDIERR_STILLPLAYING);
|
|
|
|
ERR_TO_STR(MIDIERR_NOTREADY);
|
|
|
|
ERR_TO_STR(MIDIERR_NODEVICE);
|
|
|
|
ERR_TO_STR(MIDIERR_INVALIDSETUP);
|
|
|
|
ERR_TO_STR(TIMERR_NOCANDO);
|
|
|
|
ERR_TO_STR(TIMERR_STRUCT);
|
|
|
|
ERR_TO_STR(JOYERR_PARMS);
|
|
|
|
ERR_TO_STR(JOYERR_NOCANDO);
|
|
|
|
ERR_TO_STR(JOYERR_UNPLUGGED);
|
|
|
|
ERR_TO_STR(MIXERR_INVALLINE);
|
|
|
|
ERR_TO_STR(MIXERR_INVALCONTROL);
|
|
|
|
ERR_TO_STR(MIXERR_INVALVALUE);
|
|
|
|
ERR_TO_STR(MMIOERR_FILENOTFOUND);
|
|
|
|
ERR_TO_STR(MMIOERR_OUTOFMEMORY);
|
|
|
|
ERR_TO_STR(MMIOERR_CANNOTOPEN);
|
|
|
|
ERR_TO_STR(MMIOERR_CANNOTCLOSE);
|
|
|
|
ERR_TO_STR(MMIOERR_CANNOTREAD);
|
|
|
|
ERR_TO_STR(MMIOERR_CANNOTWRITE);
|
|
|
|
ERR_TO_STR(MMIOERR_CANNOTSEEK);
|
|
|
|
ERR_TO_STR(MMIOERR_CANNOTEXPAND);
|
|
|
|
ERR_TO_STR(MMIOERR_CHUNKNOTFOUND);
|
|
|
|
ERR_TO_STR(MMIOERR_UNBUFFERED);
|
2004-05-27 22:00:26 +02:00
|
|
|
}
|
2004-05-21 22:53:45 +02:00
|
|
|
sprintf(unknown, "Unknown(0x%08x)", error);
|
|
|
|
return unknown;
|
2004-05-27 22:00:26 +02:00
|
|
|
#undef ERR_TO_STR
|
2004-05-21 22:53:45 +02:00
|
|
|
}
|
|
|
|
|
2004-08-03 00:29:02 +02:00
|
|
|
const char* wave_out_error(MMRESULT error)
|
2003-04-03 00:38:42 +02:00
|
|
|
{
|
|
|
|
static char msg[1024];
|
2004-05-21 22:53:45 +02:00
|
|
|
static char long_msg[1100];
|
2003-04-03 00:38:42 +02:00
|
|
|
MMRESULT rc;
|
|
|
|
|
|
|
|
rc = waveOutGetErrorText(error, msg, sizeof(msg));
|
|
|
|
if (rc != MMSYSERR_NOERROR)
|
2004-08-19 03:13:58 +02:00
|
|
|
sprintf(long_msg, "waveOutGetErrorText(%x) failed with error %x",
|
|
|
|
error, rc);
|
2004-05-21 22:53:45 +02:00
|
|
|
else
|
|
|
|
sprintf(long_msg, "%s(%s)", mmsys_error(error), msg);
|
|
|
|
return long_msg;
|
2004-05-13 21:41:53 +02:00
|
|
|
}
|
|
|
|
|
2004-05-20 03:39:47 +02:00
|
|
|
const char * wave_open_flags(DWORD flags)
|
2003-04-03 00:38:42 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2006-12-11 21:22:02 +01:00
|
|
|
static const char * wave_header_flags(DWORD flags)
|
2006-05-07 23:06:04 +02:00
|
|
|
{
|
|
|
|
#define WHDR_MASK (WHDR_BEGINLOOP|WHDR_DONE|WHDR_ENDLOOP|WHDR_INQUEUE|WHDR_PREPARED)
|
|
|
|
static char msg[1024];
|
|
|
|
int first = TRUE;
|
|
|
|
msg[0] = 0;
|
|
|
|
if (flags & WHDR_BEGINLOOP) {
|
|
|
|
strcat(msg, "WHDR_BEGINLOOP");
|
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if (flags & WHDR_DONE) {
|
|
|
|
if (!first) strcat(msg, " ");
|
|
|
|
strcat(msg, "WHDR_DONE");
|
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if (flags & WHDR_ENDLOOP) {
|
|
|
|
if (!first) strcat(msg, " ");
|
|
|
|
strcat(msg, "WHDR_ENDLOOP");
|
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if (flags & WHDR_INQUEUE) {
|
|
|
|
if (!first) strcat(msg, " ");
|
|
|
|
strcat(msg, "WHDR_INQUEUE");
|
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if (flags & WHDR_PREPARED) {
|
|
|
|
if (!first) strcat(msg, " ");
|
|
|
|
strcat(msg, "WHDR_PREPARED");
|
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
if (flags & ~WHDR_MASK) {
|
|
|
|
char temp[32];
|
2006-11-12 21:06:57 +01:00
|
|
|
sprintf(temp, "UNKNOWN(0x%08x)", flags & ~WHDR_MASK);
|
2006-05-07 23:06:04 +02:00
|
|
|
if (!first) strcat(msg, " ");
|
|
|
|
strcat(msg, temp);
|
|
|
|
}
|
|
|
|
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 : "";
|
2004-05-21 22:53:45 +02:00
|
|
|
#undef ADD_FLAG
|
2004-05-14 06:54:54 +02:00
|
|
|
}
|
|
|
|
|
2005-04-11 14:49:22 +02:00
|
|
|
const char * wave_time_format(UINT type)
|
2004-07-20 03:22:47 +02:00
|
|
|
{
|
|
|
|
static char msg[32];
|
|
|
|
#define TIME_FORMAT(f) case f: return #f
|
|
|
|
switch (type) {
|
|
|
|
TIME_FORMAT(TIME_MS);
|
|
|
|
TIME_FORMAT(TIME_SAMPLES);
|
|
|
|
TIME_FORMAT(TIME_BYTES);
|
|
|
|
TIME_FORMAT(TIME_SMPTE);
|
|
|
|
TIME_FORMAT(TIME_MIDI);
|
|
|
|
TIME_FORMAT(TIME_TICKS);
|
|
|
|
}
|
|
|
|
#undef TIME_FORMAT
|
|
|
|
sprintf(msg, "Unknown(0x%04x)", type);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
const char * get_format_str(WORD format)
|
|
|
|
{
|
|
|
|
static char msg[32];
|
|
|
|
#define WAVE_FORMAT(f) case f: return #f
|
|
|
|
switch (format) {
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_PCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ALAW);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MULAW);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGISTD);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGIFIX);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_SONARC);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ECHOSC1);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_APTX);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_GSM610);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGIREAL);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MPEG);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLIGSM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLIADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLICELP);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLISBC);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLIOPR);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE);
|
|
|
|
}
|
|
|
|
#undef WAVE_FORMAT
|
|
|
|
sprintf(msg, "Unknown(0x%04x)", format);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2005-04-11 14:49:22 +02:00
|
|
|
DWORD bytes_to_samples(DWORD bytes, LPWAVEFORMATEX pwfx)
|
|
|
|
{
|
|
|
|
return bytes / pwfx->nBlockAlign;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD bytes_to_ms(DWORD bytes, LPWAVEFORMATEX pwfx)
|
|
|
|
{
|
|
|
|
return bytes_to_samples(bytes, pwfx) * 1000 / pwfx->nSamplesPerSec;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD time_to_bytes(LPMMTIME mmtime, LPWAVEFORMATEX pwfx)
|
|
|
|
{
|
|
|
|
if (mmtime->wType == TIME_BYTES)
|
|
|
|
return mmtime->u.cb;
|
|
|
|
else if (mmtime->wType == TIME_SAMPLES)
|
|
|
|
return mmtime->u.sample * pwfx->nBlockAlign;
|
|
|
|
else if (mmtime->wType == TIME_MS)
|
|
|
|
return mmtime->u.ms * pwfx->nAvgBytesPerSec / 1000;
|
|
|
|
else if (mmtime->wType == TIME_SMPTE)
|
2012-01-04 20:54:48 +01:00
|
|
|
return ((mmtime->u.smpte.hour * 60 * 60) +
|
|
|
|
(mmtime->u.smpte.min * 60) +
|
|
|
|
(mmtime->u.smpte.sec)) * pwfx->nAvgBytesPerSec +
|
|
|
|
mmtime->u.smpte.frame * pwfx->nAvgBytesPerSec / 30;
|
2005-04-11 14:49:22 +02:00
|
|
|
|
|
|
|
trace("FIXME: time_to_bytes() type not supported\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
static void check_position(int device, HWAVEOUT wout, DWORD bytes,
|
|
|
|
LPWAVEFORMATEX pwfx )
|
2004-06-01 22:20:54 +02:00
|
|
|
{
|
|
|
|
MMTIME mmtime;
|
|
|
|
MMRESULT rc;
|
2005-04-11 14:49:22 +02:00
|
|
|
DWORD returned;
|
2004-06-01 22:20:54 +02:00
|
|
|
|
|
|
|
mmtime.wType = TIME_BYTES;
|
|
|
|
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2005-04-11 14:49:22 +02:00
|
|
|
if (mmtime.wType != TIME_BYTES && winetest_debug > 1)
|
2004-08-16 23:10:04 +02:00
|
|
|
trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
|
|
|
|
dev_name(device),wave_time_format(mmtime.wType));
|
2005-04-11 14:49:22 +02:00
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(returned == bytes, "waveOutGetPosition(%s): returned %d bytes, "
|
|
|
|
"should be %d\n", dev_name(device), returned, bytes);
|
2004-06-01 22:20:54 +02:00
|
|
|
|
|
|
|
mmtime.wType = TIME_SAMPLES;
|
|
|
|
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2005-04-11 14:49:22 +02:00
|
|
|
if (mmtime.wType != TIME_SAMPLES && winetest_debug > 1)
|
2004-08-19 03:13:58 +02:00
|
|
|
trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
|
|
|
|
"returned %s\n",dev_name(device),wave_time_format(mmtime.wType));
|
2005-04-11 14:49:22 +02:00
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(returned == bytes, "waveOutGetPosition(%s): returned %d samples "
|
|
|
|
"(%d bytes), should be %d (%d bytes)\n", dev_name(device),
|
2006-05-09 13:55:21 +02:00
|
|
|
bytes_to_samples(returned, pwfx), returned,
|
|
|
|
bytes_to_samples(bytes, pwfx), bytes);
|
2004-06-01 22:20:54 +02:00
|
|
|
|
|
|
|
mmtime.wType = TIME_MS;
|
|
|
|
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2005-04-11 14:49:22 +02:00
|
|
|
if (mmtime.wType != TIME_MS && winetest_debug > 1)
|
2004-08-16 23:10:04 +02:00
|
|
|
trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
|
2005-04-11 14:49:22 +02:00
|
|
|
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, "waveOutGetPosition(%s): returned %d ms, "
|
|
|
|
"(%d bytes), should be %d (%d bytes)\n", dev_name(device),
|
2006-05-28 22:50:09 +02:00
|
|
|
bytes_to_ms(returned, pwfx), returned,
|
|
|
|
bytes_to_ms(bytes, pwfx), bytes);
|
2004-06-01 22:20:54 +02:00
|
|
|
|
|
|
|
mmtime.wType = TIME_SMPTE;
|
|
|
|
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2005-04-11 14:49:22 +02:00
|
|
|
if (mmtime.wType != TIME_SMPTE && winetest_debug > 1)
|
2004-08-16 23:10:04 +02:00
|
|
|
trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
|
|
|
|
dev_name(device),wave_time_format(mmtime.wType));
|
2005-04-11 14:49:22 +02:00
|
|
|
returned = time_to_bytes(&mmtime, pwfx);
|
|
|
|
ok(returned == bytes, "waveOutGetPosition(%s): SMPTE test failed\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
mmtime.wType = TIME_MIDI;
|
|
|
|
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (mmtime.wType != TIME_MIDI && winetest_debug > 1)
|
|
|
|
trace("waveOutGetPosition(%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, "waveOutGetPosition(%s): MIDI test failed\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
|
|
|
mmtime.wType = TIME_TICKS;
|
|
|
|
rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (mmtime.wType != TIME_TICKS && winetest_debug > 1)
|
|
|
|
trace("waveOutGetPosition(%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, "waveOutGetPosition(%s): TICKS test failed\n",
|
|
|
|
dev_name(device));
|
2004-06-01 22:20:54 +02:00
|
|
|
}
|
|
|
|
|
2006-05-07 23:06:04 +02:00
|
|
|
static void CALLBACK callback_func(HWAVEOUT hwo, UINT uMsg,
|
|
|
|
DWORD_PTR dwInstance,
|
|
|
|
DWORD dwParam1, DWORD dwParam2)
|
|
|
|
{
|
2011-07-18 18:19:35 +02:00
|
|
|
if(uMsg == WOM_OPEN || uMsg == WOM_CLOSE)
|
|
|
|
ok(GetCurrentThreadId() == g_tid, "Got different thread ID\n");
|
2006-05-07 23:06:04 +02:00
|
|
|
SetEvent((HANDLE)dwInstance);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI callback_thread(LPVOID lpParameter)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
|
2008-02-28 19:56:48 +01:00
|
|
|
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure the thread has a message queue */
|
2009-02-20 10:23:08 +01:00
|
|
|
SetEvent(lpParameter);
|
2006-05-31 00:14:18 +02:00
|
|
|
|
2006-05-19 13:34:08 +02:00
|
|
|
while (GetMessage(&msg, 0, 0, 0)) {
|
|
|
|
UINT message = msg.message;
|
2006-05-28 22:50:09 +02:00
|
|
|
/* for some reason XP sends a WM_USER message before WOM_OPEN */
|
|
|
|
ok (message == WOM_OPEN || message == WOM_DONE ||
|
2006-05-31 00:14:18 +02:00
|
|
|
message == WOM_CLOSE || message == WM_USER || message == WM_APP,
|
2006-05-19 13:34:08 +02:00
|
|
|
"GetMessage returned unexpected message: %u\n", message);
|
|
|
|
if (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE)
|
2009-02-20 10:23:08 +01:00
|
|
|
SetEvent(lpParameter);
|
2006-05-31 00:14:18 +02:00
|
|
|
else if (message == WM_APP) {
|
2009-02-20 10:23:08 +01:00
|
|
|
SetEvent(lpParameter);
|
2006-05-31 00:14:18 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2006-05-19 13:34:08 +02:00
|
|
|
}
|
2006-05-07 23:06:04 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
static void wave_out_test_deviceOut(int device, double duration,
|
2006-05-28 22:50:09 +02:00
|
|
|
int headers, int loops,
|
2004-08-19 03:13:58 +02:00
|
|
|
LPWAVEFORMATEX pwfx, DWORD format,
|
2004-10-26 23:18:27 +02:00
|
|
|
DWORD flags, LPWAVEOUTCAPS pcaps,
|
2005-10-31 11:03:25 +01:00
|
|
|
BOOL interactive, BOOL sine, BOOL pause)
|
2002-12-16 23:12:32 +01:00
|
|
|
{
|
|
|
|
HWAVEOUT wout;
|
|
|
|
HANDLE hevent;
|
2006-05-31 00:14:18 +02:00
|
|
|
WAVEHDR *frags = 0;
|
2002-12-16 23:12:32 +01:00
|
|
|
MMRESULT rc;
|
|
|
|
DWORD volume;
|
2004-05-27 22:00:26 +02:00
|
|
|
WORD nChannels = pwfx->nChannels;
|
|
|
|
WORD wBitsPerSample = pwfx->wBitsPerSample;
|
|
|
|
DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
|
2012-07-31 10:58:15 +02:00
|
|
|
BOOL has_volume = (pcaps->dwSupport & WAVECAPS_VOLUME) != 0;
|
2005-10-31 11:03:25 +01:00
|
|
|
double paused = 0.0;
|
2009-01-03 20:15:25 +01:00
|
|
|
DWORD_PTR callback = 0;
|
|
|
|
DWORD_PTR callback_instance = 0;
|
2006-05-07 23:06:04 +02:00
|
|
|
HANDLE thread = 0;
|
2006-05-31 00:14:18 +02:00
|
|
|
DWORD thread_id;
|
|
|
|
char * buffer;
|
2006-05-28 22:50:09 +02:00
|
|
|
DWORD length;
|
|
|
|
DWORD frag_length;
|
|
|
|
int i, j;
|
2002-12-16 23:12:32 +01:00
|
|
|
|
|
|
|
hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(hevent!=NULL,"CreateEvent(): error=%d\n",GetLastError());
|
2002-12-16 23:12:32 +01:00
|
|
|
if (hevent==NULL)
|
|
|
|
return;
|
|
|
|
|
2006-05-07 23:06:04 +02:00
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_EVENT) {
|
2009-01-03 20:15:25 +01:00
|
|
|
callback = (DWORD_PTR)hevent;
|
2006-05-07 23:06:04 +02:00
|
|
|
callback_instance = 0;
|
|
|
|
} else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION) {
|
2009-01-03 20:15:25 +01:00
|
|
|
callback = (DWORD_PTR)callback_func;
|
|
|
|
callback_instance = (DWORD_PTR)hevent;
|
2006-05-07 23:06:04 +02:00
|
|
|
} else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
|
|
|
|
thread = CreateThread(NULL, 0, callback_thread, hevent, 0, &thread_id);
|
|
|
|
if (thread) {
|
2006-05-31 00:14:18 +02:00
|
|
|
/* make sure thread is running */
|
2009-02-11 14:49:43 +01:00
|
|
|
WaitForSingleObject(hevent,10000);
|
2006-05-07 23:06:04 +02:00
|
|
|
callback = thread_id;
|
|
|
|
callback_instance = 0;
|
|
|
|
} else {
|
|
|
|
trace("CreateThread() failed\n");
|
2006-05-19 13:34:08 +02:00
|
|
|
CloseHandle(hevent);
|
2006-05-07 23:06:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) {
|
|
|
|
trace("CALLBACK_THREAD not implemented\n");
|
2006-05-19 13:34:08 +02:00
|
|
|
CloseHandle(hevent);
|
2006-05-07 23:06:04 +02:00
|
|
|
return;
|
2009-06-07 11:28:44 +02:00
|
|
|
} else if (flags & CALLBACK_TYPEMASK) {
|
2006-05-07 23:06:04 +02:00
|
|
|
trace("Undefined callback type!\n");
|
2006-05-19 13:34:08 +02:00
|
|
|
CloseHandle(hevent);
|
2006-05-07 23:06:04 +02:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
trace("CALLBACK_NULL not implemented\n");
|
2006-05-19 13:34:08 +02:00
|
|
|
CloseHandle(hevent);
|
2006-05-07 23:06:04 +02:00
|
|
|
return;
|
|
|
|
}
|
2002-12-16 23:12:32 +01:00
|
|
|
wout=NULL;
|
2011-07-18 18:19:35 +02:00
|
|
|
g_tid = GetCurrentThreadId();
|
2006-05-07 23:06:04 +02:00
|
|
|
rc=waveOutOpen(&wout,device,pwfx,callback,callback_instance,flags);
|
2002-12-16 23:12:32 +01:00
|
|
|
/* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
|
2004-05-27 22:00:26 +02:00
|
|
|
/* It is acceptable to fail on formats that are not specified to work */
|
2002-12-16 23:12:32 +01:00
|
|
|
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)) ||
|
2002-12-16 23:12:32 +01:00
|
|
|
(rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
|
2011-10-24 23:22:16 +02:00
|
|
|
"waveOutOpen(%s): format=%dx%2dx%d flags=%x(%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_out_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("waveOutOpen(%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));
|
2006-05-31 00:14:18 +02:00
|
|
|
if (rc!=MMSYSERR_NOERROR)
|
|
|
|
goto EXIT;
|
|
|
|
|
2012-01-18 20:30:31 +01:00
|
|
|
rc=WaitForSingleObject(hevent,9000);
|
|
|
|
ok(rc==WAIT_OBJECT_0, "missing WOM_OPEN notification\n");
|
2002-12-16 23:12:32 +01:00
|
|
|
|
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);
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2007-06-26 01:05:56 +02:00
|
|
|
frags = HeapAlloc(GetProcessHeap(), 0, headers * sizeof(WAVEHDR));
|
2006-05-28 22:50:09 +02:00
|
|
|
|
2004-10-26 23:18:27 +02:00
|
|
|
if (sine)
|
2006-05-28 22:50:09 +02:00
|
|
|
buffer=wave_generate_la(pwfx,duration / (loops + 1),&length);
|
2004-10-26 23:18:27 +02:00
|
|
|
else
|
2006-05-28 22:50:09 +02:00
|
|
|
buffer=wave_generate_silence(pwfx,duration / (loops + 1),&length);
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2006-05-09 02:51:23 +02:00
|
|
|
rc=waveOutGetVolume(wout,0);
|
|
|
|
ok(rc==MMSYSERR_INVALPARAM,"waveOutGetVolume(%s,0) expected "
|
|
|
|
"MMSYSERR_INVALPARAM, got %s\n", dev_name(device),wave_out_error(rc));
|
2002-12-16 23:12:32 +01:00
|
|
|
rc=waveOutGetVolume(wout,&volume);
|
2009-02-16 12:26:18 +01:00
|
|
|
if (rc == MMSYSERR_NOTSUPPORTED) has_volume = FALSE;
|
2005-03-18 11:25:48 +01:00
|
|
|
ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveOutGetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
/* make sure fragment length is a multiple of block size */
|
|
|
|
frag_length = ((length / headers) / pwfx->nBlockAlign) * pwfx->nBlockAlign;
|
|
|
|
|
|
|
|
for (i = 0; i < headers; i++) {
|
|
|
|
frags[i].lpData=buffer + (i * frag_length);
|
|
|
|
if (i != (headers-1))
|
|
|
|
frags[i].dwBufferLength=frag_length;
|
|
|
|
else {
|
|
|
|
/* use remainder of buffer for last fragment */
|
|
|
|
frags[i].dwBufferLength=length - (i * frag_length);
|
|
|
|
}
|
|
|
|
frags[i].dwFlags=0;
|
|
|
|
frags[i].dwLoops=0;
|
|
|
|
rc=waveOutPrepareHeader(wout, &frags[i], sizeof(frags[0]));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutPrepareHeader(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
}
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2004-10-26 23:18:27 +02:00
|
|
|
if (interactive && rc==MMSYSERR_NOERROR) {
|
2006-11-12 21:06:57 +01:00
|
|
|
trace("Playing %g second %s at %5dx%2dx%d %2d header%s %d loop%s %d bytes %s %s\n",duration,
|
2004-10-26 23:18:27 +02:00
|
|
|
sine ? "440Hz tone" : "silence",pwfx->nSamplesPerSec,
|
2006-05-28 22:50:09 +02:00
|
|
|
pwfx->wBitsPerSample,pwfx->nChannels, headers, headers > 1 ? "s": " ",
|
|
|
|
loops, loops == 1 ? " " : "s", length * (loops + 1),
|
2004-08-19 03:13:58 +02:00
|
|
|
get_format_str(pwfx->wFormatTag),
|
2006-05-07 23:06:04 +02:00
|
|
|
wave_open_flags(flags));
|
2006-05-11 01:40:25 +02:00
|
|
|
if (sine && has_volume && volume == 0)
|
2005-03-03 14:49:30 +01:00
|
|
|
trace("*** Warning the sound is muted, you will not hear the test\n");
|
2004-07-20 03:22:47 +02:00
|
|
|
|
|
|
|
/* Check that the position is 0 at start */
|
2005-02-16 18:52:35 +01:00
|
|
|
check_position(device, wout, 0, pwfx);
|
2004-07-20 03:22:47 +02:00
|
|
|
|
2002-12-16 23:12:32 +01:00
|
|
|
rc=waveOutSetVolume(wout,0x20002000);
|
2005-03-18 11:25:48 +01:00
|
|
|
ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2005-02-23 21:28:28 +01:00
|
|
|
rc=waveOutSetVolume(wout,volume);
|
2005-03-18 11:25:48 +01:00
|
|
|
ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
|
2005-02-23 21:28:28 +01:00
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
rc=waveOutWrite(wout, &frags[0], sizeof(frags[0]));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2005-10-31 11:03:25 +01:00
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
ok(frags[0].dwFlags==(WHDR_PREPARED|WHDR_INQUEUE),
|
2006-05-07 23:06:04 +02:00
|
|
|
"WHDR_INQUEUE WHDR_PREPARED expected, got= %s\n",
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_header_flags(frags[0].dwFlags));
|
2006-05-07 23:06:04 +02:00
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
rc=waveOutWrite(wout, &frags[0], sizeof(frags[0]));
|
2006-05-07 23:06:04 +02:00
|
|
|
ok(rc==WAVERR_STILLPLAYING,
|
|
|
|
"waveOutWrite(%s): WAVE_STILLPLAYING expected, got %s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
ok(frags[0].dwFlags==(WHDR_PREPARED|WHDR_INQUEUE),
|
2006-05-07 23:06:04 +02:00
|
|
|
"WHDR_INQUEUE WHDR_PREPARED expected, got %s\n",
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_header_flags(frags[0].dwFlags));
|
2006-05-07 23:06:04 +02:00
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
if (headers == 1 && loops == 0 && pause) {
|
2005-10-31 11:03:25 +01:00
|
|
|
paused = duration / 2;
|
|
|
|
Sleep(paused * 1000);
|
|
|
|
rc=waveOutPause(wout);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutPause(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
|
|
|
trace("pausing for %g seconds\n", paused);
|
|
|
|
Sleep(paused * 1000);
|
|
|
|
rc=waveOutRestart(wout);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutRestart(%s): rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
|
|
|
}
|
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
for (j = 0; j <= loops; j++) {
|
|
|
|
for (i = 0; i < headers; i++) {
|
|
|
|
/* don't do last one */
|
|
|
|
if (!((j == loops) && (i == (headers - 1)))) {
|
|
|
|
if (j > 0)
|
|
|
|
frags[(i+1) % headers].dwFlags = WHDR_PREPARED;
|
|
|
|
rc=waveOutWrite(wout, &frags[(i+1) % headers], sizeof(frags[0]));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s, header[%d]): rc=%s\n",
|
|
|
|
dev_name(device),(i+1)%headers,wave_out_error(rc));
|
|
|
|
}
|
2012-01-18 20:30:31 +01:00
|
|
|
rc=WaitForSingleObject(hevent,8000);
|
|
|
|
ok(rc==WAIT_OBJECT_0, "missing WOM_DONE notification\n");
|
2006-05-28 22:50:09 +02:00
|
|
|
}
|
|
|
|
}
|
2002-12-16 23:12:32 +01:00
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
for (i = 0; i < headers; i++) {
|
2009-10-14 10:56:36 +02:00
|
|
|
ok(frags[i].dwFlags==(WHDR_DONE|WHDR_PREPARED) ||
|
|
|
|
broken((flags & CALLBACK_TYPEMASK)==CALLBACK_EVENT &&
|
|
|
|
frags[i].dwFlags==(WHDR_DONE|WHDR_PREPARED|0x1000)), /* < NT4 */
|
|
|
|
"(%02d) WHDR_DONE WHDR_PREPARED expected, got %s\n",
|
|
|
|
i, wave_header_flags(frags[i].dwFlags));
|
2006-05-28 22:50:09 +02:00
|
|
|
}
|
|
|
|
check_position(device, wout, length * (loops + 1), pwfx);
|
2002-12-16 23:12:32 +01:00
|
|
|
}
|
|
|
|
|
2006-05-28 22:50:09 +02:00
|
|
|
for (i = 0; i < headers; i++) {
|
|
|
|
rc=waveOutUnprepareHeader(wout, &frags[i], sizeof(frags[0]));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device),
|
|
|
|
wave_out_error(rc));
|
|
|
|
}
|
2004-05-27 22:00:26 +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));
|
2012-01-18 20:30:31 +01:00
|
|
|
if (rc==WAVERR_STILLPLAYING) {
|
|
|
|
/* waveOutReset ought to return all buffers s.t. waveOutClose succeeds */
|
|
|
|
rc=waveOutReset(wout);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutReset(%s): rc=%s\n",dev_name(device),
|
|
|
|
wave_out_error(rc));
|
|
|
|
|
|
|
|
for (i = 0; i < headers; i++) {
|
|
|
|
rc=waveOutUnprepareHeader(wout, &frags[i], sizeof(frags[0]));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device),
|
|
|
|
wave_out_error(rc));
|
|
|
|
}
|
|
|
|
rc=waveOutClose(wout);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
|
|
|
|
wave_out_error(rc));
|
|
|
|
}
|
|
|
|
rc=WaitForSingleObject(hevent,1500);
|
|
|
|
ok(rc==WAIT_OBJECT_0, "missing WOM_CLOSE notification\n");
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2006-05-31 00:14:18 +02:00
|
|
|
EXIT:
|
|
|
|
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
|
|
|
|
PostThreadMessage(thread_id, WM_APP, 0, 0);
|
2009-02-11 14:49:43 +01:00
|
|
|
WaitForSingleObject(hevent,10000);
|
2006-05-31 00:14:18 +02:00
|
|
|
}
|
2006-05-19 13:34:08 +02:00
|
|
|
CloseHandle(hevent);
|
2007-06-26 01:05:56 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, frags);
|
2002-12-16 23:12:32 +01:00
|
|
|
}
|
|
|
|
|
2009-01-03 20:15:25 +01:00
|
|
|
static void wave_out_test_device(UINT_PTR device)
|
2002-11-05 00:47:49 +01:00
|
|
|
{
|
2004-07-21 05:10:24 +02:00
|
|
|
WAVEOUTCAPSA capsA;
|
|
|
|
WAVEOUTCAPSW capsW;
|
2011-06-23 20:12:07 +02:00
|
|
|
WAVEFORMATEX format;
|
2004-08-19 03:13:58 +02:00
|
|
|
WAVEFORMATEXTENSIBLE wfex;
|
2009-10-06 06:37:06 +02:00
|
|
|
IMAADPCMWAVEFORMAT wfa;
|
2002-11-05 00:47:49 +01:00
|
|
|
HWAVEOUT wout;
|
|
|
|
MMRESULT rc;
|
2004-06-04 19:58:00 +02:00
|
|
|
UINT f;
|
2004-07-21 05:10:24 +02:00
|
|
|
WCHAR * nameW;
|
|
|
|
CHAR * nameA;
|
2004-04-27 01:30:26 +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;
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2004-07-21 05:10:24 +02:00
|
|
|
rc=waveOutGetDevCapsA(device,&capsA,sizeof(capsA));
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
|
|
|
|
rc==MMSYSERR_NODRIVER,
|
|
|
|
"waveOutGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
|
|
|
|
return;
|
|
|
|
|
2004-07-21 05:10:24 +02:00
|
|
|
rc=waveOutGetDevCapsW(device,&capsW,sizeof(capsW));
|
2004-07-23 21:05:37 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_out_error(rc));
|
2004-07-21 05:10:24 +02:00
|
|
|
|
|
|
|
rc=waveOutGetDevCapsA(device,0,sizeof(capsA));
|
|
|
|
ok(rc==MMSYSERR_INVALPARAM,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, "
|
|
|
|
"got %s\n",dev_name(device),wave_out_error(rc));
|
2004-07-21 05:10:24 +02:00
|
|
|
|
|
|
|
rc=waveOutGetDevCapsW(device,0,sizeof(capsW));
|
2004-07-23 21:05:37 +02:00
|
|
|
ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_out_error(rc));
|
2004-06-14 19:54:45 +02:00
|
|
|
|
2007-01-11 15:35:11 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* FIXME: this works on windows but crashes wine */
|
2004-07-21 05:10:24 +02:00
|
|
|
rc=waveOutGetDevCapsA(device,(LPWAVEOUTCAPSA)1,sizeof(capsA));
|
2004-06-14 19:54:45 +02:00
|
|
|
ok(rc==MMSYSERR_INVALPARAM,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-07-21 05:10:24 +02:00
|
|
|
|
|
|
|
rc=waveOutGetDevCapsW(device,(LPWAVEOUTCAPSW)1,sizeof(capsW));
|
2004-07-23 21:05:37 +02:00
|
|
|
ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(device),wave_out_error(rc));
|
2007-01-11 15:35:11 +01:00
|
|
|
}
|
2004-06-14 19:54:45 +02:00
|
|
|
|
2004-07-21 05:10:24 +02:00
|
|
|
rc=waveOutGetDevCapsA(device,&capsA,4);
|
2008-04-25 01:39:43 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_NOERROR or MMSYSERR_INVALPARAM "
|
|
|
|
"expected, got %s\n", dev_name(device),wave_out_error(rc));
|
2004-06-14 19:54:45 +02:00
|
|
|
|
2004-07-21 05:10:24 +02:00
|
|
|
rc=waveOutGetDevCapsW(device,&capsW,4);
|
2008-11-11 17:31:44 +01:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED ||
|
|
|
|
rc==MMSYSERR_INVALPARAM, /* Vista, W2K8 */
|
|
|
|
"waveOutGetDevCapsW(%s): unexpected return value %s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-07-21 05:10:24 +02:00
|
|
|
|
2011-10-04 15:24:27 +02:00
|
|
|
rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYMAPPABLE, 0, 0);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"DRV_QUERYMAPPABLE(%s): unexpected return value %s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
|
|
|
|
2004-07-21 05:10:24 +02:00
|
|
|
nameA=NULL;
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACESIZE,
|
|
|
|
(DWORD_PTR)&size, 0);
|
2012-04-05 21:16:44 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || broken(rc==MMSYSERR_INVALPARAM ||
|
|
|
|
rc==MMSYSERR_NOTSUPPORTED),
|
2004-08-19 03:13:58 +02:00
|
|
|
"waveOutMessage(%s): failed to get interface size, rc=%s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2007-06-26 01:05:56 +02:00
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, size);
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACE,
|
|
|
|
(DWORD_PTR)nameW, size);
|
|
|
|
ok(rc==MMSYSERR_NOERROR,"waveOutMessage(%s): failed to get interface "
|
|
|
|
"name, rc=%s\n",dev_name(device),wave_out_error(rc));
|
2006-11-12 21:06:57 +01:00
|
|
|
ok(lstrlenW(nameW)+1==size/sizeof(WCHAR),"got an incorrect size %d\n",size);
|
2004-06-04 19:58:00 +02:00
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
2007-06-26 01:05:56 +02:00
|
|
|
nameA = HeapAlloc(GetProcessHeap(), 0, 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
|
|
|
}
|
2007-06-26 01:05:56 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
else if (rc==MMSYSERR_NOTSUPPORTED) {
|
2008-05-22 20:07:27 +02:00
|
|
|
nameA=HeapAlloc(GetProcessHeap(), 0, sizeof("not supported"));
|
|
|
|
strcpy(nameA, "not supported");
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 01:39:43 +02:00
|
|
|
rc=waveOutGetDevCapsA(device,&capsA,sizeof(capsA));
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
|
|
|
|
dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc!=MMSYSERR_NOERROR)
|
|
|
|
return;
|
|
|
|
|
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 support=%04x\n",
|
2004-08-19 03:13:58 +02:00
|
|
|
capsA.wChannels,capsA.dwFormats,capsA.dwSupport);
|
|
|
|
trace(" %s\n",wave_out_caps(capsA.dwSupport));
|
2007-06-26 01:05:56 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, nameA);
|
2004-06-04 19:58:00 +02:00
|
|
|
|
|
|
|
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;
|
2006-05-28 22:50:09 +02:00
|
|
|
|
|
|
|
wave_out_test_deviceOut(device,5.0,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,TRUE,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,5.0,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION,&capsA,TRUE,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,5.0,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD,&capsA,TRUE,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
|
|
|
|
wave_out_test_deviceOut(device,5.0,10,0,&format,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT,&capsA,TRUE,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,5.0,5,1,&format,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT,&capsA,TRUE,TRUE,FALSE);
|
2004-10-26 23:18:27 +02:00
|
|
|
} else {
|
|
|
|
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;
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.6,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,TRUE,FALSE,FALSE);
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.6,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,TRUE,FALSE,TRUE);
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.6,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION,&capsA,TRUE,FALSE,FALSE);
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.6,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION,&capsA,TRUE,FALSE,TRUE);
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.6,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD,&capsA,TRUE,FALSE,FALSE);
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.6,1,0,&format,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD,&capsA,TRUE,FALSE,TRUE);
|
2006-05-28 22:50:09 +02:00
|
|
|
|
2012-01-18 20:30:31 +01:00
|
|
|
wave_out_test_deviceOut(device,0.8,10,0,&format,WAVE_FORMAT_2M08,
|
2006-05-28 22:50:09 +02:00
|
|
|
CALLBACK_EVENT,&capsA,TRUE,FALSE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&format,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT,&capsA,TRUE,FALSE,FALSE);
|
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;
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&format,win_formats[f][0],
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&format,win_formats[f][0],
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
|
2006-05-07 23:06:04 +02:00
|
|
|
if (winetest_interactive) {
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,TRUE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION,&capsA,winetest_interactive,
|
|
|
|
TRUE,TRUE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD,&capsA,winetest_interactive,
|
|
|
|
TRUE,TRUE);
|
2006-05-28 22:50:09 +02:00
|
|
|
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&format,win_formats[f][0],
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,TRUE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&format,win_formats[f][0],
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,TRUE);
|
2006-05-07 23:06:04 +02:00
|
|
|
}
|
2005-02-23 13:42:43 +01:00
|
|
|
if (device != WAVE_MAPPER)
|
|
|
|
{
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT|WAVE_FORMAT_DIRECT,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT|WAVE_MAPPED,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION|WAVE_FORMAT_DIRECT,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_FUNCTION|WAVE_MAPPED,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD|WAVE_FORMAT_DIRECT,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_THREAD|WAVE_MAPPED,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&format,win_formats[f][0],
|
|
|
|
CALLBACK_EVENT|WAVE_FORMAT_DIRECT,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&format,win_formats[f][0],
|
|
|
|
CALLBACK_EVENT|WAVE_FORMAT_DIRECT,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2005-02-23 13:42:43 +01: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;
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,pwfx,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2005-02-23 13:42:43 +01:00
|
|
|
if (device != WAVE_MAPPER)
|
|
|
|
{
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT|WAVE_FORMAT_DIRECT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT|WAVE_MAPPED,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT|WAVE_FORMAT_DIRECT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,pwfx,WAVE_FORMAT_2M08,
|
|
|
|
CALLBACK_EVENT|WAVE_MAPPED,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,pwfx,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT|WAVE_FORMAT_DIRECT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,pwfx,WAVE_FORMAT_2M08,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT|WAVE_MAPPED,&capsA,
|
|
|
|
winetest_interactive,TRUE,FALSE);
|
2005-02-23 13:42:43 +01:00
|
|
|
}
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
2005-10-31 11:03:25 +01:00
|
|
|
VirtualFree(twoPages, 0, MEM_RELEASE);
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
|
2004-08-19 03:13:58 +02:00
|
|
|
/* try some 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=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR ||rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&format,0,CALLBACK_EVENT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&format,0,CALLBACK_EVENT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&format,0,CALLBACK_EVENT,
|
2005-10-31 11:03:25 +01:00
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
2004-08-19 03:13:58 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%s): WAVE_FORMAT_MULAW not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
2009-10-06 06:37:06 +02:00
|
|
|
wfa.wfx.wFormatTag=WAVE_FORMAT_IMA_ADPCM;
|
|
|
|
wfa.wfx.nChannels=1;
|
|
|
|
wfa.wfx.nSamplesPerSec=11025;
|
|
|
|
wfa.wfx.nAvgBytesPerSec=5588;
|
|
|
|
wfa.wfx.nBlockAlign=256;
|
|
|
|
wfa.wfx.wBitsPerSample=4; /* see imaadp32.c */
|
|
|
|
wfa.wfx.cbSize=2;
|
|
|
|
wfa.wSamplesPerBlock=505;
|
|
|
|
rc=waveOutOpen(&wout,device,&wfa.wfx,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
2004-08-19 03:13:58 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR ||rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2009-10-06 06:37:06 +02:00
|
|
|
/* TODO: teach wave_generate_* ADPCM
|
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfa.wfx,0,CALLBACK_EVENT,
|
2006-05-28 22:50:09 +02:00
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
2009-10-06 06:37:06 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&wfa.wfx,0,CALLBACK_EVENT,
|
2006-05-28 22:50:09 +02:00
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
2009-10-06 06:37:06 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&wfa.wfx,0,CALLBACK_EVENT,
|
2005-10-31 11:03:25 +01:00
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
2009-10-06 06:37:06 +02:00
|
|
|
*/
|
2004-08-19 03:13:58 +02:00
|
|
|
} else
|
2009-10-06 06:37:06 +02:00
|
|
|
trace("waveOutOpen(%s): WAVE_FORMAT_IMA_ADPCM not supported\n",
|
2004-08-19 03:13:58 +02:00
|
|
|
dev_name(device));
|
|
|
|
|
2004-08-16 23:10:04 +02:00
|
|
|
/* 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;
|
2004-08-19 03:13:58 +02:00
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
2004-08-16 23:10:04 +02:00
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2004-08-16 23:10:04 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%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;
|
2004-08-19 03:13:58 +02:00
|
|
|
wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
|
|
|
|
wfex.Format.nBlockAlign;
|
2004-08-16 23:10:04 +02:00
|
|
|
wfex.Format.cbSize=22;
|
|
|
|
wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
|
|
|
|
wfex.dwChannelMask=SPEAKER_ALL;
|
|
|
|
wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
|
2004-08-19 03:13:58 +02:00
|
|
|
rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,0,CALLBACK_EVENT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,0,CALLBACK_EVENT,
|
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,0,CALLBACK_EVENT,
|
2005-10-31 11:03:25 +01:00
|
|
|
&capsA,winetest_interactive,TRUE,FALSE);
|
2004-08-16 23:10:04 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%s): 4 channels not supported\n",
|
|
|
|
dev_name(device));
|
2004-08-19 03:13:58 +02:00
|
|
|
|
|
|
|
/* 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=waveOutOpen(&wout,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2004-08-19 03:13:58 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%s): 6 channels not supported\n",
|
|
|
|
dev_name(device));
|
|
|
|
|
2007-01-11 15:35:11 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* FIXME: ALSA doesn't like this format */
|
2004-08-19 03:13:58 +02:00
|
|
|
/* 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=waveOutOpen(&wout,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2004-08-19 03:13:58 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%s): 24 bit samples not supported\n",
|
|
|
|
dev_name(device));
|
2007-01-11 15:35:11 +01:00
|
|
|
}
|
2004-08-19 03:13:58 +02:00
|
|
|
|
|
|
|
/* 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=waveOutOpen(&wout,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2004-08-19 03:13:58 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%s): 32 bit samples not supported\n",
|
|
|
|
dev_name(device));
|
2004-08-30 20:36:06 +02:00
|
|
|
|
|
|
|
/* 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=waveOutOpen(&wout,device,&wfex.Format,0,0,
|
|
|
|
CALLBACK_NULL|WAVE_FORMAT_DIRECT);
|
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
|
|
|
|
rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
|
|
|
|
"waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
|
|
|
|
if (rc==MMSYSERR_NOERROR) {
|
|
|
|
waveOutClose(wout);
|
2006-05-28 22:50:09 +02:00
|
|
|
wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
|
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
|
|
|
wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
|
2006-05-07 23:06:04 +02:00
|
|
|
CALLBACK_EVENT,&capsA,winetest_interactive,
|
|
|
|
TRUE,FALSE);
|
2004-08-30 20:36:06 +02:00
|
|
|
} else
|
|
|
|
trace("waveOutOpen(%s): 32 bit float samples not supported\n",
|
|
|
|
dev_name(device));
|
2004-06-04 19:58:00 +02:00
|
|
|
}
|
|
|
|
|
2005-06-17 12:11:37 +02:00
|
|
|
static void wave_out_tests(void)
|
2004-06-04 19:58:00 +02:00
|
|
|
{
|
2004-08-14 01:50:18 +02:00
|
|
|
WAVEOUTCAPSA capsA;
|
|
|
|
WAVEOUTCAPSW capsW;
|
2004-06-04 19:58:00 +02:00
|
|
|
WAVEFORMATEX format;
|
|
|
|
HWAVEOUT wout;
|
|
|
|
MMRESULT rc;
|
2012-03-27 19:41:04 +02:00
|
|
|
DWORD preferred, status;
|
2004-06-04 19:58:00 +02:00
|
|
|
UINT ndev,d;
|
|
|
|
|
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
|
|
|
|
2012-03-27 19:41:04 +02:00
|
|
|
rc = waveOutMessage((HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET,
|
|
|
|
(DWORD_PTR)&preferred, (DWORD_PTR)&status);
|
|
|
|
ok((ndev == 0 && rc == MMSYSERR_NODRIVER) ||
|
|
|
|
rc == MMSYSERR_NOERROR, "waveOutMessage(DRVM_MAPPER_PREFERRED_GET) failed: %u\n", rc);
|
|
|
|
|
|
|
|
ok((ndev == 0 && (preferred == -1 || broken(preferred != -1))) ||
|
|
|
|
preferred < ndev, "Got invalid preferred device: 0x%x\n", preferred);
|
|
|
|
|
2004-08-14 01:50:18 +02:00
|
|
|
rc=waveOutGetDevCapsA(ndev+1,&capsA,sizeof(capsA));
|
2002-12-15 02:11:41 +01:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
|
|
|
|
dev_name(ndev+1),mmsys_error(rc));
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2004-08-14 01:50:18 +02:00
|
|
|
rc=waveOutGetDevCapsW(ndev+1,&capsW,sizeof(capsW));
|
2004-10-26 23:18:27 +02:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(ndev+1),mmsys_error(rc));
|
2004-08-14 01:50:18 +02:00
|
|
|
|
|
|
|
rc=waveOutGetDevCapsA(WAVE_MAPPER,&capsA,sizeof(capsA));
|
2004-04-30 06:14:58 +02:00
|
|
|
if (ndev>0)
|
|
|
|
ok(rc==MMSYSERR_NOERROR,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
|
|
|
|
dev_name(WAVE_MAPPER),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,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
|
|
|
|
"expected, got %s\n",dev_name(WAVE_MAPPER),mmsys_error(rc));
|
2004-04-27 01:30:26 +02:00
|
|
|
|
2004-08-14 01:50:18 +02:00
|
|
|
rc=waveOutGetDevCapsW(WAVE_MAPPER,&capsW,sizeof(capsW));
|
|
|
|
if (ndev>0)
|
2004-10-26 23:18:27 +02:00
|
|
|
ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
|
|
|
|
"waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
|
|
|
|
"expected, got %s\n",dev_name(WAVE_MAPPER),mmsys_error(rc));
|
2004-08-14 01:50:18 +02:00
|
|
|
else
|
2005-04-11 14:49:22 +02:00
|
|
|
ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER ||
|
2004-10-26 23:18:27 +02:00
|
|
|
rc==MMSYSERR_NOTSUPPORTED,
|
2004-08-16 23:10:04 +02:00
|
|
|
"waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
|
2004-10-26 23:18:27 +02:00
|
|
|
" or MMSYSERR_NOTSUPPORTED expected, got %s\n",
|
|
|
|
dev_name(WAVE_MAPPER),mmsys_error(rc));
|
2004-08-14 01:50:18 +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-08-16 23:10:04 +02:00
|
|
|
"waveOutOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
|
|
|
|
dev_name(ndev+1),mmsys_error(rc));
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2004-06-04 19:58:00 +02:00
|
|
|
for (d=0;d<ndev;d++)
|
|
|
|
wave_out_test_device(d);
|
2002-11-05 00:47:49 +01:00
|
|
|
|
2004-06-04 19:58:00 +02:00
|
|
|
if (ndev>0)
|
|
|
|
wave_out_test_device(WAVE_MAPPER);
|
2002-11-05 00:47:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(wave)
|
|
|
|
{
|
2008-08-18 23:56:56 +02:00
|
|
|
test_multiple_waveopens();
|
2002-11-05 00:47:49 +01:00
|
|
|
wave_out_tests();
|
|
|
|
}
|