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"
39 #include "winmm_test.h"
43 static void test_multiple_waveopens(void)
45 HWAVEOUT handle1
, handle2
;
49 wfx
.wFormatTag
= WAVE_FORMAT_PCM
;
51 wfx
.nSamplesPerSec
= 11025;
53 wfx
.nAvgBytesPerSec
= wfx
.nSamplesPerSec
* wfx
.nBlockAlign
;
54 wfx
.wBitsPerSample
= 8;
57 ret
= waveOutOpen(&handle1
, 0, &wfx
, 0, 0, 0);
58 if (ret
!= MMSYSERR_NOERROR
)
60 skip("Could not do the duplicate waveopen test\n");
64 ret
= waveOutOpen(&handle2
, 0, &wfx
, 0, 0, 0);
65 /* Modern Windows allows for wave-out devices to be opened multiple times.
66 * Some Wine audio drivers allow that and some don't. To avoid false alarms
67 * for those that do, don't "todo_wine ok(...)" on success.
69 if (ret
!= MMSYSERR_NOERROR
)
71 todo_wine
ok(ret
== MMSYSERR_NOERROR
|| broken(ret
== MMSYSERR_ALLOCATED
), /* winME */
72 "second waveOutOpen returns: %x\n", ret
);
75 waveOutClose(handle2
);
77 waveOutClose(handle1
);
81 * Note that in most of this test we may get MMSYSERR_BADDEVICEID errors
82 * at about any time if the user starts another application that uses the
83 * sound device. So we should not report these as test failures.
85 * This test can play a test tone. But this only makes sense if someone
86 * is going to carefully listen to it, and would only bother everyone else.
87 * So this is only done if the test is being run in interactive mode.
90 #define PI 3.14159265358979323846
91 static char* wave_generate_la(WAVEFORMATEX
* wfx
, double duration
, DWORD
* size
)
97 WAVEFORMATEXTENSIBLE
*wfex
= (WAVEFORMATEXTENSIBLE
*)wfx
;
99 nb_samples
=(int)(duration
*wfx
->nSamplesPerSec
);
100 *size
=nb_samples
*wfx
->nBlockAlign
;
101 b
=buf
=HeapAlloc(GetProcessHeap(), 0, *size
);
102 for (i
=0;i
<nb_samples
;i
++) {
103 double y
=sin(440.0*2*PI
*i
/wfx
->nSamplesPerSec
);
104 if (wfx
->wBitsPerSample
==8) {
105 unsigned char sample
=(unsigned char)((double)127.5*(y
+1.0));
106 for (j
= 0; j
< wfx
->nChannels
; j
++)
108 } else if (wfx
->wBitsPerSample
==16) {
109 signed short sample
=(signed short)((double)32767.5*y
-0.5);
110 for (j
= 0; j
< wfx
->nChannels
; j
++) {
115 } else if (wfx
->wBitsPerSample
==24) {
116 signed int sample
=(signed int)(((double)0x7fffff+0.5)*y
-0.5);
117 for (j
= 0; j
< wfx
->nChannels
; j
++) {
119 b
[1]=(sample
>> 8) & 0xff;
120 b
[2]=(sample
>> 16) & 0xff;
123 } else if ((wfx
->wBitsPerSample
==32) && ((wfx
->wFormatTag
== WAVE_FORMAT_PCM
) ||
124 ((wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
125 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
)))) {
126 signed int sample
=(signed int)(((double)0x7fffffff+0.5)*y
-0.5);
127 for (j
= 0; j
< wfx
->nChannels
; j
++) {
129 b
[1]=(sample
>> 8) & 0xff;
130 b
[2]=(sample
>> 16) & 0xff;
131 b
[3]=(sample
>> 24) & 0xff;
134 } else if ((wfx
->wBitsPerSample
==32) && (wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
135 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)) {
136 union { float f
; char c
[4]; } sample
;
138 for (j
= 0; j
< wfx
->nChannels
; j
++) {
150 static char* wave_generate_silence(WAVEFORMATEX
* wfx
, double duration
, DWORD
* size
)
156 WAVEFORMATEXTENSIBLE
*wfex
= (WAVEFORMATEXTENSIBLE
*)wfx
;
158 nb_samples
=(int)(duration
*wfx
->nSamplesPerSec
);
159 *size
=nb_samples
*wfx
->nBlockAlign
;
160 b
=buf
=HeapAlloc(GetProcessHeap(), 0, *size
);
161 for (i
=0;i
<nb_samples
;i
++) {
162 if (wfx
->wBitsPerSample
==8) {
163 for (j
= 0; j
< wfx
->nChannels
; j
++)
165 } else if (wfx
->wBitsPerSample
==16) {
166 for (j
= 0; j
< wfx
->nChannels
; j
++) {
171 } else if (wfx
->wBitsPerSample
==24) {
172 for (j
= 0; j
< wfx
->nChannels
; j
++) {
178 } else if ((wfx
->wBitsPerSample
==32) && ((wfx
->wFormatTag
== WAVE_FORMAT_PCM
) ||
179 ((wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
180 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
)))) {
181 for (j
= 0; j
< wfx
->nChannels
; j
++) {
188 } else if ((wfx
->wBitsPerSample
==32) && (wfx
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
) &&
189 IsEqualGUID(&wfex
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)) {
190 union { float f
; char c
[4]; } sample
;
192 for (j
= 0; j
< wfx
->nChannels
; j
++) {
204 const char * dev_name(int device
)
206 static char name
[16];
207 if (device
== WAVE_MAPPER
)
208 return "WAVE_MAPPER";
209 sprintf(name
, "%d", device
);
213 const char* mmsys_error(MMRESULT error
)
215 #define ERR_TO_STR(dev) case dev: return #dev
216 static char unknown
[32];
218 ERR_TO_STR(MMSYSERR_NOERROR
);
219 ERR_TO_STR(MMSYSERR_ERROR
);
220 ERR_TO_STR(MMSYSERR_BADDEVICEID
);
221 ERR_TO_STR(MMSYSERR_NOTENABLED
);
222 ERR_TO_STR(MMSYSERR_ALLOCATED
);
223 ERR_TO_STR(MMSYSERR_INVALHANDLE
);
224 ERR_TO_STR(MMSYSERR_NODRIVER
);
225 ERR_TO_STR(MMSYSERR_NOMEM
);
226 ERR_TO_STR(MMSYSERR_NOTSUPPORTED
);
227 ERR_TO_STR(MMSYSERR_BADERRNUM
);
228 ERR_TO_STR(MMSYSERR_INVALFLAG
);
229 ERR_TO_STR(MMSYSERR_INVALPARAM
);
230 ERR_TO_STR(WAVERR_BADFORMAT
);
231 ERR_TO_STR(WAVERR_STILLPLAYING
);
232 ERR_TO_STR(WAVERR_UNPREPARED
);
233 ERR_TO_STR(WAVERR_SYNC
);
234 ERR_TO_STR(MIDIERR_UNPREPARED
);
235 ERR_TO_STR(MIDIERR_STILLPLAYING
);
236 ERR_TO_STR(MIDIERR_NOTREADY
);
237 ERR_TO_STR(MIDIERR_NODEVICE
);
238 ERR_TO_STR(MIDIERR_INVALIDSETUP
);
239 ERR_TO_STR(TIMERR_NOCANDO
);
240 ERR_TO_STR(TIMERR_STRUCT
);
241 ERR_TO_STR(JOYERR_PARMS
);
242 ERR_TO_STR(JOYERR_NOCANDO
);
243 ERR_TO_STR(JOYERR_UNPLUGGED
);
244 ERR_TO_STR(MIXERR_INVALLINE
);
245 ERR_TO_STR(MIXERR_INVALCONTROL
);
246 ERR_TO_STR(MIXERR_INVALVALUE
);
247 ERR_TO_STR(MMIOERR_FILENOTFOUND
);
248 ERR_TO_STR(MMIOERR_OUTOFMEMORY
);
249 ERR_TO_STR(MMIOERR_CANNOTOPEN
);
250 ERR_TO_STR(MMIOERR_CANNOTCLOSE
);
251 ERR_TO_STR(MMIOERR_CANNOTREAD
);
252 ERR_TO_STR(MMIOERR_CANNOTWRITE
);
253 ERR_TO_STR(MMIOERR_CANNOTSEEK
);
254 ERR_TO_STR(MMIOERR_CANNOTEXPAND
);
255 ERR_TO_STR(MMIOERR_CHUNKNOTFOUND
);
256 ERR_TO_STR(MMIOERR_UNBUFFERED
);
258 sprintf(unknown
, "Unknown(0x%08x)", error
);
263 const char* wave_out_error(MMRESULT error
)
265 static char msg
[1024];
266 static char long_msg
[1100];
269 rc
= waveOutGetErrorText(error
, msg
, sizeof(msg
));
270 if (rc
!= MMSYSERR_NOERROR
)
271 sprintf(long_msg
, "waveOutGetErrorText(%x) failed with error %x",
274 sprintf(long_msg
, "%s(%s)", mmsys_error(error
), msg
);
278 const char * wave_open_flags(DWORD flags
)
280 static char msg
[1024];
283 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_EVENT
) {
284 strcat(msg
, "CALLBACK_EVENT");
287 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
) {
288 if (!first
) strcat(msg
, "|");
289 strcat(msg
, "CALLBACK_FUNCTION");
292 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_NULL
) {
293 if (!first
) strcat(msg
, "|");
294 strcat(msg
, "CALLBACK_NULL");
297 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
298 if (!first
) strcat(msg
, "|");
299 strcat(msg
, "CALLBACK_THREAD");
302 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_WINDOW
) {
303 if (!first
) strcat(msg
, "|");
304 strcat(msg
, "CALLBACK_WINDOW");
307 if ((flags
& WAVE_ALLOWSYNC
) == WAVE_ALLOWSYNC
) {
308 if (!first
) strcat(msg
, "|");
309 strcat(msg
, "WAVE_ALLOWSYNC");
312 if ((flags
& WAVE_FORMAT_DIRECT
) == WAVE_FORMAT_DIRECT
) {
313 if (!first
) strcat(msg
, "|");
314 strcat(msg
, "WAVE_FORMAT_DIRECT");
317 if ((flags
& WAVE_FORMAT_QUERY
) == WAVE_FORMAT_QUERY
) {
318 if (!first
) strcat(msg
, "|");
319 strcat(msg
, "WAVE_FORMAT_QUERY");
322 if ((flags
& WAVE_MAPPED
) == WAVE_MAPPED
) {
323 if (!first
) strcat(msg
, "|");
324 strcat(msg
, "WAVE_MAPPED");
329 static const char * wave_header_flags(DWORD flags
)
331 #define WHDR_MASK (WHDR_BEGINLOOP|WHDR_DONE|WHDR_ENDLOOP|WHDR_INQUEUE|WHDR_PREPARED)
332 static char msg
[1024];
335 if (flags
& WHDR_BEGINLOOP
) {
336 strcat(msg
, "WHDR_BEGINLOOP");
339 if (flags
& WHDR_DONE
) {
340 if (!first
) strcat(msg
, " ");
341 strcat(msg
, "WHDR_DONE");
344 if (flags
& WHDR_ENDLOOP
) {
345 if (!first
) strcat(msg
, " ");
346 strcat(msg
, "WHDR_ENDLOOP");
349 if (flags
& WHDR_INQUEUE
) {
350 if (!first
) strcat(msg
, " ");
351 strcat(msg
, "WHDR_INQUEUE");
354 if (flags
& WHDR_PREPARED
) {
355 if (!first
) strcat(msg
, " ");
356 strcat(msg
, "WHDR_PREPARED");
359 if (flags
& ~WHDR_MASK
) {
361 sprintf(temp
, "UNKNOWN(0x%08x)", flags
& ~WHDR_MASK
);
362 if (!first
) strcat(msg
, " ");
368 static const char * wave_out_caps(DWORD dwSupport
)
370 #define ADD_FLAG(f) if (dwSupport & f) strcat(msg, " " #f)
371 static char msg
[256];
374 ADD_FLAG(WAVECAPS_PITCH
);
375 ADD_FLAG(WAVECAPS_PLAYBACKRATE
);
376 ADD_FLAG(WAVECAPS_VOLUME
);
377 ADD_FLAG(WAVECAPS_LRVOLUME
);
378 ADD_FLAG(WAVECAPS_SYNC
);
379 ADD_FLAG(WAVECAPS_SAMPLEACCURATE
);
381 return msg
[0] ? msg
+ 1 : "";
385 const char * wave_time_format(UINT type
)
388 #define TIME_FORMAT(f) case f: return #f
390 TIME_FORMAT(TIME_MS
);
391 TIME_FORMAT(TIME_SAMPLES
);
392 TIME_FORMAT(TIME_BYTES
);
393 TIME_FORMAT(TIME_SMPTE
);
394 TIME_FORMAT(TIME_MIDI
);
395 TIME_FORMAT(TIME_TICKS
);
398 sprintf(msg
, "Unknown(0x%04x)", type
);
402 const char * get_format_str(WORD format
)
405 #define WAVE_FORMAT(f) case f: return #f
407 WAVE_FORMAT(WAVE_FORMAT_PCM
);
408 WAVE_FORMAT(WAVE_FORMAT_ADPCM
);
409 WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD
);
410 WAVE_FORMAT(WAVE_FORMAT_ALAW
);
411 WAVE_FORMAT(WAVE_FORMAT_MULAW
);
412 WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM
);
413 WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM
);
414 WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM
);
415 WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM
);
416 WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM
);
417 WAVE_FORMAT(WAVE_FORMAT_DIGISTD
);
418 WAVE_FORMAT(WAVE_FORMAT_DIGIFIX
);
419 WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM
);
420 WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM
);
421 WAVE_FORMAT(WAVE_FORMAT_SONARC
);
422 WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH
);
423 WAVE_FORMAT(WAVE_FORMAT_ECHOSC1
);
424 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36
);
425 WAVE_FORMAT(WAVE_FORMAT_APTX
);
426 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10
);
427 WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2
);
428 WAVE_FORMAT(WAVE_FORMAT_GSM610
);
429 WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME
);
430 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC
);
431 WAVE_FORMAT(WAVE_FORMAT_DIGIREAL
);
432 WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM
);
433 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10
);
434 WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM
);
435 WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM
);
436 WAVE_FORMAT(WAVE_FORMAT_MPEG
);
437 WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3
);
438 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM
);
439 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8
);
440 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10
);
441 WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND
);
442 WAVE_FORMAT(WAVE_FORMAT_OLIGSM
);
443 WAVE_FORMAT(WAVE_FORMAT_OLIADPCM
);
444 WAVE_FORMAT(WAVE_FORMAT_OLICELP
);
445 WAVE_FORMAT(WAVE_FORMAT_OLISBC
);
446 WAVE_FORMAT(WAVE_FORMAT_OLIOPR
);
447 WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT
);
448 WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE
);
451 sprintf(msg
, "Unknown(0x%04x)", format
);
455 DWORD
bytes_to_samples(DWORD bytes
, LPWAVEFORMATEX pwfx
)
457 return bytes
/ pwfx
->nBlockAlign
;
460 DWORD
bytes_to_ms(DWORD bytes
, LPWAVEFORMATEX pwfx
)
462 return bytes_to_samples(bytes
, pwfx
) * 1000 / pwfx
->nSamplesPerSec
;
465 DWORD
time_to_bytes(LPMMTIME mmtime
, LPWAVEFORMATEX pwfx
)
467 if (mmtime
->wType
== TIME_BYTES
)
469 else if (mmtime
->wType
== TIME_SAMPLES
)
470 return mmtime
->u
.sample
* pwfx
->nBlockAlign
;
471 else if (mmtime
->wType
== TIME_MS
)
472 return mmtime
->u
.ms
* pwfx
->nAvgBytesPerSec
/ 1000;
473 else if (mmtime
->wType
== TIME_SMPTE
)
474 return ((mmtime
->u
.smpte
.hour
* 60 * 60) +
475 (mmtime
->u
.smpte
.min
* 60) +
476 (mmtime
->u
.smpte
.sec
)) * pwfx
->nAvgBytesPerSec
+
477 mmtime
->u
.smpte
.frame
* pwfx
->nAvgBytesPerSec
/ 30;
479 trace("FIXME: time_to_bytes() type not supported\n");
483 static void check_position(int device
, HWAVEOUT wout
, DWORD bytes
,
484 LPWAVEFORMATEX pwfx
)
490 mmtime
.wType
= TIME_BYTES
;
491 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
492 ok(rc
==MMSYSERR_NOERROR
,
493 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
494 if (mmtime
.wType
!= TIME_BYTES
&& winetest_debug
> 1)
495 trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
496 dev_name(device
),wave_time_format(mmtime
.wType
));
497 returned
= time_to_bytes(&mmtime
, pwfx
);
498 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d bytes, "
499 "should be %d\n", dev_name(device
), returned
, bytes
);
501 mmtime
.wType
= TIME_SAMPLES
;
502 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
503 ok(rc
==MMSYSERR_NOERROR
,
504 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
505 if (mmtime
.wType
!= TIME_SAMPLES
&& winetest_debug
> 1)
506 trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
507 "returned %s\n",dev_name(device
),wave_time_format(mmtime
.wType
));
508 returned
= time_to_bytes(&mmtime
, pwfx
);
509 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d samples "
510 "(%d bytes), should be %d (%d bytes)\n", dev_name(device
),
511 bytes_to_samples(returned
, pwfx
), returned
,
512 bytes_to_samples(bytes
, pwfx
), bytes
);
514 mmtime
.wType
= TIME_MS
;
515 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
516 ok(rc
==MMSYSERR_NOERROR
,
517 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
518 if (mmtime
.wType
!= TIME_MS
&& winetest_debug
> 1)
519 trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
520 dev_name(device
), wave_time_format(mmtime
.wType
));
521 returned
= time_to_bytes(&mmtime
, pwfx
);
522 ok(returned
== bytes
, "waveOutGetPosition(%s): returned %d ms, "
523 "(%d bytes), should be %d (%d bytes)\n", dev_name(device
),
524 bytes_to_ms(returned
, pwfx
), returned
,
525 bytes_to_ms(bytes
, pwfx
), bytes
);
527 mmtime
.wType
= TIME_SMPTE
;
528 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
529 ok(rc
==MMSYSERR_NOERROR
,
530 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
531 if (mmtime
.wType
!= TIME_SMPTE
&& winetest_debug
> 1)
532 trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
533 dev_name(device
),wave_time_format(mmtime
.wType
));
534 returned
= time_to_bytes(&mmtime
, pwfx
);
535 ok(returned
== bytes
, "waveOutGetPosition(%s): SMPTE test failed\n",
538 mmtime
.wType
= TIME_MIDI
;
539 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
540 ok(rc
==MMSYSERR_NOERROR
,
541 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
542 if (mmtime
.wType
!= TIME_MIDI
&& winetest_debug
> 1)
543 trace("waveOutGetPosition(%s): TIME_MIDI not supported, returned %s\n",
544 dev_name(device
),wave_time_format(mmtime
.wType
));
545 returned
= time_to_bytes(&mmtime
, pwfx
);
546 ok(returned
== bytes
, "waveOutGetPosition(%s): MIDI test failed\n",
549 mmtime
.wType
= TIME_TICKS
;
550 rc
=waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
551 ok(rc
==MMSYSERR_NOERROR
,
552 "waveOutGetPosition(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
553 if (mmtime
.wType
!= TIME_TICKS
&& winetest_debug
> 1)
554 trace("waveOutGetPosition(%s): TIME_TICKS not supported, returned %s\n",
555 dev_name(device
),wave_time_format(mmtime
.wType
));
556 returned
= time_to_bytes(&mmtime
, pwfx
);
557 ok(returned
== bytes
, "waveOutGetPosition(%s): TICKS test failed\n",
561 static void CALLBACK
callback_func(HWAVEOUT hwo
, UINT uMsg
,
562 DWORD_PTR dwInstance
,
563 DWORD dwParam1
, DWORD dwParam2
)
565 if(uMsg
== WOM_OPEN
|| uMsg
== WOM_CLOSE
)
566 ok(GetCurrentThreadId() == g_tid
, "Got different thread ID\n");
567 SetEvent((HANDLE
)dwInstance
);
570 static DWORD WINAPI
callback_thread(LPVOID lpParameter
)
574 PeekMessageW( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure the thread has a message queue */
575 SetEvent(lpParameter
);
577 while (GetMessage(&msg
, 0, 0, 0)) {
578 UINT message
= msg
.message
;
579 /* for some reason XP sends a WM_USER message before WOM_OPEN */
580 ok (message
== WOM_OPEN
|| message
== WOM_DONE
||
581 message
== WOM_CLOSE
|| message
== WM_USER
|| message
== WM_APP
,
582 "GetMessage returned unexpected message: %u\n", message
);
583 if (message
== WOM_OPEN
|| message
== WOM_DONE
|| message
== WOM_CLOSE
)
584 SetEvent(lpParameter
);
585 else if (message
== WM_APP
) {
586 SetEvent(lpParameter
);
594 static void wave_out_test_deviceOut(int device
, double duration
,
595 int headers
, int loops
,
596 LPWAVEFORMATEX pwfx
, DWORD format
,
597 DWORD flags
, LPWAVEOUTCAPS pcaps
,
598 BOOL interactive
, BOOL sine
, BOOL pause
)
605 WORD nChannels
= pwfx
->nChannels
;
606 WORD wBitsPerSample
= pwfx
->wBitsPerSample
;
607 DWORD nSamplesPerSec
= pwfx
->nSamplesPerSec
;
608 BOOL has_volume
= (pcaps
->dwSupport
& WAVECAPS_VOLUME
) != 0;
610 DWORD_PTR callback
= 0;
611 DWORD_PTR callback_instance
= 0;
619 hevent
=CreateEvent(NULL
,FALSE
,FALSE
,NULL
);
620 ok(hevent
!=NULL
,"CreateEvent(): error=%d\n",GetLastError());
624 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_EVENT
) {
625 callback
= (DWORD_PTR
)hevent
;
626 callback_instance
= 0;
627 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_FUNCTION
) {
628 callback
= (DWORD_PTR
)callback_func
;
629 callback_instance
= (DWORD_PTR
)hevent
;
630 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
631 thread
= CreateThread(NULL
, 0, callback_thread
, hevent
, 0, &thread_id
);
633 /* make sure thread is running */
634 WaitForSingleObject(hevent
,10000);
635 callback
= thread_id
;
636 callback_instance
= 0;
638 trace("CreateThread() failed\n");
642 } else if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_WINDOW
) {
643 trace("CALLBACK_THREAD not implemented\n");
646 } else if (flags
& CALLBACK_TYPEMASK
) {
647 trace("Undefined callback type!\n");
651 trace("CALLBACK_NULL not implemented\n");
656 g_tid
= GetCurrentThreadId();
657 rc
=waveOutOpen(&wout
,device
,pwfx
,callback
,callback_instance
,flags
);
658 /* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
659 /* It is acceptable to fail on formats that are not specified to work */
660 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_BADDEVICEID
||
661 rc
==MMSYSERR_NOTENABLED
|| rc
==MMSYSERR_NODRIVER
||
662 rc
==MMSYSERR_ALLOCATED
||
663 ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
664 (flags
& WAVE_FORMAT_DIRECT
) && !(pcaps
->dwFormats
& format
)) ||
665 ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
666 (!(flags
& WAVE_FORMAT_DIRECT
) || (flags
& WAVE_MAPPED
)) &&
667 !(pcaps
->dwFormats
& format
)) ||
668 (rc
==MMSYSERR_INVALFLAG
&& (flags
& WAVE_FORMAT_DIRECT
)),
669 "waveOutOpen(%s): format=%dx%2dx%d flags=%x(%s) rc=%s\n",
670 dev_name(device
),pwfx
->nSamplesPerSec
,pwfx
->wBitsPerSample
,
671 pwfx
->nChannels
,CALLBACK_EVENT
|flags
,
672 wave_open_flags(CALLBACK_EVENT
|flags
),wave_out_error(rc
));
673 if ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
674 (flags
& WAVE_FORMAT_DIRECT
) && (pcaps
->dwFormats
& format
))
675 trace(" Reason: The device lists this format as supported in it's "
676 "capabilities but opening it failed.\n");
677 if ((rc
==WAVERR_BADFORMAT
|| rc
==MMSYSERR_NOTSUPPORTED
) &&
678 !(pcaps
->dwFormats
& format
))
679 trace("waveOutOpen(%s): format=%dx%2dx%d %s rc=%s failed but format "
680 "not supported so OK.\n", dev_name(device
), pwfx
->nSamplesPerSec
,
681 pwfx
->wBitsPerSample
,pwfx
->nChannels
,
682 flags
& WAVE_FORMAT_DIRECT
? "flags=WAVE_FORMAT_DIRECT" :
683 flags
& WAVE_MAPPED
? "flags=WAVE_MAPPED" : "", mmsys_error(rc
));
684 if (rc
!=MMSYSERR_NOERROR
)
687 rc
=WaitForSingleObject(hevent
,9000);
688 ok(rc
==WAIT_OBJECT_0
, "missing WOM_OPEN notification\n");
690 ok(pwfx
->nChannels
==nChannels
&&
691 pwfx
->wBitsPerSample
==wBitsPerSample
&&
692 pwfx
->nSamplesPerSec
==nSamplesPerSec
,
693 "got the wrong format: %dx%2dx%d instead of %dx%2dx%d\n",
694 pwfx
->nSamplesPerSec
, pwfx
->wBitsPerSample
,
695 pwfx
->nChannels
, nSamplesPerSec
, wBitsPerSample
, nChannels
);
697 frags
= HeapAlloc(GetProcessHeap(), 0, headers
* sizeof(WAVEHDR
));
700 buffer
=wave_generate_la(pwfx
,duration
/ (loops
+ 1),&length
);
702 buffer
=wave_generate_silence(pwfx
,duration
/ (loops
+ 1),&length
);
704 rc
=waveOutGetVolume(wout
,0);
705 ok(rc
==MMSYSERR_INVALPARAM
,"waveOutGetVolume(%s,0) expected "
706 "MMSYSERR_INVALPARAM, got %s\n", dev_name(device
),wave_out_error(rc
));
707 rc
=waveOutGetVolume(wout
,&volume
);
708 if (rc
== MMSYSERR_NOTSUPPORTED
) has_volume
= FALSE
;
709 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
710 "waveOutGetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
712 /* make sure fragment length is a multiple of block size */
713 frag_length
= ((length
/ headers
) / pwfx
->nBlockAlign
) * pwfx
->nBlockAlign
;
715 for (i
= 0; i
< headers
; i
++) {
716 frags
[i
].lpData
=buffer
+ (i
* frag_length
);
717 if (i
!= (headers
-1))
718 frags
[i
].dwBufferLength
=frag_length
;
720 /* use remainder of buffer for last fragment */
721 frags
[i
].dwBufferLength
=length
- (i
* frag_length
);
725 rc
=waveOutPrepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
726 ok(rc
==MMSYSERR_NOERROR
,
727 "waveOutPrepareHeader(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
730 if (interactive
&& rc
==MMSYSERR_NOERROR
) {
731 trace("Playing %g second %s at %5dx%2dx%d %2d header%s %d loop%s %d bytes %s %s\n",duration
,
732 sine
? "440Hz tone" : "silence",pwfx
->nSamplesPerSec
,
733 pwfx
->wBitsPerSample
,pwfx
->nChannels
, headers
, headers
> 1 ? "s": " ",
734 loops
, loops
== 1 ? " " : "s", length
* (loops
+ 1),
735 get_format_str(pwfx
->wFormatTag
),
736 wave_open_flags(flags
));
737 if (sine
&& has_volume
&& volume
== 0)
738 trace("*** Warning the sound is muted, you will not hear the test\n");
740 /* Check that the position is 0 at start */
741 check_position(device
, wout
, 0, pwfx
);
743 rc
=waveOutSetVolume(wout
,0x20002000);
744 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
745 "waveOutSetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
747 rc
=waveOutSetVolume(wout
,volume
);
748 ok(has_volume
? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
,
749 "waveOutSetVolume(%s): rc=%s\n",dev_name(device
),wave_out_error(rc
));
751 rc
=waveOutWrite(wout
, &frags
[0], sizeof(frags
[0]));
752 ok(rc
==MMSYSERR_NOERROR
,"waveOutWrite(%s): rc=%s\n",
753 dev_name(device
),wave_out_error(rc
));
755 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
),
756 "WHDR_INQUEUE WHDR_PREPARED expected, got= %s\n",
757 wave_header_flags(frags
[0].dwFlags
));
759 rc
=waveOutWrite(wout
, &frags
[0], sizeof(frags
[0]));
760 ok(rc
==WAVERR_STILLPLAYING
,
761 "waveOutWrite(%s): WAVE_STILLPLAYING expected, got %s\n",
762 dev_name(device
),wave_out_error(rc
));
764 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
),
765 "WHDR_INQUEUE WHDR_PREPARED expected, got %s\n",
766 wave_header_flags(frags
[0].dwFlags
));
768 if (headers
== 1 && loops
== 0 && pause
) {
769 paused
= duration
/ 2;
770 Sleep(paused
* 1000);
771 rc
=waveOutPause(wout
);
772 ok(rc
==MMSYSERR_NOERROR
,"waveOutPause(%s): rc=%s\n",
773 dev_name(device
),wave_out_error(rc
));
774 trace("pausing for %g seconds\n", paused
);
775 Sleep(paused
* 1000);
776 rc
=waveOutRestart(wout
);
777 ok(rc
==MMSYSERR_NOERROR
,"waveOutRestart(%s): rc=%s\n",
778 dev_name(device
),wave_out_error(rc
));
781 for (j
= 0; j
<= loops
; j
++) {
782 for (i
= 0; i
< headers
; i
++) {
783 /* don't do last one */
784 if (!((j
== loops
) && (i
== (headers
- 1)))) {
786 frags
[(i
+1) % headers
].dwFlags
= WHDR_PREPARED
;
787 rc
=waveOutWrite(wout
, &frags
[(i
+1) % headers
], sizeof(frags
[0]));
788 ok(rc
==MMSYSERR_NOERROR
,"waveOutWrite(%s, header[%d]): rc=%s\n",
789 dev_name(device
),(i
+1)%headers
,wave_out_error(rc
));
791 rc
=WaitForSingleObject(hevent
,8000);
792 ok(rc
==WAIT_OBJECT_0
, "missing WOM_DONE notification\n");
796 for (i
= 0; i
< headers
; i
++) {
797 ok(frags
[i
].dwFlags
==(WHDR_DONE
|WHDR_PREPARED
) ||
798 broken((flags
& CALLBACK_TYPEMASK
)==CALLBACK_EVENT
&&
799 frags
[i
].dwFlags
==(WHDR_DONE
|WHDR_PREPARED
|0x1000)), /* < NT4 */
800 "(%02d) WHDR_DONE WHDR_PREPARED expected, got %s\n",
801 i
, wave_header_flags(frags
[i
].dwFlags
));
803 check_position(device
, wout
, length
* (loops
+ 1), pwfx
);
806 for (i
= 0; i
< headers
; i
++) {
807 rc
=waveOutUnprepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
808 ok(rc
==MMSYSERR_NOERROR
,
809 "waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device
),
813 ok(frags
[0].dwFlags
==(interactive
? WHDR_DONE
: 0), "dwFlags(%d)=%x\n",device
,frags
[0].dwFlags
);
815 frags
[0].dwFlags
|= WHDR_DONE
;
816 rc
=waveOutUnprepareHeader(wout
, &frags
[0], sizeof(frags
[0]));
817 ok(rc
==MMSYSERR_NOERROR
, "waveOutUnprepareHeader(%d): rc=%s\n",device
,wave_out_error(rc
));
818 ok(frags
[0].dwFlags
==WHDR_DONE
, "dwFlags(%d)=%x\n",device
,frags
[0].dwFlags
);
820 frags
[0].dwFlags
|= WHDR_INQUEUE
;
821 rc
=waveOutPrepareHeader(wout
, &frags
[0], sizeof(frags
[0]));
822 ok(rc
==MMSYSERR_NOERROR
, "waveOutPrepareHeader(%d): rc=%s\n",device
,wave_out_error(rc
));
823 ok(frags
[0].dwFlags
==WHDR_PREPARED
, "dwFlags(%d)=%x\n",device
,frags
[0].dwFlags
);
825 frags
[0].dwFlags
|= WHDR_INQUEUE
;
826 rc
=waveOutPrepareHeader(wout
, &frags
[0], sizeof(frags
[0]));
827 ok(rc
==MMSYSERR_NOERROR
, "waveOutPrepareHeader(%d): rc=%s\n",device
,wave_out_error(rc
));
828 ok(frags
[0].dwFlags
==(WHDR_PREPARED
|WHDR_INQUEUE
), "dwFlags(%d)=%x\n",device
,frags
[0].dwFlags
);
830 frags
[0].dwFlags
&= ~(WHDR_INQUEUE
|WHDR_DONE
);
831 rc
=waveOutUnprepareHeader(wout
, &frags
[0], sizeof(frags
[0]));
832 ok(rc
==MMSYSERR_NOERROR
, "waveOutUnprepareHeader(%d): rc=%s\n",device
,wave_out_error(rc
));
833 ok(frags
[0].dwFlags
==0, "dwFlags(%d)=%x\n",device
,frags
[0].dwFlags
);
835 rc
=waveOutClose(wout
);
836 ok(rc
==MMSYSERR_NOERROR
,"waveOutClose(%s): rc=%s\n",dev_name(device
),
838 if (rc
==WAVERR_STILLPLAYING
) {
839 /* waveOutReset ought to return all buffers s.t. waveOutClose succeeds */
840 rc
=waveOutReset(wout
);
841 ok(rc
==MMSYSERR_NOERROR
,"waveOutReset(%s): rc=%s\n",dev_name(device
),
844 for (i
= 0; i
< headers
; i
++) {
845 rc
=waveOutUnprepareHeader(wout
, &frags
[i
], sizeof(frags
[0]));
846 ok(rc
==MMSYSERR_NOERROR
,
847 "waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device
),
850 rc
=waveOutClose(wout
);
851 ok(rc
==MMSYSERR_NOERROR
,"waveOutClose(%s): rc=%s\n",dev_name(device
),
854 rc
=WaitForSingleObject(hevent
,1500);
855 ok(rc
==WAIT_OBJECT_0
, "missing WOM_CLOSE notification\n");
857 wout
= (HWAVEOUT
)0xdeadf00d;
858 rc
=waveOutOpen(&wout
,device
,pwfx
,callback
,callback_instance
,flags
|WAVE_FORMAT_QUERY
);
859 ok(rc
==MMSYSERR_NOERROR
, "WAVE_FORMAT_QUERY(%s): rc=%s\n",dev_name(device
),
861 ok(wout
==(HWAVEOUT
)0xdeadf00d, "WAVE_FORMAT_QUERY handle %p\n", wout
);
863 rc
=WaitForSingleObject(hevent
,20);
864 ok(rc
==WAIT_TIMEOUT
, "Notification from %s rc=%x\n",
865 wave_open_flags(flags
|WAVE_FORMAT_QUERY
),rc
);
867 HeapFree(GetProcessHeap(), 0, buffer
);
869 if ((flags
& CALLBACK_TYPEMASK
) == CALLBACK_THREAD
) {
870 PostThreadMessage(thread_id
, WM_APP
, 0, 0);
871 WaitForSingleObject(hevent
,10000);
874 HeapFree(GetProcessHeap(), 0, frags
);
877 static void wave_out_test_device(UINT_PTR device
)
882 WAVEFORMATEXTENSIBLE wfex
;
883 IMAADPCMWAVEFORMAT wfa
;
892 SYSTEM_INFO sSysInfo
;
896 GetSystemInfo(&sSysInfo
);
897 dwPageSize
= sSysInfo
.dwPageSize
;
899 rc
=waveOutGetDevCapsA(device
,&capsA
,sizeof(capsA
));
900 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_BADDEVICEID
||
901 rc
==MMSYSERR_NODRIVER
,
902 "waveOutGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
903 dev_name(device
),wave_out_error(rc
));
904 if (rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
)
907 rc
=waveOutGetDevCapsW(device
,&capsW
,sizeof(capsW
));
908 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
909 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
910 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
912 rc
=waveOutGetDevCapsA(device
,0,sizeof(capsA
));
913 ok(rc
==MMSYSERR_INVALPARAM
,
914 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, "
915 "got %s\n",dev_name(device
),wave_out_error(rc
));
917 rc
=waveOutGetDevCapsW(device
,0,sizeof(capsW
));
918 ok(rc
==MMSYSERR_INVALPARAM
|| rc
==MMSYSERR_NOTSUPPORTED
,
919 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
920 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
924 /* FIXME: this works on windows but crashes wine */
925 rc
=waveOutGetDevCapsA(device
,(LPWAVEOUTCAPSA
)1,sizeof(capsA
));
926 ok(rc
==MMSYSERR_INVALPARAM
,
927 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
928 dev_name(device
),wave_out_error(rc
));
930 rc
=waveOutGetDevCapsW(device
,(LPWAVEOUTCAPSW
)1,sizeof(capsW
));
931 ok(rc
==MMSYSERR_INVALPARAM
|| rc
==MMSYSERR_NOTSUPPORTED
,
932 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
933 "expected, got %s\n",dev_name(device
),wave_out_error(rc
));
936 rc
=waveOutGetDevCapsA(device
,&capsA
,4);
937 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_INVALPARAM
,
938 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR or MMSYSERR_INVALPARAM "
939 "expected, got %s\n", dev_name(device
),wave_out_error(rc
));
941 rc
=waveOutGetDevCapsW(device
,&capsW
,4);
942 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
||
943 rc
==MMSYSERR_INVALPARAM
, /* Vista, W2K8 */
944 "waveOutGetDevCapsW(%s): unexpected return value %s\n",
945 dev_name(device
),wave_out_error(rc
));
947 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYMAPPABLE
, 0, 0);
948 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
949 "DRV_QUERYMAPPABLE(%s): unexpected return value %s\n",
950 dev_name(device
),wave_out_error(rc
));
953 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYDEVICEINTERFACESIZE
,
954 (DWORD_PTR
)&size
, 0);
955 ok(rc
==MMSYSERR_NOERROR
|| broken(rc
==MMSYSERR_INVALPARAM
||
956 rc
==MMSYSERR_NOTSUPPORTED
),
957 "waveOutMessage(%s): failed to get interface size, rc=%s\n",
958 dev_name(device
),wave_out_error(rc
));
959 if (rc
==MMSYSERR_NOERROR
) {
960 nameW
= HeapAlloc(GetProcessHeap(), 0, size
);
961 rc
=waveOutMessage((HWAVEOUT
)device
, DRV_QUERYDEVICEINTERFACE
,
962 (DWORD_PTR
)nameW
, size
);
963 ok(rc
==MMSYSERR_NOERROR
,"waveOutMessage(%s): failed to get interface "
964 "name, rc=%s\n",dev_name(device
),wave_out_error(rc
));
965 ok(lstrlenW(nameW
)+1==size
/sizeof(WCHAR
),"got an incorrect size %d\n",size
);
966 if (rc
==MMSYSERR_NOERROR
) {
967 nameA
= HeapAlloc(GetProcessHeap(), 0, size
/sizeof(WCHAR
));
968 WideCharToMultiByte(CP_ACP
, 0, nameW
, size
/sizeof(WCHAR
), nameA
,
969 size
/sizeof(WCHAR
), NULL
, NULL
);
971 HeapFree(GetProcessHeap(), 0, nameW
);
973 else if (rc
==MMSYSERR_NOTSUPPORTED
) {
974 nameA
=HeapAlloc(GetProcessHeap(), 0, sizeof("not supported"));
975 strcpy(nameA
, "not supported");
978 rc
=waveOutGetDevCapsA(device
,&capsA
,sizeof(capsA
));
979 ok(rc
==MMSYSERR_NOERROR
,
980 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
981 dev_name(device
),wave_out_error(rc
));
982 if (rc
!=MMSYSERR_NOERROR
)
985 trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device
),capsA
.szPname
,
986 (nameA
?nameA
:"failed"),capsA
.vDriverVersion
>> 8,
987 capsA
.vDriverVersion
& 0xff, capsA
.wMid
,capsA
.wPid
);
988 trace(" channels=%d formats=%05x support=%04x\n",
989 capsA
.wChannels
,capsA
.dwFormats
,capsA
.dwSupport
);
990 trace(" %s\n",wave_out_caps(capsA
.dwSupport
));
991 HeapFree(GetProcessHeap(), 0, nameA
);
993 if (winetest_interactive
&& (device
!= WAVE_MAPPER
))
995 trace("Playing a 5 seconds reference tone.\n");
996 trace("All subsequent tones should be identical to this one.\n");
997 trace("Listen for stutter, changes in pitch, volume, etc.\n");
998 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1000 format
.wBitsPerSample
=8;
1001 format
.nSamplesPerSec
=22050;
1002 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1003 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1006 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
1007 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
1008 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
1009 CALLBACK_FUNCTION
,&capsA
,TRUE
,TRUE
,FALSE
);
1010 wave_out_test_deviceOut(device
,5.0,1,0,&format
,WAVE_FORMAT_2M08
,
1011 CALLBACK_THREAD
,&capsA
,TRUE
,TRUE
,FALSE
);
1013 wave_out_test_deviceOut(device
,5.0,10,0,&format
,WAVE_FORMAT_2M08
,
1014 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
1015 wave_out_test_deviceOut(device
,5.0,5,1,&format
,WAVE_FORMAT_2M08
,
1016 CALLBACK_EVENT
,&capsA
,TRUE
,TRUE
,FALSE
);
1018 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1020 format
.wBitsPerSample
=8;
1021 format
.nSamplesPerSec
=22050;
1022 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1023 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1025 wave_out_test_deviceOut(device
,0.6,1,0,&format
,WAVE_FORMAT_2M08
,
1026 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
1027 wave_out_test_deviceOut(device
,0.6,1,0,&format
,WAVE_FORMAT_2M08
,
1028 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,TRUE
);
1029 wave_out_test_deviceOut(device
,0.6,1,0,&format
,WAVE_FORMAT_2M08
,
1030 CALLBACK_FUNCTION
,&capsA
,TRUE
,FALSE
,FALSE
);
1031 wave_out_test_deviceOut(device
,0.6,1,0,&format
,WAVE_FORMAT_2M08
,
1032 CALLBACK_FUNCTION
,&capsA
,TRUE
,FALSE
,TRUE
);
1033 wave_out_test_deviceOut(device
,0.6,1,0,&format
,WAVE_FORMAT_2M08
,
1034 CALLBACK_THREAD
,&capsA
,TRUE
,FALSE
,FALSE
);
1035 wave_out_test_deviceOut(device
,0.6,1,0,&format
,WAVE_FORMAT_2M08
,
1036 CALLBACK_THREAD
,&capsA
,TRUE
,FALSE
,TRUE
);
1038 wave_out_test_deviceOut(device
,0.8,10,0,&format
,WAVE_FORMAT_2M08
,
1039 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
1040 wave_out_test_deviceOut(device
,1.0,5,1,&format
,WAVE_FORMAT_2M08
,
1041 CALLBACK_EVENT
,&capsA
,TRUE
,FALSE
,FALSE
);
1044 for (f
=0;f
<NB_WIN_FORMATS
;f
++) {
1045 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1046 format
.nChannels
=win_formats
[f
][3];
1047 format
.wBitsPerSample
=win_formats
[f
][2];
1048 format
.nSamplesPerSec
=win_formats
[f
][1];
1049 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1050 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1052 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1053 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1055 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1056 CALLBACK_FUNCTION
,&capsA
,winetest_interactive
,
1058 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1059 CALLBACK_THREAD
,&capsA
,winetest_interactive
,
1062 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1063 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1065 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1066 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1069 if (winetest_interactive
) {
1070 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1071 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1073 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1074 CALLBACK_FUNCTION
,&capsA
,winetest_interactive
,
1076 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1077 CALLBACK_THREAD
,&capsA
,winetest_interactive
,
1080 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1081 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1083 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1084 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1087 if (device
!= WAVE_MAPPER
)
1089 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1090 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1091 winetest_interactive
,TRUE
,FALSE
);
1092 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1093 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1094 winetest_interactive
,TRUE
,FALSE
);
1095 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1096 CALLBACK_FUNCTION
|WAVE_FORMAT_DIRECT
,&capsA
,
1097 winetest_interactive
,TRUE
,FALSE
);
1098 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1099 CALLBACK_FUNCTION
|WAVE_MAPPED
,&capsA
,
1100 winetest_interactive
,TRUE
,FALSE
);
1101 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1102 CALLBACK_THREAD
|WAVE_FORMAT_DIRECT
,&capsA
,
1103 winetest_interactive
,TRUE
,FALSE
);
1104 wave_out_test_deviceOut(device
,1.0,1,0,&format
,win_formats
[f
][0],
1105 CALLBACK_THREAD
|WAVE_MAPPED
,&capsA
,
1106 winetest_interactive
,TRUE
,FALSE
);
1108 wave_out_test_deviceOut(device
,1.0,10,0,&format
,win_formats
[f
][0],
1109 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1110 winetest_interactive
,TRUE
,FALSE
);
1111 wave_out_test_deviceOut(device
,1.0,5,1,&format
,win_formats
[f
][0],
1112 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,&capsA
,
1113 winetest_interactive
,TRUE
,FALSE
);
1117 /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
1119 twoPages
= VirtualAlloc(NULL
, 2 * dwPageSize
, MEM_RESERVE
| MEM_COMMIT
,
1121 ok(twoPages
!=NULL
,"Failed to allocate 2 pages of memory\n");
1123 res
= VirtualProtect(twoPages
+ dwPageSize
, dwPageSize
, PAGE_NOACCESS
,
1125 ok(res
, "Failed to set memory access on second page\n");
1127 LPWAVEFORMATEX pwfx
= (LPWAVEFORMATEX
)(twoPages
+ dwPageSize
-
1128 sizeof(PCMWAVEFORMAT
));
1129 pwfx
->wFormatTag
=WAVE_FORMAT_PCM
;
1131 pwfx
->wBitsPerSample
=8;
1132 pwfx
->nSamplesPerSec
=22050;
1133 pwfx
->nBlockAlign
=pwfx
->nChannels
*pwfx
->wBitsPerSample
/8;
1134 pwfx
->nAvgBytesPerSec
=pwfx
->nSamplesPerSec
*pwfx
->nBlockAlign
;
1135 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1136 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1138 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1139 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1141 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1142 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1144 if (device
!= WAVE_MAPPER
)
1146 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1147 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1148 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1149 wave_out_test_deviceOut(device
,1.0,1,0,pwfx
,WAVE_FORMAT_2M08
,
1150 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1151 winetest_interactive
,TRUE
,FALSE
);
1152 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1153 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1154 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1155 wave_out_test_deviceOut(device
,1.0,10,0,pwfx
,WAVE_FORMAT_2M08
,
1156 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1157 winetest_interactive
,TRUE
,FALSE
);
1158 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1159 CALLBACK_EVENT
|WAVE_FORMAT_DIRECT
,
1160 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1161 wave_out_test_deviceOut(device
,1.0,5,1,pwfx
,WAVE_FORMAT_2M08
,
1162 CALLBACK_EVENT
|WAVE_MAPPED
,&capsA
,
1163 winetest_interactive
,TRUE
,FALSE
);
1166 VirtualFree(twoPages
, 0, MEM_RELEASE
);
1169 /* try some non PCM formats */
1170 format
.wFormatTag
=WAVE_FORMAT_MULAW
;
1172 format
.wBitsPerSample
=8;
1173 format
.nSamplesPerSec
=8000;
1174 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1175 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1177 rc
=waveOutOpen(&wout
,device
,&format
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1178 ok(rc
==MMSYSERR_NOERROR
||rc
==WAVERR_BADFORMAT
||
1179 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1180 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1181 if (rc
==MMSYSERR_NOERROR
) {
1183 wave_out_test_deviceOut(device
,1.0,1,0,&format
,0,CALLBACK_EVENT
,
1184 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1185 wave_out_test_deviceOut(device
,1.0,10,0,&format
,0,CALLBACK_EVENT
,
1186 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1187 wave_out_test_deviceOut(device
,1.0,5,1,&format
,0,CALLBACK_EVENT
,
1188 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1190 trace("waveOutOpen(%s): WAVE_FORMAT_MULAW not supported\n",
1193 wfa
.wfx
.wFormatTag
=WAVE_FORMAT_IMA_ADPCM
;
1194 wfa
.wfx
.nChannels
=1;
1195 wfa
.wfx
.nSamplesPerSec
=11025;
1196 wfa
.wfx
.nAvgBytesPerSec
=5588;
1197 wfa
.wfx
.nBlockAlign
=256;
1198 wfa
.wfx
.wBitsPerSample
=4; /* see imaadp32.c */
1200 wfa
.wSamplesPerBlock
=505;
1201 rc
=waveOutOpen(&wout
,device
,&wfa
.wfx
,0,0,CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1202 ok(rc
==MMSYSERR_NOERROR
||rc
==WAVERR_BADFORMAT
||
1203 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1204 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1205 if (rc
==MMSYSERR_NOERROR
) {
1207 /* TODO: teach wave_generate_* ADPCM
1208 wave_out_test_deviceOut(device,1.0,1,0,&wfa.wfx,0,CALLBACK_EVENT,
1209 &capsA,winetest_interactive,TRUE,FALSE);
1210 wave_out_test_deviceOut(device,1.0,10,0,&wfa.wfx,0,CALLBACK_EVENT,
1211 &capsA,winetest_interactive,TRUE,FALSE);
1212 wave_out_test_deviceOut(device,1.0,5,1,&wfa.wfx,0,CALLBACK_EVENT,
1213 &capsA,winetest_interactive,TRUE,FALSE);
1216 trace("waveOutOpen(%s): WAVE_FORMAT_IMA_ADPCM not supported\n",
1219 /* test if WAVEFORMATEXTENSIBLE supported */
1220 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1221 wfex
.Format
.nChannels
=2;
1222 wfex
.Format
.wBitsPerSample
=16;
1223 wfex
.Format
.nSamplesPerSec
=22050;
1224 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1225 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1226 wfex
.Format
.nBlockAlign
;
1227 wfex
.Format
.cbSize
=22;
1228 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1229 wfex
.dwChannelMask
=SPEAKER_ALL
;
1230 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1231 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1232 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1233 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1234 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1235 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1236 if (rc
==MMSYSERR_NOERROR
) {
1238 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1239 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1241 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1242 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1244 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1245 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1248 trace("waveOutOpen(%s): WAVE_FORMAT_EXTENSIBLE not supported\n",
1251 /* test if 4 channels supported */
1252 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1253 wfex
.Format
.nChannels
=4;
1254 wfex
.Format
.wBitsPerSample
=16;
1255 wfex
.Format
.nSamplesPerSec
=22050;
1256 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1257 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1258 wfex
.Format
.nBlockAlign
;
1259 wfex
.Format
.cbSize
=22;
1260 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1261 wfex
.dwChannelMask
=SPEAKER_ALL
;
1262 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1263 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1264 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1265 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1266 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1267 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1268 if (rc
==MMSYSERR_NOERROR
) {
1270 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,0,CALLBACK_EVENT
,
1271 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1272 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,0,CALLBACK_EVENT
,
1273 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1274 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,0,CALLBACK_EVENT
,
1275 &capsA
,winetest_interactive
,TRUE
,FALSE
);
1277 trace("waveOutOpen(%s): 4 channels not supported\n",
1280 /* test if 6 channels supported */
1281 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1282 wfex
.Format
.nChannels
=6;
1283 wfex
.Format
.wBitsPerSample
=16;
1284 wfex
.Format
.nSamplesPerSec
=22050;
1285 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1286 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1287 wfex
.Format
.nBlockAlign
;
1288 wfex
.Format
.cbSize
=22;
1289 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1290 wfex
.dwChannelMask
=SPEAKER_ALL
;
1291 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1292 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1293 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1294 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1295 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1296 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1297 if (rc
==MMSYSERR_NOERROR
) {
1299 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1300 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1302 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1303 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1305 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1306 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1309 trace("waveOutOpen(%s): 6 channels not supported\n",
1314 /* FIXME: ALSA doesn't like this format */
1315 /* test if 24 bit samples supported */
1316 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1317 wfex
.Format
.nChannels
=2;
1318 wfex
.Format
.wBitsPerSample
=24;
1319 wfex
.Format
.nSamplesPerSec
=22050;
1320 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1321 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1322 wfex
.Format
.nBlockAlign
;
1323 wfex
.Format
.cbSize
=22;
1324 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1325 wfex
.dwChannelMask
=SPEAKER_ALL
;
1326 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1327 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1328 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1329 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1330 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1331 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1332 if (rc
==MMSYSERR_NOERROR
) {
1334 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1335 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1338 trace("waveOutOpen(%s): 24 bit samples not supported\n",
1342 /* test if 32 bit samples supported */
1343 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1344 wfex
.Format
.nChannels
=2;
1345 wfex
.Format
.wBitsPerSample
=32;
1346 wfex
.Format
.nSamplesPerSec
=22050;
1347 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1348 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1349 wfex
.Format
.nBlockAlign
;
1350 wfex
.Format
.cbSize
=22;
1351 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1352 wfex
.dwChannelMask
=SPEAKER_ALL
;
1353 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_PCM
;
1354 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1355 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1356 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1357 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1358 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1359 if (rc
==MMSYSERR_NOERROR
) {
1361 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1362 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1364 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1365 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1367 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1368 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1371 trace("waveOutOpen(%s): 32 bit samples not supported\n",
1374 /* test if 32 bit float samples supported */
1375 wfex
.Format
.wFormatTag
=WAVE_FORMAT_EXTENSIBLE
;
1376 wfex
.Format
.nChannels
=2;
1377 wfex
.Format
.wBitsPerSample
=32;
1378 wfex
.Format
.nSamplesPerSec
=22050;
1379 wfex
.Format
.nBlockAlign
=wfex
.Format
.nChannels
*wfex
.Format
.wBitsPerSample
/8;
1380 wfex
.Format
.nAvgBytesPerSec
=wfex
.Format
.nSamplesPerSec
*
1381 wfex
.Format
.nBlockAlign
;
1382 wfex
.Format
.cbSize
=22;
1383 wfex
.Samples
.wValidBitsPerSample
=wfex
.Format
.wBitsPerSample
;
1384 wfex
.dwChannelMask
=SPEAKER_ALL
;
1385 wfex
.SubFormat
=KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
;
1386 rc
=waveOutOpen(&wout
,device
,&wfex
.Format
,0,0,
1387 CALLBACK_NULL
|WAVE_FORMAT_DIRECT
);
1388 ok(rc
==MMSYSERR_NOERROR
|| rc
==WAVERR_BADFORMAT
||
1389 rc
==MMSYSERR_INVALFLAG
|| rc
==MMSYSERR_INVALPARAM
,
1390 "waveOutOpen(%s): returned %s\n",dev_name(device
),wave_out_error(rc
));
1391 if (rc
==MMSYSERR_NOERROR
) {
1393 wave_out_test_deviceOut(device
,1.0,1,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1394 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1396 wave_out_test_deviceOut(device
,1.0,10,0,&wfex
.Format
,WAVE_FORMAT_2M16
,
1397 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1399 wave_out_test_deviceOut(device
,1.0,5,1,&wfex
.Format
,WAVE_FORMAT_2M16
,
1400 CALLBACK_EVENT
,&capsA
,winetest_interactive
,
1403 trace("waveOutOpen(%s): 32 bit float samples not supported\n",
1407 static void wave_out_tests(void)
1411 WAVEFORMATEX format
;
1414 DWORD preferred
, status
;
1417 ndev
=waveOutGetNumDevs();
1418 trace("found %d WaveOut devices\n",ndev
);
1420 rc
= waveOutMessage((HWAVEOUT
)WAVE_MAPPER
, DRVM_MAPPER_PREFERRED_GET
,
1421 (DWORD_PTR
)&preferred
, (DWORD_PTR
)&status
);
1422 ok((ndev
== 0 && (rc
== MMSYSERR_NODRIVER
|| rc
== MMSYSERR_BADDEVICEID
)) ||
1423 rc
== MMSYSERR_NOTSUPPORTED
||
1424 rc
== MMSYSERR_NOERROR
, "waveOutMessage(DRVM_MAPPER_PREFERRED_GET) failed: %u\n", rc
);
1426 if(rc
!= MMSYSERR_NOTSUPPORTED
)
1427 ok((ndev
== 0 && (preferred
== -1 || broken(preferred
!= -1))) ||
1428 preferred
< ndev
, "Got invalid preferred device: 0x%x\n", preferred
);
1430 rc
=waveOutGetDevCapsA(ndev
+1,&capsA
,sizeof(capsA
));
1431 ok(rc
==MMSYSERR_BADDEVICEID
,
1432 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1433 dev_name(ndev
+1),mmsys_error(rc
));
1435 rc
=waveOutGetDevCapsW(ndev
+1,&capsW
,sizeof(capsW
));
1436 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NOTSUPPORTED
,
1437 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
1438 "expected, got %s\n",dev_name(ndev
+1),mmsys_error(rc
));
1440 rc
=waveOutGetDevCapsA(WAVE_MAPPER
,&capsA
,sizeof(capsA
));
1442 ok(rc
==MMSYSERR_NOERROR
,
1443 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
1444 dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1446 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
,
1447 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1448 "expected, got %s\n",dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1450 rc
=waveOutGetDevCapsW(WAVE_MAPPER
,&capsW
,sizeof(capsW
));
1452 ok(rc
==MMSYSERR_NOERROR
|| rc
==MMSYSERR_NOTSUPPORTED
,
1453 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
1454 "expected, got %s\n",dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1456 ok(rc
==MMSYSERR_BADDEVICEID
|| rc
==MMSYSERR_NODRIVER
||
1457 rc
==MMSYSERR_NOTSUPPORTED
,
1458 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1459 " or MMSYSERR_NOTSUPPORTED expected, got %s\n",
1460 dev_name(WAVE_MAPPER
),mmsys_error(rc
));
1462 format
.wFormatTag
=WAVE_FORMAT_PCM
;
1464 format
.wBitsPerSample
=16;
1465 format
.nSamplesPerSec
=44100;
1466 format
.nBlockAlign
=format
.nChannels
*format
.wBitsPerSample
/8;
1467 format
.nAvgBytesPerSec
=format
.nSamplesPerSec
*format
.nBlockAlign
;
1469 rc
=waveOutOpen(&wout
,ndev
+1,&format
,0,0,CALLBACK_NULL
);
1470 ok(rc
==MMSYSERR_BADDEVICEID
,
1471 "waveOutOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1472 dev_name(ndev
+1),mmsys_error(rc
));
1474 if(winetest_interactive
)
1475 for (d
=0;d
<ndev
;d
++)
1476 wave_out_test_device(d
);
1479 wave_out_test_device(WAVE_MAPPER
);
1482 static void test_sndPlaySound(void)
1486 static const WCHAR not_existW
[] = {'C',':','\\','n','o','t','_','e','x','i','s','t','.','w','a','v',0};
1487 static const WCHAR SystemAsteriskW
[] = {'S','y','s','t','e','m','A','s','t','e','r','i','s','k',0};
1489 br
= sndPlaySoundA((LPCSTR
)SND_ALIAS_SYSTEMASTERISK
, SND_ALIAS_ID
|SND_SYNC
);
1490 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1492 br
= sndPlaySoundW((LPCWSTR
)SND_ALIAS_SYSTEMASTERISK
, SND_ALIAS_ID
|SND_SYNC
);
1493 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1495 br
= sndPlaySoundA((LPCSTR
)sndAlias('X','Y'), SND_ALIAS_ID
|SND_SYNC
);
1496 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1498 br
= sndPlaySoundW((LPCWSTR
)sndAlias('X','Y'), SND_ALIAS_ID
|SND_SYNC
);
1499 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1501 br
= sndPlaySoundA("SystemAsterisk", SND_ALIAS
|SND_SYNC
);
1502 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1504 br
= sndPlaySoundW(SystemAsteriskW
, SND_ALIAS
|SND_SYNC
);
1505 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1507 br
= sndPlaySoundA("C:\not_exist.wav", SND_FILENAME
|SND_SYNC
);
1508 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1510 br
= sndPlaySoundW(not_existW
, SND_FILENAME
|SND_SYNC
);
1511 ok(br
== TRUE
|| br
== FALSE
, "sndPlaySound gave strange return: %u\n", br
);
1514 static void test_fragmentsize(void)
1524 if(waveOutGetNumDevs() == 0)
1527 fmt
.wFormatTag
= WAVE_FORMAT_PCM
;
1529 fmt
.nSamplesPerSec
= 44100;
1530 fmt
.wBitsPerSample
= 16;
1531 fmt
.nBlockAlign
= fmt
.nChannels
* fmt
.wBitsPerSample
/ 8;
1532 fmt
.nAvgBytesPerSec
= fmt
.nBlockAlign
* fmt
.nSamplesPerSec
;
1533 fmt
.cbSize
= sizeof(WAVEFORMATEX
);
1535 hevent
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
1536 g_tid
= GetCurrentThreadId();
1538 rc
= waveOutOpen(&wout
, WAVE_MAPPER
, &fmt
, (DWORD_PTR
)callback_func
,
1539 (DWORD_PTR
)hevent
, CALLBACK_FUNCTION
);
1540 ok(rc
== MMSYSERR_NOERROR
|| rc
== WAVERR_BADFORMAT
||
1541 rc
== MMSYSERR_INVALFLAG
|| rc
== MMSYSERR_INVALPARAM
,
1542 "waveOutOpen(%s) failed: %s\n", dev_name(WAVE_MAPPER
), wave_out_error(rc
));
1543 if(rc
!= MMSYSERR_NOERROR
){
1544 CloseHandle(hevent
);
1548 wait
= WaitForSingleObject(hevent
, 1000);
1549 ok(wait
== WAIT_OBJECT_0
, "wave open callback missed\n");
1551 memset(hdr
, 0, sizeof(hdr
));
1552 hdr
[0].dwBufferLength
= (fmt
.nSamplesPerSec
* fmt
.nBlockAlign
/ 4) + 1;
1553 hdr
[1].dwBufferLength
= hdr
[0].dwBufferLength
- 2;
1554 hdr
[1].lpData
= hdr
[0].lpData
=
1555 HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, hdr
[0].dwBufferLength
);
1557 rc
= waveOutPrepareHeader(wout
, &hdr
[0], sizeof(hdr
[0]));
1558 ok(rc
== MMSYSERR_NOERROR
, "waveOutPrepareHeader failed: %s\n", wave_out_error(rc
));
1560 rc
= waveOutPrepareHeader(wout
, &hdr
[1], sizeof(hdr
[1]));
1561 ok(rc
== MMSYSERR_NOERROR
, "waveOutPrepareHeader failed: %s\n", wave_out_error(rc
));
1563 trace("writing %u bytes then %u bytes\n", hdr
[0].dwBufferLength
, hdr
[1].dwBufferLength
);
1564 rc
= waveOutWrite(wout
, &hdr
[0], sizeof(hdr
[0]));
1565 ok(rc
== MMSYSERR_NOERROR
, "waveOutWrite failed: %s\n", wave_out_error(rc
));
1567 rc
= waveOutWrite(wout
, &hdr
[1], sizeof(hdr
[1]));
1568 ok(rc
== MMSYSERR_NOERROR
, "waveOutWrite failed: %s\n", wave_out_error(rc
));
1570 wait
= WaitForSingleObject(hevent
, 1000);
1571 ok(wait
== WAIT_OBJECT_0
, "header 1 callback missed\n");
1573 wait
= WaitForSingleObject(hevent
, 1000);
1574 ok(wait
== WAIT_OBJECT_0
, "header 2 callback missed\n");
1576 memset(&mmtime
, 0, sizeof(mmtime
));
1577 mmtime
.wType
= TIME_BYTES
;
1579 rc
= waveOutGetPosition(wout
, &mmtime
, sizeof(mmtime
));
1580 ok(rc
== MMSYSERR_NOERROR
, "waveOutGetPosition failed: %s\n", wave_out_error(rc
));
1582 /* windows behavior is inconsistent */
1583 ok(mmtime
.u
.cb
== 88200 ||
1584 mmtime
.u
.cb
== 88196, "after position: %u\n", mmtime
.u
.cb
);
1586 rc
= waveOutClose(wout
);
1587 ok(rc
== MMSYSERR_NOERROR
, "waveOutClose failed: %s\n", wave_out_error(rc
));
1589 CloseHandle(hevent
);
1594 test_multiple_waveopens();
1596 test_sndPlaySound();
1597 test_fragmentsize();