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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/test.h"
37 #include "winmm_test.h"
40 * Note that in most of this test we may get MMSYSERR_BADDEVICEID errors
41 * at about any time if the user starts another application that uses the
42 * sound device. So we should not report these as test failures.
44 * This test can play a test tone. But this only makes sense if someone
45 * is going to carefully listen to it, and would only bother everyone else.
46 * So this is only done if the test is being run in interactive mode.
49 #define PI 3.14159265358979323846
50 static char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
56 WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE*)wfx;
58 nb_samples=(int)(duration*wfx->nSamplesPerSec);
59 *size=nb_samples*wfx->nBlockAlign;
61 for (i=0;i<nb_samples;i++) {
62 double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
63 if (wfx->wBitsPerSample==8) {
64 unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
65 for (j = 0; j < wfx->nChannels; j++)
67 } else if (wfx->wBitsPerSample==16) {
68 signed short sample=(signed short)((double)32767.5*y-0.5);
69 for (j = 0; j < wfx->nChannels; j++) {
74 } else if (wfx->wBitsPerSample==24) {
75 signed int sample=(signed int)(((double)0x7fffff+0.5)*y-0.5);
76 for (j = 0; j < wfx->nChannels; j++) {
78 b[1]=(sample >> 8) & 0xff;
79 b[2]=(sample >> 16) & 0xff;
82 } else if ((wfx->wBitsPerSample==32) && ((wfx->wFormatTag == WAVE_FORMAT_PCM) ||
83 ((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
84 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)))) {
85 signed int sample=(signed int)(((double)0x7fffffff+0.5)*y-0.5);
86 for (j = 0; j < wfx->nChannels; j++) {
88 b[1]=(sample >> 8) & 0xff;
89 b[2]=(sample >> 16) & 0xff;
90 b[3]=(sample >> 24) & 0xff;
93 } else if ((wfx->wBitsPerSample==32) && (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
94 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
95 union { float f; char c[4]; } sample;
97 for (j = 0; j < wfx->nChannels; j++) {
109 static char* wave_generate_silence(WAVEFORMATEX* wfx, double duration, DWORD* size)
115 WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE*)wfx;
117 nb_samples=(int)(duration*wfx->nSamplesPerSec);
118 *size=nb_samples*wfx->nBlockAlign;
120 for (i=0;i<nb_samples;i++) {
121 if (wfx->wBitsPerSample==8) {
122 for (j = 0; j < wfx->nChannels; j++)
124 } else if (wfx->wBitsPerSample==16) {
125 for (j = 0; j < wfx->nChannels; j++) {
130 } else if (wfx->wBitsPerSample==24) {
131 for (j = 0; j < wfx->nChannels; j++) {
137 } else if ((wfx->wBitsPerSample==32) && ((wfx->wFormatTag == WAVE_FORMAT_PCM) ||
138 ((wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
139 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)))) {
140 for (j = 0; j < wfx->nChannels; j++) {
147 } else if ((wfx->wBitsPerSample==32) && (wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) &&
148 IsEqualGUID(&wfex->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
149 union { float f; char c[4]; } sample;
151 for (j = 0; j < wfx->nChannels; j++) {
163 const char * dev_name(int device)
165 static char name[16];
166 if (device == WAVE_MAPPER)
167 return "WAVE_MAPPER";
168 sprintf(name, "%d", device);
172 const char* mmsys_error(MMRESULT error)
174 #define ERR_TO_STR(dev) case dev: return #dev
175 static char unknown[32];
177 ERR_TO_STR(MMSYSERR_NOERROR);
178 ERR_TO_STR(MMSYSERR_ERROR);
179 ERR_TO_STR(MMSYSERR_BADDEVICEID);
180 ERR_TO_STR(MMSYSERR_NOTENABLED);
181 ERR_TO_STR(MMSYSERR_ALLOCATED);
182 ERR_TO_STR(MMSYSERR_INVALHANDLE);
183 ERR_TO_STR(MMSYSERR_NODRIVER);
184 ERR_TO_STR(MMSYSERR_NOMEM);
185 ERR_TO_STR(MMSYSERR_NOTSUPPORTED);
186 ERR_TO_STR(MMSYSERR_BADERRNUM);
187 ERR_TO_STR(MMSYSERR_INVALFLAG);
188 ERR_TO_STR(MMSYSERR_INVALPARAM);
189 ERR_TO_STR(WAVERR_BADFORMAT);
190 ERR_TO_STR(WAVERR_STILLPLAYING);
191 ERR_TO_STR(WAVERR_UNPREPARED);
192 ERR_TO_STR(WAVERR_SYNC);
193 ERR_TO_STR(MIDIERR_UNPREPARED);
194 ERR_TO_STR(MIDIERR_STILLPLAYING);
195 ERR_TO_STR(MIDIERR_NOTREADY);
196 ERR_TO_STR(MIDIERR_NODEVICE);
197 ERR_TO_STR(MIDIERR_INVALIDSETUP);
198 ERR_TO_STR(TIMERR_NOCANDO);
199 ERR_TO_STR(TIMERR_STRUCT);
200 ERR_TO_STR(JOYERR_PARMS);
201 ERR_TO_STR(JOYERR_NOCANDO);
202 ERR_TO_STR(JOYERR_UNPLUGGED);
203 ERR_TO_STR(MIXERR_INVALLINE);
204 ERR_TO_STR(MIXERR_INVALCONTROL);
205 ERR_TO_STR(MIXERR_INVALVALUE);
206 ERR_TO_STR(MMIOERR_FILENOTFOUND);
207 ERR_TO_STR(MMIOERR_OUTOFMEMORY);
208 ERR_TO_STR(MMIOERR_CANNOTOPEN);
209 ERR_TO_STR(MMIOERR_CANNOTCLOSE);
210 ERR_TO_STR(MMIOERR_CANNOTREAD);
211 ERR_TO_STR(MMIOERR_CANNOTWRITE);
212 ERR_TO_STR(MMIOERR_CANNOTSEEK);
213 ERR_TO_STR(MMIOERR_CANNOTEXPAND);
214 ERR_TO_STR(MMIOERR_CHUNKNOTFOUND);
215 ERR_TO_STR(MMIOERR_UNBUFFERED);
217 sprintf(unknown, "Unknown(0x%08x)", error);
222 const char* wave_out_error(MMRESULT error)
224 static char msg[1024];
225 static char long_msg[1100];
228 rc = waveOutGetErrorText(error, msg, sizeof(msg));
229 if (rc != MMSYSERR_NOERROR)
230 sprintf(long_msg, "waveOutGetErrorText(%x) failed with error %x",
233 sprintf(long_msg, "%s(%s)", mmsys_error(error), msg);
237 const char * wave_open_flags(DWORD flags)
239 static char msg[1024];
242 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_EVENT) {
243 strcat(msg, "CALLBACK_EVENT");
246 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_FUNCTION) {
247 if (!first) strcat(msg, "|");
248 strcat(msg, "CALLBACK_FUNCTION");
251 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_NULL) {
252 if (!first) strcat(msg, "|");
253 strcat(msg, "CALLBACK_NULL");
256 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
257 if (!first) strcat(msg, "|");
258 strcat(msg, "CALLBACK_THREAD");
261 if ((flags & CALLBACK_TYPEMASK) == CALLBACK_WINDOW) {
262 if (!first) strcat(msg, "|");
263 strcat(msg, "CALLBACK_WINDOW");
266 if ((flags & WAVE_ALLOWSYNC) == WAVE_ALLOWSYNC) {
267 if (!first) strcat(msg, "|");
268 strcat(msg, "WAVE_ALLOWSYNC");
271 if ((flags & WAVE_FORMAT_DIRECT) == WAVE_FORMAT_DIRECT) {
272 if (!first) strcat(msg, "|");
273 strcat(msg, "WAVE_FORMAT_DIRECT");
276 if ((flags & WAVE_FORMAT_QUERY) == WAVE_FORMAT_QUERY) {
277 if (!first) strcat(msg, "|");
278 strcat(msg, "WAVE_FORMAT_QUERY");
281 if ((flags & WAVE_MAPPED) == WAVE_MAPPED) {
282 if (!first) strcat(msg, "|");
283 strcat(msg, "WAVE_MAPPED");
289 static const char * wave_out_caps(DWORD dwSupport)
291 #define ADD_FLAG(f) if (dwSupport & f) strcat(msg, " " #f)
292 static char msg[256];
295 ADD_FLAG(WAVECAPS_PITCH);
296 ADD_FLAG(WAVECAPS_PLAYBACKRATE);
297 ADD_FLAG(WAVECAPS_VOLUME);
298 ADD_FLAG(WAVECAPS_LRVOLUME);
299 ADD_FLAG(WAVECAPS_SYNC);
300 ADD_FLAG(WAVECAPS_SAMPLEACCURATE);
302 return msg[0] ? msg + 1 : "";
306 const char * wave_time_format(UINT type)
309 #define TIME_FORMAT(f) case f: return #f
311 TIME_FORMAT(TIME_MS);
312 TIME_FORMAT(TIME_SAMPLES);
313 TIME_FORMAT(TIME_BYTES);
314 TIME_FORMAT(TIME_SMPTE);
315 TIME_FORMAT(TIME_MIDI);
316 TIME_FORMAT(TIME_TICKS);
319 sprintf(msg, "Unknown(0x%04x)", type);
323 const char * get_format_str(WORD format)
326 #define WAVE_FORMAT(f) case f: return #f
328 WAVE_FORMAT(WAVE_FORMAT_PCM);
329 WAVE_FORMAT(WAVE_FORMAT_ADPCM);
330 WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD);
331 WAVE_FORMAT(WAVE_FORMAT_ALAW);
332 WAVE_FORMAT(WAVE_FORMAT_MULAW);
333 WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM);
334 WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM);
335 WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM);
336 WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM);
337 WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM);
338 WAVE_FORMAT(WAVE_FORMAT_DIGISTD);
339 WAVE_FORMAT(WAVE_FORMAT_DIGIFIX);
340 WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM);
341 WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM);
342 WAVE_FORMAT(WAVE_FORMAT_SONARC);
343 WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH);
344 WAVE_FORMAT(WAVE_FORMAT_ECHOSC1);
345 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36);
346 WAVE_FORMAT(WAVE_FORMAT_APTX);
347 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10);
348 WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2);
349 WAVE_FORMAT(WAVE_FORMAT_GSM610);
350 WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME);
351 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC);
352 WAVE_FORMAT(WAVE_FORMAT_DIGIREAL);
353 WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM);
354 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10);
355 WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM);
356 WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM);
357 WAVE_FORMAT(WAVE_FORMAT_MPEG);
358 WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3);
359 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM);
360 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8);
361 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10);
362 WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND);
363 WAVE_FORMAT(WAVE_FORMAT_OLIGSM);
364 WAVE_FORMAT(WAVE_FORMAT_OLIADPCM);
365 WAVE_FORMAT(WAVE_FORMAT_OLICELP);
366 WAVE_FORMAT(WAVE_FORMAT_OLISBC);
367 WAVE_FORMAT(WAVE_FORMAT_OLIOPR);
368 WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT);
369 WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE);
372 sprintf(msg, "Unknown(0x%04x)", format);
376 DWORD bytes_to_samples(DWORD bytes, LPWAVEFORMATEX pwfx)
378 return bytes / pwfx->nBlockAlign;
381 DWORD bytes_to_ms(DWORD bytes, LPWAVEFORMATEX pwfx)
383 return bytes_to_samples(bytes, pwfx) * 1000 / pwfx->nSamplesPerSec;
386 DWORD time_to_bytes(LPMMTIME mmtime, LPWAVEFORMATEX pwfx)
388 if (mmtime->wType == TIME_BYTES)
390 else if (mmtime->wType == TIME_SAMPLES)
391 return mmtime->u.sample * pwfx->nBlockAlign;
392 else if (mmtime->wType == TIME_MS)
393 return mmtime->u.ms * pwfx->nAvgBytesPerSec / 1000;
394 else if (mmtime->wType == TIME_SMPTE)
395 return ((mmtime->u.smpte.hour * 60.0 * 60.0) +
396 (mmtime->u.smpte.min * 60.0) +
397 (mmtime->u.smpte.sec) +
398 (mmtime->u.smpte.frame / 30.0)) * pwfx->nAvgBytesPerSec;
400 trace("FIXME: time_to_bytes() type not supported\n");
404 static void check_position(int device, HWAVEOUT wout, DWORD bytes,
405 LPWAVEFORMATEX pwfx )
413 samples=bytes/(pwfx->wBitsPerSample/8*pwfx->nChannels);
414 duration=((double)samples)/pwfx->nSamplesPerSec;
416 mmtime.wType = TIME_BYTES;
417 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
418 ok(rc==MMSYSERR_NOERROR,
419 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
420 if (mmtime.wType != TIME_BYTES && winetest_debug > 1)
421 trace("waveOutGetPosition(%s): TIME_BYTES not supported, returned %s\n",
422 dev_name(device),wave_time_format(mmtime.wType));
423 returned = time_to_bytes(&mmtime, pwfx);
424 ok(returned == bytes, "waveOutGetPosition(%s): returned %ld bytes, "
425 "should be %ld\n", dev_name(device), returned, bytes);
427 mmtime.wType = TIME_SAMPLES;
428 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
429 ok(rc==MMSYSERR_NOERROR,
430 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
431 if (mmtime.wType != TIME_SAMPLES && winetest_debug > 1)
432 trace("waveOutGetPosition(%s): TIME_SAMPLES not supported, "
433 "returned %s\n",dev_name(device),wave_time_format(mmtime.wType));
434 returned = time_to_bytes(&mmtime, pwfx);
435 ok(returned == bytes, "waveOutGetPosition(%s): returned %ld samples, "
436 "should be %ld\n", dev_name(device), bytes_to_samples(returned, pwfx),
437 bytes_to_samples(bytes, pwfx));
439 mmtime.wType = TIME_MS;
440 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
441 ok(rc==MMSYSERR_NOERROR,
442 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
443 if (mmtime.wType != TIME_MS && winetest_debug > 1)
444 trace("waveOutGetPosition(%s): TIME_MS not supported, returned %s\n",
445 dev_name(device), wave_time_format(mmtime.wType));
446 returned = time_to_bytes(&mmtime, pwfx);
447 ok(returned == bytes, "waveOutGetPosition(%s): returned %ld ms, "
448 "should be %ld\n", dev_name(device), bytes_to_ms(returned, pwfx),
449 bytes_to_ms(bytes, pwfx));
451 mmtime.wType = TIME_SMPTE;
452 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
453 ok(rc==MMSYSERR_NOERROR,
454 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
455 if (mmtime.wType != TIME_SMPTE && winetest_debug > 1)
456 trace("waveOutGetPosition(%s): TIME_SMPTE not supported, returned %s\n",
457 dev_name(device),wave_time_format(mmtime.wType));
458 returned = time_to_bytes(&mmtime, pwfx);
459 ok(returned == bytes, "waveOutGetPosition(%s): SMPTE test failed\n",
462 mmtime.wType = TIME_MIDI;
463 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
464 ok(rc==MMSYSERR_NOERROR,
465 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
466 if (mmtime.wType != TIME_MIDI && winetest_debug > 1)
467 trace("waveOutGetPosition(%s): TIME_MIDI not supported, returned %s\n",
468 dev_name(device),wave_time_format(mmtime.wType));
469 returned = time_to_bytes(&mmtime, pwfx);
470 ok(returned == bytes, "waveOutGetPosition(%s): MIDI test failed\n",
473 mmtime.wType = TIME_TICKS;
474 rc=waveOutGetPosition(wout, &mmtime, sizeof(mmtime));
475 ok(rc==MMSYSERR_NOERROR,
476 "waveOutGetPosition(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
477 if (mmtime.wType != TIME_TICKS && winetest_debug > 1)
478 trace("waveOutGetPosition(%s): TIME_TICKS not supported, returned %s\n",
479 dev_name(device),wave_time_format(mmtime.wType));
480 returned = time_to_bytes(&mmtime, pwfx);
481 ok(returned == bytes, "waveOutGetPosition(%s): TICKS test failed\n",
485 static void wave_out_test_deviceOut(int device, double duration,
486 LPWAVEFORMATEX pwfx, DWORD format,
487 DWORD flags, LPWAVEOUTCAPS pcaps,
488 BOOL interactive, BOOL sine)
495 WORD nChannels = pwfx->nChannels;
496 WORD wBitsPerSample = pwfx->wBitsPerSample;
497 DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
498 BOOL has_volume = pcaps->dwSupport & WAVECAPS_VOLUME;
500 hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
501 ok(hevent!=NULL,"CreateEvent(): error=%ld\n",GetLastError());
506 rc=waveOutOpen(&wout,device,pwfx,(DWORD)hevent,0,CALLBACK_EVENT|flags);
507 /* Note: Win9x doesn't know WAVE_FORMAT_DIRECT */
508 /* It is acceptable to fail on formats that are not specified to work */
509 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
510 rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER ||
511 rc==MMSYSERR_ALLOCATED ||
512 ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
513 (flags & WAVE_FORMAT_DIRECT) && !(pcaps->dwFormats & format)) ||
514 ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
515 (!(flags & WAVE_FORMAT_DIRECT) || (flags & WAVE_MAPPED)) &&
516 !(pcaps->dwFormats & format)) ||
517 (rc==MMSYSERR_INVALFLAG && (flags & WAVE_FORMAT_DIRECT)),
518 "waveOutOpen(%s): format=%ldx%2dx%d flags=%lx(%s) rc=%s\n",
519 dev_name(device),pwfx->nSamplesPerSec,pwfx->wBitsPerSample,
520 pwfx->nChannels,CALLBACK_EVENT|flags,
521 wave_open_flags(CALLBACK_EVENT|flags),wave_out_error(rc));
522 if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
523 (flags & WAVE_FORMAT_DIRECT) && (pcaps->dwFormats & format))
524 trace(" Reason: The device lists this format as supported in it's "
525 "capabilities but opening it failed.\n");
526 if ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
527 !(pcaps->dwFormats & format))
528 trace("waveOutOpen(%s): format=%ldx%2dx%d %s rc=%s failed but format "
529 "not supported so OK.\n", dev_name(device), pwfx->nSamplesPerSec,
530 pwfx->wBitsPerSample,pwfx->nChannels,
531 flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
532 flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
533 if (rc!=MMSYSERR_NOERROR) {
538 ok(pwfx->nChannels==nChannels &&
539 pwfx->wBitsPerSample==wBitsPerSample &&
540 pwfx->nSamplesPerSec==nSamplesPerSec,
541 "got the wrong format: %ldx%2dx%d instead of %ldx%2dx%d\n",
542 pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
543 pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels);
546 frag.lpData=wave_generate_la(pwfx,duration,&frag.dwBufferLength);
548 frag.lpData=wave_generate_silence(pwfx,duration,&frag.dwBufferLength);
553 rc=waveOutGetVolume(wout,&volume);
554 ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
555 "waveOutGetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
557 rc=waveOutPrepareHeader(wout, &frag, sizeof(frag));
558 ok(rc==MMSYSERR_NOERROR,
559 "waveOutPrepareHeader(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
561 if (interactive && rc==MMSYSERR_NOERROR) {
563 trace("Playing %g second %s at %5ldx%2dx%d %s %s\n",duration,
564 sine ? "440Hz tone" : "silence",pwfx->nSamplesPerSec,
565 pwfx->wBitsPerSample,pwfx->nChannels,
566 get_format_str(pwfx->wFormatTag),
567 flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" :
568 flags & WAVE_MAPPED ? "WAVE_MAPPED" : "");
570 trace("*** Warning the sound is muted, you will not hear the test\n");
572 /* Check that the position is 0 at start */
573 check_position(device, wout, 0, pwfx);
575 rc=waveOutSetVolume(wout,0x20002000);
576 ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
577 "waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
578 WaitForSingleObject(hevent,INFINITE);
580 rc=waveOutSetVolume(wout,volume);
581 ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
582 "waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
584 start=GetTickCount();
585 rc=waveOutWrite(wout, &frag, sizeof(frag));
586 ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s): rc=%s\n",
587 dev_name(device),wave_out_error(rc));
588 WaitForSingleObject(hevent,INFINITE);
590 /* Check the sound duration was within 10% of the expected value */
592 if (winetest_debug > 1)
593 trace("sound duration=%ld\n",end-start);
594 ok(fabs(1000*duration-end+start)<=100*duration,
595 "The sound played for %ld ms instead of %g ms\n",
596 end-start,1000*duration);
598 check_position(device, wout, frag.dwBufferLength, pwfx);
601 rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag));
602 ok(rc==MMSYSERR_NOERROR,
603 "waveOutUnprepareHeader(%s): rc=%s\n",dev_name(device),
608 rc=waveOutClose(wout);
609 ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
613 static void wave_out_test_device(int device)
617 WAVEFORMATEX format, oformat;
618 WAVEFORMATEXTENSIBLE wfex;
627 SYSTEM_INFO sSysInfo;
631 GetSystemInfo(&sSysInfo);
632 dwPageSize = sSysInfo.dwPageSize;
634 rc=waveOutGetDevCapsA(device,&capsA,sizeof(capsA));
635 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
636 rc==MMSYSERR_NODRIVER,
637 "waveOutGetDevCapsA(%s): failed to get capabilities: rc=%s\n",
638 dev_name(device),wave_out_error(rc));
639 if (rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER)
642 rc=waveOutGetDevCapsW(device,&capsW,sizeof(capsW));
643 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
644 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
645 "expected, got %s\n",dev_name(device),wave_out_error(rc));
647 rc=waveOutGetDevCapsA(device,0,sizeof(capsA));
648 ok(rc==MMSYSERR_INVALPARAM,
649 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, "
650 "got %s\n",dev_name(device),wave_out_error(rc));
652 rc=waveOutGetDevCapsW(device,0,sizeof(capsW));
653 ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
654 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
655 "expected, got %s\n",dev_name(device),wave_out_error(rc));
657 #if 0 /* FIXME: this works on windows but crashes wine */
658 rc=waveOutGetDevCapsA(device,(LPWAVEOUTCAPSA)1,sizeof(capsA));
659 ok(rc==MMSYSERR_INVALPARAM,
660 "waveOutGetDevCapsA(%s): MMSYSERR_INVALPARAM expected, got %s\n",
661 dev_name(device),wave_out_error(rc));
663 rc=waveOutGetDevCapsW(device,(LPWAVEOUTCAPSW)1,sizeof(capsW));
664 ok(rc==MMSYSERR_INVALPARAM || rc==MMSYSERR_NOTSUPPORTED,
665 "waveOutGetDevCapsW(%s): MMSYSERR_INVALPARAM or MMSYSERR_NOTSUPPORTED "
666 "expected, got %s\n",dev_name(device),wave_out_error(rc));
669 rc=waveOutGetDevCapsA(device,&capsA,4);
670 ok(rc==MMSYSERR_NOERROR,
671 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
672 dev_name(device),wave_out_error(rc));
674 rc=waveOutGetDevCapsW(device,&capsW,4);
675 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
676 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
677 "expected, got %s\n",dev_name(device),wave_out_error(rc));
680 rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACESIZE,
681 (DWORD_PTR)&size, 0);
682 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_INVALPARAM ||
683 rc==MMSYSERR_NOTSUPPORTED,
684 "waveOutMessage(%s): failed to get interface size, rc=%s\n",
685 dev_name(device),wave_out_error(rc));
686 if (rc==MMSYSERR_NOERROR) {
687 nameW = (WCHAR *)malloc(size);
688 rc=waveOutMessage((HWAVEOUT)device, DRV_QUERYDEVICEINTERFACE,
689 (DWORD_PTR)nameW, size);
690 ok(rc==MMSYSERR_NOERROR,"waveOutMessage(%s): failed to get interface "
691 "name, rc=%s\n",dev_name(device),wave_out_error(rc));
692 ok(lstrlenW(nameW)+1==size/sizeof(WCHAR),"got an incorrect size: "
693 "%ld instead of %d\n",size,(lstrlenW(nameW)+1)*sizeof(WCHAR));
694 if (rc==MMSYSERR_NOERROR) {
695 nameA = malloc(size/sizeof(WCHAR));
696 WideCharToMultiByte(CP_ACP, 0, nameW, size/sizeof(WCHAR), nameA,
697 size/sizeof(WCHAR), NULL, NULL);
701 else if (rc==MMSYSERR_NOTSUPPORTED) {
702 nameA=strdup("not supported");
705 trace(" %s: \"%s\" (%s) %d.%d (%d:%d)\n",dev_name(device),capsA.szPname,
706 (nameA?nameA:"failed"),capsA.vDriverVersion >> 8,
707 capsA.vDriverVersion & 0xff, capsA.wMid,capsA.wPid);
708 trace(" channels=%d formats=%05lx support=%04lx\n",
709 capsA.wChannels,capsA.dwFormats,capsA.dwSupport);
710 trace(" %s\n",wave_out_caps(capsA.dwSupport));
713 if (winetest_interactive && (device != WAVE_MAPPER))
715 trace("Playing a 5 seconds reference tone.\n");
716 trace("All subsequent tones should be identical to this one.\n");
717 trace("Listen for stutter, changes in pitch, volume, etc.\n");
718 format.wFormatTag=WAVE_FORMAT_PCM;
720 format.wBitsPerSample=8;
721 format.nSamplesPerSec=22050;
722 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
723 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
725 wave_out_test_deviceOut(device,5.0,&format,WAVE_FORMAT_2M08,0,&capsA,
728 format.wFormatTag=WAVE_FORMAT_PCM;
730 format.wBitsPerSample=8;
731 format.nSamplesPerSec=22050;
732 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
733 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
735 wave_out_test_deviceOut(device,1.0,&format,WAVE_FORMAT_2M08,0,&capsA,
739 for (f=0;f<NB_WIN_FORMATS;f++) {
740 format.wFormatTag=WAVE_FORMAT_PCM;
741 format.nChannels=win_formats[f][3];
742 format.wBitsPerSample=win_formats[f][2];
743 format.nSamplesPerSec=win_formats[f][1];
744 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
745 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
747 wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],
748 0,&capsA,winetest_interactive,TRUE);
749 if (device != WAVE_MAPPER)
751 wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],
752 WAVE_FORMAT_DIRECT,&capsA,winetest_interactive,
754 wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],
755 WAVE_MAPPED,&capsA,winetest_interactive,
760 /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds
762 twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT,
764 ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
766 res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS,
768 ok(res, "Failed to set memory access on second page\n");
770 LPWAVEFORMATEX pwfx = (LPWAVEFORMATEX)(twoPages + dwPageSize -
771 sizeof(PCMWAVEFORMAT));
772 pwfx->wFormatTag=WAVE_FORMAT_PCM;
774 pwfx->wBitsPerSample=8;
775 pwfx->nSamplesPerSec=22050;
776 pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
777 pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
778 wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,0,
779 &capsA,winetest_interactive,TRUE);
780 if (device != WAVE_MAPPER)
782 wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,
783 WAVE_FORMAT_DIRECT,&capsA,
784 winetest_interactive,TRUE);
785 wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,
786 WAVE_MAPPED,&capsA,winetest_interactive,
790 VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
793 /* Testing invalid format: 11 bits per sample */
794 format.wFormatTag=WAVE_FORMAT_PCM;
796 format.wBitsPerSample=11;
797 format.nSamplesPerSec=22050;
798 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
799 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
802 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
803 ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG ||
804 rc==MMSYSERR_INVALPARAM,
805 "waveOutOpen(%s): opening the device in 11 bits mode should fail: "
806 "rc=%s\n",dev_name(device),wave_out_error(rc));
807 if (rc==MMSYSERR_NOERROR) {
808 trace(" got %ldx%2dx%d for %ldx%2dx%d\n",
809 format.nSamplesPerSec, format.wBitsPerSample,
811 oformat.nSamplesPerSec, oformat.wBitsPerSample,
816 /* Testing invalid format: 2 MHz sample rate */
817 format.wFormatTag=WAVE_FORMAT_PCM;
819 format.wBitsPerSample=16;
820 format.nSamplesPerSec=2000000;
821 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
822 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
825 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
826 ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG ||
827 rc==MMSYSERR_INVALPARAM,
828 "waveOutOpen(%s): opening the device at 2 MHz sample rate should fail: "
829 "rc=%s\n",dev_name(device),wave_out_error(rc));
830 if (rc==MMSYSERR_NOERROR) {
831 trace(" got %ldx%2dx%d for %ldx%2dx%d\n",
832 format.nSamplesPerSec, format.wBitsPerSample,
834 oformat.nSamplesPerSec, oformat.wBitsPerSample,
839 /* try some non PCM formats */
840 format.wFormatTag=WAVE_FORMAT_MULAW;
842 format.wBitsPerSample=8;
843 format.nSamplesPerSec=8000;
844 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
845 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
848 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
849 ok(rc==MMSYSERR_NOERROR ||rc==WAVERR_BADFORMAT ||
850 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
851 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
852 if (rc==MMSYSERR_NOERROR) {
854 wave_out_test_deviceOut(device,1.0,&format,0,0,
855 &capsA,winetest_interactive,TRUE);
857 trace("waveOutOpen(%s): WAVE_FORMAT_MULAW not supported\n",
860 format.wFormatTag=WAVE_FORMAT_ADPCM;
862 format.wBitsPerSample=4;
863 format.nSamplesPerSec=22050;
864 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
865 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
868 rc=waveOutOpen(&wout,device,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
869 ok(rc==MMSYSERR_NOERROR ||rc==WAVERR_BADFORMAT ||
870 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
871 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
872 if (rc==MMSYSERR_NOERROR) {
874 wave_out_test_deviceOut(device,1.0,&format,0,0,
875 &capsA,winetest_interactive,TRUE);
877 trace("waveOutOpen(%s): WAVE_FORMAT_ADPCM not supported\n",
880 /* test if WAVEFORMATEXTENSIBLE supported */
881 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
882 wfex.Format.nChannels=2;
883 wfex.Format.wBitsPerSample=16;
884 wfex.Format.nSamplesPerSec=22050;
885 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
886 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
887 wfex.Format.nBlockAlign;
888 wfex.Format.cbSize=22;
889 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
890 wfex.dwChannelMask=SPEAKER_ALL;
891 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
892 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
893 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
894 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
895 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
896 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
897 if (rc==MMSYSERR_NOERROR) {
899 wave_out_test_deviceOut(device,1.0,&wfex.Format,WAVE_FORMAT_2M16,0,
900 &capsA,winetest_interactive,TRUE);
902 trace("waveOutOpen(%s): WAVE_FORMAT_EXTENSIBLE not supported\n",
905 /* test if 4 channels supported */
906 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
907 wfex.Format.nChannels=4;
908 wfex.Format.wBitsPerSample=16;
909 wfex.Format.nSamplesPerSec=22050;
910 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
911 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
912 wfex.Format.nBlockAlign;
913 wfex.Format.cbSize=22;
914 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
915 wfex.dwChannelMask=SPEAKER_ALL;
916 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
917 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
918 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
919 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
920 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
921 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
922 if (rc==MMSYSERR_NOERROR) {
924 wave_out_test_deviceOut(device,1.0,&wfex.Format,0,0,
925 &capsA,winetest_interactive,TRUE);
927 trace("waveOutOpen(%s): 4 channels not supported\n",
930 /* test if 6 channels supported */
931 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
932 wfex.Format.nChannels=6;
933 wfex.Format.wBitsPerSample=16;
934 wfex.Format.nSamplesPerSec=22050;
935 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
936 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
937 wfex.Format.nBlockAlign;
938 wfex.Format.cbSize=22;
939 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
940 wfex.dwChannelMask=SPEAKER_ALL;
941 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
942 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
943 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
944 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
945 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
946 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
947 if (rc==MMSYSERR_NOERROR) {
949 wave_out_test_deviceOut(device,1.0,&wfex.Format,WAVE_FORMAT_2M16,0,
950 &capsA,winetest_interactive,TRUE);
952 trace("waveOutOpen(%s): 6 channels not supported\n",
955 #if 0 /* ALSA doesn't like this format */
956 /* test if 24 bit samples supported */
957 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
958 wfex.Format.nChannels=2;
959 wfex.Format.wBitsPerSample=24;
960 wfex.Format.nSamplesPerSec=22050;
961 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
962 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
963 wfex.Format.nBlockAlign;
964 wfex.Format.cbSize=22;
965 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
966 wfex.dwChannelMask=SPEAKER_ALL;
967 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
968 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
969 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
970 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
971 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
972 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
973 if (rc==MMSYSERR_NOERROR) {
975 wave_out_test_deviceOut(device,1.0,&wfex.Format,WAVE_FORMAT_2M16,0,
976 &capsA,winetest_interactive,TRUE);
978 trace("waveOutOpen(%s): 24 bit samples not supported\n",
982 /* test if 32 bit samples supported */
983 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
984 wfex.Format.nChannels=2;
985 wfex.Format.wBitsPerSample=32;
986 wfex.Format.nSamplesPerSec=22050;
987 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
988 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
989 wfex.Format.nBlockAlign;
990 wfex.Format.cbSize=22;
991 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
992 wfex.dwChannelMask=SPEAKER_ALL;
993 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
994 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
995 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
996 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
997 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
998 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
999 if (rc==MMSYSERR_NOERROR) {
1001 wave_out_test_deviceOut(device,1.0,&wfex.Format,WAVE_FORMAT_2M16,0,
1002 &capsA,winetest_interactive,TRUE);
1004 trace("waveOutOpen(%s): 32 bit samples not supported\n",
1007 /* test if 32 bit float samples supported */
1008 wfex.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
1009 wfex.Format.nChannels=2;
1010 wfex.Format.wBitsPerSample=32;
1011 wfex.Format.nSamplesPerSec=22050;
1012 wfex.Format.nBlockAlign=wfex.Format.nChannels*wfex.Format.wBitsPerSample/8;
1013 wfex.Format.nAvgBytesPerSec=wfex.Format.nSamplesPerSec*
1014 wfex.Format.nBlockAlign;
1015 wfex.Format.cbSize=22;
1016 wfex.Samples.wValidBitsPerSample=wfex.Format.wBitsPerSample;
1017 wfex.dwChannelMask=SPEAKER_ALL;
1018 wfex.SubFormat=KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
1019 rc=waveOutOpen(&wout,device,&wfex.Format,0,0,
1020 CALLBACK_NULL|WAVE_FORMAT_DIRECT);
1021 ok(rc==MMSYSERR_NOERROR || rc==WAVERR_BADFORMAT ||
1022 rc==MMSYSERR_INVALFLAG || rc==MMSYSERR_INVALPARAM,
1023 "waveOutOpen(%s): returned %s\n",dev_name(device),wave_out_error(rc));
1024 if (rc==MMSYSERR_NOERROR) {
1026 wave_out_test_deviceOut(device,1.0,&wfex.Format,WAVE_FORMAT_2M16,0,
1027 &capsA,winetest_interactive,TRUE);
1029 trace("waveOutOpen(%s): 32 bit float samples not supported\n",
1033 static void wave_out_tests()
1037 WAVEFORMATEX format;
1042 ndev=waveOutGetNumDevs();
1043 trace("found %d WaveOut devices\n",ndev);
1045 rc=waveOutGetDevCapsA(ndev+1,&capsA,sizeof(capsA));
1046 ok(rc==MMSYSERR_BADDEVICEID,
1047 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1048 dev_name(ndev+1),mmsys_error(rc));
1050 rc=waveOutGetDevCapsW(ndev+1,&capsW,sizeof(capsW));
1051 ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NOTSUPPORTED,
1052 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NOTSUPPORTED "
1053 "expected, got %s\n",dev_name(ndev+1),mmsys_error(rc));
1055 rc=waveOutGetDevCapsA(WAVE_MAPPER,&capsA,sizeof(capsA));
1057 ok(rc==MMSYSERR_NOERROR,
1058 "waveOutGetDevCapsA(%s): MMSYSERR_NOERROR expected, got %s\n",
1059 dev_name(WAVE_MAPPER),mmsys_error(rc));
1061 ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER,
1062 "waveOutGetDevCapsA(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1063 "expected, got %s\n",dev_name(WAVE_MAPPER),mmsys_error(rc));
1065 rc=waveOutGetDevCapsW(WAVE_MAPPER,&capsW,sizeof(capsW));
1067 ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_NOTSUPPORTED,
1068 "waveOutGetDevCapsW(%s): MMSYSERR_NOERROR or MMSYSERR_NOTSUPPORTED "
1069 "expected, got %s\n",dev_name(WAVE_MAPPER),mmsys_error(rc));
1071 ok(rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_NODRIVER ||
1072 rc==MMSYSERR_NOTSUPPORTED,
1073 "waveOutGetDevCapsW(%s): MMSYSERR_BADDEVICEID or MMSYSERR_NODRIVER "
1074 " or MMSYSERR_NOTSUPPORTED expected, got %s\n",
1075 dev_name(WAVE_MAPPER),mmsys_error(rc));
1077 format.wFormatTag=WAVE_FORMAT_PCM;
1079 format.wBitsPerSample=16;
1080 format.nSamplesPerSec=44100;
1081 format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
1082 format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
1084 rc=waveOutOpen(&wout,ndev+1,&format,0,0,CALLBACK_NULL);
1085 ok(rc==MMSYSERR_BADDEVICEID,
1086 "waveOutOpen(%s): MMSYSERR_BADDEVICEID expected, got %s\n",
1087 dev_name(ndev+1),mmsys_error(rc));
1089 for (d=0;d<ndev;d++)
1090 wave_out_test_device(d);
1093 wave_out_test_device(WAVE_MAPPER);