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
26 #include "wine/test.h"
38 #include "winmm_test.h"
40 static void test_multiple_waveopens(void)
42 HWAVEOUT handle1
, handle2
;
46 wfx
.wFormatTag
= WAVE_FORMAT_PCM
;
48 wfx
.nSamplesPerSec
= 11025;
50 wfx
.nAvgBytesPerSec
= wfx
.nSamplesPerSec
* wfx
.nBlockAlign
;
51 wfx
.wBitsPerSample
= 8;
54 ret
= waveOutOpen(&handle1
, 0, &wfx
, 0, 0, 0);
55 if (ret
!= MMSYSERR_NOERROR
)
57 skip("Could not do the duplicate waveopen test\n");
61 ret
= waveOutOpen(&handle2
, 0, &wfx
, 0, 0, 0);
62 /* In windows this is most likely allowed, in wine an application can use the waveout
63 * interface, but so can directsound.. this causes problems if directsound goes active
65 todo_wine
ok(ret
== MMSYSERR_NOERROR
|| broken(ret
== MMSYSERR_ALLOCATED
), /* winME */
66 "waveOutOpen returns: %x\n", ret
);
67 if (ret
== MMSYSERR_NOERROR
)
68 waveOutClose(handle2
);
70 waveOutClose(handle1
);
74 * Note that in most of this test we may get MMSYSERR_BADDEVICEID errors
75 * at about any time if the user starts another application that uses the
76 * sound device. So we should not report these as test failures.
78 * This test can play a test tone. But this only makes sense if someone
79 * is going to carefully listen to it, and would only bother everyone else.
80 * So this is only done if the test is being run in interactive mode.
83 #define PI 3.14159265358979323846
84 static char* wave_generate_la(WAVEFORMATEX
* wfx
, double duration
, DWORD
* size
)
90 WAVEFORMATEXTENSIBLE
*wfex
= (WAVEFORMATEXTENSIBLE
*)wfx
;
92 nb_samples
=(int)(duration
*wfx
->nSamplesPerSec
);
93 *size
=nb_samples
*wfx
->nBlockAlign
;
94 b
=buf
=HeapAlloc(GetProcessHeap(), 0, *size
);
95 for (i
=0;i
<nb_samples
;i
++) {
96 double y
=sin(440.0*2*PI
*i
/wfx
->nSamplesPerSec
);
97 if (wfx
->wBitsPerSample
==8) {
98 unsigned char sample
=(unsigned char)((double)127.5*(y
+1.0));
99 for (j
= 0; j
< wfx
->nChannels
; j
++)
101 } else if (wfx
->wBitsPerSample
==16) {
102 signed short sample
=(signed short)((double)32767.5*y
-0.5);
103 for (j
= 0; j
< wfx
->nChannels
; j
++) {
108 } else if (wfx
->wBitsPerSample
==24) {
109 signed int sample
=(signed int)(((double)0x7fffff+0.5)*y
-0.5);
110 for (j
= 0; j
< wfx
->nChannels
; j
++) {
112 b
[1]=(sample
>> 8) & 0xff;
113 b
[2]=(sample
>> 16) & 0xff;
116 } else if ((wfx
->wBitsPerSample
==32) && ((wfx
->wFormatTag
== WAVE_FORMAT_PCM
) ||
117 ((wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
118 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
)))) {
119 signed int sample
=(signed int)(((double)0x7fffffff+0.5)*y
-0.5);
120 for (j
= 0; j
< wfx
->nChannels
; j
++) {
122 b
[1]=(sample
>> 8) & 0xff;
123 b
[2]=(sample
>> 16) & 0xff;
124 b
[3]=(sample
>> 24) & 0xff;
127 } else if ((wfx
->wBitsPerSample
==32) && (wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
128 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)) {
129 union { float f
; char c
[4]; } sample
;
131 for (j
= 0; j
< wfx
->nChannels
; j
++) {
143 static char* wave_generate_silence(WAVEFORMATEX
* wfx
, double duration
, DWORD
* size
)
149 WAVEFORMATEXTENSIBLE
*wfex
= (WAVEFORMATEXTENSIBLE
*)wfx
;
151 nb_samples
=(int)(duration
*wfx
->nSamplesPerSec
);
152 *size
=nb_samples
*wfx
->nBlockAlign
;
153 b
=buf
=HeapAlloc(GetProcessHeap(), 0, *size
);
154 for (i
=0;i
<nb_samples
;i
++) {
155 if (wfx
->wBitsPerSample
==8) {
156 for (j
= 0; j
< wfx
->nChannels
; j
++)
158 } else if (wfx
->wBitsPerSample
==16) {
159 for (j
= 0; j
< wfx
->nChannels
; j
++) {
164 } else if (wfx
->wBitsPerSample
==24) {
165 for (j
= 0; j
< wfx
->nChannels
; j
++) {
171 } else if ((wfx
->wBitsPerSample
==32) && ((wfx
->wFormatTag
== WAVE_FORMAT_PCM
) ||
172 ((wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
173 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
)))) {
174 for (j
= 0; j
< wfx
->nChannels
; j
++) {
181 } else if ((wfx
->wBitsPerSample
==32) && (wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
182 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)) {
183 union { float f
; char c
[4]; } sample
;
185 for (j
= 0; j
< wfx
->nChannels
; j
++) {
197 const char * dev_name(int device
)
199 static char name
[16];
200 if (device
== WAVE_MAPPER
)
201 return "WAVE_MAPPER";
202 sprintf(name
, "%d", device
);
206 const char* mmsys_error(MMRESULT error
)
208 #define ERR_TO_STR(dev) case dev: return #dev
209 static char unknown
[32];
211 ERR_TO_STR(MMSYSERR_NOERROR
);
212 ERR_TO_STR(MMSYSERR_ERROR
);
213 ERR_TO_STR(MMSYSERR_BADDEVICEID
);
214 ERR_TO_STR(MMSYSERR_NOTENABLED
);
215 ERR_TO_STR(MMSYSERR_ALLOCATED
);
216 ERR_TO_STR(MMSYSERR_INVALHANDLE
);
217 ERR_TO_STR(MMSYSERR_NODRIVER
);
218 ERR_TO_STR(MMSYSERR_NOMEM
);
219 ERR_TO_STR(MMSYSERR_NOTSUPPORTED
);
220 ERR_TO_STR(MMSYSERR_BADERRNUM
);
221 ERR_TO_STR(MMSYSERR_INVALFLAG
);
222 ERR_TO_STR(MMSYSERR_INVALPARAM
);
223 ERR_TO_STR(WAVERR_BADFORMAT
);
224 ERR_TO_STR(WAVERR_STILLPLAYING
);
225 ERR_TO_STR(WAVERR_UNPREPARED
);
226 ERR_TO_STR(WAVERR_SYNC
);
227 ERR_TO_STR(MIDIERR_UNPREPARED
);
228 ERR_TO_STR(MIDIERR_STILLPLAYING
);
229 ERR_TO_STR(MIDIERR_NOTREADY
);
230 ERR_TO_STR(MIDIERR_NODEVICE
);
231 ERR_TO_STR(MIDIERR_INVALIDSETUP
);
232 ERR_TO_STR(TIMERR_NOCANDO
);
233 ERR_TO_STR(TIMERR_STRUCT
);
234 ERR_TO_STR(JOYERR_PARMS
);
235 ERR_TO_STR(JOYERR_NOCANDO
);
236 ERR_TO_STR(JOYERR_UNPLUGGED
);
237 ERR_TO_STR(MIXERR_INVALLINE
);
238 ERR_TO_STR(MIXERR_INVALCONTROL
);
239 ERR_TO_STR(MIXERR_INVALVALUE
);
240 ERR_TO_STR(MMIOERR_FILENOTFOUND
);
241 ERR_TO_STR(MMIOERR_OUTOFMEMORY
);
242 ERR_TO_STR(MMIOERR_CANNOTOPEN
);
243 ERR_TO_STR(MMIOERR_CANNOTCLOSE
);
244 ERR_TO_STR(MMIOERR_CANNOTREAD
);
245 ERR_TO_STR(MMIOERR_CANNOTWRITE
);
246 ERR_TO_STR(MMIOERR_CANNOTSEEK
);
247 ERR_TO_STR(MMIOERR_CANNOTEXPAND
);
248 ERR_TO_STR(MMIOERR_CHUNKNOTFOUND
);
249 ERR_TO_STR(MMIOERR_UNBUFFERED
);
251 sprintf(unknown
, "Unknown(0x%08x)", error
);
256 const char* wave_out_error(MMRESULT error
)
258 static char msg
[1024];
259 static char long_msg
[1100];
262 rc
= waveOutGetErrorText(error
, msg
, sizeof(msg
));
263 if (rc
!= MMSYSERR_NOERROR
)
264 sprintf(long_msg
, "waveOutGetErrorText(%x) failed with error %x",
267 sprintf(long_msg
, "%s(%s)", mmsys_error(error
), msg
);
271 const char * wave_open_flags(DWORD flags
)
273 static char msg
[1024];
276 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_EVENT
) {
277 strcat(msg
, "CALLBACK_EVENT");
280 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
) {
281 if (!first
) strcat(msg
, "|");
282 strcat(msg
, "CALLBACK_FUNCTION");
285 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_NULL
) {
286 if (!first
) strcat(msg
, "|");
287 strcat(msg
, "CALLBACK_NULL");
290 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
291 if (!first
) strcat(msg
, "|");
292 strcat(msg
, "CALLBACK_THREAD");
295 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_WINDOW
) {
296 if (!first
) strcat(msg
, "|");
297 strcat(msg
, "CALLBACK_WINDOW");
300 if ((flags
& WAVE_ALLOWSYNC
) == WAVE_ALLOWSYNC
) {
301 if (!first
) strcat(msg
, "|");
302 strcat(msg
, "WAVE_ALLOWSYNC");
305 if ((flags
& WAVE_FORMAT_DIRECT
) == WAVE_FORMAT_DIRECT
) {
306 if (!first
) strcat(msg
, "|");
307 strcat(msg
, "WAVE_FORMAT_DIRECT");
310 if ((flags
& WAVE_FORMAT_QUERY
) == WAVE_FORMAT_QUERY
) {
311 if (!first
) strcat(msg
, "|");
312 strcat(msg
, "WAVE_FORMAT_QUERY");
315 if ((flags
& WAVE_MAPPED
) == WAVE_MAPPED
) {
316 if (!first
) strcat(msg
, "|");
317 strcat(msg
, "WAVE_MAPPED");
323 static const char * wave_header_flags(DWORD flags
)
325 #define WHDR_MASK (WHDR_BEGINLOOP|WHDR_DONE|WHDR_ENDLOOP|WHDR_INQUEUE|WHDR_PREPARED)
326 static char msg
[1024];
329 if (flags
& WHDR_BEGINLOOP
) {
330 strcat(msg
, "WHDR_BEGINLOOP");
333 if (flags
& WHDR_DONE
) {
334 if (!first
) strcat(msg
, " ");
335 strcat(msg
, "WHDR_DONE");
338 if (flags
& WHDR_ENDLOOP
) {
339 if (!first
) strcat(msg
, " ");
340 strcat(msg
, "WHDR_ENDLOOP");
343 if (flags
& WHDR_INQUEUE
) {
344 if (!first
) strcat(msg
, " ");
345 strcat(msg
, "WHDR_INQUEUE");
348 if (flags
& WHDR_PREPARED
) {
349 if (!first
) strcat(msg
, " ");
350 strcat(msg
, "WHDR_PREPARED");
353 if (flags
& ~WHDR_MASK
) {
355 sprintf(temp
, "UNKNOWN(0x%08x)", flags
& ~WHDR_MASK
);
356 if (!first
) strcat(msg
, " ");
362 static const char * wave_out_caps(DWORD dwSupport
)
364 #define ADD_FLAG(f) if (dwSupport & f) strcat(msg, " " #f)
365 static char msg
[256];
368 ADD_FLAG(WAVECAPS_PITCH
);
369 ADD_FLAG(WAVECAPS_PLAYBACKRATE
);
370 ADD_FLAG(WAVECAPS_VOLUME
);
371 ADD_FLAG(WAVECAPS_LRVOLUME
);
372 ADD_FLAG(WAVECAPS_SYNC
);
373 ADD_FLAG(WAVECAPS_SAMPLEACCURATE
);
375 return msg
[0] ? msg
+ 1 : "";
379 const char * wave_time_format(UINT type
)
382 #define TIME_FORMAT(f) case f: return #f
384 TIME_FORMAT(TIME_MS
);
385 TIME_FORMAT(TIME_SAMPLES
);
386 TIME_FORMAT(TIME_BYTES
);
387 TIME_FORMAT(TIME_SMPTE
);
388 TIME_FORMAT(TIME_MIDI
);
389 TIME_FORMAT(TIME_TICKS
);
392 sprintf(msg
, "Unknown(0x%04x)", type
);
396 const char * get_format_str(WORD format
)
399 #define WAVE_FORMAT(f) case f: return #f
401 WAVE_FORMAT(WAVE_FORMAT_PCM
);
402 WAVE_FORMAT(WAVE_FORMAT_ADPCM
);
403 WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD
);
404 WAVE_FORMAT(WAVE_FORMAT_ALAW
);
405 WAVE_FORMAT(WAVE_FORMAT_MULAW
);
406 WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM
);
407 WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM
);
408 WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM
);
409 WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM
);
410 WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM
);
411 WAVE_FORMAT(WAVE_FORMAT_DIGISTD
);
412 WAVE_FORMAT(WAVE_FORMAT_DIGIFIX
);
413 WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM
);
414 WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM
);
415 WAVE_FORMAT(WAVE_FORMAT_SONARC
);
416 WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH
);
417 WAVE_FORMAT(WAVE_FORMAT_ECHOSC1
);
418 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36
);
419 WAVE_FORMAT(WAVE_FORMAT_APTX
);
420 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10
);
421 WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2
);
422 WAVE_FORMAT(WAVE_FORMAT_GSM610
);
423 WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME
);
424 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC
);
425 WAVE_FORMAT(WAVE_FORMAT_DIGIREAL
);
426 WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM
);
427 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10
);
428 WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM
);
429 WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM
);
430 WAVE_FORMAT(WAVE_FORMAT_MPEG
);
431 WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3
);
432 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM
);
433 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8
);
434 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10
);
435 WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND
);
436 WAVE_FORMAT(WAVE_FORMAT_OLIGSM
);
437 WAVE_FORMAT(WAVE_FORMAT_OLIADPCM
);
438 WAVE_FORMAT(WAVE_FORMAT_OLICELP
);
439 WAVE_FORMAT(WAVE_FORMAT_OLISBC
);
440 WAVE_FORMAT(WAVE_FORMAT_OLIOPR
);
441 WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT
);
442 WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE
);
445 sprintf(msg
, "Unknown(0x%04x)", format
);
449 DWORD
bytes_to_samples(DWORD bytes
, LPWAVEFORMATEX pwfx
)
451 return bytes
/ pwfx
->nBlockAlign
;
454 DWORD
bytes_to_ms(DWORD bytes
, LPWAVEFORMATEX pwfx
)
456 return bytes_to_samples(bytes
, pwfx
) * 1000 / pwfx
->nSamplesPerSec
;
459 DWORD
time_to_bytes(LPMMTIME mmtime
, LPWAVEFORMATEX pwfx
)
461 if (mmtime
->wType
== TIME_BYTES
)
463 else if (mmtime
->wType
== TIME_SAMPLES
)
464 return mmtime
->u
.sample
* pwfx
->nBlockAlign
;
465 else if (mmtime
->wType
== TIME_MS
)
466 return mmtime
->u
.ms
* pwfx
->nAvgBytesPerSec
/ 1000;
467 else if (mmtime
->wType
== TIME_SMPTE
)
468 return ((mmtime
->u
.smpte
.hour
* 60.0 * 60.0) +
469 (mmtime
->u
.smpte
.min
* 60.0) +
470 (mmtime
->u
.smpte
.sec
) +
471 (mmtime
->u
.smpte
.frame
/ 30.0)) * pwfx
->nAvgBytesPerSec
;
473 trace("FIXME: time_to_bytes() type not supported\n");
477 static void check_position(int device
, HWAVEOUT wout
, DWORD bytes
,
478 LPWAVEFORMATEX pwfx
)
486 samples
=bytes
/(pwfx
->wBitsPerSample
/8*pwfx
->nChannels
);
487 duration
=((double)samples
)/pwfx
->nSamplesPerSec
;
489 mmtime
.wType
= TIME_BYTES
;
490 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
491 ok(rc
==MMSYSERR_NOERROR
,
492 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
493 if (mmtime
.wType
!= TIME_BYTES
&& winetest_debug
> 1)
494 trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
495 dev_name(device
),wave_time_format(mmtime
.wType
));
496 returned
= time_to_bytes(&mmtime
, pwfx
);
497 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d bytes, "
498 "should be %d\n", dev_name(device
), returned
, bytes
);
500 mmtime
.wType
= TIME_SAMPLES
;
501 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
502 ok(rc
==MMSYSERR_NOERROR
,
503 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
504 if (mmtime
.wType
!= TIME_SAMPLES
&& winetest_debug
> 1)
505 trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
506 "returned %s\n",dev_name(device
),wave_time_format(mmtime
.wType
));
507 returned
= time_to_bytes(&mmtime
, pwfx
);
508 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d samples "
509 "(%d bytes), should be %d (%d bytes)\n", dev_name(device
),
510 bytes_to_samples(returned
, pwfx
), returned
,
511 bytes_to_samples(bytes
, pwfx
), bytes
);
513 mmtime
.wType
= TIME_MS
;
514 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
515 ok(rc
==MMSYSERR_NOERROR
,
516 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
517 if (mmtime
.wType
!= TIME_MS
&& winetest_debug
> 1)
518 trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
519 dev_name(device
), wave_time_format(mmtime
.wType
));
520 returned
= time_to_bytes(&mmtime
, pwfx
);
521 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d ms, "
522 "(%d bytes), should be %d (%d bytes)\n", dev_name(device
),
523 bytes_to_ms(returned
, pwfx
), returned
,
524 bytes_to_ms(bytes
, pwfx
), bytes
);
526 mmtime
.wType
= TIME_SMPTE
;
527 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
528 ok(rc
==MMSYSERR_NOERROR
,
529 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
530 if (mmtime
.wType
!= TIME_SMPTE
&& winetest_debug
> 1)
531 trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
532 dev_name(device
),wave_time_format(mmtime
.wType
));
533 returned
= time_to_bytes(&mmtime
, pwfx
);
534 ok(returned
== bytes
, "waveOutGetPosition(%s): SMPTE test failed\n",
537 mmtime
.wType
= TIME_MIDI
;
538 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
539 ok(rc
==MMSYSERR_NOERROR
,
540 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
541 if (mmtime
.wType
!= TIME_MIDI
&& winetest_debug
> 1)
542 trace("waveOutGetPosition(%s): TIME_MIDI not supported, returned %s\n",
543 dev_name(device
),wave_time_format(mmtime
.wType
));
544 returned
= time_to_bytes(&mmtime
, pwfx
);
545 ok(returned
== bytes
, "waveOutGetPosition(%s): MIDI test failed\n",
548 mmtime
.wType
= TIME_TICKS
;
549 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
550 ok(rc
==MMSYSERR_NOERROR
,
551 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
552 if (mmtime
.wType
!= TIME_TICKS
&& winetest_debug
> 1)
553 trace("waveOutGetPosition(%s): TIME_TICKS not supported, returned %s\n",
554 dev_name(device
),wave_time_format(mmtime
.wType
));
555 returned
= time_to_bytes(&mmtime
, pwfx
);
556 ok(returned
== bytes
, "waveOutGetPosition(%s): TICKS test failed\n",
560 static void CALLBACK
callback_func(HWAVEOUT hwo
, UINT uMsg
,
561 DWORD_PTR dwInstance
,
562 DWORD dwParam1
, DWORD dwParam2
)
564 SetEvent((HANDLE
)dwInstance
);
567 static DWORD WINAPI
callback_thread(LPVOID lpParameter
)
571 PeekMessageW( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure the thread has a message queue */
572 SetEvent(lpParameter
);
574 while (GetMessage(&msg
, 0, 0, 0)) {
575 UINT message
= msg
.message
;
576 /* for some reason XP sends a WM_USER message before WOM_OPEN */
577 ok (message
== WOM_OPEN
|| message
== WOM_DONE
||
578 message
== WOM_CLOSE
|| message
== WM_USER
|| message
== WM_APP
,
579 "GetMessage returned unexpected message: %u\n", message
);
580 if (message
== WOM_OPEN
|| message
== WOM_DONE
|| message
== WOM_CLOSE
)
581 SetEvent(lpParameter
);
582 else if (message
== WM_APP
) {
583 SetEvent(lpParameter
);
591 static void wave_out_test_deviceOut(int device
, double duration
,
592 int headers
, int loops
,
593 LPWAVEFORMATEX pwfx
, DWORD format
,
594 DWORD flags
, LPWAVEOUTCAPS pcaps
,
595 BOOL interactive
, BOOL sine
, BOOL pause
)
602 WORD nChannels
= pwfx
->nChannels
;
603 WORD wBitsPerSample
= pwfx
->wBitsPerSample
;
604 DWORD nSamplesPerSec
= pwfx
->nSamplesPerSec
;
605 BOOL has_volume
= pcaps
->dwSupport
& WAVECAPS_VOLUME
? TRUE
: FALSE
;
607 DWORD_PTR callback
= 0;
608 DWORD_PTR callback_instance
= 0;
616 hevent
=CreateEvent(NULL
,FALSE
,FALSE
,NULL
);
617 ok(hevent
!=NULL
,"CreateEvent(): error=%d\n",GetLastError());
621 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_EVENT
) {
622 callback
= (DWORD_PTR
)hevent
;
623 callback_instance
= 0;
624 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
) {
625 callback
= (DWORD_PTR
)callback_func
;
626 callback_instance
= (DWORD_PTR
)hevent
;
627 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
628 thread
= CreateThread(NULL
, 0, callback_thread
, hevent
, 0, &thread_id
);
630 /* make sure thread is running */
631 WaitForSingleObject(hevent
,10000);
632 callback
= thread_id
;
633 callback_instance
= 0;
635 trace("CreateThread() failed\n");
639 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_WINDOW
) {
640 trace("CALLBACK_THREAD not implemented\n");
643 } else if (flags
& CALLBACK_TYPEMASK
) {
644 trace("Undefined callback type!\n");
648 trace("CALLBACK_NULL not implemented\n");
653 rc
=waveOutOpen(&wout
,device
,pwfx
,callback
,callback_instance
,flags
);
654 /* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
655 /* It is acceptable to fail on formats that are not specified to work */
656 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_BADDEVICEID
||
657 rc
==MMSYSERR_NOTENABLED
|| rc
==MMSYSERR_NODRIVER
||
658 rc
==MMSYSERR_ALLOCATED
||
659 ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
660 (flags
& WAVE_FORMAT_DIRECT
) && !(pcaps
->dwFormats
& format
)) ||
661 ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
662 (!(flags
& WAVE_FORMAT_DIRECT
) || (flags
& WAVE_MAPPED
)) &&
663 !(pcaps
->dwFormats
& format
)) ||
664 (rc
==MMSYSERR_INVALFLAG
&& (flags
& WAVE_FORMAT_DIRECT
)),
665 "waveOutOpen(%s): format=%dx%2dx%d flags=%lx(%s) rc=%s\n",
666 dev_name(device
),pwfx
->nSamplesPerSec
,pwfx
->wBitsPerSample
,
667 pwfx
->nChannels
,CALLBACK_EVENT
|flags
,
668 wave_open_flags(CALLBACK_EVENT
|flags
),wave_out_error(rc
));
669 if ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
670 (flags
& WAVE_FORMAT_DIRECT
) && (pcaps
->dwFormats
& format
))
671 trace(" Reason: The device lists this format as supported in it's "
672 "capabilities but opening it failed.\n");
673 if ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
674 !(pcaps
->dwFormats
& format
))
675 trace("waveOutOpen(%s): format=%dx%2dx%d %s rc=%s failed but format "
676 "not supported so OK.\n", dev_name(device
), pwfx
->nSamplesPerSec
,
677 pwfx
->wBitsPerSample
,pwfx
->nChannels
,
678 flags
& WAVE_FORMAT_DIRECT
? "flags=WAVE_FORMAT_DIRECT" :
679 flags
& WAVE_MAPPED
? "flags=WAVE_MAPPED" : "", mmsys_error(rc
));
680 if (rc
!=MMSYSERR_NOERROR
)
683 WaitForSingleObject(hevent
,10000);
685 ok(pwfx
->nChannels
==nChannels
&&
686 pwfx
->wBitsPerSample
==wBitsPerSample
&&
687 pwfx
->nSamplesPerSec
==nSamplesPerSec
,
688 "got the wrong format: %dx%2dx%d instead of %dx%2dx%d\n",
689 pwfx
->nSamplesPerSec
, pwfx
->wBitsPerSample
,
690 pwfx
->nChannels
, nSamplesPerSec
, wBitsPerSample
, nChannels
);
692 frags
= HeapAlloc(GetProcessHeap(), 0, headers
* sizeof(WAVEHDR
));
695 buffer
=wave_generate_la(pwfx
,duration
/ (loops
+ 1),&length
);
697 buffer
=wave_generate_silence(pwfx
,duration
/ (loops
+ 1),&length
);
699 rc
=waveOutGetVolume(wout
,0);
700 ok(rc
==MMSYSERR_INVALPARAM
,"waveOutGetVolume(%s,0) expected "
701 "MMSYSERR_INVALPARAM, got %s\n", dev_name(device
),wave_out_error(rc
));
702 rc
=waveOutGetVolume(wout
,&volume
);
703 if (rc
== MMSYSERR_NOTSUPPORTED
) has_volume
= FALSE
;
704 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
705 "waveOutGetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
707 /* make sure fragment length is a multiple of block size */
708 frag_length
= ((length
/ headers
) / pwfx
->nBlockAlign
) * pwfx
->nBlockAlign
;
710 for (i
= 0; i
< headers
; i
++) {
711 frags
[i
].lpData
=buffer
+ (i
* frag_length
);
712 if (i
!= (headers
-1))
713 frags
[i
].dwBufferLength
=frag_length
;
715 /* use remainder of buffer for last fragment */
716 frags
[i
].dwBufferLength
=length
- (i
* frag_length
);
720 rc
=waveOutPrepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
721 ok(rc
==MMSYSERR_NOERROR
,
722 "waveOutPrepareHeader(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
725 if (interactive
&& rc
==MMSYSERR_NOERROR
) {
727 trace("Playing %g second %s at %5dx%2dx%d %2d header%s %d loop%s %d bytes %s %s\n",duration
,
728 sine
? "440Hz tone" : "silence",pwfx
->nSamplesPerSec
,
729 pwfx
->wBitsPerSample
,pwfx
->nChannels
, headers
, headers
> 1 ? "s": " ",
730 loops
, loops
== 1 ? " " : "s", length
* (loops
+ 1),
731 get_format_str(pwfx
->wFormatTag
),
732 wave_open_flags(flags
));
733 if (sine
&& has_volume
&& volume
== 0)
734 trace("*** Warning the sound is muted, you will not hear the test\n");
736 /* Check that the position is 0 at start */
737 check_position(device
, wout
, 0, pwfx
);
739 rc
=waveOutSetVolume(wout
,0x20002000);
740 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
741 "waveOutSetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
743 rc
=waveOutSetVolume(wout
,volume
);
744 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
745 "waveOutSetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
747 start
=GetTickCount();
749 rc
=waveOutWrite(wout
, &frags
[0], sizeof(frags
[0]));
750 ok(rc
==MMSYSERR_NOERROR
,"waveOutWrite(%s): rc=%s\n",
751 dev_name(device
),wave_out_error(rc
));
753 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
),
754 "WHDR_INQUEUE WHDR_PREPARED expected, got= %s\n",
755 wave_header_flags(frags
[0].dwFlags
));
757 rc
=waveOutWrite(wout
, &frags
[0], sizeof(frags
[0]));
758 ok(rc
==WAVERR_STILLPLAYING
,
759 "waveOutWrite(%s): WAVE_STILLPLAYING expected, got %s\n",
760 dev_name(device
),wave_out_error(rc
));
762 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
),
763 "WHDR_INQUEUE WHDR_PREPARED expected, got %s\n",
764 wave_header_flags(frags
[0].dwFlags
));
766 if (headers
== 1 && loops
== 0 && pause
) {
767 paused
= duration
/ 2;
768 Sleep(paused
* 1000);
769 rc
=waveOutPause(wout
);
770 ok(rc
==MMSYSERR_NOERROR
,"waveOutPause(%s): rc=%s\n",
771 dev_name(device
),wave_out_error(rc
));
772 trace("pausing for %g seconds\n", paused
);
773 Sleep(paused
* 1000);
774 rc
=waveOutRestart(wout
);
775 ok(rc
==MMSYSERR_NOERROR
,"waveOutRestart(%s): rc=%s\n",
776 dev_name(device
),wave_out_error(rc
));
779 for (j
= 0; j
<= loops
; j
++) {
780 for (i
= 0; i
< headers
; i
++) {
781 /* don't do last one */
782 if (!((j
== loops
) && (i
== (headers
- 1)))) {
784 frags
[(i
+1) % headers
].dwFlags
= WHDR_PREPARED
;
785 rc
=waveOutWrite(wout
, &frags
[(i
+1) % headers
], sizeof(frags
[0]));
786 ok(rc
==MMSYSERR_NOERROR
,"waveOutWrite(%s, header[%d]): rc=%s\n",
787 dev_name(device
),(i
+1)%headers
,wave_out_error(rc
));
789 WaitForSingleObject(hevent
,10000);
793 for (i
= 0; i
< headers
; i
++) {
794 ok(frags
[i
].dwFlags
==(WHDR_DONE
|WHDR_PREPARED
) ||
795 broken((flags
& CALLBACK_TYPEMASK
)==CALLBACK_EVENT
&&
796 frags
[i
].dwFlags
==(WHDR_DONE
|WHDR_PREPARED
|0x1000)), /* < NT4 */
797 "(%02d) WHDR_DONE WHDR_PREPARED expected, got %s\n",
798 i
, wave_header_flags(frags
[i
].dwFlags
));
800 check_position(device
, wout
, length
* (loops
+ 1), pwfx
);
803 for (i
= 0; i
< headers
; i
++) {
804 rc
=waveOutUnprepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
805 ok(rc
==MMSYSERR_NOERROR
,
806 "waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device
),
809 HeapFree(GetProcessHeap(), 0, buffer
);
811 rc
=waveOutClose(wout
);
812 ok(rc
==MMSYSERR_NOERROR
,"waveOutClose(%s): rc=%s\n",dev_name(device
),
814 WaitForSingleObject(hevent
,10000);
816 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
817 PostThreadMessage(thread_id
, WM_APP
, 0, 0);
818 WaitForSingleObject(hevent
,10000);
821 HeapFree(GetProcessHeap(), 0, frags
);
824 static void wave_out_test_device(UINT_PTR device
)
828 WAVEFORMATEX format
, oformat
;
829 WAVEFORMATEXTENSIBLE wfex
;
830 IMAADPCMWAVEFORMAT wfa
;
839 SYSTEM_INFO sSysInfo
;
843 GetSystemInfo(&sSysInfo
);
844 dwPageSize
= sSysInfo
.dwPageSize
;
846 rc
=waveOutGetDevCapsA(device
,&capsA
,sizeof(capsA
));
847 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_BADDEVICEID
||
848 rc
==MMSYSERR_NODRIVER
,
849 "waveOutGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
850 dev_name(device
),wave_out_error(rc
));
851 if (rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
)
854 rc
=waveOutGetDevCapsW(device
,&capsW
,sizeof(capsW
));
855 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
856 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
857 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
859 rc
=waveOutGetDevCapsA(device
,0,sizeof(capsA
));
860 ok(rc
==MMSYSERR_INVALPARAM
,
861 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, "
862 "got %s\n",dev_name(device
),wave_out_error(rc
));
864 rc
=waveOutGetDevCapsW(device
,0,sizeof(capsW
));
865 ok(rc
==MMSYSERR_INVALPARAM
|| rc
==MMSYSERR_NOTSUPPORTED
,
866 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
867 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
871 /* FIXME: this works on windows but crashes wine */
872 rc
=waveOutGetDevCapsA(device
,(LPWAVEOUTCAPSA
)1,sizeof(capsA
));
873 ok(rc
==MMSYSERR_INVALPARAM
,
874 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
875 dev_name(device
),wave_out_error(rc
));
877 rc
=waveOutGetDevCapsW(device
,(LPWAVEOUTCAPSW
)1,sizeof(capsW
));
878 ok(rc
==MMSYSERR_INVALPARAM
|| rc
==MMSYSERR_NOTSUPPORTED
,
879 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
880 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
883 rc
=waveOutGetDevCapsA(device
,&capsA
,4);
884 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_INVALPARAM
,
885 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR or MMSYSERR_INVALPARAM "
886 "expected, got %s\n", dev_name(device
),wave_out_error(rc
));
888 rc
=waveOutGetDevCapsW(device
,&capsW
,4);
889 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
||
890 rc
==MMSYSERR_INVALPARAM
, /* Vista, W2K8 */
891 "waveOutGetDevCapsW(%s): unexpected return value %s\n",
892 dev_name(device
),wave_out_error(rc
));
895 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYDEVICEINTERFACESIZE
,
896 (DWORD_PTR
)&size
, 0);
897 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_INVALPARAM
||
898 rc
==MMSYSERR_NOTSUPPORTED
,
899 "waveOutMessage(%s): failed to get interface size, rc=%s\n",
900 dev_name(device
),wave_out_error(rc
));
901 if (rc
==MMSYSERR_NOERROR
) {
902 nameW
= HeapAlloc(GetProcessHeap(), 0, size
);
903 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYDEVICEINTERFACE
,
904 (DWORD_PTR
)nameW
, size
);
905 ok(rc
==MMSYSERR_NOERROR
,"waveOutMessage(%s): failed to get interface "
906 "name, rc=%s\n",dev_name(device
),wave_out_error(rc
));
907 ok(lstrlenW(nameW
)+1==size
/sizeof(WCHAR
),"got an incorrect size %d\n",size
);
908 if (rc
==MMSYSERR_NOERROR
) {
909 nameA
= HeapAlloc(GetProcessHeap(), 0, size
/sizeof(WCHAR
));
910 WideCharToMultiByte(CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), nameA
,
911 size
/sizeof(WCHAR
), NULL
, NULL
);
913 HeapFree(GetProcessHeap(), 0, nameW
);
915 else if (rc
==MMSYSERR_NOTSUPPORTED
) {
916 nameA
=HeapAlloc(GetProcessHeap(), 0, sizeof("not supported"));
917 strcpy(nameA
, "not supported");
920 rc
=waveOutGetDevCapsA(device
,&capsA
,sizeof(capsA
));
921 ok(rc
==MMSYSERR_NOERROR
,
922 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
923 dev_name(device
),wave_out_error(rc
));
924 if (rc
!=MMSYSERR_NOERROR
)
927 trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device
),capsA
.szPname
,
928 (nameA
?nameA
:"failed"),capsA
.vDriverVersion
>> 8,
929 capsA
.vDriverVersion
& 0xff, capsA
.wMid
,capsA
.wPid
);
930 trace(" channels=%d formats=%05x support=%04x\n",
931 capsA
.wChannels
,capsA
.dwFormats
,capsA
.dwSupport
);
932 trace(" %s\n",wave_out_caps(capsA
.dwSupport
));
933 HeapFree(GetProcessHeap(), 0, nameA
);
935 if (winetest_interactive
&& (device
!= WAVE_MAPPER
))
937 trace("Playing a 5 seconds reference tone.\n");
938 trace("All subsequent tones should be identical to this one.\n");
939 trace("Listen for stutter, changes in pitch, volume, etc.\n");
940 format
.wFormatTag
=WAVE_FORMAT_PCM
;
942 format
.wBitsPerSample
=8;
943 format
.nSamplesPerSec
=22050;
944 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
945 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
948 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
949 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
950 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
951 CALLBACK_FUNCTION
,&capsA
,TRUE
,TRUE
,FALSE
);
952 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
953 CALLBACK_THREAD
,&capsA
,TRUE
,TRUE
,FALSE
);
955 wave_out_test_deviceOut(device
,5.0,10,0,&format
,WAVE_FORMAT_2M08
,
956 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
957 wave_out_test_deviceOut(device
,5.0,5,1,&format
,WAVE_FORMAT_2M08
,
958 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
960 format
.wFormatTag
=WAVE_FORMAT_PCM
;
962 format
.wBitsPerSample
=8;
963 format
.nSamplesPerSec
=22050;
964 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
965 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
967 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
968 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
969 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
970 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,TRUE
);
971 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
972 CALLBACK_FUNCTION
,&capsA
,TRUE
,FALSE
,FALSE
);
973 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
974 CALLBACK_FUNCTION
,&capsA
,TRUE
,FALSE
,TRUE
);
975 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
976 CALLBACK_THREAD
,&capsA
,TRUE
,FALSE
,FALSE
);
977 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
978 CALLBACK_THREAD
,&capsA
,TRUE
,FALSE
,TRUE
);
980 wave_out_test_deviceOut(device
,1.0,10,0,&format
,WAVE_FORMAT_2M08
,
981 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
982 wave_out_test_deviceOut(device
,1.0,5,1,&format
,WAVE_FORMAT_2M08
,
983 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
986 for (f
=0;f
<NB_WIN_FORMATS
;f
++) {
987 format
.wFormatTag
=WAVE_FORMAT_PCM
;
988 format
.nChannels
=win_formats
[f
][3];
989 format
.wBitsPerSample
=win_formats
[f
][2];
990 format
.nSamplesPerSec
=win_formats
[f
][1];
991 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
992 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
994 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
995 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
997 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
998 CALLBACK_FUNCTION
,&capsA
,winetest_interactive
,
1000 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1001 CALLBACK_THREAD
,&capsA
,winetest_interactive
,
1004 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1005 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1007 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1008 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1011 if (winetest_interactive
) {
1012 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1013 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1015 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1016 CALLBACK_FUNCTION
,&capsA
,winetest_interactive
,
1018 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1019 CALLBACK_THREAD
,&capsA
,winetest_interactive
,
1022 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1023 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1025 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1026 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1029 if (device
!= WAVE_MAPPER
)
1031 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1032 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1033 winetest_interactive
,TRUE
,FALSE
);
1034 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1035 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1036 winetest_interactive
,TRUE
,FALSE
);
1037 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1038 CALLBACK_FUNCTION
|WAVE_FORMAT_DIRECT
,&capsA
,
1039 winetest_interactive
,TRUE
,FALSE
);
1040 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1041 CALLBACK_FUNCTION
|WAVE_MAPPED
,&capsA
,
1042 winetest_interactive
,TRUE
,FALSE
);
1043 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1044 CALLBACK_THREAD
|WAVE_FORMAT_DIRECT
,&capsA
,
1045 winetest_interactive
,TRUE
,FALSE
);
1046 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1047 CALLBACK_THREAD
|WAVE_MAPPED
,&capsA
,
1048 winetest_interactive
,TRUE
,FALSE
);
1050 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1051 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1052 winetest_interactive
,TRUE
,FALSE
);
1053 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1054 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1055 winetest_interactive
,TRUE
,FALSE
);
1059 /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
1061 twoPages
= VirtualAlloc(NULL
, 2 * dwPageSize
, MEM_RESERVE
| MEM_COMMIT
,
1063 ok(twoPages
!=NULL
,"Failed to allocate 2 pages of memory\n");
1065 res
= VirtualProtect(twoPages
+ dwPageSize
, dwPageSize
, PAGE_NOACCESS
,
1067 ok(res
, "Failed to set memory access on second page\n");
1069 LPWAVEFORMATEX pwfx
= (LPWAVEFORMATEX
)(twoPages
+ dwPageSize
-
1070 sizeof(PCMWAVEFORMAT
));
1071 pwfx
->wFormatTag
=WAVE_FORMAT_PCM
;
1073 pwfx
->wBitsPerSample
=8;
1074 pwfx
->nSamplesPerSec
=22050;
1075 pwfx
->nBlockAlign
=pwfx
->nChannels
*pwfx
->wBitsPerSample
/8;
1076 pwfx
->nAvgBytesPerSec
=pwfx
->nSamplesPerSec
*pwfx
->nBlockAlign
;
1077 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1078 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1080 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1081 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1083 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1084 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1086 if (device
!= WAVE_MAPPER
)
1088 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1089 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1090 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1091 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1092 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1093 winetest_interactive
,TRUE
,FALSE
);
1094 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1095 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1096 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1097 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1098 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1099 winetest_interactive
,TRUE
,FALSE
);
1100 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1101 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1102 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1103 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1104 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1105 winetest_interactive
,TRUE
,FALSE
);
1108 VirtualFree(twoPages
, 0, MEM_RELEASE
);
1111 /* Testing invalid format: 11 bits per sample */
1112 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1114 format
.wBitsPerSample
=11;
1115 format
.nSamplesPerSec
=22050;
1116 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1117 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1120 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1121 ok(rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_INVALFLAG
||
1122 rc
==MMSYSERR_INVALPARAM
,
1123 "waveOutOpen(%s): opening the device in 11 bits mode should fail: "
1124 "rc=%s\n",dev_name(device
),wave_out_error(rc
));
1125 if (rc
==MMSYSERR_NOERROR
) {
1126 trace(" got %dx%2dx%d for %dx%2dx%d\n",
1127 format
.nSamplesPerSec
, format
.wBitsPerSample
,
1129 oformat
.nSamplesPerSec
, oformat
.wBitsPerSample
,
1134 /* Testing invalid format: 2 MHz sample rate */
1135 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1137 format
.wBitsPerSample
=16;
1138 format
.nSamplesPerSec
=2000000;
1139 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1140 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1143 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1144 ok(rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_INVALFLAG
||
1145 rc
==MMSYSERR_INVALPARAM
,
1146 "waveOutOpen(%s): opening the device at 2 MHz sample rate should fail: "
1147 "rc=%s\n",dev_name(device
),wave_out_error(rc
));
1148 if (rc
==MMSYSERR_NOERROR
) {
1149 trace(" got %dx%2dx%d for %dx%2dx%d\n",
1150 format
.nSamplesPerSec
, format
.wBitsPerSample
,
1152 oformat
.nSamplesPerSec
, oformat
.wBitsPerSample
,
1157 /* try some non PCM formats */
1158 format
.wFormatTag
=WAVE_FORMAT_MULAW
;
1160 format
.wBitsPerSample
=8;
1161 format
.nSamplesPerSec
=8000;
1162 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1163 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1165 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1166 ok(rc
==MMSYSERR_NOERROR
||rc
==WAVERR_BADFORMAT
||
1167 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1168 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1169 if (rc
==MMSYSERR_NOERROR
) {
1171 wave_out_test_deviceOut(device
,1.0,1,0,&format
,0,CALLBACK_EVENT
,
1172 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1173 wave_out_test_deviceOut(device
,1.0,10,0,&format
,0,CALLBACK_EVENT
,
1174 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1175 wave_out_test_deviceOut(device
,1.0,5,1,&format
,0,CALLBACK_EVENT
,
1176 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1178 trace("waveOutOpen(%s): WAVE_FORMAT_MULAW not supported\n",
1181 wfa
.wfx
.wFormatTag
=WAVE_FORMAT_IMA_ADPCM
;
1182 wfa
.wfx
.nChannels
=1;
1183 wfa
.wfx
.nSamplesPerSec
=11025;
1184 wfa
.wfx
.nAvgBytesPerSec
=5588;
1185 wfa
.wfx
.nBlockAlign
=256;
1186 wfa
.wfx
.wBitsPerSample
=4; /* see imaadp32.c */
1188 wfa
.wSamplesPerBlock
=505;
1189 rc
=waveOutOpen(&wout
,device
,&wfa
.wfx
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1190 ok(rc
==MMSYSERR_NOERROR
||rc
==WAVERR_BADFORMAT
||
1191 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1192 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1193 if (rc
==MMSYSERR_NOERROR
) {
1195 /* TODO: teach wave_generate_* ADPCM
1196 wave_out_test_deviceOut(device,1.0,1,0,&wfa.wfx,0,CALLBACK_EVENT,
1197 &capsA,winetest_interactive,TRUE,FALSE);
1198 wave_out_test_deviceOut(device,1.0,10,0,&wfa.wfx,0,CALLBACK_EVENT,
1199 &capsA,winetest_interactive,TRUE,FALSE);
1200 wave_out_test_deviceOut(device,1.0,5,1,&wfa.wfx,0,CALLBACK_EVENT,
1201 &capsA,winetest_interactive,TRUE,FALSE);
1204 trace("waveOutOpen(%s): WAVE_FORMAT_IMA_ADPCM not supported\n",
1207 /* test if WAVEFORMATEXTENSIBLE supported */
1208 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1209 wfex
.Format
.nChannels
=2;
1210 wfex
.Format
.wBitsPerSample
=16;
1211 wfex
.Format
.nSamplesPerSec
=22050;
1212 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1213 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1214 wfex
.Format
.nBlockAlign
;
1215 wfex
.Format
.cbSize
=22;
1216 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1217 wfex
.dwChannelMask
=SPEAKER_ALL
;
1218 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1219 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1220 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1221 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1222 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1223 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1224 if (rc
==MMSYSERR_NOERROR
) {
1226 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1227 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1229 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1230 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1232 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1233 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1236 trace("waveOutOpen(%s): WAVE_FORMAT_EXTENSIBLE not supported\n",
1239 /* test if 4 channels supported */
1240 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1241 wfex
.Format
.nChannels
=4;
1242 wfex
.Format
.wBitsPerSample
=16;
1243 wfex
.Format
.nSamplesPerSec
=22050;
1244 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1245 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1246 wfex
.Format
.nBlockAlign
;
1247 wfex
.Format
.cbSize
=22;
1248 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1249 wfex
.dwChannelMask
=SPEAKER_ALL
;
1250 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1251 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1252 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1253 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1254 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1255 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1256 if (rc
==MMSYSERR_NOERROR
) {
1258 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,0,CALLBACK_EVENT
,
1259 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1260 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,0,CALLBACK_EVENT
,
1261 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1262 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,0,CALLBACK_EVENT
,
1263 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1265 trace("waveOutOpen(%s): 4 channels not supported\n",
1268 /* test if 6 channels supported */
1269 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1270 wfex
.Format
.nChannels
=6;
1271 wfex
.Format
.wBitsPerSample
=16;
1272 wfex
.Format
.nSamplesPerSec
=22050;
1273 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1274 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1275 wfex
.Format
.nBlockAlign
;
1276 wfex
.Format
.cbSize
=22;
1277 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1278 wfex
.dwChannelMask
=SPEAKER_ALL
;
1279 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1280 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1281 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1282 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1283 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1284 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1285 if (rc
==MMSYSERR_NOERROR
) {
1287 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1288 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1290 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1291 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1293 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1294 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1297 trace("waveOutOpen(%s): 6 channels not supported\n",
1302 /* FIXME: ALSA doesn't like this format */
1303 /* test if 24 bit samples supported */
1304 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1305 wfex
.Format
.nChannels
=2;
1306 wfex
.Format
.wBitsPerSample
=24;
1307 wfex
.Format
.nSamplesPerSec
=22050;
1308 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1309 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1310 wfex
.Format
.nBlockAlign
;
1311 wfex
.Format
.cbSize
=22;
1312 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1313 wfex
.dwChannelMask
=SPEAKER_ALL
;
1314 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1315 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1316 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1317 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1318 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1319 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1320 if (rc
==MMSYSERR_NOERROR
) {
1322 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1323 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1326 trace("waveOutOpen(%s): 24 bit samples not supported\n",
1330 /* test if 32 bit samples supported */
1331 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1332 wfex
.Format
.nChannels
=2;
1333 wfex
.Format
.wBitsPerSample
=32;
1334 wfex
.Format
.nSamplesPerSec
=22050;
1335 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1336 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1337 wfex
.Format
.nBlockAlign
;
1338 wfex
.Format
.cbSize
=22;
1339 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1340 wfex
.dwChannelMask
=SPEAKER_ALL
;
1341 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1342 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1343 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1344 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1345 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1346 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1347 if (rc
==MMSYSERR_NOERROR
) {
1349 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1350 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1352 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1353 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1355 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1356 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1359 trace("waveOutOpen(%s): 32 bit samples not supported\n",
1362 /* test if 32 bit float samples supported */
1363 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1364 wfex
.Format
.nChannels
=2;
1365 wfex
.Format
.wBitsPerSample
=32;
1366 wfex
.Format
.nSamplesPerSec
=22050;
1367 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1368 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1369 wfex
.Format
.nBlockAlign
;
1370 wfex
.Format
.cbSize
=22;
1371 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1372 wfex
.dwChannelMask
=SPEAKER_ALL
;
1373 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
;
1374 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1375 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1376 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1377 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1378 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1379 if (rc
==MMSYSERR_NOERROR
) {
1381 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1382 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1384 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1385 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1387 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1388 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1391 trace("waveOutOpen(%s): 32 bit float samples not supported\n",
1395 static void wave_out_tests(void)
1399 WAVEFORMATEX format
;
1404 ndev
=waveOutGetNumDevs();
1405 trace("found %d WaveOut devices\n",ndev
);
1407 rc
=waveOutGetDevCapsA(ndev
+1,&capsA
,sizeof(capsA
));
1408 ok(rc
==MMSYSERR_BADDEVICEID
,
1409 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1410 dev_name(ndev
+1),mmsys_error(rc
));
1412 rc
=waveOutGetDevCapsW(ndev
+1,&capsW
,sizeof(capsW
));
1413 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NOTSUPPORTED
,
1414 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
1415 "expected, got %s\n",dev_name(ndev
+1),mmsys_error(rc
));
1417 rc
=waveOutGetDevCapsA(WAVE_MAPPER
,&capsA
,sizeof(capsA
));
1419 ok(rc
==MMSYSERR_NOERROR
,
1420 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
1421 dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1423 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
,
1424 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1425 "expected, got %s\n",dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1427 rc
=waveOutGetDevCapsW(WAVE_MAPPER
,&capsW
,sizeof(capsW
));
1429 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
1430 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
1431 "expected, got %s\n",dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1433 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
||
1434 rc
==MMSYSERR_NOTSUPPORTED
,
1435 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1436 " or MMSYSERR_NOTSUPPORTED expected, got %s\n",
1437 dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1439 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1441 format
.wBitsPerSample
=16;
1442 format
.nSamplesPerSec
=44100;
1443 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1444 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1446 rc
=waveOutOpen(&wout
,ndev
+1,&format
,0,0,CALLBACK_NULL
);
1447 ok(rc
==MMSYSERR_BADDEVICEID
,
1448 "waveOutOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1449 dev_name(ndev
+1),mmsys_error(rc
));
1451 for (d
=0;d
<ndev
;d
++)
1452 wave_out_test_device(d
);
1455 wave_out_test_device(WAVE_MAPPER
);
1460 test_multiple_waveopens();