push 87b6981010d7405c33b14cddcceec21b47729eba
[wine/hacks.git] / dlls / winmm / tests / midi.c
blob4a39cfc7f5f48adec4719981715d32ace4238963
1 /*
2 * Test winmm midi
4 * Copyright 2010 Jörg Höhle
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdio.h>
22 #include "windows.h"
23 #include "mmsystem.h"
24 #include "wine/test.h"
26 extern const char* mmsys_error(MMRESULT error); /* from wave.c */
28 /* Test in order of increasing probability to hang.
29 * On many UNIX systems, the Timidity softsynth provides
30 * MIDI sequencer services and it is not particularly robust.
33 #define MYCBINST 0x4CAFE5A8 /* not used with window or thread callbacks */
34 #define WHATEVER 0xFEEDF00D
36 static BOOL spurious_message(LPMSG msg)
38 /* WM_DEVICECHANGE 0x0219 appears randomly */
39 if(msg->message == WM_DEVICECHANGE) {
40 trace("skipping spurious message %04x\n", msg->message);
41 return TRUE;
43 return FALSE;
46 static UINT cbmsg = 0;
47 static DWORD_PTR cbval1 = WHATEVER;
48 static DWORD_PTR cbval2 = 0;
49 static DWORD_PTR cbinst = MYCBINST;
51 static void CALLBACK callback_func(HWAVEOUT hwo, UINT uMsg,
52 DWORD_PTR dwInstance,
53 DWORD_PTR dwParam1, DWORD_PTR dwParam2)
55 if (winetest_debug>1)
56 trace("Callback! msg=%x %lx %lx\n", uMsg, dwParam1, dwParam2);
57 cbmsg = uMsg;
58 cbval1 = dwParam1; /* mhdr or 0 */
59 cbval2 = dwParam2; /* always 0 */
60 cbinst = dwInstance; /* MYCBINST, see midiOut/StreamOpen */
63 static void test_notification(HWND hwnd, const char* command, UINT m1, DWORD_PTR p2)
64 { /* Use message type 0 as meaning no message */
65 MSG msg;
66 if (hwnd) {
67 /* msg.wParam is hmidiout, msg.lParam is the mhdr (or 0) */
68 BOOL seen;
69 do { seen = PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE); }
70 while(seen && spurious_message(&msg));
71 if (seen) {
72 trace("Message %x, wParam=%lx, lParam=%lx from %s\n",
73 msg.message, msg.wParam, msg.lParam, command);
74 ok(msg.hwnd==hwnd, "Didn't get the handle to our test window\n");
75 ok(msg.message==m1 && msg.lParam==p2, "bad message %x/%lx from %s, expect %x/%lx\n", msg.message, msg.lParam, command, m1, p2);
77 else ok(m1==0, "Expect message %x from %s\n", m1, command);
79 else {
80 /* FIXME: MOM_POSITIONCB and MOM_DONE are so close that a queue is needed. */
81 if (cbmsg) {
82 ok(cbmsg==m1 && cbval1==p2 && cbval2==0, "bad callback %x/%lx/%lx from %s, expect %x/%lx\n", cbmsg, cbval1, cbval2, command, m1, p2);
83 cbmsg = 0; /* Mark as read */
84 cbval1 = cbval2 = WHATEVER;
85 ok(cbinst==MYCBINST, "callback dwInstance changed to %lx\n", cbinst);
87 else ok(m1==0, "Expect callback %x from %s\n", m1, command);
92 static void test_midiIn_device(UINT udev, HWND hwnd)
94 HMIDIIN hm;
95 MMRESULT rc;
96 MIDIINCAPSA capsA;
97 MIDIHDR mhdr;
99 rc = midiInGetDevCapsA(udev, &capsA, sizeof(capsA));
100 ok((MIDIMAPPER==udev) ? (rc==MMSYSERR_BADDEVICEID || broken(rc==MMSYSERR_NODRIVER /*nt,w2k*/)) : rc==0,
101 "midiInGetDevCaps(dev=%d) rc=%s\n", udev, mmsys_error(rc));
102 if (!rc) {
103 /* MIDI IN capsA.dwSupport may contain garbage, absent in old MS-Windows */
104 trace("* %s: manufacturer=%d, product=%d, support=%X\n", capsA.szPname, capsA.wMid, capsA.wPid, capsA.dwSupport);
107 if (hwnd)
108 rc = midiInOpen(&hm, udev, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
109 else
110 rc = midiInOpen(&hm, udev, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
111 ok((MIDIMAPPER!=udev) ? rc==0 : (rc==MMSYSERR_BADDEVICEID || broken(rc==MMSYSERR_NODRIVER /*nt,w2k*/)),
112 "midiInOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
113 if (rc) return;
115 test_notification(hwnd, "midiInOpen", MIM_OPEN, 0);
117 mhdr.dwFlags = 0;
118 mhdr.dwUser = 0x56FA552C;
119 mhdr.dwBufferLength = 70000; /* > 64KB! */
120 mhdr.lpData = HeapAlloc(GetProcessHeap(), 0 , mhdr.dwBufferLength);
121 ok(mhdr.lpData!=NULL, "No %d bytes of memory!\n", mhdr.dwBufferLength);
122 if (mhdr.lpData) {
123 rc = midiInPrepareHeader(hm, &mhdr, sizeof(mhdr));
124 ok(!rc, "midiInPrepare rc=%s\n", mmsys_error(rc));
125 rc = midiInUnprepareHeader(hm, &mhdr, sizeof(mhdr));
126 ok(!rc, "midiInUnprepare rc=%s\n", mmsys_error(rc));
127 trace("MIDIHDR flags=%x when unsent\n", mhdr.dwFlags);
129 HeapFree(GetProcessHeap(), 0, mhdr.lpData);
131 ok(mhdr.dwUser==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr.dwUser);
133 rc = midiInReset(hm); /* Return any pending buffer */
134 ok(!rc, "midiInReset rc=%s\n", mmsys_error(rc));
136 rc = midiInClose(hm);
137 ok(!rc, "midiInClose rc=%s\n", mmsys_error(rc));
138 test_notification(hwnd, "midiInClose", MIM_CLOSE, 0);
139 test_notification(hwnd, "midiIn over", 0, WHATEVER);
142 static void test_midi_infns(HWND hwnd)
144 HMIDIIN hm;
145 MMRESULT rc;
146 UINT udev, ndevs = midiInGetNumDevs();
148 rc = midiInOpen(&hm, ndevs, 0, 0, CALLBACK_NULL);
149 ok(rc==MMSYSERR_BADDEVICEID, "midiInOpen udev>max rc=%s\n", mmsys_error(rc));
150 if (!rc) {
151 rc = midiInClose(hm);
152 ok(!rc, "midiInClose rc=%s\n", mmsys_error(rc));
154 if (!ndevs) {
155 trace("Found no MIDI IN device\n"); /* no skip for this common situation */
156 rc = midiInOpen(&hm, MIDIMAPPER, 0, 0, CALLBACK_NULL);
157 ok(rc==MMSYSERR_BADDEVICEID || broken(rc==MMSYSERR_NODRIVER /*nt,w2k*/), "midiInOpen MAPPER with no MIDI rc=%s\n", mmsys_error(rc));
158 if (!rc) {
159 rc = midiInClose(hm);
160 ok(!rc, "midiInClose rc=%s\n", mmsys_error(rc));
162 return;
164 trace("Found %d MIDI IN devices\n", ndevs);
165 for (udev=0; udev < ndevs; udev++) {
166 trace("** Testing device %d\n", udev);
167 test_midiIn_device(udev, hwnd);
168 Sleep(50);
170 trace("** Testing MIDI mapper\n");
171 test_midiIn_device(MIDIMAPPER, hwnd);
175 static void test_midi_mci(HWND hwnd)
177 MCIERROR err;
178 char buf[1024];
179 memset(buf, 0, sizeof(buf));
181 err = mciSendString("sysinfo sequencer quantity", buf, sizeof(buf), hwnd);
182 ok(!err, "mci sysinfo sequencer quantity returned %d\n", err);
183 if (!err) trace("Found %s MCI sequencer devices\n", buf);
187 static void test_midiOut_device(UINT udev, HWND hwnd)
189 HMIDIOUT hm;
190 MMRESULT rc;
191 MIDIOUTCAPSA capsA;
192 DWORD ovolume;
193 MIDIHDR mhdr;
195 rc = midiOutGetDevCapsA(udev, &capsA, sizeof(capsA));
196 ok(!rc, "midiOutGetDevCaps(dev=%d) rc=%s\n", udev, mmsys_error(rc));
197 if (!rc) {
198 trace("* %s: manufacturer=%d, product=%d, tech=%d, support=%X: %d voices, %d notes\n",
199 capsA.szPname, capsA.wMid, capsA.wPid, capsA.wTechnology, capsA.dwSupport, capsA.wVoices, capsA.wNotes);
202 if (hwnd)
203 rc = midiOutOpen(&hm, udev, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
204 else
205 rc = midiOutOpen(&hm, udev, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
206 ok(!rc, "midiOutOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
207 if (rc) return;
209 test_notification(hwnd, "midiOutOpen", MOM_OPEN, 0);
211 rc = midiOutGetVolume(hm, &ovolume);
212 ok(rc==((capsA.dwSupport & MIDICAPS_VOLUME) ? MMSYSERR_NOERROR : MMSYSERR_NOTSUPPORTED), "midiOutGetVolume rc=%s\n", mmsys_error(rc));
213 /* The native mapper responds with FFFFFFFF initially,
214 * real devices with the volume GUI SW-synth settings. */
215 if (!rc) trace("Current volume %x on device %d\n", ovolume, udev);
217 /* Tests with midiOutSetvolume show that the midi mapper forwards
218 * the value to the real device, but Get initially always reports
219 * FFFFFFFF. Therefore, a Get+SetVolume pair with the mapper is
220 * not adequate to restore the value prior to tests.
222 if (winetest_interactive && (capsA.dwSupport & MIDICAPS_VOLUME)) {
223 DWORD volume2 = (ovolume < 0x80000000) ? 0xC000C000 : 0x40004000;
224 rc = midiOutSetVolume(hm, volume2);
225 ok(!rc, "midiOutSetVolume rc=%s\n", mmsys_error(rc));
226 if (!rc) {
227 DWORD volume3;
228 rc = midiOutGetVolume(hm, &volume3);
229 ok(!rc, "midiOutGetVolume new rc=%s\n", mmsys_error(rc));
230 if (!rc) trace("New volume %x on device %d\n", volume3, udev);
231 todo_wine ok(volume2==volume3, "volume Set %x = Get %x\n", volume2, volume3);
233 rc = midiOutSetVolume(hm, ovolume);
234 ok(!rc, "midiOutSetVolume restore rc=%s\n", mmsys_error(rc));
237 rc = midiOutGetDevCapsA((UINT)hm, &capsA, sizeof(capsA));
238 ok(!rc, "midiOutGetDevCaps(dev=%d) by handle rc=%s\n", udev, mmsys_error(rc));
239 rc = midiInGetDevCapsA((UINT)hm, (LPMIDIINCAPSA)&capsA, sizeof(DWORD));
240 ok(rc==MMSYSERR_BADDEVICEID, "midiInGetDevCaps(dev=%d) by out handle rc=%s\n", udev, mmsys_error(rc));
242 { DWORD e = 0x006F4893; /* velocity, note (#69 would be 440Hz) channel */
243 trace("ShortMsg type %x\n", LOBYTE(LOWORD(e)));
244 rc = midiOutShortMsg(hm, e);
245 ok(!rc, "midiOutShortMsg rc=%s\n", mmsys_error(rc));
246 if (!rc) Sleep(400); /* Hear note */
249 mhdr.dwFlags = 0;
250 mhdr.dwUser = 0x56FA552C;
251 mhdr.dwBufferLength = 70000; /* > 64KB! */
252 mhdr.lpData = HeapAlloc(GetProcessHeap(), 0 , mhdr.dwBufferLength);
253 ok(mhdr.lpData!=NULL, "No %d bytes of memory!\n", mhdr.dwBufferLength);
254 if (mhdr.lpData) {
255 rc = midiOutLongMsg(hm, &mhdr, sizeof(mhdr));
256 ok(rc==MIDIERR_UNPREPARED, "midiOutLongMsg unprepared rc=%s\n", mmsys_error(rc));
257 test_notification(hwnd, "midiOutLong unprepared", 0, WHATEVER);
259 rc = midiOutPrepareHeader(hm, &mhdr, sizeof(mhdr));
260 ok(!rc, "midiOutPrepare rc=%s\n", mmsys_error(rc));
261 rc = midiOutUnprepareHeader(hm, &mhdr, sizeof(mhdr));
262 ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
263 trace("MIDIHDR flags=%x when unsent\n", mhdr.dwFlags);
265 HeapFree(GetProcessHeap(), 0, mhdr.lpData);
267 ok(mhdr.dwUser==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr.dwUser);
269 rc = midiOutReset(hm); /* Quiet everything */
270 ok(!rc, "midiOutReset rc=%s\n", mmsys_error(rc));
272 rc = midiOutClose(hm);
273 ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc));
274 test_notification(hwnd, "midiOutClose", MOM_CLOSE, 0);
275 test_notification(hwnd, "midiOut over", 0, WHATEVER);
278 static void test_position(HMIDISTRM hm, UINT typein, UINT typeout)
280 MMRESULT rc;
281 MMTIME mmtime;
282 mmtime.wType = typein;
283 rc = midiStreamPosition(hm, &mmtime, sizeof(MMTIME));
284 /* Ugly, but a single ok() herein enables using the todo_wine prefix */
285 ok(!rc && (mmtime.wType == typeout), "midiStreamPosition type %x converted to %x rc=%s\n", typein, mmtime.wType, mmsys_error(rc));
286 if (!rc) switch(mmtime.wType) {
287 case TIME_MS:
288 trace("Stream position %ums\n", mmtime.u.ms);
289 break;
290 case TIME_TICKS:
291 trace("Stream position %u ticks\n", mmtime.u.ticks);
292 break;
293 case TIME_MIDI:
294 trace("Stream position song pointer %u\n", mmtime.u.midi.songptrpos);
295 break;
299 static BYTE strmEvents[] = { /* A set of variable-sized MIDIEVENT structs */
300 0, 0, 0, 0, 0, 0, 0, 0, /* dwDeltaTime and dwStreamID */
301 0, 0, 0, MEVT_NOP | 0x40, /* with MEVT_F_CALLBACK */
302 0, 0, 0, 0, 0, 0, 0, 0, /* dwDeltaTime and dwStreamID */
303 0x93, 0x48, 0x6F, MEVT_SHORTMSG,
306 static void test_midiStream(UINT udev, HWND hwnd)
308 HMIDISTRM hm;
309 MMRESULT rc, rc2;
310 MIDIHDR mhdr;
312 if (hwnd)
313 rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
314 else
315 rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)callback_func, (DWORD_PTR)MYCBINST, CALLBACK_FUNCTION);
316 ok(!rc, "midiStreamOpen(dev=%d) rc=%s\n", udev, mmsys_error(rc));
317 if (rc) return;
319 test_notification(hwnd, "midiStreamOpen", MOM_OPEN, 0);
321 mhdr.dwFlags = 0;
322 mhdr.dwUser = 0x56FA552C;
323 mhdr.dwBufferLength = sizeof(strmEvents) * sizeof(strmEvents[0]);
324 mhdr.dwBytesRecorded = mhdr.dwBufferLength; /* unused? */
325 mhdr.lpData = (LPSTR)&strmEvents[0];
326 if (mhdr.lpData) {
327 rc = midiOutLongMsg((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
328 ok(rc==MIDIERR_UNPREPARED, "midiOutLongMsg unprepared rc=%s\n", mmsys_error(rc));
329 test_notification(hwnd, "midiOutLong unprepared", 0, WHATEVER);
331 rc = midiOutPrepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
332 ok(!rc, "midiOutPrepare rc=%s\n", mmsys_error(rc));
333 ok(mhdr.dwFlags & MHDR_PREPARED, "MHDR.dwFlags when prepared %x\n", mhdr.dwFlags);
335 /* The device is still in paused mode and should queue the message. */
336 rc = midiStreamOut(hm, &mhdr, sizeof(mhdr));
337 ok(!rc, "midiStreamOut rc=%s\n", mmsys_error(rc));
338 rc2 = rc;
339 trace("MIDIHDR flags=%x when submitted\n", mhdr.dwFlags);
340 /* w9X/me does not set MHDR_ISSTRM when StreamOut exits,
341 * but it will be set on all systems after the job is finished. */
343 Sleep(90);
344 /* Wine <1.1.39 started playing immediately */
345 test_notification(hwnd, "midiStream still paused", 0, WHATEVER);
347 /* MSDN asks to use midiStreamRestart prior to midiStreamOut()
348 * because the starting state is 'pause', but some apps seem to
349 * work with the inverse order.
352 rc = midiStreamRestart(hm);
353 ok(!rc, "midiStreamRestart rc=%s\n", mmsys_error(rc));
355 if (!rc2) while(mhdr.dwFlags & MHDR_INQUEUE) {
356 trace("async MIDI still queued\n");
357 Sleep(100);
358 } /* Checking INQUEUE is not the recommended way to wait for the end of a job, but we're testing. */
359 /* MHDR_ISSTRM is not necessarily set when midiStreamOut returns
360 * rather than when the queue is eventually processed. */
361 ok(mhdr.dwFlags & MHDR_ISSTRM, "MHDR.dwFlags %x no ISSTRM when out of queue\n", mhdr.dwFlags);
362 if (!rc2) while(!(mhdr.dwFlags & MHDR_DONE)) {
363 /* Never to be seen except perhaps on multicore */
364 trace("async MIDI still not done\n");
365 Sleep(100);
367 ok(mhdr.dwFlags & MHDR_DONE, "MHDR.dwFlags %x not DONE when out of queue\n", mhdr.dwFlags);
368 test_notification(hwnd, "midiStream callback", MOM_POSITIONCB, (DWORD)&mhdr);
369 test_notification(hwnd, "midiStreamOut", MOM_DONE, (DWORD)&mhdr);
371 rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
372 ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
373 rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
374 ok(!rc, "midiOutUnprepare #2 rc=%s\n", mmsys_error(rc));
376 trace("MIDIHDR stream flags=%x when finished\n", mhdr.dwFlags);
377 ok(mhdr.dwFlags & MHDR_DONE, "MHDR.dwFlags when done %x\n", mhdr.dwFlags);
379 test_position(hm, TIME_MS, TIME_MS);
380 test_position(hm, TIME_TICKS, TIME_TICKS);
381 todo_wine test_position(hm, TIME_MIDI, TIME_MIDI);
382 test_position(hm, TIME_SMPTE, TIME_MS);
383 test_position(hm, TIME_SAMPLES, TIME_MS);
384 test_position(hm, TIME_BYTES, TIME_MS);
386 Sleep(400); /* Hear note */
388 rc = midiStreamRestart(hm);
389 ok(!rc, "midiStreamRestart #2 rc=%s\n", mmsys_error(rc));
391 mhdr.dwFlags |= MHDR_ISSTRM; /* just in case */
392 /* Preset flags (e.g. MHDR_ISSTRM) do not disturb. */
393 rc = midiOutPrepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
394 ok(!rc, "midiOutPrepare used flags %x rc=%s\n", mhdr.dwFlags, mmsys_error(rc));
395 rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
396 ok(!rc, "midiOutUnprepare used flags %x rc=%s\n", mhdr.dwFlags, mmsys_error(rc));
398 rc = midiStreamRestart(hm);
399 ok(!rc, "midiStreamRestart #3 rc=%s\n", mmsys_error(rc));
401 ok(mhdr.dwUser==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr.dwUser);
403 rc = midiStreamStop(hm);
404 ok(!rc, "midiStreamStop rc=%s\n", mmsys_error(rc));
406 mhdr.dwBufferLength = 70000; /* > 64KB! */
407 mhdr.lpData = HeapAlloc(GetProcessHeap(), 0 , mhdr.dwBufferLength);
408 ok(mhdr.lpData!=NULL, "No %d bytes of memory!\n", mhdr.dwBufferLength);
409 if (mhdr.lpData) {
410 mhdr.dwFlags = 0;
411 /* PrepareHeader detects the too large buffer is for a stream. */
412 rc = midiOutPrepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
413 todo_wine ok(rc==MMSYSERR_INVALPARAM, "midiOutPrepare stream too large rc=%s\n", mmsys_error(rc));
415 rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr));
416 ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc));
418 HeapFree(GetProcessHeap(), 0, mhdr.lpData);
421 rc = midiStreamClose(hm);
422 ok(!rc, "midiStreamClose rc=%s\n", mmsys_error(rc));
423 test_notification(hwnd, "midiStreamClose", MOM_CLOSE, 0);
424 test_notification(hwnd, "midiStream over", 0, WHATEVER);
427 static void test_midi_outfns(HWND hwnd)
429 HMIDIOUT hm;
430 MMRESULT rc;
431 UINT udev, ndevs = midiOutGetNumDevs();
433 rc = midiOutOpen(&hm, ndevs, 0, 0, CALLBACK_NULL);
434 ok(rc==MMSYSERR_BADDEVICEID, "midiOutOpen udev>max rc=%s\n", mmsys_error(rc));
435 if (!rc) {
436 rc = midiOutClose(hm);
437 ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc));
439 if (!ndevs) {
440 skip("Found no MIDI out device\n");
441 rc = midiOutOpen(&hm, MIDIMAPPER, 0, 0, CALLBACK_NULL);
442 if (rc==MIDIERR_INVALIDSETUP) todo_wine /* Wine without snd-seq */
443 ok(rc==MMSYSERR_BADDEVICEID || broken(rc==MMSYSERR_NODRIVER /*w2k*/), "midiOutOpen MAPPER with no MIDI rc=%s\n", mmsys_error(rc));
444 else
445 ok(rc==MMSYSERR_BADDEVICEID || broken(rc==MMSYSERR_NODRIVER /*w2k sound disabled*/),
446 "midiOutOpen MAPPER with no MIDI rc=%s\n", mmsys_error(rc));
447 if (!rc) {
448 rc = midiOutClose(hm);
449 ok(!rc, "midiOutClose rc=%s\n", mmsys_error(rc));
451 return;
453 trace("Found %d MIDI OUT devices\n", ndevs);
455 test_midi_mci(hwnd);
457 for (udev=0; udev < ndevs; udev++) {
458 trace("** Testing device %d\n", udev);
459 test_midiOut_device(udev, hwnd);
460 Sleep(800); /* Let the synth rest */
461 test_midiStream(udev, hwnd);
462 Sleep(800);
464 trace("** Testing MIDI mapper\n");
465 test_midiOut_device(MIDIMAPPER, hwnd);
466 Sleep(800);
467 test_midiStream(MIDIMAPPER, hwnd);
470 START_TEST(midi)
472 HWND hwnd;
473 if (1) /* select 1 for CALLBACK_WINDOW or 0 for CALLBACK_FUNCTION */
474 hwnd = CreateWindowExA(0, "static", "winmm midi test", WS_POPUP, 0,0,100,100,
475 0, 0, 0, NULL);
476 test_midi_infns(hwnd);
477 test_midi_outfns(hwnd);
478 if (hwnd) DestroyWindow(hwnd);