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 /* 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
);
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
)
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
++)
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
++) {
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
++) {
116 b
[1]=(sample
>> 8) & 0xff;
117 b
[2]=(sample
>> 16) & 0xff;
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
++) {
126 b
[1]=(sample
>> 8) & 0xff;
127 b
[2]=(sample
>> 16) & 0xff;
128 b
[3]=(sample
>> 24) & 0xff;
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
;
135 for (j
= 0; j
< wfx
->nChannels
; j
++) {
147 static char* wave_generate_silence(WAVEFORMATEX
* wfx
, double duration
, DWORD
* size
)
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
++)
162 } else if (wfx
->wBitsPerSample
==16) {
163 for (j
= 0; j
< wfx
->nChannels
; j
++) {
168 } else if (wfx
->wBitsPerSample
==24) {
169 for (j
= 0; j
< wfx
->nChannels
; j
++) {
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
++) {
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
;
189 for (j
= 0; j
< wfx
->nChannels
; j
++) {
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
);
210 const char* mmsys_error(MMRESULT error
)
212 #define ERR_TO_STR(dev) case dev: return #dev
213 static char unknown
[32];
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
);
260 const char* wave_out_error(MMRESULT error
)
262 static char msg
[1024];
263 static char long_msg
[1100];
266 rc
= waveOutGetErrorText(error
, msg
, sizeof(msg
));
267 if (rc
!= MMSYSERR_NOERROR
)
268 sprintf(long_msg
, "waveOutGetErrorText(%x) failed with error %x",
271 sprintf(long_msg
, "%s(%s)", mmsys_error(error
), msg
);
275 const char * wave_open_flags(DWORD flags
)
277 static char msg
[1024];
280 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_EVENT
) {
281 strcat(msg
, "CALLBACK_EVENT");
284 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
) {
285 if (!first
) strcat(msg
, "|");
286 strcat(msg
, "CALLBACK_FUNCTION");
289 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_NULL
) {
290 if (!first
) strcat(msg
, "|");
291 strcat(msg
, "CALLBACK_NULL");
294 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
295 if (!first
) strcat(msg
, "|");
296 strcat(msg
, "CALLBACK_THREAD");
299 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_WINDOW
) {
300 if (!first
) strcat(msg
, "|");
301 strcat(msg
, "CALLBACK_WINDOW");
304 if ((flags
& WAVE_ALLOWSYNC
) == WAVE_ALLOWSYNC
) {
305 if (!first
) strcat(msg
, "|");
306 strcat(msg
, "WAVE_ALLOWSYNC");
309 if ((flags
& WAVE_FORMAT_DIRECT
) == WAVE_FORMAT_DIRECT
) {
310 if (!first
) strcat(msg
, "|");
311 strcat(msg
, "WAVE_FORMAT_DIRECT");
314 if ((flags
& WAVE_FORMAT_QUERY
) == WAVE_FORMAT_QUERY
) {
315 if (!first
) strcat(msg
, "|");
316 strcat(msg
, "WAVE_FORMAT_QUERY");
319 if ((flags
& WAVE_MAPPED
) == WAVE_MAPPED
) {
320 if (!first
) strcat(msg
, "|");
321 strcat(msg
, "WAVE_MAPPED");
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];
333 if (flags
& WHDR_BEGINLOOP
) {
334 strcat(msg
, "WHDR_BEGINLOOP");
337 if (flags
& WHDR_DONE
) {
338 if (!first
) strcat(msg
, " ");
339 strcat(msg
, "WHDR_DONE");
342 if (flags
& WHDR_ENDLOOP
) {
343 if (!first
) strcat(msg
, " ");
344 strcat(msg
, "WHDR_ENDLOOP");
347 if (flags
& WHDR_INQUEUE
) {
348 if (!first
) strcat(msg
, " ");
349 strcat(msg
, "WHDR_INQUEUE");
352 if (flags
& WHDR_PREPARED
) {
353 if (!first
) strcat(msg
, " ");
354 strcat(msg
, "WHDR_PREPARED");
357 if (flags
& ~WHDR_MASK
) {
359 sprintf(temp
, "UNKNOWN(0x%08x)", flags
& ~WHDR_MASK
);
360 if (!first
) strcat(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];
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 : "";
383 const char * wave_time_format(UINT type
)
386 #define TIME_FORMAT(f) case f: return #f
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
);
396 sprintf(msg
, "Unknown(0x%04x)", type
);
400 const char * get_format_str(WORD format
)
403 #define WAVE_FORMAT(f) case f: return #f
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
);
449 sprintf(msg
, "Unknown(0x%04x)", format
);
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
)
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");
481 static void check_position(int device
, HWAVEOUT wout
, DWORD bytes
,
482 LPWAVEFORMATEX pwfx
)
488 mmtime
.wType
= TIME_BYTES
;
489 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
490 ok(rc
==MMSYSERR_NOERROR
,
491 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
492 if (mmtime
.wType
!= TIME_BYTES
&& winetest_debug
> 1)
493 trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
494 dev_name(device
),wave_time_format(mmtime
.wType
));
495 returned
= time_to_bytes(&mmtime
, pwfx
);
496 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d bytes, "
497 "should be %d\n", dev_name(device
), returned
, bytes
);
499 mmtime
.wType
= TIME_SAMPLES
;
500 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
501 ok(rc
==MMSYSERR_NOERROR
,
502 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
503 if (mmtime
.wType
!= TIME_SAMPLES
&& winetest_debug
> 1)
504 trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
505 "returned %s\n",dev_name(device
),wave_time_format(mmtime
.wType
));
506 returned
= time_to_bytes(&mmtime
, pwfx
);
507 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d samples "
508 "(%d bytes), should be %d (%d bytes)\n", dev_name(device
),
509 bytes_to_samples(returned
, pwfx
), returned
,
510 bytes_to_samples(bytes
, pwfx
), bytes
);
512 mmtime
.wType
= TIME_MS
;
513 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
514 ok(rc
==MMSYSERR_NOERROR
,
515 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
516 if (mmtime
.wType
!= TIME_MS
&& winetest_debug
> 1)
517 trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
518 dev_name(device
), wave_time_format(mmtime
.wType
));
519 returned
= time_to_bytes(&mmtime
, pwfx
);
520 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d ms, "
521 "(%d bytes), should be %d (%d bytes)\n", dev_name(device
),
522 bytes_to_ms(returned
, pwfx
), returned
,
523 bytes_to_ms(bytes
, pwfx
), bytes
);
525 mmtime
.wType
= TIME_SMPTE
;
526 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
527 ok(rc
==MMSYSERR_NOERROR
,
528 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
529 if (mmtime
.wType
!= TIME_SMPTE
&& winetest_debug
> 1)
530 trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
531 dev_name(device
),wave_time_format(mmtime
.wType
));
532 returned
= time_to_bytes(&mmtime
, pwfx
);
533 ok(returned
== bytes
, "waveOutGetPosition(%s): SMPTE test failed\n",
536 mmtime
.wType
= TIME_MIDI
;
537 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
538 ok(rc
==MMSYSERR_NOERROR
,
539 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
540 if (mmtime
.wType
!= TIME_MIDI
&& winetest_debug
> 1)
541 trace("waveOutGetPosition(%s): TIME_MIDI not supported, returned %s\n",
542 dev_name(device
),wave_time_format(mmtime
.wType
));
543 returned
= time_to_bytes(&mmtime
, pwfx
);
544 ok(returned
== bytes
, "waveOutGetPosition(%s): MIDI test failed\n",
547 mmtime
.wType
= TIME_TICKS
;
548 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
549 ok(rc
==MMSYSERR_NOERROR
,
550 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
551 if (mmtime
.wType
!= TIME_TICKS
&& winetest_debug
> 1)
552 trace("waveOutGetPosition(%s): TIME_TICKS not supported, returned %s\n",
553 dev_name(device
),wave_time_format(mmtime
.wType
));
554 returned
= time_to_bytes(&mmtime
, pwfx
);
555 ok(returned
== bytes
, "waveOutGetPosition(%s): TICKS test failed\n",
559 static void CALLBACK
callback_func(HWAVEOUT hwo
, UINT uMsg
,
560 DWORD_PTR dwInstance
,
561 DWORD dwParam1
, DWORD dwParam2
)
563 SetEvent((HANDLE
)dwInstance
);
566 static DWORD WINAPI
callback_thread(LPVOID lpParameter
)
570 PeekMessageW( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure the thread has a message queue */
571 SetEvent(lpParameter
);
573 while (GetMessage(&msg
, 0, 0, 0)) {
574 UINT message
= msg
.message
;
575 /* for some reason XP sends a WM_USER message before WOM_OPEN */
576 ok (message
== WOM_OPEN
|| message
== WOM_DONE
||
577 message
== WOM_CLOSE
|| message
== WM_USER
|| message
== WM_APP
,
578 "GetMessage returned unexpected message: %u\n", message
);
579 if (message
== WOM_OPEN
|| message
== WOM_DONE
|| message
== WOM_CLOSE
)
580 SetEvent(lpParameter
);
581 else if (message
== WM_APP
) {
582 SetEvent(lpParameter
);
590 static void wave_out_test_deviceOut(int device
, double duration
,
591 int headers
, int loops
,
592 LPWAVEFORMATEX pwfx
, DWORD format
,
593 DWORD flags
, LPWAVEOUTCAPS pcaps
,
594 BOOL interactive
, BOOL sine
, BOOL pause
)
601 WORD nChannels
= pwfx
->nChannels
;
602 WORD wBitsPerSample
= pwfx
->wBitsPerSample
;
603 DWORD nSamplesPerSec
= pwfx
->nSamplesPerSec
;
604 BOOL has_volume
= pcaps
->dwSupport
& WAVECAPS_VOLUME
? TRUE
: FALSE
;
606 DWORD_PTR callback
= 0;
607 DWORD_PTR callback_instance
= 0;
615 hevent
=CreateEvent(NULL
,FALSE
,FALSE
,NULL
);
616 ok(hevent
!=NULL
,"CreateEvent(): error=%d\n",GetLastError());
620 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_EVENT
) {
621 callback
= (DWORD_PTR
)hevent
;
622 callback_instance
= 0;
623 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
) {
624 callback
= (DWORD_PTR
)callback_func
;
625 callback_instance
= (DWORD_PTR
)hevent
;
626 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
627 thread
= CreateThread(NULL
, 0, callback_thread
, hevent
, 0, &thread_id
);
629 /* make sure thread is running */
630 WaitForSingleObject(hevent
,10000);
631 callback
= thread_id
;
632 callback_instance
= 0;
634 trace("CreateThread() failed\n");
638 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_WINDOW
) {
639 trace("CALLBACK_THREAD not implemented\n");
642 } else if (flags
& CALLBACK_TYPEMASK
) {
643 trace("Undefined callback type!\n");
647 trace("CALLBACK_NULL not implemented\n");
652 rc
=waveOutOpen(&wout
,device
,pwfx
,callback
,callback_instance
,flags
);
653 /* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
654 /* It is acceptable to fail on formats that are not specified to work */
655 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_BADDEVICEID
||
656 rc
==MMSYSERR_NOTENABLED
|| rc
==MMSYSERR_NODRIVER
||
657 rc
==MMSYSERR_ALLOCATED
||
658 ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
659 (flags
& WAVE_FORMAT_DIRECT
) && !(pcaps
->dwFormats
& format
)) ||
660 ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
661 (!(flags
& WAVE_FORMAT_DIRECT
) || (flags
& WAVE_MAPPED
)) &&
662 !(pcaps
->dwFormats
& format
)) ||
663 (rc
==MMSYSERR_INVALFLAG
&& (flags
& WAVE_FORMAT_DIRECT
)),
664 "waveOutOpen(%s): format=%dx%2dx%d flags=%lx(%s) rc=%s\n",
665 dev_name(device
),pwfx
->nSamplesPerSec
,pwfx
->wBitsPerSample
,
666 pwfx
->nChannels
,CALLBACK_EVENT
|flags
,
667 wave_open_flags(CALLBACK_EVENT
|flags
),wave_out_error(rc
));
668 if ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
669 (flags
& WAVE_FORMAT_DIRECT
) && (pcaps
->dwFormats
& format
))
670 trace(" Reason: The device lists this format as supported in it's "
671 "capabilities but opening it failed.\n");
672 if ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
673 !(pcaps
->dwFormats
& format
))
674 trace("waveOutOpen(%s): format=%dx%2dx%d %s rc=%s failed but format "
675 "not supported so OK.\n", dev_name(device
), pwfx
->nSamplesPerSec
,
676 pwfx
->wBitsPerSample
,pwfx
->nChannels
,
677 flags
& WAVE_FORMAT_DIRECT
? "flags=WAVE_FORMAT_DIRECT" :
678 flags
& WAVE_MAPPED
? "flags=WAVE_MAPPED" : "", mmsys_error(rc
));
679 if (rc
!=MMSYSERR_NOERROR
)
682 WaitForSingleObject(hevent
,10000);
684 ok(pwfx
->nChannels
==nChannels
&&
685 pwfx
->wBitsPerSample
==wBitsPerSample
&&
686 pwfx
->nSamplesPerSec
==nSamplesPerSec
,
687 "got the wrong format: %dx%2dx%d instead of %dx%2dx%d\n",
688 pwfx
->nSamplesPerSec
, pwfx
->wBitsPerSample
,
689 pwfx
->nChannels
, nSamplesPerSec
, wBitsPerSample
, nChannels
);
691 frags
= HeapAlloc(GetProcessHeap(), 0, headers
* sizeof(WAVEHDR
));
694 buffer
=wave_generate_la(pwfx
,duration
/ (loops
+ 1),&length
);
696 buffer
=wave_generate_silence(pwfx
,duration
/ (loops
+ 1),&length
);
698 rc
=waveOutGetVolume(wout
,0);
699 ok(rc
==MMSYSERR_INVALPARAM
,"waveOutGetVolume(%s,0) expected "
700 "MMSYSERR_INVALPARAM, got %s\n", dev_name(device
),wave_out_error(rc
));
701 rc
=waveOutGetVolume(wout
,&volume
);
702 if (rc
== MMSYSERR_NOTSUPPORTED
) has_volume
= FALSE
;
703 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
704 "waveOutGetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
706 /* make sure fragment length is a multiple of block size */
707 frag_length
= ((length
/ headers
) / pwfx
->nBlockAlign
) * pwfx
->nBlockAlign
;
709 for (i
= 0; i
< headers
; i
++) {
710 frags
[i
].lpData
=buffer
+ (i
* frag_length
);
711 if (i
!= (headers
-1))
712 frags
[i
].dwBufferLength
=frag_length
;
714 /* use remainder of buffer for last fragment */
715 frags
[i
].dwBufferLength
=length
- (i
* frag_length
);
719 rc
=waveOutPrepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
720 ok(rc
==MMSYSERR_NOERROR
,
721 "waveOutPrepareHeader(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
724 if (interactive
&& rc
==MMSYSERR_NOERROR
) {
725 trace("Playing %g second %s at %5dx%2dx%d %2d header%s %d loop%s %d bytes %s %s\n",duration
,
726 sine
? "440Hz tone" : "silence",pwfx
->nSamplesPerSec
,
727 pwfx
->wBitsPerSample
,pwfx
->nChannels
, headers
, headers
> 1 ? "s": " ",
728 loops
, loops
== 1 ? " " : "s", length
* (loops
+ 1),
729 get_format_str(pwfx
->wFormatTag
),
730 wave_open_flags(flags
));
731 if (sine
&& has_volume
&& volume
== 0)
732 trace("*** Warning the sound is muted, you will not hear the test\n");
734 /* Check that the position is 0 at start */
735 check_position(device
, wout
, 0, pwfx
);
737 rc
=waveOutSetVolume(wout
,0x20002000);
738 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
739 "waveOutSetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
741 rc
=waveOutSetVolume(wout
,volume
);
742 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
743 "waveOutSetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
745 rc
=waveOutWrite(wout
, &frags
[0], sizeof(frags
[0]));
746 ok(rc
==MMSYSERR_NOERROR
,"waveOutWrite(%s): rc=%s\n",
747 dev_name(device
),wave_out_error(rc
));
749 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
),
750 "WHDR_INQUEUE WHDR_PREPARED expected, got= %s\n",
751 wave_header_flags(frags
[0].dwFlags
));
753 rc
=waveOutWrite(wout
, &frags
[0], sizeof(frags
[0]));
754 ok(rc
==WAVERR_STILLPLAYING
,
755 "waveOutWrite(%s): WAVE_STILLPLAYING expected, got %s\n",
756 dev_name(device
),wave_out_error(rc
));
758 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
),
759 "WHDR_INQUEUE WHDR_PREPARED expected, got %s\n",
760 wave_header_flags(frags
[0].dwFlags
));
762 if (headers
== 1 && loops
== 0 && pause
) {
763 paused
= duration
/ 2;
764 Sleep(paused
* 1000);
765 rc
=waveOutPause(wout
);
766 ok(rc
==MMSYSERR_NOERROR
,"waveOutPause(%s): rc=%s\n",
767 dev_name(device
),wave_out_error(rc
));
768 trace("pausing for %g seconds\n", paused
);
769 Sleep(paused
* 1000);
770 rc
=waveOutRestart(wout
);
771 ok(rc
==MMSYSERR_NOERROR
,"waveOutRestart(%s): rc=%s\n",
772 dev_name(device
),wave_out_error(rc
));
775 for (j
= 0; j
<= loops
; j
++) {
776 for (i
= 0; i
< headers
; i
++) {
777 /* don't do last one */
778 if (!((j
== loops
) && (i
== (headers
- 1)))) {
780 frags
[(i
+1) % headers
].dwFlags
= WHDR_PREPARED
;
781 rc
=waveOutWrite(wout
, &frags
[(i
+1) % headers
], sizeof(frags
[0]));
782 ok(rc
==MMSYSERR_NOERROR
,"waveOutWrite(%s, header[%d]): rc=%s\n",
783 dev_name(device
),(i
+1)%headers
,wave_out_error(rc
));
785 WaitForSingleObject(hevent
,10000);
789 for (i
= 0; i
< headers
; i
++) {
790 ok(frags
[i
].dwFlags
==(WHDR_DONE
|WHDR_PREPARED
) ||
791 broken((flags
& CALLBACK_TYPEMASK
)==CALLBACK_EVENT
&&
792 frags
[i
].dwFlags
==(WHDR_DONE
|WHDR_PREPARED
|0x1000)), /* < NT4 */
793 "(%02d) WHDR_DONE WHDR_PREPARED expected, got %s\n",
794 i
, wave_header_flags(frags
[i
].dwFlags
));
796 check_position(device
, wout
, length
* (loops
+ 1), pwfx
);
799 for (i
= 0; i
< headers
; i
++) {
800 rc
=waveOutUnprepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
801 ok(rc
==MMSYSERR_NOERROR
,
802 "waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device
),
805 HeapFree(GetProcessHeap(), 0, buffer
);
807 rc
=waveOutClose(wout
);
808 ok(rc
==MMSYSERR_NOERROR
,"waveOutClose(%s): rc=%s\n",dev_name(device
),
810 WaitForSingleObject(hevent
,10000);
812 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
813 PostThreadMessage(thread_id
, WM_APP
, 0, 0);
814 WaitForSingleObject(hevent
,10000);
817 HeapFree(GetProcessHeap(), 0, frags
);
820 static void wave_out_test_device(UINT_PTR device
)
824 WAVEFORMATEX format
, oformat
;
825 WAVEFORMATEXTENSIBLE wfex
;
826 IMAADPCMWAVEFORMAT wfa
;
835 SYSTEM_INFO sSysInfo
;
839 GetSystemInfo(&sSysInfo
);
840 dwPageSize
= sSysInfo
.dwPageSize
;
842 rc
=waveOutGetDevCapsA(device
,&capsA
,sizeof(capsA
));
843 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_BADDEVICEID
||
844 rc
==MMSYSERR_NODRIVER
,
845 "waveOutGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
846 dev_name(device
),wave_out_error(rc
));
847 if (rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
)
850 rc
=waveOutGetDevCapsW(device
,&capsW
,sizeof(capsW
));
851 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
852 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
853 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
855 rc
=waveOutGetDevCapsA(device
,0,sizeof(capsA
));
856 ok(rc
==MMSYSERR_INVALPARAM
,
857 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, "
858 "got %s\n",dev_name(device
),wave_out_error(rc
));
860 rc
=waveOutGetDevCapsW(device
,0,sizeof(capsW
));
861 ok(rc
==MMSYSERR_INVALPARAM
|| rc
==MMSYSERR_NOTSUPPORTED
,
862 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
863 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
867 /* FIXME: this works on windows but crashes wine */
868 rc
=waveOutGetDevCapsA(device
,(LPWAVEOUTCAPSA
)1,sizeof(capsA
));
869 ok(rc
==MMSYSERR_INVALPARAM
,
870 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
871 dev_name(device
),wave_out_error(rc
));
873 rc
=waveOutGetDevCapsW(device
,(LPWAVEOUTCAPSW
)1,sizeof(capsW
));
874 ok(rc
==MMSYSERR_INVALPARAM
|| rc
==MMSYSERR_NOTSUPPORTED
,
875 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
876 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
879 rc
=waveOutGetDevCapsA(device
,&capsA
,4);
880 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_INVALPARAM
,
881 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR or MMSYSERR_INVALPARAM "
882 "expected, got %s\n", dev_name(device
),wave_out_error(rc
));
884 rc
=waveOutGetDevCapsW(device
,&capsW
,4);
885 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
||
886 rc
==MMSYSERR_INVALPARAM
, /* Vista, W2K8 */
887 "waveOutGetDevCapsW(%s): unexpected return value %s\n",
888 dev_name(device
),wave_out_error(rc
));
891 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYDEVICEINTERFACESIZE
,
892 (DWORD_PTR
)&size
, 0);
893 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_INVALPARAM
||
894 rc
==MMSYSERR_NOTSUPPORTED
,
895 "waveOutMessage(%s): failed to get interface size, rc=%s\n",
896 dev_name(device
),wave_out_error(rc
));
897 if (rc
==MMSYSERR_NOERROR
) {
898 nameW
= HeapAlloc(GetProcessHeap(), 0, size
);
899 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYDEVICEINTERFACE
,
900 (DWORD_PTR
)nameW
, size
);
901 ok(rc
==MMSYSERR_NOERROR
,"waveOutMessage(%s): failed to get interface "
902 "name, rc=%s\n",dev_name(device
),wave_out_error(rc
));
903 ok(lstrlenW(nameW
)+1==size
/sizeof(WCHAR
),"got an incorrect size %d\n",size
);
904 if (rc
==MMSYSERR_NOERROR
) {
905 nameA
= HeapAlloc(GetProcessHeap(), 0, size
/sizeof(WCHAR
));
906 WideCharToMultiByte(CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), nameA
,
907 size
/sizeof(WCHAR
), NULL
, NULL
);
909 HeapFree(GetProcessHeap(), 0, nameW
);
911 else if (rc
==MMSYSERR_NOTSUPPORTED
) {
912 nameA
=HeapAlloc(GetProcessHeap(), 0, sizeof("not supported"));
913 strcpy(nameA
, "not supported");
916 rc
=waveOutGetDevCapsA(device
,&capsA
,sizeof(capsA
));
917 ok(rc
==MMSYSERR_NOERROR
,
918 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
919 dev_name(device
),wave_out_error(rc
));
920 if (rc
!=MMSYSERR_NOERROR
)
923 trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device
),capsA
.szPname
,
924 (nameA
?nameA
:"failed"),capsA
.vDriverVersion
>> 8,
925 capsA
.vDriverVersion
& 0xff, capsA
.wMid
,capsA
.wPid
);
926 trace(" channels=%d formats=%05x support=%04x\n",
927 capsA
.wChannels
,capsA
.dwFormats
,capsA
.dwSupport
);
928 trace(" %s\n",wave_out_caps(capsA
.dwSupport
));
929 HeapFree(GetProcessHeap(), 0, nameA
);
931 if (winetest_interactive
&& (device
!= WAVE_MAPPER
))
933 trace("Playing a 5 seconds reference tone.\n");
934 trace("All subsequent tones should be identical to this one.\n");
935 trace("Listen for stutter, changes in pitch, volume, etc.\n");
936 format
.wFormatTag
=WAVE_FORMAT_PCM
;
938 format
.wBitsPerSample
=8;
939 format
.nSamplesPerSec
=22050;
940 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
941 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
944 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
945 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
946 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
947 CALLBACK_FUNCTION
,&capsA
,TRUE
,TRUE
,FALSE
);
948 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
949 CALLBACK_THREAD
,&capsA
,TRUE
,TRUE
,FALSE
);
951 wave_out_test_deviceOut(device
,5.0,10,0,&format
,WAVE_FORMAT_2M08
,
952 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
953 wave_out_test_deviceOut(device
,5.0,5,1,&format
,WAVE_FORMAT_2M08
,
954 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
956 format
.wFormatTag
=WAVE_FORMAT_PCM
;
958 format
.wBitsPerSample
=8;
959 format
.nSamplesPerSec
=22050;
960 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
961 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
963 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
964 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
965 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
966 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,TRUE
);
967 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
968 CALLBACK_FUNCTION
,&capsA
,TRUE
,FALSE
,FALSE
);
969 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
970 CALLBACK_FUNCTION
,&capsA
,TRUE
,FALSE
,TRUE
);
971 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
972 CALLBACK_THREAD
,&capsA
,TRUE
,FALSE
,FALSE
);
973 wave_out_test_deviceOut(device
,1.0,1,0,&format
,WAVE_FORMAT_2M08
,
974 CALLBACK_THREAD
,&capsA
,TRUE
,FALSE
,TRUE
);
976 wave_out_test_deviceOut(device
,1.0,10,0,&format
,WAVE_FORMAT_2M08
,
977 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
978 wave_out_test_deviceOut(device
,1.0,5,1,&format
,WAVE_FORMAT_2M08
,
979 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
982 for (f
=0;f
<NB_WIN_FORMATS
;f
++) {
983 format
.wFormatTag
=WAVE_FORMAT_PCM
;
984 format
.nChannels
=win_formats
[f
][3];
985 format
.wBitsPerSample
=win_formats
[f
][2];
986 format
.nSamplesPerSec
=win_formats
[f
][1];
987 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
988 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
990 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
991 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
993 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
994 CALLBACK_FUNCTION
,&capsA
,winetest_interactive
,
996 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
997 CALLBACK_THREAD
,&capsA
,winetest_interactive
,
1000 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1001 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1003 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1004 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1007 if (winetest_interactive
) {
1008 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1009 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1011 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1012 CALLBACK_FUNCTION
,&capsA
,winetest_interactive
,
1014 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1015 CALLBACK_THREAD
,&capsA
,winetest_interactive
,
1018 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1019 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1021 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1022 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1025 if (device
!= WAVE_MAPPER
)
1027 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1028 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1029 winetest_interactive
,TRUE
,FALSE
);
1030 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1031 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1032 winetest_interactive
,TRUE
,FALSE
);
1033 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1034 CALLBACK_FUNCTION
|WAVE_FORMAT_DIRECT
,&capsA
,
1035 winetest_interactive
,TRUE
,FALSE
);
1036 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1037 CALLBACK_FUNCTION
|WAVE_MAPPED
,&capsA
,
1038 winetest_interactive
,TRUE
,FALSE
);
1039 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1040 CALLBACK_THREAD
|WAVE_FORMAT_DIRECT
,&capsA
,
1041 winetest_interactive
,TRUE
,FALSE
);
1042 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1043 CALLBACK_THREAD
|WAVE_MAPPED
,&capsA
,
1044 winetest_interactive
,TRUE
,FALSE
);
1046 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1047 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1048 winetest_interactive
,TRUE
,FALSE
);
1049 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1050 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1051 winetest_interactive
,TRUE
,FALSE
);
1055 /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
1057 twoPages
= VirtualAlloc(NULL
, 2 * dwPageSize
, MEM_RESERVE
| MEM_COMMIT
,
1059 ok(twoPages
!=NULL
,"Failed to allocate 2 pages of memory\n");
1061 res
= VirtualProtect(twoPages
+ dwPageSize
, dwPageSize
, PAGE_NOACCESS
,
1063 ok(res
, "Failed to set memory access on second page\n");
1065 LPWAVEFORMATEX pwfx
= (LPWAVEFORMATEX
)(twoPages
+ dwPageSize
-
1066 sizeof(PCMWAVEFORMAT
));
1067 pwfx
->wFormatTag
=WAVE_FORMAT_PCM
;
1069 pwfx
->wBitsPerSample
=8;
1070 pwfx
->nSamplesPerSec
=22050;
1071 pwfx
->nBlockAlign
=pwfx
->nChannels
*pwfx
->wBitsPerSample
/8;
1072 pwfx
->nAvgBytesPerSec
=pwfx
->nSamplesPerSec
*pwfx
->nBlockAlign
;
1073 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1074 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1076 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1077 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1079 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1080 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1082 if (device
!= WAVE_MAPPER
)
1084 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1085 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1086 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1087 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1088 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1089 winetest_interactive
,TRUE
,FALSE
);
1090 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1091 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1092 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1093 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1094 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1095 winetest_interactive
,TRUE
,FALSE
);
1096 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1097 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1098 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1099 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1100 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1101 winetest_interactive
,TRUE
,FALSE
);
1104 VirtualFree(twoPages
, 0, MEM_RELEASE
);
1107 /* Testing invalid format: 11 bits per sample */
1108 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1110 format
.wBitsPerSample
=11;
1111 format
.nSamplesPerSec
=22050;
1112 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1113 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1116 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1117 ok(rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_INVALFLAG
||
1118 rc
==MMSYSERR_INVALPARAM
,
1119 "waveOutOpen(%s): opening the device in 11 bits mode should fail: "
1120 "rc=%s\n",dev_name(device
),wave_out_error(rc
));
1121 if (rc
==MMSYSERR_NOERROR
) {
1122 trace(" got %dx%2dx%d for %dx%2dx%d\n",
1123 format
.nSamplesPerSec
, format
.wBitsPerSample
,
1125 oformat
.nSamplesPerSec
, oformat
.wBitsPerSample
,
1130 /* Testing invalid format: 2 MHz sample rate */
1131 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1133 format
.wBitsPerSample
=16;
1134 format
.nSamplesPerSec
=2000000;
1135 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1136 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1139 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1140 ok(rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_INVALFLAG
||
1141 rc
==MMSYSERR_INVALPARAM
,
1142 "waveOutOpen(%s): opening the device at 2 MHz sample rate should fail: "
1143 "rc=%s\n",dev_name(device
),wave_out_error(rc
));
1144 if (rc
==MMSYSERR_NOERROR
) {
1145 trace(" got %dx%2dx%d for %dx%2dx%d\n",
1146 format
.nSamplesPerSec
, format
.wBitsPerSample
,
1148 oformat
.nSamplesPerSec
, oformat
.wBitsPerSample
,
1153 /* try some non PCM formats */
1154 format
.wFormatTag
=WAVE_FORMAT_MULAW
;
1156 format
.wBitsPerSample
=8;
1157 format
.nSamplesPerSec
=8000;
1158 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1159 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1161 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1162 ok(rc
==MMSYSERR_NOERROR
||rc
==WAVERR_BADFORMAT
||
1163 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1164 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1165 if (rc
==MMSYSERR_NOERROR
) {
1167 wave_out_test_deviceOut(device
,1.0,1,0,&format
,0,CALLBACK_EVENT
,
1168 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1169 wave_out_test_deviceOut(device
,1.0,10,0,&format
,0,CALLBACK_EVENT
,
1170 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1171 wave_out_test_deviceOut(device
,1.0,5,1,&format
,0,CALLBACK_EVENT
,
1172 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1174 trace("waveOutOpen(%s): WAVE_FORMAT_MULAW not supported\n",
1177 wfa
.wfx
.wFormatTag
=WAVE_FORMAT_IMA_ADPCM
;
1178 wfa
.wfx
.nChannels
=1;
1179 wfa
.wfx
.nSamplesPerSec
=11025;
1180 wfa
.wfx
.nAvgBytesPerSec
=5588;
1181 wfa
.wfx
.nBlockAlign
=256;
1182 wfa
.wfx
.wBitsPerSample
=4; /* see imaadp32.c */
1184 wfa
.wSamplesPerBlock
=505;
1185 rc
=waveOutOpen(&wout
,device
,&wfa
.wfx
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1186 ok(rc
==MMSYSERR_NOERROR
||rc
==WAVERR_BADFORMAT
||
1187 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1188 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1189 if (rc
==MMSYSERR_NOERROR
) {
1191 /* TODO: teach wave_generate_* ADPCM
1192 wave_out_test_deviceOut(device,1.0,1,0,&wfa.wfx,0,CALLBACK_EVENT,
1193 &capsA,winetest_interactive,TRUE,FALSE);
1194 wave_out_test_deviceOut(device,1.0,10,0,&wfa.wfx,0,CALLBACK_EVENT,
1195 &capsA,winetest_interactive,TRUE,FALSE);
1196 wave_out_test_deviceOut(device,1.0,5,1,&wfa.wfx,0,CALLBACK_EVENT,
1197 &capsA,winetest_interactive,TRUE,FALSE);
1200 trace("waveOutOpen(%s): WAVE_FORMAT_IMA_ADPCM not supported\n",
1203 /* test if WAVEFORMATEXTENSIBLE supported */
1204 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1205 wfex
.Format
.nChannels
=2;
1206 wfex
.Format
.wBitsPerSample
=16;
1207 wfex
.Format
.nSamplesPerSec
=22050;
1208 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1209 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1210 wfex
.Format
.nBlockAlign
;
1211 wfex
.Format
.cbSize
=22;
1212 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1213 wfex
.dwChannelMask
=SPEAKER_ALL
;
1214 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1215 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1216 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1217 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1218 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1219 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1220 if (rc
==MMSYSERR_NOERROR
) {
1222 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1223 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1225 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1226 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1228 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1229 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1232 trace("waveOutOpen(%s): WAVE_FORMAT_EXTENSIBLE not supported\n",
1235 /* test if 4 channels supported */
1236 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1237 wfex
.Format
.nChannels
=4;
1238 wfex
.Format
.wBitsPerSample
=16;
1239 wfex
.Format
.nSamplesPerSec
=22050;
1240 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1241 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1242 wfex
.Format
.nBlockAlign
;
1243 wfex
.Format
.cbSize
=22;
1244 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1245 wfex
.dwChannelMask
=SPEAKER_ALL
;
1246 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1247 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1248 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1249 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1250 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1251 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1252 if (rc
==MMSYSERR_NOERROR
) {
1254 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,0,CALLBACK_EVENT
,
1255 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1256 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,0,CALLBACK_EVENT
,
1257 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1258 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,0,CALLBACK_EVENT
,
1259 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1261 trace("waveOutOpen(%s): 4 channels not supported\n",
1264 /* test if 6 channels supported */
1265 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1266 wfex
.Format
.nChannels
=6;
1267 wfex
.Format
.wBitsPerSample
=16;
1268 wfex
.Format
.nSamplesPerSec
=22050;
1269 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1270 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1271 wfex
.Format
.nBlockAlign
;
1272 wfex
.Format
.cbSize
=22;
1273 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1274 wfex
.dwChannelMask
=SPEAKER_ALL
;
1275 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1276 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1277 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1278 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1279 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1280 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1281 if (rc
==MMSYSERR_NOERROR
) {
1283 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1284 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1286 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1287 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1289 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1290 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1293 trace("waveOutOpen(%s): 6 channels not supported\n",
1298 /* FIXME: ALSA doesn't like this format */
1299 /* test if 24 bit samples supported */
1300 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1301 wfex
.Format
.nChannels
=2;
1302 wfex
.Format
.wBitsPerSample
=24;
1303 wfex
.Format
.nSamplesPerSec
=22050;
1304 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1305 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1306 wfex
.Format
.nBlockAlign
;
1307 wfex
.Format
.cbSize
=22;
1308 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1309 wfex
.dwChannelMask
=SPEAKER_ALL
;
1310 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1311 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1312 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1313 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1314 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1315 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1316 if (rc
==MMSYSERR_NOERROR
) {
1318 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1319 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1322 trace("waveOutOpen(%s): 24 bit samples not supported\n",
1326 /* test if 32 bit samples supported */
1327 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1328 wfex
.Format
.nChannels
=2;
1329 wfex
.Format
.wBitsPerSample
=32;
1330 wfex
.Format
.nSamplesPerSec
=22050;
1331 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1332 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1333 wfex
.Format
.nBlockAlign
;
1334 wfex
.Format
.cbSize
=22;
1335 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1336 wfex
.dwChannelMask
=SPEAKER_ALL
;
1337 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1338 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1339 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1340 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1341 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1342 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1343 if (rc
==MMSYSERR_NOERROR
) {
1345 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1346 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1348 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1349 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1351 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1352 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1355 trace("waveOutOpen(%s): 32 bit samples not supported\n",
1358 /* test if 32 bit float samples supported */
1359 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1360 wfex
.Format
.nChannels
=2;
1361 wfex
.Format
.wBitsPerSample
=32;
1362 wfex
.Format
.nSamplesPerSec
=22050;
1363 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1364 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1365 wfex
.Format
.nBlockAlign
;
1366 wfex
.Format
.cbSize
=22;
1367 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1368 wfex
.dwChannelMask
=SPEAKER_ALL
;
1369 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
;
1370 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1371 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1372 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1373 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1374 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1375 if (rc
==MMSYSERR_NOERROR
) {
1377 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1378 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1380 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1381 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1383 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1384 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1387 trace("waveOutOpen(%s): 32 bit float samples not supported\n",
1391 static void wave_out_tests(void)
1395 WAVEFORMATEX format
;
1400 ndev
=waveOutGetNumDevs();
1401 trace("found %d WaveOut devices\n",ndev
);
1403 rc
=waveOutGetDevCapsA(ndev
+1,&capsA
,sizeof(capsA
));
1404 ok(rc
==MMSYSERR_BADDEVICEID
,
1405 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1406 dev_name(ndev
+1),mmsys_error(rc
));
1408 rc
=waveOutGetDevCapsW(ndev
+1,&capsW
,sizeof(capsW
));
1409 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NOTSUPPORTED
,
1410 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
1411 "expected, got %s\n",dev_name(ndev
+1),mmsys_error(rc
));
1413 rc
=waveOutGetDevCapsA(WAVE_MAPPER
,&capsA
,sizeof(capsA
));
1415 ok(rc
==MMSYSERR_NOERROR
,
1416 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
1417 dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1419 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
,
1420 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1421 "expected, got %s\n",dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1423 rc
=waveOutGetDevCapsW(WAVE_MAPPER
,&capsW
,sizeof(capsW
));
1425 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
1426 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
1427 "expected, got %s\n",dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1429 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
||
1430 rc
==MMSYSERR_NOTSUPPORTED
,
1431 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1432 " or MMSYSERR_NOTSUPPORTED expected, got %s\n",
1433 dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1435 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1437 format
.wBitsPerSample
=16;
1438 format
.nSamplesPerSec
=44100;
1439 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1440 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1442 rc
=waveOutOpen(&wout
,ndev
+1,&format
,0,0,CALLBACK_NULL
);
1443 ok(rc
==MMSYSERR_BADDEVICEID
,
1444 "waveOutOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1445 dev_name(ndev
+1),mmsys_error(rc
));
1447 for (d
=0;d
<ndev
;d
++)
1448 wave_out_test_device(d
);
1451 wave_out_test_device(WAVE_MAPPER
);
1456 test_multiple_waveopens();