adapi32/tests: Fix test failures when the computername is fully qualified on W2K3...
[wine/hacks.git] / dlls / winmm / tests / wave.c
blob98a16f58a3dc90f793c0366796a9c5d623b3d3fd
1 /*
2 * Test winmm sound playback in each sound format
4 * Copyright (c) 2002 Francois Gouget
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <math.h>
26 #include "wine/test.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "mmsystem.h"
32 #define NOBITMAP
33 #include "mmreg.h"
34 #include "ks.h"
35 #include "ksguid.h"
36 #include "ksmedia.h"
38 #include "winmm_test.h"
40 static void test_multiple_waveopens(void)
42 HWAVEOUT handle1, handle2;
43 MMRESULT ret;
44 WAVEFORMATEX wfx;
46 wfx.wFormatTag = WAVE_FORMAT_PCM;
47 wfx.nChannels = 1;
48 wfx.nSamplesPerSec = 11025;
49 wfx.nBlockAlign = 1;
50 wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
51 wfx.wBitsPerSample = 8;
52 wfx.cbSize = 0;
54 ret = waveOutOpen(&handle1, 0, &wfx, 0, 0, 0);
55 if (ret != MMSYSERR_NOERROR)
57 skip("Could not do the duplicate waveopen test\n");
58 return;
61 ret = waveOutOpen(&handle2, 0, &wfx, 0, 0, 0);
62 /* Modern Windows allows for wave-out devices to be opened multiple times.
63 * Some Wine audio drivers allow that and some don't. To avoid false alarms
64 * for those that do, don't "todo_wine ok(...)" on success.
66 if (ret != MMSYSERR_NOERROR)
68 todo_wine ok(ret == MMSYSERR_NOERROR || broken(ret == MMSYSERR_ALLOCATED), /* winME */
69 "second waveOutOpen returns: %x\n", ret);
71 else
72 waveOutClose(handle2);
74 waveOutClose(handle1);
78 * Note that in most of this test we may get MMSYSERR_BADDEVICEID errors
79 * at about any time if the user starts another application that uses the
80 * sound device. So we should not report these as test failures.
82 * This test can play a test tone. But this only makes sense if someone
83 * is going to carefully listen to it, and would only bother everyone else.
84 * So this is only done if the test is being run in interactive mode.
87 #define PI 3.14159265358979323846
88 static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
90 int i,j;
91 int nb_samples;
92 char* buf;
93 char* b;
94 WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE*)wfx;
96 nb_samples=(int)(duration*wfx->nSamplesPerSec);
97 *size=nb_samples*wfx->nBlockAlign;
98 b=buf=HeapAlloc(GetProcessHeap(), 0, *size);
99 for (i=0;i<nb_samples;i++) {
100 double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
101 if (wfx->wBitsPerSample==8) {
102 unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
103 for (j = 0; j < wfx->nChannels; j++)
104 *b++=sample;
105 } else if (wfx->wBitsPerSample==16) {
106 signed short sample=(signed short)((double)32767.5*y-0.5);
107 for (j = 0; j < wfx->nChannels; j++) {
108 b[0]=sample & 0xff;
109 b[1]=sample >> 8;
110 b+=2;
112 } else if (wfx->wBitsPerSample==24) {
113 signed int sample=(signed int)(((double)0x7fffff+0.5)*y-0.5);
114 for (j = 0; j < wfx->nChannels; j++) {
115 b[0]=sample & 0xff;
116 b[1]=(sample >> 8) & 0xff;
117 b[2]=(sample >> 16) & 0xff;
118 b+=3;
120 } else if ((wfx->wBitsPerSample==32) && ((wfx->wFormatTag == WAVE_FORMAT_PCM) ||
121 ((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
122 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)))) {
123 signed int sample=(signed int)(((double)0x7fffffff+0.5)*y-0.5);
124 for (j = 0; j < wfx->nChannels; j++) {
125 b[0]=sample & 0xff;
126 b[1]=(sample >> 8) & 0xff;
127 b[2]=(sample >> 16) & 0xff;
128 b[3]=(sample >> 24) & 0xff;
129 b+=4;
131 } else if ((wfx->wBitsPerSample==32) && (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
132 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
133 union { float f; char c[4]; } sample;
134 sample.f=(float)y;
135 for (j = 0; j < wfx->nChannels; j++) {
136 b[0]=sample.c[0];
137 b[1]=sample.c[1];
138 b[2]=sample.c[2];
139 b[3]=sample.c[3];
140 b+=4;
144 return buf;
147 static char* wave_generate_silence(WAVEFORMATEX* wfx, double duration, DWORD* size)
149 int i,j;
150 int nb_samples;
151 char* buf;
152 char* b;
153 WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE*)wfx;
155 nb_samples=(int)(duration*wfx->nSamplesPerSec);
156 *size=nb_samples*wfx->nBlockAlign;
157 b=buf=HeapAlloc(GetProcessHeap(), 0, *size);
158 for (i=0;i<nb_samples;i++) {
159 if (wfx->wBitsPerSample==8) {
160 for (j = 0; j < wfx->nChannels; j++)
161 *b++=128;
162 } else if (wfx->wBitsPerSample==16) {
163 for (j = 0; j < wfx->nChannels; j++) {
164 b[0]=0;
165 b[1]=0;
166 b+=2;
168 } else if (wfx->wBitsPerSample==24) {
169 for (j = 0; j < wfx->nChannels; j++) {
170 b[0]=0;
171 b[1]=0;
172 b[2]=0;
173 b+=3;
175 } else if ((wfx->wBitsPerSample==32) && ((wfx->wFormatTag == WAVE_FORMAT_PCM) ||
176 ((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
177 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)))) {
178 for (j = 0; j < wfx->nChannels; j++) {
179 b[0]=0;
180 b[1]=0;
181 b[2]=0;
182 b[3]=0;
183 b+=4;
185 } else if ((wfx->wBitsPerSample==32) && (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
186 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
187 union { float f; char c[4]; } sample;
188 sample.f=0;
189 for (j = 0; j < wfx->nChannels; j++) {
190 b[0]=sample.c[0];
191 b[1]=sample.c[1];
192 b[2]=sample.c[2];
193 b[3]=sample.c[3];
194 b+=4;
198 return buf;
201 const char * dev_name(int device)
203 static char name[16];
204 if (device == WAVE_MAPPER)
205 return "WAVE_MAPPER";
206 sprintf(name, "%d", device);
207 return name;
210 const char* mmsys_error(MMRESULT error)
212 #define ERR_TO_STR(dev) case dev: return #dev
213 static char unknown[32];
214 switch (error) {
215 ERR_TO_STR(MMSYSERR_NOERROR);
216 ERR_TO_STR(MMSYSERR_ERROR);
217 ERR_TO_STR(MMSYSERR_BADDEVICEID);
218 ERR_TO_STR(MMSYSERR_NOTENABLED);
219 ERR_TO_STR(MMSYSERR_ALLOCATED);
220 ERR_TO_STR(MMSYSERR_INVALHANDLE);
221 ERR_TO_STR(MMSYSERR_NODRIVER);
222 ERR_TO_STR(MMSYSERR_NOMEM);
223 ERR_TO_STR(MMSYSERR_NOTSUPPORTED);
224 ERR_TO_STR(MMSYSERR_BADERRNUM);
225 ERR_TO_STR(MMSYSERR_INVALFLAG);
226 ERR_TO_STR(MMSYSERR_INVALPARAM);
227 ERR_TO_STR(WAVERR_BADFORMAT);
228 ERR_TO_STR(WAVERR_STILLPLAYING);
229 ERR_TO_STR(WAVERR_UNPREPARED);
230 ERR_TO_STR(WAVERR_SYNC);
231 ERR_TO_STR(MIDIERR_UNPREPARED);
232 ERR_TO_STR(MIDIERR_STILLPLAYING);
233 ERR_TO_STR(MIDIERR_NOTREADY);
234 ERR_TO_STR(MIDIERR_NODEVICE);
235 ERR_TO_STR(MIDIERR_INVALIDSETUP);
236 ERR_TO_STR(TIMERR_NOCANDO);
237 ERR_TO_STR(TIMERR_STRUCT);
238 ERR_TO_STR(JOYERR_PARMS);
239 ERR_TO_STR(JOYERR_NOCANDO);
240 ERR_TO_STR(JOYERR_UNPLUGGED);
241 ERR_TO_STR(MIXERR_INVALLINE);
242 ERR_TO_STR(MIXERR_INVALCONTROL);
243 ERR_TO_STR(MIXERR_INVALVALUE);
244 ERR_TO_STR(MMIOERR_FILENOTFOUND);
245 ERR_TO_STR(MMIOERR_OUTOFMEMORY);
246 ERR_TO_STR(MMIOERR_CANNOTOPEN);
247 ERR_TO_STR(MMIOERR_CANNOTCLOSE);
248 ERR_TO_STR(MMIOERR_CANNOTREAD);
249 ERR_TO_STR(MMIOERR_CANNOTWRITE);
250 ERR_TO_STR(MMIOERR_CANNOTSEEK);
251 ERR_TO_STR(MMIOERR_CANNOTEXPAND);
252 ERR_TO_STR(MMIOERR_CHUNKNOTFOUND);
253 ERR_TO_STR(MMIOERR_UNBUFFERED);
255 sprintf(unknown, "Unknown(0x%08x)", error);
256 return unknown;
257 #undef ERR_TO_STR
260 const char* wave_out_error(MMRESULT error)
262 static char msg[1024];
263 static char long_msg[1100];
264 MMRESULT rc;
266 rc = waveOutGetErrorText(error, msg, sizeof(msg));
267 if (rc != MMSYSERR_NOERROR)
268 sprintf(long_msg, "waveOutGetErrorText(%x) failed with error %x",
269 error, rc);
270 else
271 sprintf(long_msg, "%s(%s)", mmsys_error(error), msg);
272 return long_msg;
275 const char * wave_open_flags(DWORD flags)
277 static char msg[1024];
278 int first = TRUE;
279 msg[0] = 0;
280 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_EVENT) {
281 strcat(msg, "CALLBACK_EVENT");
282 first = FALSE;
284 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION) {
285 if (!first) strcat(msg, "|");
286 strcat(msg, "CALLBACK_FUNCTION");
287 first = FALSE;
289 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_NULL) {
290 if (!first) strcat(msg, "|");
291 strcat(msg, "CALLBACK_NULL");
292 first = FALSE;
294 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
295 if (!first) strcat(msg, "|");
296 strcat(msg, "CALLBACK_THREAD");
297 first = FALSE;
299 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) {
300 if (!first) strcat(msg, "|");
301 strcat(msg, "CALLBACK_WINDOW");
302 first = FALSE;
304 if ((flags & WAVE_ALLOWSYNC) == WAVE_ALLOWSYNC) {
305 if (!first) strcat(msg, "|");
306 strcat(msg, "WAVE_ALLOWSYNC");
307 first = FALSE;
309 if ((flags & WAVE_FORMAT_DIRECT) == WAVE_FORMAT_DIRECT) {
310 if (!first) strcat(msg, "|");
311 strcat(msg, "WAVE_FORMAT_DIRECT");
312 first = FALSE;
314 if ((flags & WAVE_FORMAT_QUERY) == WAVE_FORMAT_QUERY) {
315 if (!first) strcat(msg, "|");
316 strcat(msg, "WAVE_FORMAT_QUERY");
317 first = FALSE;
319 if ((flags & WAVE_MAPPED) == WAVE_MAPPED) {
320 if (!first) strcat(msg, "|");
321 strcat(msg, "WAVE_MAPPED");
322 first = FALSE;
324 return msg;
327 static const char * wave_header_flags(DWORD flags)
329 #define WHDR_MASK (WHDR_BEGINLOOP|WHDR_DONE|WHDR_ENDLOOP|WHDR_INQUEUE|WHDR_PREPARED)
330 static char msg[1024];
331 int first = TRUE;
332 msg[0] = 0;
333 if (flags & WHDR_BEGINLOOP) {
334 strcat(msg, "WHDR_BEGINLOOP");
335 first = FALSE;
337 if (flags & WHDR_DONE) {
338 if (!first) strcat(msg, " ");
339 strcat(msg, "WHDR_DONE");
340 first = FALSE;
342 if (flags & WHDR_ENDLOOP) {
343 if (!first) strcat(msg, " ");
344 strcat(msg, "WHDR_ENDLOOP");
345 first = FALSE;
347 if (flags & WHDR_INQUEUE) {
348 if (!first) strcat(msg, " ");
349 strcat(msg, "WHDR_INQUEUE");
350 first = FALSE;
352 if (flags & WHDR_PREPARED) {
353 if (!first) strcat(msg, " ");
354 strcat(msg, "WHDR_PREPARED");
355 first = FALSE;
357 if (flags & ~WHDR_MASK) {
358 char temp[32];
359 sprintf(temp, "UNKNOWN(0x%08x)", flags & ~WHDR_MASK);
360 if (!first) strcat(msg, " ");
361 strcat(msg, temp);
363 return msg;
366 static const char * wave_out_caps(DWORD dwSupport)
368 #define ADD_FLAG(f) if (dwSupport & f) strcat(msg, " " #f)
369 static char msg[256];
370 msg[0] = 0;
372 ADD_FLAG(WAVECAPS_PITCH);
373 ADD_FLAG(WAVECAPS_PLAYBACKRATE);
374 ADD_FLAG(WAVECAPS_VOLUME);
375 ADD_FLAG(WAVECAPS_LRVOLUME);
376 ADD_FLAG(WAVECAPS_SYNC);
377 ADD_FLAG(WAVECAPS_SAMPLEACCURATE);
379 return msg[0] ? msg + 1 : "";
380 #undef ADD_FLAG
383 const char * wave_time_format(UINT type)
385 static char msg[32];
386 #define TIME_FORMAT(f) case f: return #f
387 switch (type) {
388 TIME_FORMAT(TIME_MS);
389 TIME_FORMAT(TIME_SAMPLES);
390 TIME_FORMAT(TIME_BYTES);
391 TIME_FORMAT(TIME_SMPTE);
392 TIME_FORMAT(TIME_MIDI);
393 TIME_FORMAT(TIME_TICKS);
395 #undef TIME_FORMAT
396 sprintf(msg, "Unknown(0x%04x)", type);
397 return msg;
400 const char * get_format_str(WORD format)
402 static char msg[32];
403 #define WAVE_FORMAT(f) case f: return #f
404 switch (format) {
405 WAVE_FORMAT(WAVE_FORMAT_PCM);
406 WAVE_FORMAT(WAVE_FORMAT_ADPCM);
407 WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD);
408 WAVE_FORMAT(WAVE_FORMAT_ALAW);
409 WAVE_FORMAT(WAVE_FORMAT_MULAW);
410 WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM);
411 WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM);
412 WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM);
413 WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM);
414 WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM);
415 WAVE_FORMAT(WAVE_FORMAT_DIGISTD);
416 WAVE_FORMAT(WAVE_FORMAT_DIGIFIX);
417 WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM);
418 WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM);
419 WAVE_FORMAT(WAVE_FORMAT_SONARC);
420 WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH);
421 WAVE_FORMAT(WAVE_FORMAT_ECHOSC1);
422 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36);
423 WAVE_FORMAT(WAVE_FORMAT_APTX);
424 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10);
425 WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2);
426 WAVE_FORMAT(WAVE_FORMAT_GSM610);
427 WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME);
428 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC);
429 WAVE_FORMAT(WAVE_FORMAT_DIGIREAL);
430 WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM);
431 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10);
432 WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM);
433 WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM);
434 WAVE_FORMAT(WAVE_FORMAT_MPEG);
435 WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3);
436 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM);
437 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8);
438 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10);
439 WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND);
440 WAVE_FORMAT(WAVE_FORMAT_OLIGSM);
441 WAVE_FORMAT(WAVE_FORMAT_OLIADPCM);
442 WAVE_FORMAT(WAVE_FORMAT_OLICELP);
443 WAVE_FORMAT(WAVE_FORMAT_OLISBC);
444 WAVE_FORMAT(WAVE_FORMAT_OLIOPR);
445 WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT);
446 WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE);
448 #undef WAVE_FORMAT
449 sprintf(msg, "Unknown(0x%04x)", format);
450 return msg;
453 DWORD bytes_to_samples(DWORD bytes, LPWAVEFORMATEX pwfx)
455 return bytes / pwfx->nBlockAlign;
458 DWORD bytes_to_ms(DWORD bytes, LPWAVEFORMATEX pwfx)
460 return bytes_to_samples(bytes, pwfx) * 1000 / pwfx->nSamplesPerSec;
463 DWORD time_to_bytes(LPMMTIME mmtime, LPWAVEFORMATEX pwfx)
465 if (mmtime->wType == TIME_BYTES)
466 return mmtime->u.cb;
467 else if (mmtime->wType == TIME_SAMPLES)
468 return mmtime->u.sample * pwfx->nBlockAlign;
469 else if (mmtime->wType == TIME_MS)
470 return mmtime->u.ms * pwfx->nAvgBytesPerSec / 1000;
471 else if (mmtime->wType == TIME_SMPTE)
472 return ((mmtime->u.smpte.hour * 60.0 * 60.0) +
473 (mmtime->u.smpte.min * 60.0) +
474 (mmtime->u.smpte.sec) +
475 (mmtime->u.smpte.frame / 30.0)) * pwfx->nAvgBytesPerSec;
477 trace("FIXME: time_to_bytes() type not supported\n");
478 return -1;
481 static void check_position(int device, HWAVEOUT wout, DWORD bytes,
482 LPWAVEFORMATEX pwfx )
484 MMTIME mmtime;
485 DWORD samples;
486 double duration;
487 MMRESULT rc;
488 DWORD returned;
490 samples=bytes/(pwfx->wBitsPerSample/8*pwfx->nChannels);
491 duration=((double)samples)/pwfx->nSamplesPerSec;
493 mmtime.wType = TIME_BYTES;
494 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
495 ok(rc==MMSYSERR_NOERROR,
496 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
497 if (mmtime.wType != TIME_BYTES && winetest_debug > 1)
498 trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
499 dev_name(device),wave_time_format(mmtime.wType));
500 returned = time_to_bytes(&mmtime, pwfx);
501 ok(returned == bytes, "waveOutGetPosition(%s): returned %d bytes, "
502 "should be %d\n", dev_name(device), returned, bytes);
504 mmtime.wType = TIME_SAMPLES;
505 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
506 ok(rc==MMSYSERR_NOERROR,
507 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
508 if (mmtime.wType != TIME_SAMPLES && winetest_debug > 1)
509 trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
510 "returned %s\n",dev_name(device),wave_time_format(mmtime.wType));
511 returned = time_to_bytes(&mmtime, pwfx);
512 ok(returned == bytes, "waveOutGetPosition(%s): returned %d samples "
513 "(%d bytes), should be %d (%d bytes)\n", dev_name(device),
514 bytes_to_samples(returned, pwfx), returned,
515 bytes_to_samples(bytes, pwfx), bytes);
517 mmtime.wType = TIME_MS;
518 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
519 ok(rc==MMSYSERR_NOERROR,
520 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
521 if (mmtime.wType != TIME_MS && winetest_debug > 1)
522 trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
523 dev_name(device), wave_time_format(mmtime.wType));
524 returned = time_to_bytes(&mmtime, pwfx);
525 ok(returned == bytes, "waveOutGetPosition(%s): returned %d ms, "
526 "(%d bytes), should be %d (%d bytes)\n", dev_name(device),
527 bytes_to_ms(returned, pwfx), returned,
528 bytes_to_ms(bytes, pwfx), bytes);
530 mmtime.wType = TIME_SMPTE;
531 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
532 ok(rc==MMSYSERR_NOERROR,
533 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
534 if (mmtime.wType != TIME_SMPTE && winetest_debug > 1)
535 trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
536 dev_name(device),wave_time_format(mmtime.wType));
537 returned = time_to_bytes(&mmtime, pwfx);
538 ok(returned == bytes, "waveOutGetPosition(%s): SMPTE test failed\n",
539 dev_name(device));
541 mmtime.wType = TIME_MIDI;
542 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
543 ok(rc==MMSYSERR_NOERROR,
544 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
545 if (mmtime.wType != TIME_MIDI && winetest_debug > 1)
546 trace("waveOutGetPosition(%s): TIME_MIDI not supported, returned %s\n",
547 dev_name(device),wave_time_format(mmtime.wType));
548 returned = time_to_bytes(&mmtime, pwfx);
549 ok(returned == bytes, "waveOutGetPosition(%s): MIDI test failed\n",
550 dev_name(device));
552 mmtime.wType = TIME_TICKS;
553 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
554 ok(rc==MMSYSERR_NOERROR,
555 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
556 if (mmtime.wType != TIME_TICKS && winetest_debug > 1)
557 trace("waveOutGetPosition(%s): TIME_TICKS not supported, returned %s\n",
558 dev_name(device),wave_time_format(mmtime.wType));
559 returned = time_to_bytes(&mmtime, pwfx);
560 ok(returned == bytes, "waveOutGetPosition(%s): TICKS test failed\n",
561 dev_name(device));
564 static void CALLBACK callback_func(HWAVEOUT hwo, UINT uMsg,
565 DWORD_PTR dwInstance,
566 DWORD dwParam1, DWORD dwParam2)
568 SetEvent((HANDLE)dwInstance);
571 static DWORD WINAPI callback_thread(LPVOID lpParameter)
573 MSG msg;
575 PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure the thread has a message queue */
576 SetEvent(lpParameter);
578 while (GetMessage(&msg, 0, 0, 0)) {
579 UINT message = msg.message;
580 /* for some reason XP sends a WM_USER message before WOM_OPEN */
581 ok (message == WOM_OPEN || message == WOM_DONE ||
582 message == WOM_CLOSE || message == WM_USER || message == WM_APP,
583 "GetMessage returned unexpected message: %u\n", message);
584 if (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE)
585 SetEvent(lpParameter);
586 else if (message == WM_APP) {
587 SetEvent(lpParameter);
588 return 0;
592 return 0;
595 static void wave_out_test_deviceOut(int device, double duration,
596 int headers, int loops,
597 LPWAVEFORMATEX pwfx, DWORD format,
598 DWORD flags, LPWAVEOUTCAPS pcaps,
599 BOOL interactive, BOOL sine, BOOL pause)
601 HWAVEOUT wout;
602 HANDLE hevent;
603 WAVEHDR *frags = 0;
604 MMRESULT rc;
605 DWORD volume;
606 WORD nChannels = pwfx->nChannels;
607 WORD wBitsPerSample = pwfx->wBitsPerSample;
608 DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
609 BOOL has_volume = pcaps->dwSupport & WAVECAPS_VOLUME ? TRUE : FALSE;
610 double paused = 0.0;
611 DWORD_PTR callback = 0;
612 DWORD_PTR callback_instance = 0;
613 HANDLE thread = 0;
614 DWORD thread_id;
615 char * buffer;
616 DWORD length;
617 DWORD frag_length;
618 int i, j;
620 hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
621 ok(hevent!=NULL,"CreateEvent(): error=%d\n",GetLastError());
622 if (hevent==NULL)
623 return;
625 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_EVENT) {
626 callback = (DWORD_PTR)hevent;
627 callback_instance = 0;
628 } else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION) {
629 callback = (DWORD_PTR)callback_func;
630 callback_instance = (DWORD_PTR)hevent;
631 } else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
632 thread = CreateThread(NULL, 0, callback_thread, hevent, 0, &thread_id);
633 if (thread) {
634 /* make sure thread is running */
635 WaitForSingleObject(hevent,10000);
636 callback = thread_id;
637 callback_instance = 0;
638 } else {
639 trace("CreateThread() failed\n");
640 CloseHandle(hevent);
641 return;
643 } else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) {
644 trace("CALLBACK_THREAD not implemented\n");
645 CloseHandle(hevent);
646 return;
647 } else if (flags & CALLBACK_TYPEMASK) {
648 trace("Undefined callback type!\n");
649 CloseHandle(hevent);
650 return;
651 } else {
652 trace("CALLBACK_NULL not implemented\n");
653 CloseHandle(hevent);
654 return;
656 wout=NULL;
657 rc=waveOutOpen(&wout,device,pwfx,callback,callback_instance,flags);
658 /* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
659 /* It is acceptable to fail on formats that are not specified to work */
660 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
661 rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER ||
662 rc==MMSYSERR_ALLOCATED ||
663 ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
664 (flags & WAVE_FORMAT_DIRECT) && !(pcaps->dwFormats & format)) ||
665 ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
666 (!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) &&
667 !(pcaps->dwFormats & format)) ||
668 (rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
669 "waveOutOpen(%s): format=%dx%2dx%d flags=%lx(%s) rc=%s\n",
670 dev_name(device),pwfx->nSamplesPerSec,pwfx->wBitsPerSample,
671 pwfx->nChannels,CALLBACK_EVENT|flags,
672 wave_open_flags(CALLBACK_EVENT|flags),wave_out_error(rc));
673 if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
674 (flags & WAVE_FORMAT_DIRECT) && (pcaps->dwFormats & format))
675 trace(" Reason: The device lists this format as supported in it's "
676 "capabilities but opening it failed.\n");
677 if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
678 !(pcaps->dwFormats & format))
679 trace("waveOutOpen(%s): format=%dx%2dx%d %s rc=%s failed but format "
680 "not supported so OK.\n", dev_name(device), pwfx->nSamplesPerSec,
681 pwfx->wBitsPerSample,pwfx->nChannels,
682 flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
683 flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
684 if (rc!=MMSYSERR_NOERROR)
685 goto EXIT;
687 WaitForSingleObject(hevent,10000);
689 ok(pwfx->nChannels==nChannels &&
690 pwfx->wBitsPerSample==wBitsPerSample &&
691 pwfx->nSamplesPerSec==nSamplesPerSec,
692 "got the wrong format: %dx%2dx%d instead of %dx%2dx%d\n",
693 pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
694 pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels);
696 frags = HeapAlloc(GetProcessHeap(), 0, headers * sizeof(WAVEHDR));
698 if (sine)
699 buffer=wave_generate_la(pwfx,duration / (loops + 1),&length);
700 else
701 buffer=wave_generate_silence(pwfx,duration / (loops + 1),&length);
703 rc=waveOutGetVolume(wout,0);
704 ok(rc==MMSYSERR_INVALPARAM,"waveOutGetVolume(%s,0) expected "
705 "MMSYSERR_INVALPARAM, got %s\n", dev_name(device),wave_out_error(rc));
706 rc=waveOutGetVolume(wout,&volume);
707 if (rc == MMSYSERR_NOTSUPPORTED) has_volume = FALSE;
708 ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
709 "waveOutGetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
711 /* make sure fragment length is a multiple of block size */
712 frag_length = ((length / headers) / pwfx->nBlockAlign) * pwfx->nBlockAlign;
714 for (i = 0; i < headers; i++) {
715 frags[i].lpData=buffer + (i * frag_length);
716 if (i != (headers-1))
717 frags[i].dwBufferLength=frag_length;
718 else {
719 /* use remainder of buffer for last fragment */
720 frags[i].dwBufferLength=length - (i * frag_length);
722 frags[i].dwFlags=0;
723 frags[i].dwLoops=0;
724 rc=waveOutPrepareHeader(wout, &frags[i], sizeof(frags[0]));
725 ok(rc==MMSYSERR_NOERROR,
726 "waveOutPrepareHeader(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
729 if (interactive && rc==MMSYSERR_NOERROR) {
730 DWORD start;
731 trace("Playing %g second %s at %5dx%2dx%d %2d header%s %d loop%s %d bytes %s %s\n",duration,
732 sine ? "440Hz tone" : "silence",pwfx->nSamplesPerSec,
733 pwfx->wBitsPerSample,pwfx->nChannels, headers, headers > 1 ? "s": " ",
734 loops, loops == 1 ? " " : "s", length * (loops + 1),
735 get_format_str(pwfx->wFormatTag),
736 wave_open_flags(flags));
737 if (sine && has_volume && volume == 0)
738 trace("*** Warning the sound is muted, you will not hear the test\n");
740 /* Check that the position is 0 at start */
741 check_position(device, wout, 0, pwfx);
743 rc=waveOutSetVolume(wout,0x20002000);
744 ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
745 "waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
747 rc=waveOutSetVolume(wout,volume);
748 ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
749 "waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
751 start=GetTickCount();
753 rc=waveOutWrite(wout, &frags[0], sizeof(frags[0]));
754 ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s): rc=%s\n",
755 dev_name(device),wave_out_error(rc));
757 ok(frags[0].dwFlags==(WHDR_PREPARED|WHDR_INQUEUE),
758 "WHDR_INQUEUE WHDR_PREPARED expected, got= %s\n",
759 wave_header_flags(frags[0].dwFlags));
761 rc=waveOutWrite(wout, &frags[0], sizeof(frags[0]));
762 ok(rc==WAVERR_STILLPLAYING,
763 "waveOutWrite(%s): WAVE_STILLPLAYING expected, got %s\n",
764 dev_name(device),wave_out_error(rc));
766 ok(frags[0].dwFlags==(WHDR_PREPARED|WHDR_INQUEUE),
767 "WHDR_INQUEUE WHDR_PREPARED expected, got %s\n",
768 wave_header_flags(frags[0].dwFlags));
770 if (headers == 1 && loops == 0 && pause) {
771 paused = duration / 2;
772 Sleep(paused * 1000);
773 rc=waveOutPause(wout);
774 ok(rc==MMSYSERR_NOERROR,"waveOutPause(%s): rc=%s\n",
775 dev_name(device),wave_out_error(rc));
776 trace("pausing for %g seconds\n", paused);
777 Sleep(paused * 1000);
778 rc=waveOutRestart(wout);
779 ok(rc==MMSYSERR_NOERROR,"waveOutRestart(%s): rc=%s\n",
780 dev_name(device),wave_out_error(rc));
783 for (j = 0; j <= loops; j++) {
784 for (i = 0; i < headers; i++) {
785 /* don't do last one */
786 if (!((j == loops) && (i == (headers - 1)))) {
787 if (j > 0)
788 frags[(i+1) % headers].dwFlags = WHDR_PREPARED;
789 rc=waveOutWrite(wout, &frags[(i+1) % headers], sizeof(frags[0]));
790 ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s, header[%d]): rc=%s\n",
791 dev_name(device),(i+1)%headers,wave_out_error(rc));
793 WaitForSingleObject(hevent,10000);
797 for (i = 0; i < headers; i++) {
798 ok(frags[i].dwFlags==(WHDR_DONE|WHDR_PREPARED) ||
799 broken((flags & CALLBACK_TYPEMASK)==CALLBACK_EVENT &&
800 frags[i].dwFlags==(WHDR_DONE|WHDR_PREPARED|0x1000)), /* < NT4 */
801 "(%02d) WHDR_DONE WHDR_PREPARED expected, got %s\n",
802 i, wave_header_flags(frags[i].dwFlags));
804 check_position(device, wout, length * (loops + 1), pwfx);
807 for (i = 0; i < headers; i++) {
808 rc=waveOutUnprepareHeader(wout, &frags[i], sizeof(frags[0]));
809 ok(rc==MMSYSERR_NOERROR,
810 "waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device),
811 wave_out_error(rc));
813 HeapFree(GetProcessHeap(), 0, buffer);
815 rc=waveOutClose(wout);
816 ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
817 wave_out_error(rc));
818 WaitForSingleObject(hevent,10000);
819 EXIT:
820 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
821 PostThreadMessage(thread_id, WM_APP, 0, 0);
822 WaitForSingleObject(hevent,10000);
824 CloseHandle(hevent);
825 HeapFree(GetProcessHeap(), 0, frags);
828 static void wave_out_test_device(UINT_PTR device)
830 WAVEOUTCAPSA capsA;
831 WAVEOUTCAPSW capsW;
832 WAVEFORMATEX format, oformat;
833 WAVEFORMATEXTENSIBLE wfex;
834 IMAADPCMWAVEFORMAT wfa;
835 HWAVEOUT wout;
836 MMRESULT rc;
837 UINT f;
838 WCHAR * nameW;
839 CHAR * nameA;
840 DWORD size;
841 DWORD dwPageSize;
842 BYTE * twoPages;
843 SYSTEM_INFO sSysInfo;
844 DWORD flOldProtect;
845 BOOL res;
847 GetSystemInfo(&sSysInfo);
848 dwPageSize = sSysInfo.dwPageSize;
850 rc=waveOutGetDevCapsA(device,&capsA,sizeof(capsA));
851 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
852 rc==MMSYSERR_NODRIVER,
853 "waveOutGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
854 dev_name(device),wave_out_error(rc));
855 if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
856 return;
858 rc=waveOutGetDevCapsW(device,&capsW,sizeof(capsW));
859 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
860 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
861 "expected, got %s\n",dev_name(device),wave_out_error(rc));
863 rc=waveOutGetDevCapsA(device,0,sizeof(capsA));
864 ok(rc==MMSYSERR_INVALPARAM,
865 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, "
866 "got %s\n",dev_name(device),wave_out_error(rc));
868 rc=waveOutGetDevCapsW(device,0,sizeof(capsW));
869 ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
870 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
871 "expected, got %s\n",dev_name(device),wave_out_error(rc));
873 if (0)
875 /* FIXME: this works on windows but crashes wine */
876 rc=waveOutGetDevCapsA(device,(LPWAVEOUTCAPSA)1,sizeof(capsA));
877 ok(rc==MMSYSERR_INVALPARAM,
878 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
879 dev_name(device),wave_out_error(rc));
881 rc=waveOutGetDevCapsW(device,(LPWAVEOUTCAPSW)1,sizeof(capsW));
882 ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
883 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
884 "expected, got %s\n",dev_name(device),wave_out_error(rc));
887 rc=waveOutGetDevCapsA(device,&capsA,4);
888 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM,
889 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR or MMSYSERR_INVALPARAM "
890 "expected, got %s\n", dev_name(device),wave_out_error(rc));
892 rc=waveOutGetDevCapsW(device,&capsW,4);
893 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED ||
894 rc==MMSYSERR_INVALPARAM, /* Vista, W2K8 */
895 "waveOutGetDevCapsW(%s): unexpected return value %s\n",
896 dev_name(device),wave_out_error(rc));
898 nameA=NULL;
899 rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACESIZE,
900 (DWORD_PTR)&size, 0);
901 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM ||
902 rc==MMSYSERR_NOTSUPPORTED,
903 "waveOutMessage(%s): failed to get interface size, rc=%s\n",
904 dev_name(device),wave_out_error(rc));
905 if (rc==MMSYSERR_NOERROR) {
906 nameW = HeapAlloc(GetProcessHeap(), 0, size);
907 rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACE,
908 (DWORD_PTR)nameW, size);
909 ok(rc==MMSYSERR_NOERROR,"waveOutMessage(%s): failed to get interface "
910 "name, rc=%s\n",dev_name(device),wave_out_error(rc));
911 ok(lstrlenW(nameW)+1==size/sizeof(WCHAR),"got an incorrect size %d\n",size);
912 if (rc==MMSYSERR_NOERROR) {
913 nameA = HeapAlloc(GetProcessHeap(), 0, size/sizeof(WCHAR));
914 WideCharToMultiByte(CP_ACP, 0, nameW, size/sizeof(WCHAR), nameA,
915 size/sizeof(WCHAR), NULL, NULL);
917 HeapFree(GetProcessHeap(), 0, nameW);
919 else if (rc==MMSYSERR_NOTSUPPORTED) {
920 nameA=HeapAlloc(GetProcessHeap(), 0, sizeof("not supported"));
921 strcpy(nameA, "not supported");
924 rc=waveOutGetDevCapsA(device,&capsA,sizeof(capsA));
925 ok(rc==MMSYSERR_NOERROR,
926 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
927 dev_name(device),wave_out_error(rc));
928 if (rc!=MMSYSERR_NOERROR)
929 return;
931 trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device),capsA.szPname,
932 (nameA?nameA:"failed"),capsA.vDriverVersion >> 8,
933 capsA.vDriverVersion & 0xff, capsA.wMid,capsA.wPid);
934 trace(" channels=%d formats=%05x support=%04x\n",
935 capsA.wChannels,capsA.dwFormats,capsA.dwSupport);
936 trace(" %s\n",wave_out_caps(capsA.dwSupport));
937 HeapFree(GetProcessHeap(), 0, nameA);
939 if (winetest_interactive && (device != WAVE_MAPPER))
941 trace("Playing a 5 seconds reference tone.\n");
942 trace("All subsequent tones should be identical to this one.\n");
943 trace("Listen for stutter, changes in pitch, volume, etc.\n");
944 format.wFormatTag=WAVE_FORMAT_PCM;
945 format.nChannels=1;
946 format.wBitsPerSample=8;
947 format.nSamplesPerSec=22050;
948 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
949 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
950 format.cbSize=0;
952 wave_out_test_deviceOut(device,5.0,1,0,&format,WAVE_FORMAT_2M08,
953 CALLBACK_EVENT,&capsA,TRUE,TRUE,FALSE);
954 wave_out_test_deviceOut(device,5.0,1,0,&format,WAVE_FORMAT_2M08,
955 CALLBACK_FUNCTION,&capsA,TRUE,TRUE,FALSE);
956 wave_out_test_deviceOut(device,5.0,1,0,&format,WAVE_FORMAT_2M08,
957 CALLBACK_THREAD,&capsA,TRUE,TRUE,FALSE);
959 wave_out_test_deviceOut(device,5.0,10,0,&format,WAVE_FORMAT_2M08,
960 CALLBACK_EVENT,&capsA,TRUE,TRUE,FALSE);
961 wave_out_test_deviceOut(device,5.0,5,1,&format,WAVE_FORMAT_2M08,
962 CALLBACK_EVENT,&capsA,TRUE,TRUE,FALSE);
963 } else {
964 format.wFormatTag=WAVE_FORMAT_PCM;
965 format.nChannels=1;
966 format.wBitsPerSample=8;
967 format.nSamplesPerSec=22050;
968 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
969 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
970 format.cbSize=0;
971 wave_out_test_deviceOut(device,1.0,1,0,&format,WAVE_FORMAT_2M08,
972 CALLBACK_EVENT,&capsA,TRUE,FALSE,FALSE);
973 wave_out_test_deviceOut(device,1.0,1,0,&format,WAVE_FORMAT_2M08,
974 CALLBACK_EVENT,&capsA,TRUE,FALSE,TRUE);
975 wave_out_test_deviceOut(device,1.0,1,0,&format,WAVE_FORMAT_2M08,
976 CALLBACK_FUNCTION,&capsA,TRUE,FALSE,FALSE);
977 wave_out_test_deviceOut(device,1.0,1,0,&format,WAVE_FORMAT_2M08,
978 CALLBACK_FUNCTION,&capsA,TRUE,FALSE,TRUE);
979 wave_out_test_deviceOut(device,1.0,1,0,&format,WAVE_FORMAT_2M08,
980 CALLBACK_THREAD,&capsA,TRUE,FALSE,FALSE);
981 wave_out_test_deviceOut(device,1.0,1,0,&format,WAVE_FORMAT_2M08,
982 CALLBACK_THREAD,&capsA,TRUE,FALSE,TRUE);
984 wave_out_test_deviceOut(device,1.0,10,0,&format,WAVE_FORMAT_2M08,
985 CALLBACK_EVENT,&capsA,TRUE,FALSE,FALSE);
986 wave_out_test_deviceOut(device,1.0,5,1,&format,WAVE_FORMAT_2M08,
987 CALLBACK_EVENT,&capsA,TRUE,FALSE,FALSE);
990 for (f=0;f<NB_WIN_FORMATS;f++) {
991 format.wFormatTag=WAVE_FORMAT_PCM;
992 format.nChannels=win_formats[f][3];
993 format.wBitsPerSample=win_formats[f][2];
994 format.nSamplesPerSec=win_formats[f][1];
995 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
996 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
997 format.cbSize=0;
998 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
999 CALLBACK_EVENT,&capsA,winetest_interactive,
1000 TRUE,FALSE);
1001 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1002 CALLBACK_FUNCTION,&capsA,winetest_interactive,
1003 TRUE,FALSE);
1004 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1005 CALLBACK_THREAD,&capsA,winetest_interactive,
1006 TRUE,FALSE);
1008 wave_out_test_deviceOut(device,1.0,10,0,&format,win_formats[f][0],
1009 CALLBACK_EVENT,&capsA,winetest_interactive,
1010 TRUE,FALSE);
1011 wave_out_test_deviceOut(device,1.0,5,1,&format,win_formats[f][0],
1012 CALLBACK_EVENT,&capsA,winetest_interactive,
1013 TRUE,FALSE);
1015 if (winetest_interactive) {
1016 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1017 CALLBACK_EVENT,&capsA,winetest_interactive,
1018 TRUE,TRUE);
1019 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1020 CALLBACK_FUNCTION,&capsA,winetest_interactive,
1021 TRUE,TRUE);
1022 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1023 CALLBACK_THREAD,&capsA,winetest_interactive,
1024 TRUE,TRUE);
1026 wave_out_test_deviceOut(device,1.0,10,0,&format,win_formats[f][0],
1027 CALLBACK_EVENT,&capsA,winetest_interactive,
1028 TRUE,TRUE);
1029 wave_out_test_deviceOut(device,1.0,5,1,&format,win_formats[f][0],
1030 CALLBACK_EVENT,&capsA,winetest_interactive,
1031 TRUE,TRUE);
1033 if (device != WAVE_MAPPER)
1035 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1036 CALLBACK_EVENT|WAVE_FORMAT_DIRECT,&capsA,
1037 winetest_interactive,TRUE,FALSE);
1038 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1039 CALLBACK_EVENT|WAVE_MAPPED,&capsA,
1040 winetest_interactive,TRUE,FALSE);
1041 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1042 CALLBACK_FUNCTION|WAVE_FORMAT_DIRECT,&capsA,
1043 winetest_interactive,TRUE,FALSE);
1044 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1045 CALLBACK_FUNCTION|WAVE_MAPPED,&capsA,
1046 winetest_interactive,TRUE,FALSE);
1047 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1048 CALLBACK_THREAD|WAVE_FORMAT_DIRECT,&capsA,
1049 winetest_interactive,TRUE,FALSE);
1050 wave_out_test_deviceOut(device,1.0,1,0,&format,win_formats[f][0],
1051 CALLBACK_THREAD|WAVE_MAPPED,&capsA,
1052 winetest_interactive,TRUE,FALSE);
1054 wave_out_test_deviceOut(device,1.0,10,0,&format,win_formats[f][0],
1055 CALLBACK_EVENT|WAVE_FORMAT_DIRECT,&capsA,
1056 winetest_interactive,TRUE,FALSE);
1057 wave_out_test_deviceOut(device,1.0,5,1,&format,win_formats[f][0],
1058 CALLBACK_EVENT|WAVE_FORMAT_DIRECT,&capsA,
1059 winetest_interactive,TRUE,FALSE);
1063 /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
1064 * checking */
1065 twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT,
1066 PAGE_READWRITE);
1067 ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
1068 if (twoPages) {
1069 res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS,
1070 &flOldProtect);
1071 ok(res, "Failed to set memory access on second page\n");
1072 if (res) {
1073 LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize -
1074 sizeof(PCMWAVEFORMAT));
1075 pwfx->wFormatTag=WAVE_FORMAT_PCM;
1076 pwfx->nChannels=1;
1077 pwfx->wBitsPerSample=8;
1078 pwfx->nSamplesPerSec=22050;
1079 pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
1080 pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
1081 wave_out_test_deviceOut(device,1.0,1,0,pwfx,WAVE_FORMAT_2M08,
1082 CALLBACK_EVENT,&capsA,winetest_interactive,
1083 TRUE,FALSE);
1084 wave_out_test_deviceOut(device,1.0,10,0,pwfx,WAVE_FORMAT_2M08,
1085 CALLBACK_EVENT,&capsA,winetest_interactive,
1086 TRUE,FALSE);
1087 wave_out_test_deviceOut(device,1.0,5,1,pwfx,WAVE_FORMAT_2M08,
1088 CALLBACK_EVENT,&capsA,winetest_interactive,
1089 TRUE,FALSE);
1090 if (device != WAVE_MAPPER)
1092 wave_out_test_deviceOut(device,1.0,1,0,pwfx,WAVE_FORMAT_2M08,
1093 CALLBACK_EVENT|WAVE_FORMAT_DIRECT,
1094 &capsA,winetest_interactive,TRUE,FALSE);
1095 wave_out_test_deviceOut(device,1.0,1,0,pwfx,WAVE_FORMAT_2M08,
1096 CALLBACK_EVENT|WAVE_MAPPED,&capsA,
1097 winetest_interactive,TRUE,FALSE);
1098 wave_out_test_deviceOut(device,1.0,10,0,pwfx,WAVE_FORMAT_2M08,
1099 CALLBACK_EVENT|WAVE_FORMAT_DIRECT,
1100 &capsA,winetest_interactive,TRUE,FALSE);
1101 wave_out_test_deviceOut(device,1.0,10,0,pwfx,WAVE_FORMAT_2M08,
1102 CALLBACK_EVENT|WAVE_MAPPED,&capsA,
1103 winetest_interactive,TRUE,FALSE);
1104 wave_out_test_deviceOut(device,1.0,5,1,pwfx,WAVE_FORMAT_2M08,
1105 CALLBACK_EVENT|WAVE_FORMAT_DIRECT,
1106 &capsA,winetest_interactive,TRUE,FALSE);
1107 wave_out_test_deviceOut(device,1.0,5,1,pwfx,WAVE_FORMAT_2M08,
1108 CALLBACK_EVENT|WAVE_MAPPED,&capsA,
1109 winetest_interactive,TRUE,FALSE);
1112 VirtualFree(twoPages, 0, MEM_RELEASE);
1115 /* Testing invalid format: 11 bits per sample */
1116 format.wFormatTag=WAVE_FORMAT_PCM;
1117 format.nChannels=2;
1118 format.wBitsPerSample=11;
1119 format.nSamplesPerSec=22050;
1120 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
1121 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
1122 format.cbSize=0;
1123 oformat=format;
1124 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1125 ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG ||
1126 rc==MMSYSERR_INVALPARAM,
1127 "waveOutOpen(%s): opening the device in 11 bits mode should fail: "
1128 "rc=%s\n",dev_name(device),wave_out_error(rc));
1129 if (rc==MMSYSERR_NOERROR) {
1130 trace(" got %dx%2dx%d for %dx%2dx%d\n",
1131 format.nSamplesPerSec, format.wBitsPerSample,
1132 format.nChannels,
1133 oformat.nSamplesPerSec, oformat.wBitsPerSample,
1134 oformat.nChannels);
1135 waveOutClose(wout);
1138 /* Testing invalid format: 2 MHz sample rate */
1139 format.wFormatTag=WAVE_FORMAT_PCM;
1140 format.nChannels=2;
1141 format.wBitsPerSample=16;
1142 format.nSamplesPerSec=2000000;
1143 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
1144 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
1145 format.cbSize=0;
1146 oformat=format;
1147 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1148 ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG ||
1149 rc==MMSYSERR_INVALPARAM,
1150 "waveOutOpen(%s): opening the device at 2 MHz sample rate should fail: "
1151 "rc=%s\n",dev_name(device),wave_out_error(rc));
1152 if (rc==MMSYSERR_NOERROR) {
1153 trace(" got %dx%2dx%d for %dx%2dx%d\n",
1154 format.nSamplesPerSec, format.wBitsPerSample,
1155 format.nChannels,
1156 oformat.nSamplesPerSec, oformat.wBitsPerSample,
1157 oformat.nChannels);
1158 waveOutClose(wout);
1161 /* try some non PCM formats */
1162 format.wFormatTag=WAVE_FORMAT_MULAW;
1163 format.nChannels=1;
1164 format.wBitsPerSample=8;
1165 format.nSamplesPerSec=8000;
1166 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
1167 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
1168 format.cbSize=0;
1169 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1170 ok(rc==MMSYSERR_NOERROR ||rc==WAVERR_BADFORMAT ||
1171 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1172 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1173 if (rc==MMSYSERR_NOERROR) {
1174 waveOutClose(wout);
1175 wave_out_test_deviceOut(device,1.0,1,0,&format,0,CALLBACK_EVENT,
1176 &capsA,winetest_interactive,TRUE,FALSE);
1177 wave_out_test_deviceOut(device,1.0,10,0,&format,0,CALLBACK_EVENT,
1178 &capsA,winetest_interactive,TRUE,FALSE);
1179 wave_out_test_deviceOut(device,1.0,5,1,&format,0,CALLBACK_EVENT,
1180 &capsA,winetest_interactive,TRUE,FALSE);
1181 } else
1182 trace("waveOutOpen(%s): WAVE_FORMAT_MULAW not supported\n",
1183 dev_name(device));
1185 wfa.wfx.wFormatTag=WAVE_FORMAT_IMA_ADPCM;
1186 wfa.wfx.nChannels=1;
1187 wfa.wfx.nSamplesPerSec=11025;
1188 wfa.wfx.nAvgBytesPerSec=5588;
1189 wfa.wfx.nBlockAlign=256;
1190 wfa.wfx.wBitsPerSample=4; /* see imaadp32.c */
1191 wfa.wfx.cbSize=2;
1192 wfa.wSamplesPerBlock=505;
1193 rc=waveOutOpen(&wout,device,&wfa.wfx,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1194 ok(rc==MMSYSERR_NOERROR ||rc==WAVERR_BADFORMAT ||
1195 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1196 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1197 if (rc==MMSYSERR_NOERROR) {
1198 waveOutClose(wout);
1199 /* TODO: teach wave_generate_* ADPCM
1200 wave_out_test_deviceOut(device,1.0,1,0,&wfa.wfx,0,CALLBACK_EVENT,
1201 &capsA,winetest_interactive,TRUE,FALSE);
1202 wave_out_test_deviceOut(device,1.0,10,0,&wfa.wfx,0,CALLBACK_EVENT,
1203 &capsA,winetest_interactive,TRUE,FALSE);
1204 wave_out_test_deviceOut(device,1.0,5,1,&wfa.wfx,0,CALLBACK_EVENT,
1205 &capsA,winetest_interactive,TRUE,FALSE);
1207 } else
1208 trace("waveOutOpen(%s): WAVE_FORMAT_IMA_ADPCM not supported\n",
1209 dev_name(device));
1211 /* test if WAVEFORMATEXTENSIBLE supported */
1212 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1213 wfex.Format.nChannels=2;
1214 wfex.Format.wBitsPerSample=16;
1215 wfex.Format.nSamplesPerSec=22050;
1216 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1217 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1218 wfex.Format.nBlockAlign;
1219 wfex.Format.cbSize=22;
1220 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1221 wfex.dwChannelMask=SPEAKER_ALL;
1222 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
1223 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1224 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1225 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1226 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1227 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1228 if (rc==MMSYSERR_NOERROR) {
1229 waveOutClose(wout);
1230 wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
1231 CALLBACK_EVENT,&capsA,winetest_interactive,
1232 TRUE,FALSE);
1233 wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
1234 CALLBACK_EVENT,&capsA,winetest_interactive,
1235 TRUE,FALSE);
1236 wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
1237 CALLBACK_EVENT,&capsA,winetest_interactive,
1238 TRUE,FALSE);
1239 } else
1240 trace("waveOutOpen(%s): WAVE_FORMAT_EXTENSIBLE not supported\n",
1241 dev_name(device));
1243 /* test if 4 channels supported */
1244 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1245 wfex.Format.nChannels=4;
1246 wfex.Format.wBitsPerSample=16;
1247 wfex.Format.nSamplesPerSec=22050;
1248 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1249 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1250 wfex.Format.nBlockAlign;
1251 wfex.Format.cbSize=22;
1252 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1253 wfex.dwChannelMask=SPEAKER_ALL;
1254 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
1255 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1256 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1257 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1258 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1259 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1260 if (rc==MMSYSERR_NOERROR) {
1261 waveOutClose(wout);
1262 wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,0,CALLBACK_EVENT,
1263 &capsA,winetest_interactive,TRUE,FALSE);
1264 wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,0,CALLBACK_EVENT,
1265 &capsA,winetest_interactive,TRUE,FALSE);
1266 wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,0,CALLBACK_EVENT,
1267 &capsA,winetest_interactive,TRUE,FALSE);
1268 } else
1269 trace("waveOutOpen(%s): 4 channels not supported\n",
1270 dev_name(device));
1272 /* test if 6 channels supported */
1273 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1274 wfex.Format.nChannels=6;
1275 wfex.Format.wBitsPerSample=16;
1276 wfex.Format.nSamplesPerSec=22050;
1277 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1278 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1279 wfex.Format.nBlockAlign;
1280 wfex.Format.cbSize=22;
1281 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1282 wfex.dwChannelMask=SPEAKER_ALL;
1283 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
1284 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1285 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1286 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1287 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1288 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1289 if (rc==MMSYSERR_NOERROR) {
1290 waveOutClose(wout);
1291 wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
1292 CALLBACK_EVENT,&capsA,winetest_interactive,
1293 TRUE,FALSE);
1294 wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
1295 CALLBACK_EVENT,&capsA,winetest_interactive,
1296 TRUE,FALSE);
1297 wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
1298 CALLBACK_EVENT,&capsA,winetest_interactive,
1299 TRUE,FALSE);
1300 } else
1301 trace("waveOutOpen(%s): 6 channels not supported\n",
1302 dev_name(device));
1304 if (0)
1306 /* FIXME: ALSA doesn't like this format */
1307 /* test if 24 bit samples supported */
1308 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1309 wfex.Format.nChannels=2;
1310 wfex.Format.wBitsPerSample=24;
1311 wfex.Format.nSamplesPerSec=22050;
1312 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1313 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1314 wfex.Format.nBlockAlign;
1315 wfex.Format.cbSize=22;
1316 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1317 wfex.dwChannelMask=SPEAKER_ALL;
1318 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
1319 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1320 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1321 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1322 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1323 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1324 if (rc==MMSYSERR_NOERROR) {
1325 waveOutClose(wout);
1326 wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
1327 CALLBACK_EVENT,&capsA,winetest_interactive,
1328 TRUE,FALSE);
1329 } else
1330 trace("waveOutOpen(%s): 24 bit samples not supported\n",
1331 dev_name(device));
1334 /* test if 32 bit samples supported */
1335 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1336 wfex.Format.nChannels=2;
1337 wfex.Format.wBitsPerSample=32;
1338 wfex.Format.nSamplesPerSec=22050;
1339 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1340 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1341 wfex.Format.nBlockAlign;
1342 wfex.Format.cbSize=22;
1343 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1344 wfex.dwChannelMask=SPEAKER_ALL;
1345 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
1346 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1347 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1348 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1349 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1350 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1351 if (rc==MMSYSERR_NOERROR) {
1352 waveOutClose(wout);
1353 wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
1354 CALLBACK_EVENT,&capsA,winetest_interactive,
1355 TRUE,FALSE);
1356 wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
1357 CALLBACK_EVENT,&capsA,winetest_interactive,
1358 TRUE,FALSE);
1359 wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
1360 CALLBACK_EVENT,&capsA,winetest_interactive,
1361 TRUE,FALSE);
1362 } else
1363 trace("waveOutOpen(%s): 32 bit samples not supported\n",
1364 dev_name(device));
1366 /* test if 32 bit float samples supported */
1367 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1368 wfex.Format.nChannels=2;
1369 wfex.Format.wBitsPerSample=32;
1370 wfex.Format.nSamplesPerSec=22050;
1371 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1372 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1373 wfex.Format.nBlockAlign;
1374 wfex.Format.cbSize=22;
1375 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1376 wfex.dwChannelMask=SPEAKER_ALL;
1377 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
1378 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1379 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1380 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1381 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1382 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1383 if (rc==MMSYSERR_NOERROR) {
1384 waveOutClose(wout);
1385 wave_out_test_deviceOut(device,1.0,1,0,&wfex.Format,WAVE_FORMAT_2M16,
1386 CALLBACK_EVENT,&capsA,winetest_interactive,
1387 TRUE,FALSE);
1388 wave_out_test_deviceOut(device,1.0,10,0,&wfex.Format,WAVE_FORMAT_2M16,
1389 CALLBACK_EVENT,&capsA,winetest_interactive,
1390 TRUE,FALSE);
1391 wave_out_test_deviceOut(device,1.0,5,1,&wfex.Format,WAVE_FORMAT_2M16,
1392 CALLBACK_EVENT,&capsA,winetest_interactive,
1393 TRUE,FALSE);
1394 } else
1395 trace("waveOutOpen(%s): 32 bit float samples not supported\n",
1396 dev_name(device));
1399 static void wave_out_tests(void)
1401 WAVEOUTCAPSA capsA;
1402 WAVEOUTCAPSW capsW;
1403 WAVEFORMATEX format;
1404 HWAVEOUT wout;
1405 MMRESULT rc;
1406 UINT ndev,d;
1408 ndev=waveOutGetNumDevs();
1409 trace("found %d WaveOut devices\n",ndev);
1411 rc=waveOutGetDevCapsA(ndev+1,&capsA,sizeof(capsA));
1412 ok(rc==MMSYSERR_BADDEVICEID,
1413 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1414 dev_name(ndev+1),mmsys_error(rc));
1416 rc=waveOutGetDevCapsW(ndev+1,&capsW,sizeof(capsW));
1417 ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTSUPPORTED,
1418 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
1419 "expected, got %s\n",dev_name(ndev+1),mmsys_error(rc));
1421 rc=waveOutGetDevCapsA(WAVE_MAPPER,&capsA,sizeof(capsA));
1422 if (ndev>0)
1423 ok(rc==MMSYSERR_NOERROR,
1424 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
1425 dev_name(WAVE_MAPPER),mmsys_error(rc));
1426 else
1427 ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
1428 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1429 "expected, got %s\n",dev_name(WAVE_MAPPER),mmsys_error(rc));
1431 rc=waveOutGetDevCapsW(WAVE_MAPPER,&capsW,sizeof(capsW));
1432 if (ndev>0)
1433 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
1434 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
1435 "expected, got %s\n",dev_name(WAVE_MAPPER),mmsys_error(rc));
1436 else
1437 ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER ||
1438 rc==MMSYSERR_NOTSUPPORTED,
1439 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1440 " or MMSYSERR_NOTSUPPORTED expected, got %s\n",
1441 dev_name(WAVE_MAPPER),mmsys_error(rc));
1443 format.wFormatTag=WAVE_FORMAT_PCM;
1444 format.nChannels=2;
1445 format.wBitsPerSample=16;
1446 format.nSamplesPerSec=44100;
1447 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
1448 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
1449 format.cbSize=0;
1450 rc=waveOutOpen(&wout,ndev+1,&format,0,0,CALLBACK_NULL);
1451 ok(rc==MMSYSERR_BADDEVICEID,
1452 "waveOutOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1453 dev_name(ndev+1),mmsys_error(rc));
1455 for (d=0;d<ndev;d++)
1456 wave_out_test_device(d);
1458 if (ndev>0)
1459 wave_out_test_device(WAVE_MAPPER);
1462 START_TEST(wave)
1464 test_multiple_waveopens();
1465 wave_out_tests();