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
25 #include "wine/test.h"
27 extern const char* mmsys_error(MMRESULT error
); /* from wave.c */
29 /* Test in order of increasing probability to hang.
30 * On many UNIX systems, the Timidity softsynth provides
31 * MIDI sequencer services and it is not particularly robust.
34 #define MYCBINST 0x4CAFE5A8 /* not used with window or thread callbacks */
35 #define WHATEVER 0xFEEDF00D
37 static BOOL
spurious_message(LPMSG msg
)
39 /* WM_DEVICECHANGE 0x0219 appears randomly */
40 if(msg
->message
== WM_DEVICECHANGE
) {
41 trace("skipping spurious message %04x\n", msg
->message
);
47 static UINT cbmsg
= 0;
48 static DWORD_PTR cbval1
= WHATEVER
;
49 static DWORD_PTR cbval2
= 0;
50 static DWORD_PTR cbinst
= MYCBINST
;
52 static void CALLBACK
callback_func(HWAVEOUT hwo
, UINT uMsg
,
54 DWORD_PTR dwParam1
, DWORD_PTR dwParam2
)
57 trace("Callback! msg=%x %lx %lx\n", uMsg
, dwParam1
, dwParam2
);
59 cbval1
= dwParam1
; /* mhdr or 0 */
60 cbval2
= dwParam2
; /* always 0 */
61 cbinst
= dwInstance
; /* MYCBINST, see midiOut/StreamOpen */
64 #define test_notification(hwnd, command, m1, p2) test_notification_dbg(hwnd, command, m1, p2, __LINE__)
65 static void test_notification_dbg(HWND hwnd
, const char* command
, UINT m1
, DWORD_PTR p2
, int line
)
66 { /* Use message type 0 as meaning no message */
69 /* msg.wParam is hmidiout, msg.lParam is the mhdr (or 0) */
71 do { seen
= PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
); }
72 while(seen
&& spurious_message(&msg
));
74 /* We observe transient delayed notification, mostly on native.
75 * Perhaps the OS preempts the player thread after setting MHDR_DONE
76 * or clearing MHDR_INQUEUE, before calling DriverCallback. */
78 trace_(__FILE__
,line
)("Waiting for delayed message %x from %s\n", m1
, command
);
79 SetLastError(0xDEADBEEF);
80 rc
= MsgWaitForMultipleObjects(0, NULL
, FALSE
, 3000, QS_POSTMESSAGE
);
81 ok_(__FILE__
,line
)(rc
==WAIT_OBJECT_0
, "Wait failed: %04x %d\n", rc
, GetLastError());
82 seen
= PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
);
85 trace_(__FILE__
,line
)("Message %x, wParam=%lx, lParam=%lx from %s\n",
86 msg
.message
, msg
.wParam
, msg
.lParam
, command
);
87 ok_(__FILE__
,line
)(msg
.hwnd
==hwnd
, "Didn't get the handle to our test window\n");
88 ok_(__FILE__
,line
)(msg
.message
==m1
&& msg
.lParam
==p2
, "bad message %x/%lx from %s, expect %x/%lx\n", msg
.message
, msg
.lParam
, command
, m1
, p2
);
90 else ok_(__FILE__
,line
)(m1
==0, "Expect message %x from %s\n", m1
, command
);
93 /* FIXME: MOM_POSITIONCB and MOM_DONE are so close that a queue is needed. */
95 ok_(__FILE__
,line
)(cbmsg
==m1
&& cbval1
==p2
&& cbval2
==0, "bad callback %x/%lx/%lx from %s, expect %x/%lx\n", cbmsg
, cbval1
, cbval2
, command
, m1
, p2
);
96 cbmsg
= 0; /* Mark as read */
97 cbval1
= cbval2
= WHATEVER
;
98 ok_(__FILE__
,line
)(cbinst
==MYCBINST
, "callback dwInstance changed to %lx\n", cbinst
);
100 else ok_(__FILE__
,line
)(m1
==0, "Expect callback %x from %s\n", m1
, command
);
105 static void test_midiIn_device(UINT udev
, HWND hwnd
)
112 rc
= midiInGetDevCapsA(udev
, &capsA
, sizeof(capsA
));
113 ok((MIDIMAPPER
==udev
) ? (rc
==MMSYSERR_BADDEVICEID
|| broken(rc
==MMSYSERR_NODRIVER
/*nt,w2k*/)) : rc
==0,
114 "midiInGetDevCaps(dev=%d) rc=%s\n", udev
, mmsys_error(rc
));
116 /* MIDI IN capsA.dwSupport may contain garbage, absent in old MS-Windows */
117 trace("* %s: manufacturer=%d, product=%d, support=%X\n", capsA
.szPname
, capsA
.wMid
, capsA
.wPid
, capsA
.dwSupport
);
121 rc
= midiInOpen(&hm
, udev
, (DWORD_PTR
)hwnd
, (DWORD_PTR
)MYCBINST
, CALLBACK_WINDOW
);
123 rc
= midiInOpen(&hm
, udev
, (DWORD_PTR
)callback_func
, (DWORD_PTR
)MYCBINST
, CALLBACK_FUNCTION
);
124 ok((MIDIMAPPER
!=udev
) ? rc
==0 : (rc
==MMSYSERR_BADDEVICEID
|| broken(rc
==MMSYSERR_NODRIVER
/*nt,w2k*/)),
125 "midiInOpen(dev=%d) rc=%s\n", udev
, mmsys_error(rc
));
128 test_notification(hwnd
, "midiInOpen", MIM_OPEN
, 0);
130 memset(&mhdr
, 0, sizeof(mhdr
));
131 mhdr
.dwFlags
= MHDR_DONE
;
132 mhdr
.dwUser
= 0x56FA552C;
133 mhdr
.dwBufferLength
= 70000; /* > 64KB! */
134 mhdr
.dwBytesRecorded
= 5;
135 mhdr
.lpData
= HeapAlloc(GetProcessHeap(), 0 , mhdr
.dwBufferLength
);
136 ok(mhdr
.lpData
!=NULL
, "No %d bytes of memory!\n", mhdr
.dwBufferLength
);
138 rc
= midiInPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
)-1);
139 ok(rc
==MMSYSERR_INVALPARAM
, "midiInPrepare tiny rc=%s\n", mmsys_error(rc
));
140 ok(mhdr
.dwFlags
== MHDR_DONE
, "dwFlags=%x\n", mhdr
.dwFlags
);
142 mhdr
.dwFlags
|= MHDR_INQUEUE
;
143 rc
= midiInPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
144 ok(!rc
, "midiInPrepare old size rc=%s\n", mmsys_error(rc
));
145 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_INQUEUE
|MHDR_DONE
)/*w9x*/ ||
146 mhdr
.dwFlags
== MHDR_PREPARED
, "dwFlags=%x\n", mhdr
.dwFlags
);
147 trace("MIDIHDR flags=%x when unsent\n", mhdr
.dwFlags
);
149 mhdr
.dwFlags
|= MHDR_INQUEUE
|MHDR_DONE
;
150 rc
= midiInPrepareHeader(hm
, &mhdr
, sizeof(mhdr
));
151 ok(!rc
, "midiInPrepare rc=%s\n", mmsys_error(rc
));
152 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_INQUEUE
|MHDR_DONE
), "dwFlags=%x\n", mhdr
.dwFlags
);
154 mhdr
.dwFlags
&= ~MHDR_INQUEUE
;
155 rc
= midiInUnprepareHeader(hm
, &mhdr
, sizeof(mhdr
));
156 ok(!rc
, "midiInUnprepare rc=%s\n", mmsys_error(rc
));
157 ok(mhdr
.dwFlags
== MHDR_DONE
, "dwFlags=%x\n", mhdr
.dwFlags
);
159 mhdr
.dwFlags
&= ~MHDR_DONE
;
160 rc
= midiInUnprepareHeader(hm
, &mhdr
, sizeof(mhdr
));
161 ok(!rc
, "midiInUnprepare rc=%s\n", mmsys_error(rc
));
162 ok(mhdr
.dwFlags
== 0, "dwFlags=%x\n", mhdr
.dwFlags
);
164 rc
= midiInPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
165 ok(!rc
, "midiInPrepare rc=%s\n", mmsys_error(rc
));
166 ok(mhdr
.dwFlags
== MHDR_PREPARED
, "dwFlags=%x\n", mhdr
.dwFlags
);
168 mhdr
.dwFlags
|= MHDR_DONE
;
169 rc
= midiInPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
170 ok(!rc
, "midiInPrepare rc=%s\n", mmsys_error(rc
));
171 ok(mhdr
.dwBytesRecorded
== 5, "BytesRec=%u\n", mhdr
.dwBytesRecorded
);
173 mhdr
.dwFlags
|= MHDR_DONE
;
174 rc
= midiInAddBuffer(hm
, &mhdr
, sizeof(mhdr
));
175 ok(!rc
, "midiAddBuffer rc=%s\n", mmsys_error(rc
));
176 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_INQUEUE
), "dwFlags=%x\n", mhdr
.dwFlags
);
178 /* w95 does not set dwBytesRecorded=0 within midiInAddBuffer. Wine does. */
179 if (mhdr
.dwBytesRecorded
!= 0)
180 trace("dwBytesRecorded %u\n", mhdr
.dwBytesRecorded
);
182 rc
= midiInAddBuffer(hm
, &mhdr
, sizeof(mhdr
));
183 ok(rc
==MIDIERR_STILLPLAYING
, "midiAddBuffer rc=%s\n", mmsys_error(rc
));
185 rc
= midiInPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
186 ok(!rc
, "midiInPrepare rc=%s\n", mmsys_error(rc
));
187 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_INQUEUE
), "dwFlags=%x\n", mhdr
.dwFlags
);
189 rc
= midiInReset(hm
); /* Return any pending buffer */
190 ok(!rc
, "midiInReset rc=%s\n", mmsys_error(rc
));
191 test_notification(hwnd
, "midiInReset", MIM_LONGDATA
, (DWORD_PTR
)&mhdr
);
193 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_DONE
), "dwFlags=%x\n", mhdr
.dwFlags
);
194 rc
= midiInUnprepareHeader(hm
, &mhdr
, sizeof(mhdr
));
195 ok(!rc
, "midiInUnprepare rc=%s\n", mmsys_error(rc
));
197 ok(mhdr
.dwBytesRecorded
== 0, "Did some MIDI HW send %u bytes?\n", mhdr
.dwBytesRecorded
);
199 rc
= midiInClose(hm
);
200 ok(!rc
, "midiInClose rc=%s\n", mmsys_error(rc
));
202 ok(mhdr
.dwUser
==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr
.dwUser
);
203 HeapFree(GetProcessHeap(), 0, mhdr
.lpData
);
204 test_notification(hwnd
, "midiInClose", MIM_CLOSE
, 0);
205 test_notification(hwnd
, "midiIn over", 0, WHATEVER
);
208 static void test_midi_infns(HWND hwnd
)
212 UINT udev
, ndevs
= midiInGetNumDevs();
214 rc
= midiInOpen(&hm
, ndevs
, 0, 0, CALLBACK_NULL
);
215 ok(rc
==MMSYSERR_BADDEVICEID
, "midiInOpen udev>max rc=%s\n", mmsys_error(rc
));
217 rc
= midiInClose(hm
);
218 ok(!rc
, "midiInClose rc=%s\n", mmsys_error(rc
));
221 trace("Found no MIDI IN device\n"); /* no skip for this common situation */
222 rc
= midiInOpen(&hm
, MIDIMAPPER
, 0, 0, CALLBACK_NULL
);
223 ok(rc
==MMSYSERR_BADDEVICEID
|| broken(rc
==MMSYSERR_NODRIVER
/*nt,w2k*/), "midiInOpen MAPPER with no MIDI rc=%s\n", mmsys_error(rc
));
225 rc
= midiInClose(hm
);
226 ok(!rc
, "midiInClose rc=%s\n", mmsys_error(rc
));
230 trace("Found %d MIDI IN devices\n", ndevs
);
231 for (udev
=0; udev
< ndevs
; udev
++) {
232 trace("** Testing device %d\n", udev
);
233 test_midiIn_device(udev
, hwnd
);
236 trace("** Testing MIDI mapper\n");
237 test_midiIn_device(MIDIMAPPER
, hwnd
);
241 static void test_midi_mci(HWND hwnd
)
245 memset(buf
, 0, sizeof(buf
));
247 err
= mciSendStringA("sysinfo sequencer quantity", buf
, sizeof(buf
), hwnd
);
248 ok(!err
, "mci sysinfo sequencer quantity returned %d\n", err
);
249 if (!err
) trace("Found %s MCI sequencer devices\n", buf
);
251 if (!strcmp(buf
, "0")) return;
253 err
= mciSendStringA("capability sequencer can record", buf
, sizeof(buf
), hwnd
);
254 ok(!err
, "mci sysinfo sequencer quantity returned %d\n", err
);
255 if(!err
) ok(!strcmp(buf
, "false"), "capability can record is %s\n", buf
);
259 static void test_midiOut_device(UINT udev
, HWND hwnd
)
268 rc
= midiOutGetDevCapsA(udev
, &capsA
, sizeof(capsA
));
269 ok(!rc
, "midiOutGetDevCaps(dev=%d) rc=%s\n", udev
, mmsys_error(rc
));
271 trace("* %s: manufacturer=%d, product=%d, tech=%d, support=%X: %d voices, %d notes\n",
272 capsA
.szPname
, capsA
.wMid
, capsA
.wPid
, capsA
.wTechnology
, capsA
.dwSupport
, capsA
.wVoices
, capsA
.wNotes
);
273 ok(!((MIDIMAPPER
==udev
) ^ (MOD_MAPPER
==capsA
.wTechnology
)), "technology %d on device %d\n", capsA
.wTechnology
, udev
);
274 if (MOD_MIDIPORT
== capsA
.wTechnology
) {
275 ok(capsA
.wVoices
== 0 && capsA
.wNotes
== 0, "external device with notes or voices\n");
276 ok(capsA
.wChannelMask
== 0xFFFF, "external device channel mask %x\n", capsA
.wChannelMask
);
277 ok(!(capsA
.dwSupport
& (MIDICAPS_VOLUME
|MIDICAPS_LRVOLUME
|MIDICAPS_CACHE
)), "external device support=%X\n", capsA
.dwSupport
);
282 rc
= midiOutOpen(&hm
, udev
, (DWORD_PTR
)hwnd
, (DWORD_PTR
)MYCBINST
, CALLBACK_WINDOW
);
284 rc
= midiOutOpen(&hm
, udev
, (DWORD_PTR
)callback_func
, (DWORD_PTR
)MYCBINST
, CALLBACK_FUNCTION
);
285 if (rc
== MMSYSERR_NOTSUPPORTED
|| rc
== MMSYSERR_NODRIVER
)
287 skip( "MIDI out not supported\n" );
290 ok(!rc
, "midiOutOpen(dev=%d) rc=%s\n", udev
, mmsys_error(rc
));
293 test_notification(hwnd
, "midiOutOpen", MOM_OPEN
, 0);
295 rc
= midiOutGetVolume(hm
, &ovolume
);
296 ok((capsA
.dwSupport
& MIDICAPS_VOLUME
) ? rc
==MMSYSERR_NOERROR
: rc
==MMSYSERR_NOTSUPPORTED
, "midiOutGetVolume rc=%s\n", mmsys_error(rc
));
297 /* The native mapper responds with FFFFFFFF initially,
298 * real devices with the volume GUI SW-synth settings. */
299 if (!rc
) trace("Current volume %x on device %d\n", ovolume
, udev
);
301 /* The W95 ESFM Synthesis device reports NOTENABLED although
302 * GetVolume by handle works and music plays. */
303 rc
= midiOutGetVolume(UlongToHandle(udev
), &ovolume
);
304 ok((capsA
.dwSupport
& MIDICAPS_VOLUME
) ? rc
==MMSYSERR_NOERROR
|| broken(rc
==MMSYSERR_NOTENABLED
) : rc
==MMSYSERR_NOTSUPPORTED
, "midiOutGetVolume(dev=%d) rc=%s\n", udev
, mmsys_error(rc
));
306 rc
= midiOutGetVolume(hm
, NULL
);
307 ok(rc
==MMSYSERR_INVALPARAM
, "midiOutGetVolume NULL rc=%s\n", mmsys_error(rc
));
309 /* Tests with midiOutSetvolume show that the midi mapper forwards
310 * the value to the real device, but Get initially always reports
311 * FFFFFFFF. Therefore, a Get+SetVolume pair with the mapper is
312 * not adequate to restore the value prior to tests.
314 if (winetest_interactive
&& (capsA
.dwSupport
& MIDICAPS_VOLUME
)) {
315 DWORD volume2
= (ovolume
< 0x80000000) ? 0xC000C000 : 0x40004000;
316 rc
= midiOutSetVolume(hm
, volume2
);
317 ok(!rc
, "midiOutSetVolume rc=%s\n", mmsys_error(rc
));
320 rc
= midiOutGetVolume(hm
, &volume3
);
321 ok(!rc
, "midiOutGetVolume new rc=%s\n", mmsys_error(rc
));
322 if (!rc
) trace("New volume %x on device %d\n", volume3
, udev
);
323 todo_wine
ok(volume2
==volume3
, "volume Set %x = Get %x\n", volume2
, volume3
);
325 rc
= midiOutSetVolume(hm
, ovolume
);
326 ok(!rc
, "midiOutSetVolume restore rc=%s\n", mmsys_error(rc
));
329 rc
= midiOutGetDevCapsA((UINT_PTR
)hm
, &capsA
, sizeof(capsA
));
330 ok(!rc
, "midiOutGetDevCaps(dev=%d) by handle rc=%s\n", udev
, mmsys_error(rc
));
331 rc
= midiInGetDevCapsA((UINT_PTR
)hm
, (LPMIDIINCAPSA
)&capsA
, sizeof(DWORD
));
332 ok(rc
==MMSYSERR_BADDEVICEID
, "midiInGetDevCaps(dev=%d) by out handle rc=%s\n", udev
, mmsys_error(rc
));
334 { DWORD e
= 0x006F4893; /* velocity, note (#69 would be 440Hz) channel */
335 trace("ShortMsg type %x\n", LOBYTE(LOWORD(e
)));
336 rc
= midiOutShortMsg(hm
, e
);
337 ok(!rc
, "midiOutShortMsg rc=%s\n", mmsys_error(rc
));
338 if (!rc
) Sleep(400); /* Hear note */
341 memset(&mhdr
, 0, sizeof(mhdr
));
342 mhdr
.dwFlags
= MHDR_DONE
;
343 mhdr
.dwUser
= 0x56FA552C;
344 mhdr
.dwOffset
= 0xDEADBEEF;
345 mhdr
.dwBufferLength
= 70000; /* > 64KB! */
346 mhdr
.lpData
= HeapAlloc(GetProcessHeap(), 0 , mhdr
.dwBufferLength
);
347 ok(mhdr
.lpData
!=NULL
, "No %d bytes of memory!\n", mhdr
.dwBufferLength
);
349 rc
= midiOutLongMsg(hm
, &mhdr
, sizeof(mhdr
));
350 ok(rc
==MIDIERR_UNPREPARED
, "midiOutLongMsg unprepared rc=%s\n", mmsys_error(rc
));
351 ok(mhdr
.dwFlags
== MHDR_DONE
, "dwFlags=%x\n", mhdr
.dwFlags
);
352 test_notification(hwnd
, "midiOutLong unprepared", 0, WHATEVER
);
354 rc
= midiOutPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
)-1);
355 ok(rc
==MMSYSERR_INVALPARAM
, "midiOutPrepare tiny rc=%s\n", mmsys_error(rc
));
356 ok(mhdr
.dwFlags
== MHDR_DONE
, "dwFlags=%x\n", mhdr
.dwFlags
);
358 /* Since at least w2k, midiOutPrepare clears the DONE and INQUEUE flags. w95 didn't. */
359 /* mhdr.dwFlags |= MHDR_INQUEUE; would cause w95 to return STILLPLAYING from Unprepare */
360 rc
= midiOutPrepareHeader(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
361 ok(!rc
, "midiOutPrepare old size rc=%s\n", mmsys_error(rc
));
362 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_DONE
)/*w9x*/ ||
363 mhdr
.dwFlags
== MHDR_PREPARED
, "dwFlags=%x\n", mhdr
.dwFlags
);
364 trace("MIDIHDR flags=%x when unsent\n", mhdr
.dwFlags
);
366 /* No flag is cleared when already prepared. */
367 mhdr
.dwFlags
|= MHDR_DONE
|MHDR_INQUEUE
;
368 rc
= midiOutPrepareHeader(hm
, &mhdr
, sizeof(mhdr
));
369 ok(!rc
, "midiOutPrepare rc=%s\n", mmsys_error(rc
));
370 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_DONE
|MHDR_INQUEUE
), "dwFlags=%x\n", mhdr
.dwFlags
);
372 mhdr
.dwFlags
|= MHDR_INQUEUE
;
373 rc
= midiOutUnprepareHeader(hm
, &mhdr
, sizeof(mhdr
));
374 ok(rc
==MIDIERR_STILLPLAYING
, "midiOutUnprepare rc=%s\n", mmsys_error(rc
));
375 ok(mhdr
.dwFlags
== (MHDR_PREPARED
|MHDR_DONE
|MHDR_INQUEUE
), "dwFlags=%x\n", mhdr
.dwFlags
);
377 mhdr
.dwFlags
&= ~MHDR_INQUEUE
;
378 rc
= midiOutUnprepareHeader(hm
, &mhdr
, sizeof(mhdr
));
379 ok(!rc
, "midiOutUnprepare rc=%s\n", mmsys_error(rc
));
380 ok(mhdr
.dwFlags
== MHDR_DONE
, "dwFlags=%x\n", mhdr
.dwFlags
);
382 mhdr
.dwFlags
|= MHDR_INQUEUE
;
383 rc
= midiOutUnprepareHeader(hm
, &mhdr
, sizeof(mhdr
));
384 ok(!rc
, "midiOutUnprepare rc=%s\n", mmsys_error(rc
));
385 ok(mhdr
.dwFlags
== (MHDR_INQUEUE
|MHDR_DONE
), "dwFlags=%x\n", mhdr
.dwFlags
);
387 HeapFree(GetProcessHeap(), 0, mhdr
.lpData
);
389 ok(mhdr
.dwUser
==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr
.dwUser
);
390 ok(mhdr
.dwOffset
==0xDEADBEEF, "MIDIHDR.dwOffset changed to %x\n", mhdr
.dwOffset
);
392 rc
= midiOutGetID(hm
, &udevid
);
393 ok(!rc
, "midiOutGetID rc=%s\n", mmsys_error(rc
));
394 if(!rc
) ok(udevid
==udev
, "midiOutGetID gives %d, expect %d\n", udevid
, udev
);
396 rc
= midiOutReset(hm
); /* Quiet everything */
397 ok(!rc
, "midiOutReset rc=%s\n", mmsys_error(rc
));
399 rc
= midiOutClose(hm
);
400 ok(!rc
, "midiOutClose rc=%s\n", mmsys_error(rc
));
401 test_notification(hwnd
, "midiOutClose", MOM_CLOSE
, 0);
403 rc
= midiOutOpen(&hm
, udev
, 0, (DWORD_PTR
)MYCBINST
, CALLBACK_WINDOW
);
404 /* w95 broken(rc==MMSYSERR_INVALPARAM) see WINMM_CheckCallback */
405 ok(!rc
, "midiOutOpen(dev=%d) 0 CALLBACK_WINDOW rc=%s\n", udev
, mmsys_error(rc
));
406 /* PostMessage(hwnd=0) redirects to PostThreadMessage(GetCurrentThreadId())
407 * which PeekMessage((HWND)-1) queries. */
408 test_notification((HWND
)-1, "midiOutOpen WINDOW->THREAD", 0, WHATEVER
);
409 test_notification(hwnd
, "midiOutOpen WINDOW", 0, WHATEVER
);
411 rc
= midiOutClose(hm
);
412 ok(!rc
, "midiOutClose rc=%s\n", mmsys_error(rc
));
413 test_notification((HWND
)-1, "midiOutClose WINDOW->THREAD", 0, WHATEVER
);
414 test_notification(hwnd
, "midiOutClose", 0, WHATEVER
);
416 test_notification(hwnd
, "midiOut over", 0, WHATEVER
);
419 static void test_position(HMIDISTRM hm
, UINT typein
, UINT typeout
)
423 mmtime
.wType
= typein
;
424 rc
= midiStreamPosition(hm
, &mmtime
, sizeof(MMTIME
));
425 /* Ugly, but a single ok() herein enables using the todo_wine prefix */
426 ok(!rc
&& (mmtime
.wType
== typeout
), "midiStreamPosition type %x converted to %x rc=%s\n", typein
, mmtime
.wType
, mmsys_error(rc
));
427 if (!rc
) switch(mmtime
.wType
) {
429 trace("Stream position %ums\n", mmtime
.u
.ms
);
432 trace("Stream position %u ticks\n", mmtime
.u
.ticks
);
435 trace("Stream position song pointer %u\n", mmtime
.u
.midi
.songptrpos
);
440 typedef struct midishortevent_tag
{ /* ideal size for MEVT_F_SHORT event type */
446 /* Native crashes on a second run with the const qualifier set on this data! */
447 static BYTE strmEvents
[] = { /* A set of variable-sized MIDIEVENT structs */
448 0, 0, 0, 0, 0, 0, 0, 0, /* dwDeltaTime and dwStreamID */
449 0, 0, 0, MEVT_NOP
| 0x40, /* with MEVT_F_CALLBACK */
450 0, 0, 0, 0, 0, 0, 0, 0,
451 0xE0, 0x93, 0x04, MEVT_TEMPO
, /* 0493E0 == 300000 */
452 0, 0, 0, 0, 0, 0, 0, 0,
453 0x93, 0x48, 0x6F, MEVT_SHORTMSG
,
456 static MIDISHORTEVENT strmNops
[] = { /* Test callback + dwOffset */
457 { 0, 0, (MEVT_NOP
<<24)| MEVT_F_CALLBACK
},
458 { 0, 0, (MEVT_NOP
<<24)| MEVT_F_CALLBACK
},
461 static MMRESULT
playStream(HMIDISTRM hm
, LPMIDIHDR lpMidiHdr
)
463 MMRESULT rc
= midiStreamOut(hm
, lpMidiHdr
, sizeof(MIDIHDR
));
464 /* virtual machines may return MIDIERR_STILLPLAYING from the next request
465 * even after MHDR_DONE is set. It's still too early, so add MHDR_INQUEUE. */
466 if (!rc
) while (!(lpMidiHdr
->dwFlags
& MHDR_DONE
) || (lpMidiHdr
->dwFlags
& MHDR_INQUEUE
)) { Sleep(100); }
470 static void test_midiStream(UINT udev
, HWND hwnd
)
477 MIDIPROPTIMEDIV tdiv
;
481 rc
= midiStreamOpen(&hm
, &udev
, 1, (DWORD_PTR
)hwnd
, (DWORD_PTR
)MYCBINST
, CALLBACK_WINDOW
);
483 rc
= midiStreamOpen(&hm
, &udev
, 1, (DWORD_PTR
)callback_func
, (DWORD_PTR
)MYCBINST
, CALLBACK_FUNCTION
);
484 if (rc
== MMSYSERR_NOTSUPPORTED
|| rc
== MMSYSERR_NODRIVER
)
486 skip( "MIDI stream not supported\n" );
489 ok(!rc
, "midiStreamOpen(dev=%d) rc=%s\n", udev
, mmsys_error(rc
));
492 test_notification(hwnd
, "midiStreamOpen", MOM_OPEN
, 0);
494 midiprop
.tempo
.cbStruct
= sizeof(midiprop
.tempo
);
495 rc
= midiStreamProperty(hm
, (void*)&midiprop
, MIDIPROP_GET
|MIDIPROP_TEMPO
);
496 ok(!rc
, "midiStreamProperty TEMPO rc=%s\n", mmsys_error(rc
));
497 ok(midiprop
.tempo
.dwTempo
==500000, "default stream tempo %u microsec per quarter note\n", midiprop
.tempo
.dwTempo
);
499 midiprop
.tdiv
.cbStruct
= sizeof(midiprop
.tdiv
);
500 rc
= midiStreamProperty(hm
, (void*)&midiprop
, MIDIPROP_GET
|MIDIPROP_TIMEDIV
);
501 ok(!rc
, "midiStreamProperty TIMEDIV rc=%s\n", mmsys_error(rc
));
502 todo_wine
ok(24==LOWORD(midiprop
.tdiv
.dwTimeDiv
), "default stream time division %u\n", midiprop
.tdiv
.dwTimeDiv
);
504 memset(&mhdr
, 0, sizeof(mhdr
));
505 mhdr
.dwUser
= 0x56FA552C;
506 mhdr
.dwOffset
= 1234567890;
507 mhdr
.dwBufferLength
= sizeof(strmEvents
);
508 mhdr
.dwBytesRecorded
= mhdr
.dwBufferLength
;
509 mhdr
.lpData
= (LPSTR
)&strmEvents
[0];
511 rc
= midiOutLongMsg((HMIDIOUT
)hm
, &mhdr
, sizeof(mhdr
));
512 ok(rc
==MIDIERR_UNPREPARED
, "midiOutLongMsg unprepared rc=%s\n", mmsys_error(rc
));
513 test_notification(hwnd
, "midiOutLong unprepared", 0, WHATEVER
);
515 rc
= midiOutPrepareHeader((HMIDIOUT
)hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
)-1);
516 ok(rc
==MMSYSERR_INVALPARAM
, "midiOutPrepare tiny rc=%s\n", mmsys_error(rc
));
517 rc
= midiOutPrepareHeader((HMIDIOUT
)hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
518 ok(!rc
, "midiOutPrepare old size rc=%s\n", mmsys_error(rc
));
519 ok(mhdr
.dwFlags
& MHDR_PREPARED
, "MHDR.dwFlags when prepared %x\n", mhdr
.dwFlags
);
521 /* The device is still in paused mode and should queue the message. */
522 rc
= midiStreamOut(hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
523 ok(!rc
, "midiStreamOut old size rc=%s\n", mmsys_error(rc
));
525 trace("MIDIHDR flags=%x when submitted\n", mhdr
.dwFlags
);
526 /* w9X/me does not set MHDR_ISSTRM when StreamOut exits,
527 * but it will be set on all systems after the job is finished. */
530 /* Wine <1.1.39 started playing immediately */
531 test_notification(hwnd
, "midiStream still paused", 0, WHATEVER
);
533 /* MSDN asks to use midiStreamRestart prior to midiStreamOut()
534 * because the starting state is 'pause', but some apps seem to
535 * work with the inverse order: queue everything, then play.
538 rc
= midiStreamRestart(hm
);
539 ok(!rc
, "midiStreamRestart rc=%s\n", mmsys_error(rc
));
541 if (!rc2
) while(mhdr
.dwFlags
& MHDR_INQUEUE
) {
542 trace("async MIDI still queued\n");
544 } /* Checking INQUEUE is not the recommended way to wait for the end of a job, but we're testing. */
545 /* MHDR_ISSTRM is not necessarily set when midiStreamOut returns
546 * rather than when the queue is eventually processed. */
547 ok(mhdr
.dwFlags
& MHDR_ISSTRM
, "MHDR.dwFlags %x no ISSTRM when out of queue\n", mhdr
.dwFlags
);
548 if (!rc2
) while(!(mhdr
.dwFlags
& MHDR_DONE
)) {
549 /* Never to be seen except perhaps on multicore */
550 trace("async MIDI still not done\n");
553 ok(mhdr
.dwFlags
& MHDR_DONE
, "MHDR.dwFlags %x not DONE when out of queue\n", mhdr
.dwFlags
);
554 test_notification(hwnd
, "midiStream callback", MOM_POSITIONCB
, (DWORD_PTR
)&mhdr
);
555 test_notification(hwnd
, "midiStreamOut", MOM_DONE
, (DWORD_PTR
)&mhdr
);
557 /* Native fills dwOffset regardless of the cbMidiHdr size argument to midiStreamOut */
558 ok(1234567890!=mhdr
.dwOffset
, "play left MIDIHDR.dwOffset at %u\n", mhdr
.dwOffset
);
560 rc
= midiOutUnprepareHeader((HMIDIOUT
)hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
561 ok(!rc
, "midiOutUnprepare rc=%s\n", mmsys_error(rc
));
562 rc
= midiOutUnprepareHeader((HMIDIOUT
)hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
563 ok(!rc
, "midiOutUnprepare #2 rc=%s\n", mmsys_error(rc
));
565 trace("MIDIHDR stream flags=%x when finished\n", mhdr
.dwFlags
);
566 ok(mhdr
.dwFlags
& MHDR_DONE
, "MHDR.dwFlags when done %x\n", mhdr
.dwFlags
);
568 test_position(hm
, TIME_MS
, TIME_MS
);
569 test_position(hm
, TIME_TICKS
, TIME_TICKS
);
570 todo_wine
test_position(hm
, TIME_MIDI
, TIME_MIDI
);
571 test_position(hm
, TIME_SMPTE
, TIME_MS
);
572 test_position(hm
, TIME_SAMPLES
, TIME_MS
);
573 test_position(hm
, TIME_BYTES
, TIME_MS
);
575 Sleep(400); /* Hear note */
577 midiprop
.tempo
.cbStruct
= sizeof(midiprop
.tempo
);
578 rc
= midiStreamProperty(hm
, (void*)&midiprop
, MIDIPROP_GET
|MIDIPROP_TEMPO
);
579 ok(!rc
, "midiStreamProperty TEMPO rc=%s\n", mmsys_error(rc
));
580 ok(0x0493E0==midiprop
.tempo
.dwTempo
, "stream set tempo %u\n", midiprop
.tdiv
.dwTimeDiv
);
582 rc
= midiStreamRestart(hm
);
583 ok(!rc
, "midiStreamRestart #2 rc=%s\n", mmsys_error(rc
));
585 mhdr
.dwFlags
|= MHDR_ISSTRM
;
586 /* Preset flags (e.g. MHDR_ISSTRM) do not disturb. */
587 rc
= midiOutPrepareHeader((HMIDIOUT
)hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
588 ok(!rc
, "midiOutPrepare used flags %x rc=%s\n", mhdr
.dwFlags
, mmsys_error(rc
));
589 rc
= midiOutUnprepareHeader((HMIDIOUT
)hm
, &mhdr
, offsetof(MIDIHDR
,dwOffset
));
590 ok(!rc
, "midiOutUnprepare used flags %x rc=%s\n", mhdr
.dwFlags
, mmsys_error(rc
));
592 rc
= midiStreamRestart(hm
);
593 ok(!rc
, "midiStreamRestart #3 rc=%s\n", mmsys_error(rc
));
595 ok(mhdr
.dwUser
==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr
.dwUser
);
596 ok(0==((MIDISHORTEVENT
*)&strmEvents
)[0].dwStreamID
, "dwStreamID set to %x\n", ((LPMIDIEVENT
)&strmEvents
[0])->dwStreamID
);
598 /* dwBytesRecorded controls how much is played, not dwBufferLength
599 * allowing to immediately forward packets from midiIn to midiOut */
600 mhdr
.dwOffset
= 1234123123;
601 mhdr
.dwBufferLength
= sizeof(strmNops
);
602 trace("buffer: %u\n", mhdr
.dwBufferLength
);
603 mhdr
.dwBytesRecorded
= 0;
604 mhdr
.lpData
= (LPSTR
)&strmNops
[0];
605 strmNops
[0].dwEvent
|= MEVT_F_CALLBACK
;
606 strmNops
[1].dwEvent
|= MEVT_F_CALLBACK
;
608 rc
= midiOutPrepareHeader((HMIDIOUT
)hm
, &mhdr
, sizeof(mhdr
));
609 ok(!rc
, "midiOutPrepare rc=%s\n", mmsys_error(rc
));
611 rc
= playStream(hm
, &mhdr
);
612 ok(!rc
, "midiStreamOut 0 bytes recorded rc=%s\n", mmsys_error(rc
));
614 test_notification(hwnd
, "midiStreamOut", MOM_DONE
, (DWORD_PTR
)&mhdr
);
615 test_notification(hwnd
, "0 bytes recorded", 0, WHATEVER
);
617 /* FIXME: check dwOffset within callback
618 * instead of the unspecified value afterwards */
619 ok(1234123123==mhdr
.dwOffset
|| broken(0==mhdr
.dwOffset
), "play 0 set MIDIHDR.dwOffset to %u\n", mhdr
.dwOffset
);
620 /* w2k and later only set dwOffset when processing MEVT_T_CALLBACK,
621 * while w9X/me/nt always sets it. Have Wine behave like w2k because the
622 * dwOffset slot does not exist in the small size MIDIHDR. */
624 mhdr
.dwOffset
= 1234123123;
625 mhdr
.dwBytesRecorded
= 1*sizeof(MIDISHORTEVENT
);
627 rc
= playStream(hm
, &mhdr
);
628 ok(!rc
, "midiStreamOut 1 event out of 2 rc=%s\n", mmsys_error(rc
));
630 test_notification(hwnd
, "1 of 2 events", MOM_POSITIONCB
, (DWORD_PTR
)&mhdr
);
631 test_notification(hwnd
, "1 of 2 events", MOM_DONE
, (DWORD_PTR
)&mhdr
);
632 test_notification(hwnd
, "1 of 2 events", 0, WHATEVER
);
633 ok(0==mhdr
.dwOffset
, "MIDIHDR.dwOffset 1/2 changed to %u\n", mhdr
.dwOffset
);
635 mhdr
.dwOffset
= 1234123123;
636 mhdr
.dwBytesRecorded
= 2*sizeof(MIDISHORTEVENT
);
638 rc
= playStream(hm
, &mhdr
);
639 ok(!rc
, "midiStreamOut 1 event out of 2 rc=%s\n", mmsys_error(rc
));
641 test_notification(hwnd
, "2 of 2 events", MOM_POSITIONCB
, (DWORD_PTR
)&mhdr
);
642 test_notification(hwnd
, "2 of 2 events", MOM_POSITIONCB
, (DWORD_PTR
)&mhdr
);
643 test_notification(hwnd
, "2 of 2 events", MOM_DONE
, (DWORD_PTR
)&mhdr
);
644 test_notification(hwnd
, "2 of 2 events", 0, WHATEVER
);
645 ok(sizeof(MIDISHORTEVENT
)==mhdr
.dwOffset
, "MIDIHDR.dwOffset 2/2 changed to %u\n", mhdr
.dwOffset
);
646 ok(mhdr
.dwBytesRecorded
== 2*sizeof(MIDISHORTEVENT
), "dwBytesRecorded changed to %u\n", mhdr
.dwBytesRecorded
);
648 strmNops
[0].dwEvent
&= ~MEVT_F_CALLBACK
;
649 strmNops
[1].dwEvent
&= ~MEVT_F_CALLBACK
;
650 mhdr
.dwOffset
= 1234123123;
651 rc
= playStream(hm
, &mhdr
);
652 ok(!rc
, "midiStreamOut 1 event out of 2 rc=%s\n", mmsys_error(rc
));
654 test_notification(hwnd
, "0 CB in 2 events", MOM_DONE
, (DWORD_PTR
)&mhdr
);
655 test_notification(hwnd
, "0 CB in 2 events", 0, WHATEVER
);
656 /* w9X/me/nt set dwOffset to the position played last */
657 ok(1234123123==mhdr
.dwOffset
|| broken(sizeof(MIDISHORTEVENT
)==mhdr
.dwOffset
), "MIDIHDR.dwOffset nocb changed to %u\n", mhdr
.dwOffset
);
659 mhdr
.dwBytesRecorded
= mhdr
.dwBufferLength
-1;
660 rc
= playStream(hm
, &mhdr
);
661 ok(rc
==MMSYSERR_INVALPARAM
,"midiStreamOut dwBytesRecorded modulo MIDIEVENT rc=%s\n", mmsys_error(rc
));
663 test_notification(hwnd
, "2 of 2 events", MOM_DONE
, (DWORD_PTR
)&mhdr
);
666 mhdr
.dwBytesRecorded
= mhdr
.dwBufferLength
+1;
667 rc
= playStream(hm
, &mhdr
);
668 ok(rc
==MMSYSERR_INVALPARAM
,"midiStreamOut dwBufferLength<dwBytesRecorded rc=%s\n", mmsys_error(rc
));
669 test_notification(hwnd
, "past MIDIHDR tests", 0, WHATEVER
);
671 rc
= midiStreamStop(hm
);
672 ok(!rc
, "midiStreamStop rc=%s\n", mmsys_error(rc
));
673 ok(mhdr
.dwUser
==0x56FA552C, "MIDIHDR.dwUser changed to %lx\n", mhdr
.dwUser
);
675 rc
= midiOutUnprepareHeader((HMIDIOUT
)hm
, &mhdr
, sizeof(mhdr
));
676 ok(!rc
, "midiOutUnprepare rc=%s\n", mmsys_error(rc
));
677 ok(0==strmNops
[0].dwStreamID
, "dwStreamID[0] set to %x\n", strmNops
[0].dwStreamID
);
678 ok(0==strmNops
[1].dwStreamID
, "dwStreamID[1] set to %x\n", strmNops
[1].dwStreamID
);
680 mhdr
.dwBufferLength
= 70000; /* > 64KB! */
681 mhdr
.lpData
= HeapAlloc(GetProcessHeap(), 0 , mhdr
.dwBufferLength
);
682 ok(mhdr
.lpData
!=NULL
, "No %d bytes of memory!\n", mhdr
.dwBufferLength
);
685 /* PrepareHeader detects the too large buffer is for a stream. */
686 rc
= midiOutPrepareHeader((HMIDIOUT
)hm
, &mhdr
, sizeof(mhdr
));
687 todo_wine
ok(rc
==MMSYSERR_INVALPARAM
, "midiOutPrepare stream too large rc=%s\n", mmsys_error(rc
));
689 rc
= midiOutUnprepareHeader((HMIDIOUT
)hm
, &mhdr
, sizeof(mhdr
));
690 ok(!rc
, "midiOutUnprepare rc=%s\n", mmsys_error(rc
));
692 HeapFree(GetProcessHeap(), 0, mhdr
.lpData
);
695 rc
= midiStreamClose(hm
);
696 ok(!rc
, "midiStreamClose rc=%s\n", mmsys_error(rc
));
697 test_notification(hwnd
, "midiStreamClose", MOM_CLOSE
, 0);
698 test_notification(hwnd
, "midiStream over", 0, WHATEVER
);
700 rc
= midiStreamOpen(&hm
, &udev
, 1, 0, (DWORD_PTR
)MYCBINST
, CALLBACK_FUNCTION
);
701 ok(!rc
/*w2k*/|| rc
==MMSYSERR_INVALPARAM
/*w98*/, "midiStreamOpen NULL function rc=%s\n", mmsys_error(rc
));
703 trace("Device %d accepts NULL CALLBACK_FUNCTION\n", udev
);
704 rc
= midiStreamClose(hm
);
705 ok(!rc
, "midiStreamClose rc=%s\n", mmsys_error(rc
));
708 rc
= midiStreamOpen(&hm
, &udev
, 1, (DWORD_PTR
)0xDEADBEEF, (DWORD_PTR
)MYCBINST
, CALLBACK_WINDOW
);
709 ok(rc
==MMSYSERR_INVALPARAM
, "midiStreamOpen bad window rc=%s\n", mmsys_error(rc
));
711 rc
= midiStreamClose(hm
);
712 ok(!rc
, "midiStreamClose rc=%s\n", mmsys_error(rc
));
716 static BOOL
scan_subkeys(HKEY parent
, const LPCSTR
*sub_keys
)
720 DWORD name_len
= sizeof(name
);
721 BOOL found_vmware
= FALSE
;
723 if (sub_keys
[0] == NULL
)
725 /* We're at the deepest level, check "Identifier" value now */
727 if (RegQueryValueExA(parent
, "Identifier", NULL
, NULL
, (LPBYTE
) name
, &name_len
) != ERROR_SUCCESS
)
729 for (test
= name
; test
< name
+ lstrlenA(name
) - 6 && ! found_vmware
; test
++)
733 found_vmware
= (lstrcmpiA(test
, "VMware") == 0);
739 while (RegEnumKeyExA(parent
, index
, name
, &name_len
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
&&
741 char c
= name
[lstrlenA(sub_keys
[0])];
742 name
[lstrlenA(sub_keys
[0])] = '\0';
743 if (lstrcmpiA(name
, sub_keys
[0]) == 0) {
745 name
[lstrlenA(sub_keys
[0])] = c
;
746 if (RegOpenKeyExA(parent
, name
, 0, KEY_ENUMERATE_SUB_KEYS
| KEY_QUERY_VALUE
, &sub_key
) == ERROR_SUCCESS
) {
747 found_vmware
= scan_subkeys(sub_key
, sub_keys
+ 1);
748 RegCloseKey(sub_key
);
752 name_len
= sizeof(name
);
760 * Usual method to detect whether running inside a VMware virtual machine involves direct port I/O requiring
761 * some assembly and an exception handler. Can't do that in Wine tests. Alternative method of querying WMI
762 * is not available on NT4. So instead we look at the device map and check the Identifier value in the
763 * registry keys HKLM\HARDWARE\DEVICEMAP\SCSI\Scsi Port x\Scsi Bus x\Target Id x\Logical Unit Id x (where
764 * x is some number). If the Identifier value contains the string "VMware" we assume running in a VMware VM.
766 static BOOL
on_vmware(void)
768 static const LPCSTR sub_keys
[] = { "Scsi Port ", "Scsi Bus ", "Target Id ", "Logical Unit Id ", NULL
};
770 BOOL found_vmware
= FALSE
;
772 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "HARDWARE\\DEVICEMAP\\Scsi", 0, KEY_ENUMERATE_SUB_KEYS
, &scsi
) != ERROR_SUCCESS
)
775 found_vmware
= scan_subkeys(scsi
, sub_keys
);
782 static void test_midi_outfns(HWND hwnd
)
786 UINT udev
, ndevs
= midiOutGetNumDevs();
788 rc
= midiOutOpen(&hm
, ndevs
, 0, 0, CALLBACK_NULL
);
789 ok(rc
==MMSYSERR_BADDEVICEID
, "midiOutOpen udev>max rc=%s\n", mmsys_error(rc
));
791 rc
= midiOutClose(hm
);
792 ok(!rc
, "midiOutClose rc=%s\n", mmsys_error(rc
));
796 skip("Found no MIDI out device\n");
798 rc
= midiOutGetDevCapsA(MIDIMAPPER
, &capsA
, sizeof(capsA
));
799 /* GetDevCaps and Open must return compatible results */
800 ok(rc
==MMSYSERR_BADDEVICEID
|| broken(rc
==MMSYSERR_NODRIVER
/*nt,w2k*/), "midiOutGetDevCaps MAPPER with no MIDI rc=%s\n", mmsys_error(rc
));
802 rc
= midiOutOpen(&hm
, MIDIMAPPER
, 0, 0, CALLBACK_NULL
);
803 todo_wine_if (rc
== MIDIERR_INVALIDSETUP
) /* Wine without snd-seq */
804 ok(rc
== MMSYSERR_BADDEVICEID
|| broken(rc
== MMSYSERR_NODRIVER
/*w2k sound disabled*/),
805 "midiOutOpen MAPPER with no MIDI rc=%s\n", mmsys_error(rc
));
807 rc
= midiOutClose(hm
);
808 ok(!rc
, "midiOutClose rc=%s\n", mmsys_error(rc
));
812 trace("Found %d MIDI OUT devices\n", ndevs
);
816 for (udev
=0; udev
< ndevs
; udev
++) {
818 rc
= midiOutGetDevCapsA(udev
, &capsA
, sizeof(capsA
));
819 if (rc
|| strcmp(capsA
.szPname
, "Creative Sound Blaster MPU-401") != 0 || ! on_vmware()) {
820 trace("** Testing device %d\n", udev
);
821 test_midiOut_device(udev
, hwnd
);
822 Sleep(800); /* Let the synth rest */
823 test_midiStream(udev
, hwnd
);
827 win_skip("Skipping this device on VMware, driver problem\n");
829 trace("** Testing MIDI mapper\n");
830 test_midiOut_device(MIDIMAPPER
, hwnd
);
832 test_midiStream(MIDIMAPPER
, hwnd
);
838 if (1) /* select 1 for CALLBACK_WINDOW or 0 for CALLBACK_FUNCTION */
839 hwnd
= CreateWindowExA(0, "static", "winmm midi test", WS_POPUP
, 0,0,100,100,
841 test_midi_infns(hwnd
);
842 test_midi_outfns(hwnd
);
843 if (hwnd
) DestroyWindow(hwnd
);