4 * Copyright 2006 Jan Zerebecki
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 /* The tests use the MCI's own save capability to create the tempfile.wav to play.
29 * To use a pre-existing file, write-protect it. */
30 static MCIERROR ok_saved = MCIERR_FILE_NOT_FOUND;
33 MCI_STATUS_PARMS status;
34 MCI_WAVE_SET_PARMS set;
35 MCI_WAVE_OPEN_PARMS open;
36 MCI_GETDEVCAPS_PARMS caps;
37 MCI_SYSINFO_PARMS sys;
39 MCI_GENERIC_PARMS gen;
42 const char* dbg_mcierr(MCIERROR err)
45 case 0: return "0=NOERROR";
46 #define X(label) case label: return #label ;
47 X(MCIERR_INVALID_DEVICE_ID)
48 X(MCIERR_UNRECOGNIZED_KEYWORD)
49 X(MCIERR_UNRECOGNIZED_COMMAND)
51 X(MCIERR_INVALID_DEVICE_NAME)
52 X(MCIERR_OUT_OF_MEMORY)
54 X(MCIERR_CANNOT_LOAD_DRIVER)
55 X(MCIERR_MISSING_COMMAND_STRING)
56 X(MCIERR_PARAM_OVERFLOW)
57 X(MCIERR_MISSING_STRING_ARGUMENT)
59 X(MCIERR_PARSER_INTERNAL)
60 X(MCIERR_DRIVER_INTERNAL)
61 X(MCIERR_MISSING_PARAMETER)
62 X(MCIERR_UNSUPPORTED_FUNCTION)
63 X(MCIERR_FILE_NOT_FOUND)
64 X(MCIERR_DEVICE_NOT_READY)
67 X(MCIERR_CANNOT_USE_ALL)
69 X(MCIERR_EXTENSION_NOT_FOUND)
71 X(MCIERR_FLAGS_NOT_COMPATIBLE)
72 X(MCIERR_FILE_NOT_SAVED)
73 X(MCIERR_DEVICE_TYPE_REQUIRED)
74 X(MCIERR_DEVICE_LOCKED)
75 X(MCIERR_DUPLICATE_ALIAS)
76 X(MCIERR_BAD_CONSTANT)
77 X(MCIERR_MUST_USE_SHAREABLE)
78 X(MCIERR_MISSING_DEVICE_NAME)
79 X(MCIERR_BAD_TIME_FORMAT)
80 X(MCIERR_NO_CLOSING_QUOTE)
81 X(MCIERR_DUPLICATE_FLAGS)
82 X(MCIERR_INVALID_FILE)
83 X(MCIERR_NULL_PARAMETER_BLOCK)
84 X(MCIERR_UNNAMED_RESOURCE)
85 X(MCIERR_NEW_REQUIRES_ALIAS)
86 X(MCIERR_NOTIFY_ON_AUTO_OPEN)
87 X(MCIERR_NO_ELEMENT_ALLOWED)
88 X(MCIERR_NONAPPLICABLE_FUNCTION)
89 X(MCIERR_ILLEGAL_FOR_AUTO_OPEN)
90 X(MCIERR_FILENAME_REQUIRED)
91 X(MCIERR_EXTRA_CHARACTERS)
92 X(MCIERR_DEVICE_NOT_INSTALLED)
96 X(MCIERR_DEVICE_LENGTH)
97 X(MCIERR_DEVICE_ORD_LENGTH)
99 X(MCIERR_WAVE_OUTPUTSINUSE)
100 X(MCIERR_WAVE_SETOUTPUTINUSE)
101 X(MCIERR_WAVE_INPUTSINUSE)
102 X(MCIERR_WAVE_SETINPUTINUSE)
103 X(MCIERR_WAVE_OUTPUTUNSPECIFIED)
104 X(MCIERR_WAVE_INPUTUNSPECIFIED)
105 X(MCIERR_WAVE_OUTPUTSUNSUITABLE)
106 X(MCIERR_WAVE_SETOUTPUTUNSUITABLE)
107 X(MCIERR_WAVE_INPUTSUNSUITABLE)
108 X(MCIERR_WAVE_SETINPUTUNSUITABLE)
109 X(MCIERR_SEQ_DIV_INCOMPATIBLE)
110 X(MCIERR_SEQ_PORT_INUSE)
111 X(MCIERR_SEQ_PORT_NONEXISTENT)
112 X(MCIERR_SEQ_PORT_MAPNODEVICE)
113 X(MCIERR_SEQ_PORT_MISCERROR)
115 X(MCIERR_SEQ_PORTUNSPECIFIED)
116 X(MCIERR_SEQ_NOMIDIPRESENT)
118 X(MCIERR_CREATEWINDOW)
121 X(MCIERR_NO_IDENTITY)
124 static char name[20]; /* Not to be called twice in a parameter list! */
125 sprintf(name, "MMSYSERR %u", err);
131 static BOOL spurious_message(LPMSG msg)
133 /* WM_DEVICECHANGE 0x0219 appears randomly */
134 if(msg->message != MM_MCINOTIFY) {
135 trace("skipping spurious message %04x\n",msg->message);
141 /* A single ok() in each code path allows to prefix this with todo_wine */
142 #define test_notification(hwnd, command, type) test_notification_dbg(hwnd, command, type, __LINE__)
143 static void test_notification_dbg(HWND hwnd, const char* command, WPARAM type, int line)
144 { /* Use type 0 as meaning no message */
147 do { seen = PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE); }
148 while(seen && spurious_message(&msg));
150 /* We observe transient delayed notification, mostly on native.
151 * Notification is not always present right when mciSend returns. */
152 trace_(__FILE__,line)("Waiting for delayed notification from %s\n", command);
153 MsgWaitForMultipleObjects(0, NULL, FALSE, 3000, QS_POSTMESSAGE);
154 seen = PeekMessageA(&msg, hwnd, MM_MCINOTIFY, MM_MCINOTIFY, PM_REMOVE);
157 ok_(__FILE__,line)(type==0, "Expect message %04lx from %s\n", type, command);
158 else if(msg.hwnd != hwnd)
159 ok_(__FILE__,line)(msg.hwnd == hwnd, "Didn't get the handle to our test window\n");
160 else if(msg.message != MM_MCINOTIFY)
161 ok_(__FILE__,line)(msg.message == MM_MCINOTIFY, "got %04x instead of MM_MCINOTIFY from command %s\n", msg.message, command);
162 else ok_(__FILE__,line)(msg.wParam == type, "got %04lx instead of MCI_NOTIFY_xyz %04lx from command %s\n", msg.wParam, type, command);
165 static void test_mciParser(HWND hwnd)
168 MCIDEVICEID wDeviceID;
169 MCI_PARMS_UNION parm;
171 memset(buf, 0, sizeof(buf));
172 test_notification(hwnd, "-prior to parser test-", 0);
174 /* Get a handle on an MCI device, works even without sound. */
175 parm.open.lpstrDeviceType = "waveaudio";
176 parm.open.lpstrElementName = ""; /* "new" at the command level */
177 parm.open.lpstrAlias = "x"; /* to enable mciSendString */
178 parm.open.dwCallback = (DWORD_PTR)hwnd;
179 err = mciSendCommand(0, MCI_OPEN,
180 MCI_OPEN_ELEMENT | MCI_OPEN_TYPE | MCI_OPEN_ALIAS | MCI_NOTIFY,
182 ok(!err,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err));
183 wDeviceID = parm.open.wDeviceID;
184 ok(!strcmp(parm.open.lpstrDeviceType,"waveaudio"), "open modified device type\n");
186 test_notification(hwnd, "MCI_OPEN", MCI_NOTIFY_SUCCESSFUL);
187 test_notification(hwnd, "MCI_OPEN no #2", 0);
189 err = mciSendString("open avivideo alias a", buf, sizeof(buf), hwnd);
190 ok(!err,"open another: %s\n", dbg_mcierr(err));
192 err = mciSendString("", buf, sizeof(buf), NULL);
193 todo_wine ok(err==MCIERR_MISSING_COMMAND_STRING,"empty string: %s\n", dbg_mcierr(err));
195 err = mciSendString("open", buf, sizeof(buf), NULL);
196 ok(err==MCIERR_MISSING_DEVICE_NAME,"open void: %s\n", dbg_mcierr(err));
198 err = mciSendString("open notify", buf, sizeof(buf), NULL);
199 todo_wine ok(err==MCIERR_INVALID_DEVICE_NAME,"open notify: %s\n", dbg_mcierr(err));
201 err = mciSendString("open new", buf, sizeof(buf), NULL);
202 todo_wine ok(err==MCIERR_NEW_REQUIRES_ALIAS,"open new: %s\n", dbg_mcierr(err));
204 err = mciSendString("open new type waveaudio alias r shareable shareable", buf, sizeof(buf), NULL);
205 todo_wine ok(err==MCIERR_DUPLICATE_FLAGS,"open new: %s\n", dbg_mcierr(err));
206 if(!err) mciSendString("close r", NULL, 0, NULL);
208 err = mciSendString("status x position wait wait", buf, sizeof(buf), NULL);
209 todo_wine ok(err==MCIERR_DUPLICATE_FLAGS,"status wait wait: %s\n", dbg_mcierr(err));
211 err = mciSendString("status x length length", buf, sizeof(buf), NULL);
212 todo_wine ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"status 2xlength: %s\n", dbg_mcierr(err));
214 err = mciSendString("status x length position", buf, sizeof(buf), NULL);
215 todo_wine ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"status length+position: %s\n", dbg_mcierr(err));
217 err = mciSendString("set x time format milliseconds time format ms", buf, sizeof(buf), NULL);
218 todo_wine ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"status length+position: %s\n", dbg_mcierr(err));
220 /* device's response, not a parser test */
221 err = mciSendString("status x", buf, sizeof(buf), NULL);
222 todo_wine ok(err==MCIERR_MISSING_PARAMETER,"status waveaudio nokeyword: %s\n", dbg_mcierr(err));
224 err = mciSendString("status a", buf, sizeof(buf), NULL);
225 todo_wine ok(err==MCIERR_UNSUPPORTED_FUNCTION,"status avivideo nokeyword: %s\n", dbg_mcierr(err));
227 err = mciSendString("status x track", buf, sizeof(buf), NULL);
228 todo_wine ok(err==MCIERR_BAD_INTEGER,"status waveaudio no track: %s\n", dbg_mcierr(err));
230 err = mciSendString("status x track 3", buf, sizeof(buf), NULL);
231 todo_wine ok(err==MCIERR_MISSING_PARAMETER,"status waveaudio track 3: %s\n", dbg_mcierr(err));
233 err = mciSendString("status x 2 track 3", buf, sizeof(buf), NULL);
234 todo_wine ok(err==MCIERR_OUTOFRANGE,"status 2(position) track 3: %s\n", dbg_mcierr(err));
236 err = mciSendString("status x 4", buf, sizeof(buf), hwnd);
237 ok(!err,"status 4(mode): %s\n", dbg_mcierr(err));
238 if(!err)ok(!strcmp(buf,"stopped"), "status 4(mode), got: %s\n", buf);
240 err = mciSendString("status x 4 notify", buf, sizeof(buf), hwnd);
241 todo_wine ok(!err,"status 4(mode) notify: %s\n", dbg_mcierr(err));
242 if(!err)ok(!strcmp(buf,"stopped"), "status 4(mode), got: %s\n", buf);
243 test_notification(hwnd, "status 4 notify", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
245 err = mciSendString("set x milliseconds", buf, sizeof(buf), hwnd);
246 todo_wine ok(err==MCIERR_UNRECOGNIZED_KEYWORD,"set milliseconds: %s\n", dbg_mcierr(err));
248 err = mciSendString("set x milliseconds ms", buf, sizeof(buf), hwnd);
249 todo_wine ok(err==MCIERR_UNRECOGNIZED_KEYWORD,"set milliseconds ms: %s\n", dbg_mcierr(err));
251 err = mciSendString("capability x can save", buf, sizeof(buf), hwnd);
252 todo_wine ok(!err,"capability can (space) save: %s\n", dbg_mcierr(err));
254 err = mciSendString("status x nsa", buf, sizeof(buf), hwnd);
255 todo_wine ok(err==MCIERR_BAD_CONSTANT,"status nsa: %s\n", dbg_mcierr(err));
257 err = mciSendString("status all time format", buf, sizeof(buf), hwnd);
258 ok(err==MCIERR_CANNOT_USE_ALL,"status all: %s\n", dbg_mcierr(err));
260 err = mciSendString("cue all", buf, sizeof(buf), NULL);
261 ok(err==MCIERR_UNRECOGNIZED_COMMAND,"cue all: %s\n", dbg_mcierr(err));
263 err = mciSendString("open all", buf, sizeof(buf), NULL);
264 todo_wine ok(err==MCIERR_CANNOT_USE_ALL,"open all: %s\n", dbg_mcierr(err));
266 /* avivideo is not a known MCI_DEVTYPE resource name */
267 err = mciSendString("sysinfo avivideo quantity", buf, sizeof(buf), hwnd);
268 ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo sequencer quantity: %s\n", dbg_mcierr(err));
270 err = mciSendString("sysinfo digitalvideo quantity", buf, sizeof(buf), hwnd);
271 ok(!err,"sysinfo digitalvideo quantity: %s\n", dbg_mcierr(err));
272 if(!err) ok(!strcmp(buf,"0"), "sysinfo digitalvideo quantity returned %s\n", buf);
274 /* quantity 0 yet open 1 (via type "avivideo"), fun */
275 err = mciSendString("sysinfo digitalvideo quantity open", buf, sizeof(buf), hwnd);
276 ok(!err,"sysinfo digitalvideo quantity open: %s\n", dbg_mcierr(err));
277 if(!err) ok(!strcmp(buf,"1"), "sysinfo digitalvideo quantity open returned %s\n", buf);
279 err = mciSendString("put a window at 0 0", buf, sizeof(buf), NULL);
280 todo_wine ok(err==MCIERR_BAD_INTEGER,"put incomplete rect: %s\n", dbg_mcierr(err));
282 /*w9X-w2k report code from device last opened, newer versions compare them all
283 * and return the one error code or MCIERR_MULTIPLE if they differ. */
284 err = mciSendString("pause all", buf, sizeof(buf), NULL);
285 todo_wine ok(err==MCIERR_MULTIPLE || broken(err==MCIERR_NONAPPLICABLE_FUNCTION),"pause all: %s\n", dbg_mcierr(err));
287 /* MCI_STATUS' dwReturn is a DWORD_PTR, others' a plain DWORD. */
288 parm.status.dwItem = MCI_STATUS_TIME_FORMAT;
289 parm.status.dwReturn = 0xFEEDABAD;
290 err = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&parm);
291 ok(!err,"mciCommand status time format: %s\n", dbg_mcierr(err));
292 if(!err) ok(MCI_FORMAT_MILLISECONDS==parm.status.dwReturn,"status time format: %ld\n",parm.status.dwReturn);
294 parm.status.dwItem = MCI_STATUS_MODE;
295 parm.status.dwReturn = 0xFEEDABAD;
296 err = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&parm);
297 ok(!err,"mciCommand status mode: %s\n", dbg_mcierr(err));
298 if(!err) ok(MCI_MODE_STOP==parm.status.dwReturn,"STATUS mode: %ld\n",parm.status.dwReturn);
300 err = mciSendString("status x mode", buf, sizeof(buf), hwnd);
301 ok(!err,"status mode: %s\n", dbg_mcierr(err));
302 if(!err) ok(!strcmp(buf, "stopped"), "status mode is %s\n", buf);
304 parm.caps.dwItem = MCI_GETDEVCAPS_USES_FILES;
305 parm.caps.dwReturn = 0xFEEDABAD;
306 err = mciSendCommand(wDeviceID, MCI_GETDEVCAPS, MCI_GETDEVCAPS_ITEM, (DWORD_PTR)&parm);
307 ok(!err,"mciCommand getdevcaps files: %s\n", dbg_mcierr(err));
308 if(!err) ok(1==parm.caps.dwReturn,"getdevcaps files: %d\n",parm.caps.dwReturn);
310 parm.caps.dwItem = MCI_GETDEVCAPS_HAS_VIDEO;
311 parm.caps.dwReturn = 0xFEEDABAD;
312 err = mciSendCommand(wDeviceID, MCI_GETDEVCAPS, MCI_GETDEVCAPS_ITEM, (DWORD_PTR)&parm);
313 ok(!err,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err));
314 if(!err) ok(0==parm.caps.dwReturn,"getdevcaps video: %d\n",parm.caps.dwReturn);
316 parm.caps.dwItem = MCI_GETDEVCAPS_DEVICE_TYPE;
317 parm.caps.dwReturn = 0xFEEDABAD;
318 err = mciSendCommand(wDeviceID, MCI_GETDEVCAPS, MCI_GETDEVCAPS_ITEM, (DWORD_PTR)&parm);
319 ok(!err,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err));
320 if(!err) ok(MCI_DEVTYPE_WAVEFORM_AUDIO==parm.caps.dwReturn,"getdevcaps device type: %d\n",parm.caps.dwReturn);
322 err = mciSendString("capability x uses files", buf, sizeof(buf), hwnd);
323 ok(!err,"capability files: %s\n", dbg_mcierr(err));
324 if(!err) ok(!strcmp(buf, "true"), "capability files is %s\n", buf);
326 err = mciSendString("capability x has video", buf, sizeof(buf), hwnd);
327 ok(!err,"capability video: %s\n", dbg_mcierr(err));
328 if(!err) ok(!strcmp(buf, "false"), "capability video is %s\n", buf);
330 err = mciSendString("capability x device type", buf, sizeof(buf), hwnd);
331 ok(!err,"capability device type: %s\n", dbg_mcierr(err));
332 if(!err) ok(!strcmp(buf, "waveaudio"), "capability device type is %s\n", buf);
334 err = mciSendCommand(wDeviceID, MCI_CLOSE, 0, 0);
335 ok(!err,"mciCommand close returned %s\n", dbg_mcierr(err));
337 err = mciSendString("close a", buf, sizeof(buf), hwnd);
338 ok(!err,"close avi: %s\n", dbg_mcierr(err));
340 test_notification(hwnd, "-end of 1st set-", 0);
343 static void test_openCloseWAVE(HWND hwnd)
346 MCI_PARMS_UNION parm;
347 const char command_open[] = "open new type waveaudio alias mysound notify";
348 const char command_close_my[] = "close mysound notify";
349 const char command_close_all[] = "close all notify";
350 const char command_sysinfo[] = "sysinfo waveaudio quantity open";
352 DWORD intbuf[3] = { 0xDEADF00D, 99, 0xABADCAFE };
353 memset(buf, 0, sizeof(buf));
354 test_notification(hwnd, "-prior to any command-", 0);
356 /* Avoid Sysinfo quantity with notify because Win9x and newer differ. */
357 err = mciSendString("sysinfo all quantity", buf, sizeof(buf), hwnd);
358 ok(!err,"mci sysinfo all quantity returned %s\n", dbg_mcierr(err));
359 if(!err) trace("[MCI] with %s drivers\n", buf);
361 parm.sys.lpstrReturn = (LPSTR)&intbuf[1];
362 parm.sys.dwRetSize = sizeof(DWORD);
363 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
364 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (DWORD_PTR)&parm);
365 ok(!err,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO QUANTITY, MCI_WAIT, 0) returned %s\n", dbg_mcierr(err));
366 if(!err) ok(atoi(buf)==intbuf[1],"sysinfo all quantity string and command differ\n");
368 parm.sys.dwRetSize = sizeof(DWORD)-1;
369 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_QUANTITY, (DWORD_PTR)&parm);
370 ok(err==MCIERR_PARAM_OVERFLOW || broken(!err/* Win9x */),"mciSendCommand MCI_SYSINFO with too small buffer returned %s\n", dbg_mcierr(err));
372 err = mciSendString("open new type waveaudio alias r shareable", buf, sizeof(buf), NULL);
373 ok(err==MCIERR_UNSUPPORTED_FUNCTION,"mci open new shareable returned %s\n", dbg_mcierr(err));
375 err = mciSendString("close r", NULL, 0, NULL);
376 ok(!err,"mci close shareable returned %s\n", dbg_mcierr(err));
379 err = mciSendString(command_open, buf, sizeof(buf), hwnd);
380 ok(!err,"mci %s returned %s\n", command_open, dbg_mcierr(err));
381 ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
382 /* Wine<=1.1.33 used to ignore anything past alias XY */
383 test_notification(hwnd,"open new alias notify",MCI_NOTIFY_SUCCESSFUL);
385 err = mciSendString("status mysound time format", buf, sizeof(buf), hwnd);
386 ok(!err,"mci status time format returned %s\n", dbg_mcierr(err));
388 if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) == LANG_ENGLISH)
389 ok(!strcmp(buf,"milliseconds"), "mci status time format: %s\n", buf);
390 else trace("locale-dependent time format: %s (ms)\n", buf);
393 memset(buf, 0, sizeof(buf));
394 parm.sys.dwNumber = 1;
395 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
396 parm.sys.lpstrReturn = buf;
397 parm.sys.dwRetSize = sizeof(buf);
398 parm.sys.dwCallback = (DWORD_PTR)hwnd;
399 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN | MCI_NOTIFY, (DWORD_PTR)&parm);
400 ok(!err,"mciCommand MCI_SYSINFO all name 1 open notify: %s\n", dbg_mcierr(err));
401 if(!err) ok(!strcmp(buf,"mysound"), "sysinfo name returned %s\n", buf);
402 test_notification(hwnd, "SYSINFO name notify\n", MCI_NOTIFY_SUCCESSFUL);
404 memset(buf, 0, sizeof(buf));
405 parm.sys.dwNumber = 1;
406 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
407 parm.sys.lpstrReturn = buf;
408 parm.sys.dwRetSize = 8; /* mysound\0 */
409 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
410 ok(!err,"mciCommand MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err));
411 if(!err) ok(!strcmp(buf,"mysound"), "sysinfo name returned %s\n", buf);
413 /* dwRetSize counts characters, not bytes, despite what MSDN says. */
414 parm.sys.dwNumber = 1;
415 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
416 parm.sys.lpstrReturn = buf;
417 parm.sys.dwRetSize = 8; /* mysound\0 */
418 /* MCI_..._PARMSA and PARMSW share the same layout, use one for both tests. */
419 err = mciSendCommandW(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
420 ok(!err || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err));
421 /* TODO strcmpW((LPWSTR)buf,"mysound") */
423 parm.sys.dwNumber = 1;
424 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
425 parm.sys.lpstrReturn = buf;
426 parm.sys.dwRetSize = 7; /* too short for mysound\0 */
427 err = mciSendCommandW(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
428 ok(err==MCIERR_PARAM_OVERFLOW || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err));
430 /* Win9x overwrites the tiny buffer and returns success, newer versions signal overflow. */
431 memset(buf, 0, sizeof(buf));
432 parm.sys.dwNumber = 1;
433 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
434 parm.sys.lpstrReturn = buf;
435 parm.sys.dwRetSize = 2; /* too short for mysound\0 */
436 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
437 ok(err==MCIERR_PARAM_OVERFLOW || broken(!err /* Win9x */),"mciCommand MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err));
438 if(!err) ok(!strcmp(buf,"mysound"), "sysinfo short name returned %s\n", buf);
440 err = mciSendString("sysinfo mysound quantity open", buf, sizeof(buf), hwnd);
441 ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo alias quantity: %s\n", dbg_mcierr(err));
443 err = mciSendString("sysinfo nosuchalias quantity open", buf, sizeof(buf), hwnd);
444 ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo unknown quantity open: %s\n", dbg_mcierr(err));
446 err = mciSendString("sysinfo all installname", buf, sizeof(buf), hwnd);
447 ok(err==MCIERR_CANNOT_USE_ALL,"sysinfo all installname: %s\n", dbg_mcierr(err));
449 err = mciSendString("sysinfo nodev installname", buf, sizeof(buf), hwnd);
450 ok(err==MCIERR_INVALID_DEVICE_NAME,"sysinfo nodev installname: %s\n", dbg_mcierr(err));
452 err = mciGetDeviceID("all");
453 ok(MCI_ALL_DEVICE_ID==err || /* Win9x */(UINT16)MCI_ALL_DEVICE_ID==err,"mciGetDeviceID all returned %u, expected %d\n", err, MCI_ALL_DEVICE_ID);
455 err = mciSendString(command_close_my, NULL, 0, hwnd);
456 ok(!err,"mci %s returned %s\n", command_close_my, dbg_mcierr(err));
457 test_notification(hwnd, command_close_my, MCI_NOTIFY_SUCCESSFUL);
459 test_notification(hwnd, command_close_my, 0);
461 err = mciSendString("open no-such-file-exists.wav alias y", buf, sizeof(buf), NULL);
462 ok(err==MCIERR_FILE_NOT_FOUND,"open no-such-file.wav returned %s\n", dbg_mcierr(err));
464 err = mciSendString("close y", NULL, 0, NULL);
465 ok(!err,"close y returned %s\n", dbg_mcierr(err));
468 err = mciSendString("open no-such-dir\\file.wav alias y type waveaudio", buf, sizeof(buf), NULL);
469 ok(err==MCIERR_FILE_NOT_FOUND || broken(err==MCIERR_INVALID_FILE /* Win9X */),"open no-such-dir/file.wav returned %s\n", dbg_mcierr(err));
471 err = mciSendString("close y", NULL, 0, NULL);
472 ok(!err,"close y returned %s\n", dbg_mcierr(err));
475 err = mciSendString("open ! alias no", buf, sizeof(buf), NULL);
476 ok(err==MCIERR_INVALID_DEVICE_NAME,"open !(void): %s\n", dbg_mcierr(err));
478 err = mciSendString("open !no-such-file-exists.wav alias no", buf, sizeof(buf), NULL);
479 ok(err==MCIERR_FILE_NOT_FOUND || /* Win9X */err==MCIERR_INVALID_DEVICE_NAME,"open !name: %s\n", dbg_mcierr(err));
481 /* FILE_NOT_FOUND stems from mciwave,
482 * the complete name including ! is passed through since NT */
483 err = mciSendString("open nosuchdevice!tempfile.wav alias no", buf, sizeof(buf), NULL);
484 ok(err==MCIERR_FILE_NOT_FOUND || /* Win9X */err==MCIERR_INVALID_DEVICE_NAME,"open nosuchdevice!name: %s\n", dbg_mcierr(err));
485 /* FIXME? use broken(INVALID_DEVICE_NAME) and have Wine not mimic Win9X? */
487 err = mciSendString("close waveaudio", buf, sizeof(buf), NULL);
488 todo_wine ok(err==MCIERR_INVALID_DEVICE_NAME,"open nosuchdevice!name: %s\n", dbg_mcierr(err));
490 err = mciSendString(command_close_all, NULL, 0, NULL);
491 ok(!err,"mci %s (without buffer) returned %s\n", command_close_all, dbg_mcierr(err));
493 memset(buf, 0, sizeof(buf));
494 err = mciSendString(command_close_all, buf, sizeof(buf), hwnd);
495 ok(!err,"mci %s (with output buffer) returned %s\n", command_close_all, dbg_mcierr(err));
496 ok(buf[0] == 0, "mci %s changed output buffer: %s\n", command_close_all, buf);
497 /* No notification left, everything closed already */
498 test_notification(hwnd, command_close_all, 0);
499 /* TODO test close all sends one notification per open device */
501 memset(buf, 0, sizeof(buf));
502 err = mciSendString(command_sysinfo, buf, sizeof(buf), NULL);
503 ok(!err,"mci %s returned %s\n", command_sysinfo, dbg_mcierr(err));
504 ok(buf[0] == '0' && buf[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo, buf);
506 err = mciSendString("open new type waveaudio", buf, sizeof(buf), NULL);
507 ok(err==MCIERR_NEW_REQUIRES_ALIAS,"mci open new without alias returned %s\n", dbg_mcierr(err));
509 parm.open.lpstrDeviceType = (LPSTR)MCI_DEVTYPE_WAVEFORM_AUDIO;
510 err = mciSendCommand(0, MCI_OPEN,
511 MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID,
513 ok(!err,"mciCommand OPEN_TYPE_ID waveaudio: %s\n", dbg_mcierr(err));
516 MCIDEVICEID wDeviceID = parm.open.wDeviceID;
517 parm.caps.dwItem = MCI_GETDEVCAPS_DEVICE_TYPE;
518 err = mciSendCommand(wDeviceID, MCI_GETDEVCAPS, MCI_GETDEVCAPS_ITEM, (DWORD_PTR)&parm);
519 ok(!err,"mciCommand MCI_GETDEVCAPS device type: %s\n", dbg_mcierr(err));
520 ok(MCI_DEVTYPE_WAVEFORM_AUDIO==parm.caps.dwReturn,"mciCommand GETDEVCAPS says %u, expected %u\n", parm.caps.dwReturn, MCI_DEVTYPE_WAVEFORM_AUDIO);
523 ok(0xDEADF00D==intbuf[0] && 0xABADCAFE==intbuf[2],"DWORD buffer corruption\n");
525 err = mciGetDeviceID("waveaudio");
526 ok(err==1,"mciGetDeviceID waveaudio returned %u, expected 0\n", err);
528 err = mciSendString("open no-such-file.wav alias waveaudio", buf, sizeof(buf), NULL);
529 ok(err==MCIERR_DUPLICATE_ALIAS, "mci open alias waveaudio returned %s\n", dbg_mcierr(err));
530 /* If it were not already in use, open avivideo alias waveaudio would succeed,
531 * making for funny test cases. */
533 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0); /* from MSDN */
534 ok(!err,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0) returned %s\n", dbg_mcierr(err));
536 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_NOTIFY, 0);
537 ok(!err,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_NOTIFY, 0) returned %s\n", dbg_mcierr(err));
539 parm.gen.dwCallback = (DWORD_PTR)hwnd;
540 err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_NOTIFY, (DWORD_PTR)&parm);
541 ok(!err,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_NOTIFY, hwnd) returned %s\n", dbg_mcierr(err));
542 test_notification(hwnd, command_close_all, 0); /* None left */
545 static void test_recordWAVE(HWND hwnd)
549 DWORD nsamp = 16000, expect;
550 UINT ndevs = waveInGetNumDevs();
551 MCIERROR err, ok_pcm;
552 MCIDEVICEID wDeviceID;
553 MCI_PARMS_UNION parm;
555 memset(buf, 0, sizeof(buf));
556 test_notification(hwnd, "-prior to recording-", 0);
558 parm.open.lpstrDeviceType = "waveaudio";
559 parm.open.lpstrElementName = ""; /* "new" at the command level */
560 parm.open.lpstrAlias = "x"; /* to enable mciSendString */
561 parm.open.dwCallback = (DWORD_PTR)hwnd;
562 err = mciSendCommand(0, MCI_OPEN,
563 MCI_OPEN_ELEMENT | MCI_OPEN_TYPE | MCI_OPEN_ALIAS | MCI_NOTIFY,
565 ok(!err,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err));
566 wDeviceID = parm.open.wDeviceID;
568 err = mciGetDeviceID("x");
569 ok(err==wDeviceID,"mciGetDeviceID x returned %u, expected %u\n", err, wDeviceID);
571 /* Only the alias is looked up. */
572 err = mciGetDeviceID("waveaudio");
573 ok(err==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err);
575 test_notification(hwnd, "open new", MCI_NOTIFY_SUCCESSFUL);
576 test_notification(hwnd, "open new no #2", 0);
578 /* Do not query time format as string because result depends on locale! */
579 parm.status.dwItem = MCI_STATUS_TIME_FORMAT;
580 err = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&parm);
581 ok(!err,"mciCommand status time format: %s\n", dbg_mcierr(err));
582 ok(parm.status.dwReturn==MCI_FORMAT_MILLISECONDS,"status time format: %ld\n",parm.status.dwReturn);
584 /* Info file fails until named in Open or Save. */
585 err = mciSendString("info x file", buf, sizeof(buf), NULL);
586 todo_wine ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci info new file returned %s\n", dbg_mcierr(err));
588 /* Check the default recording: 8-bits per sample, mono, 11kHz */
589 err = mciSendString("status x samplespersec", buf, sizeof(buf), NULL);
590 ok(!err,"mci status samplespersec returned %s\n", dbg_mcierr(err));
591 if(!err) ok(!strcmp(buf,"11025"), "mci status samplespersec expected 11025, got: %s\n", buf);
593 /* MCI seems to solely support PCM, no need for ACM conversion. */
594 err = mciSendString("set x format tag 2", NULL, 0, NULL);
595 ok(err==MCIERR_OUTOFRANGE,"mci set format tag 2 returned %s\n", dbg_mcierr(err));
597 /* MCI appears to scan the available devices for support of this format,
598 * returning MCIERR_OUTOFRANGE on machines with no sound.
599 * However some w2k8/w7 machines return no error when there's no wave
600 * input device (perhaps querying waveOutGetNumDevs instead of waveIn?),
601 * still the record command below fails with MCIERR_WAVE_INPUTSUNSUITABLE.
602 * Don't skip here, record will fail below. */
603 err = mciSendString("set x format tag pcm", NULL, 0, NULL);
604 ok(!err || err==MCIERR_OUTOFRANGE,"mci set format tag pcm returned %s\n", dbg_mcierr(err));
607 /* MSDN warns against not setting all wave format parameters.
608 * Indeed, it produces strange results, incl.
609 * inconsistent PCMWAVEFORMAT headers in the saved file.
611 err = mciSendString("set x bytespersec 22050 alignment 2 samplespersec 11025 channels 1 bitspersample 16", NULL, 0, NULL);
612 ok(err==ok_pcm,"mci set 5 wave parameters returned %s\n", dbg_mcierr(err));
613 /* Investigate: on w2k, set samplespersec 22050 sets nChannels to 2!
614 * err = mciSendString("set x samplespersec 22050", NULL, 0, NULL);
615 * ok(!err,"mci set samplespersec returned %s\n", dbg_mcierr(err));
618 /* Checks are generally performed immediately. */
619 err = mciSendString("set x bitspersample 4", NULL, 0, NULL);
620 todo_wine ok(err==MCIERR_OUTOFRANGE,"mci set bitspersample 4 returned %s\n", dbg_mcierr(err));
622 parm.set.wFormatTag = WAVE_FORMAT_PCM;
623 parm.set.nSamplesPerSec = nsamp;
624 parm.set.wBitsPerSample = nbits;
625 parm.set.nChannels = nch;
626 parm.set.nBlockAlign = parm.set.nChannels * parm.set.wBitsPerSample /8;
627 parm.set.nAvgBytesPerSec= parm.set.nSamplesPerSec * parm.set.nBlockAlign;
628 err = mciSendCommand(wDeviceID, MCI_SET,
629 MCI_WAVE_SET_SAMPLESPERSEC | MCI_WAVE_SET_CHANNELS |
630 MCI_WAVE_SET_BITSPERSAMPLE | MCI_WAVE_SET_BLOCKALIGN |
631 MCI_WAVE_SET_AVGBYTESPERSEC| MCI_WAVE_SET_FORMATTAG, (DWORD_PTR)&parm);
632 ok(err==ok_pcm,"mciCommand set wave format: %s\n", dbg_mcierr(err));
634 parm.caps.dwItem = MCI_WAVE_GETDEVCAPS_INPUTS;
635 parm.caps.dwCallback = (DWORD_PTR)hwnd;
636 err = mciSendCommand(wDeviceID, MCI_GETDEVCAPS, MCI_GETDEVCAPS_ITEM | MCI_NOTIFY, (DWORD_PTR)&parm);
637 ok(!err,"mciCommand MCI_GETDEVCAPS inputs: %s\n", dbg_mcierr(err));
638 ok(parm.caps.dwReturn==ndevs,"mciCommand GETDEVCAPS claims %u inputs, expected %u\n", parm.caps.dwReturn, ndevs);
639 ok(!ok_pcm || !parm.caps.dwReturn,"No input device accepts PCM!?\n");
640 test_notification(hwnd, "GETDEVCAPS inputs", MCI_NOTIFY_SUCCESSFUL);
642 /* A few ME machines pass all tests except set format tag pcm! */
643 err = mciSendString("record x to 2000 wait", NULL, 0, hwnd);
644 ok(err || !ok_pcm,"can record yet set wave format pcm returned %s\n", dbg_mcierr(ok_pcm));
645 if(!ndevs) todo_wine /* with sound disabled */
646 ok(ndevs>0 ? !err : err==MCIERR_WAVE_INPUTSUNSUITABLE,"mci record to 2000 returned %s\n", dbg_mcierr(err));
648 ok(ndevs>0 ? !err : err==MCIERR_WAVE_INPUTSUNSUITABLE,"mci record to 2000 returned %s\n", dbg_mcierr(err));
650 if (err==MCIERR_WAVE_INPUTSUNSUITABLE)
651 skip("Please install audio driver. Everything is skipped.\n");
652 else skip("Cannot record cause %s. Everything is skipped.\n", dbg_mcierr(err));
654 err = mciSendString("close x", NULL, 0, NULL);
655 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
656 test_notification(hwnd,"record skipped",0);
660 /* Query some wave format parameters depending on the time format. */
661 err = mciSendString("status x position", buf, sizeof(buf), NULL);
662 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
663 if(!err) todo_wine ok(!strcmp(buf,"2000"), "mci status position gave %s, expected 2000, some tests will fail\n", buf);
665 err = mciSendString("set x time format 8", NULL, 0, NULL); /* bytes */
666 ok(!err,"mci returned %s\n", dbg_mcierr(err));
668 parm.status.dwItem = MCI_STATUS_POSITION;
669 err = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&parm);
670 ok(!err,"mciCommand status position: %s\n", dbg_mcierr(err));
671 expect = 2 * nsamp * nch * nbits/8;
672 if(!err) todo_wine ok(parm.status.dwReturn==expect,"recorded %lu bytes, expected %u\n",parm.status.dwReturn,expect);
674 parm.set.dwTimeFormat = MCI_FORMAT_SAMPLES;
675 err = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)&parm);
676 ok(!err,"mciCommand set time format samples: %s\n", dbg_mcierr(err));
678 parm.status.dwItem = MCI_STATUS_POSITION;
679 err = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&parm);
680 ok(!err,"mciCommand status position: %s\n", dbg_mcierr(err));
682 if(!err) todo_wine ok(parm.status.dwReturn==expect,"recorded %lu samples, expected %u\n",parm.status.dwReturn,expect);
684 err = mciSendString("set x time format milliseconds", NULL, 0, NULL);
685 ok(!err,"mci set time format milliseconds returned %s\n", dbg_mcierr(err));
687 err = mciSendString("save x tempfile1.wav", NULL, 0, NULL);
688 ok(!err,"mci save returned %s\n", dbg_mcierr(err));
690 err = mciSendString("save x tempfile.wav", NULL, 0, NULL);
691 ok(!err,"mci save returned %s\n", dbg_mcierr(err));
692 if(!err) ok_saved = 0;
694 /* Save must not rename the original file. */
695 if (!DeleteFile("tempfile1.wav"))
696 todo_wine ok(FALSE, "Save must not rename the original file; DeleteFile returned %d\n", GetLastError());
698 err = mciSendString("set x channels 2", NULL, 0, NULL);
699 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci set channels after saving returned %s\n", dbg_mcierr(err));
701 parm.seek.dwTo = 600;
702 err = mciSendCommand(wDeviceID, MCI_SEEK, MCI_TO | MCI_WAIT, (DWORD_PTR)&parm);
703 ok(!err,"mciCommand seek to 600: %s\n", dbg_mcierr(err));
705 /* Truncate to current position */
706 err = mciSendString("delete x", NULL, 0, NULL);
707 todo_wine ok(!err,"mci delete returned %s\n", dbg_mcierr(err));
710 err = mciSendString("status x length", buf, sizeof(buf), NULL);
711 ok(!err,"mci status length returned %s\n", dbg_mcierr(err));
712 todo_wine ok(!strcmp(buf,"600"), "mci status length after delete gave %s, expected 600\n", buf);
714 err = mciSendString("close x", NULL, 0, NULL);
715 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
716 test_notification(hwnd,"record complete",0);
719 static void test_playWAVE(HWND hwnd)
723 memset(buf, 0, sizeof(buf));
725 err = mciSendString("open waveaudio!tempfile.wav alias mysound", NULL, 0, NULL);
726 ok(err==ok_saved,"mci open waveaudio!tempfile.wav returned %s\n", dbg_mcierr(err));
728 skip("Cannot open waveaudio!tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err));
732 err = mciGetDeviceID("mysound");
733 ok(err==1,"mciGetDeviceID mysound returned %u, expected 1\n", err);
735 err = mciGetDeviceID("tempfile.wav");
736 ok(err==0,"mciGetDeviceID tempfile.wav returned %u, expected 0\n", err);
738 err = mciGetDeviceID("waveaudio");
739 ok(err==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err);
741 err = mciSendString("status mysound length", buf, sizeof(buf), NULL);
742 ok(!err,"mci status length returned %s\n", dbg_mcierr(err));
743 todo_wine ok(!strcmp(buf,"2000"), "mci status length gave %s, expected 2000, some tests will fail.\n", buf);
745 err = mciSendString("cue output", NULL, 0, NULL);
746 todo_wine ok(err==MCIERR_UNRECOGNIZED_COMMAND,"mci incorrect cue output returned %s\n", dbg_mcierr(err));
748 /* Test MCI to the bones -- Some todo_wine from Cue and
749 * from Play from 0 to 0 are not worth fixing. */
750 err = mciSendString("cue mysound output notify", NULL, 0, hwnd);
751 ok(!err,"mci cue output after open file returned %s\n", dbg_mcierr(err));
752 /* Notification is delayed as a play thread is started. */
753 todo_wine test_notification(hwnd, "cue immediate", 0);
755 /* Cue pretends to put the MCI into paused state. */
756 err = mciSendString("status mysound mode", buf, sizeof(buf), hwnd);
757 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
758 todo_wine ok(!strcmp(buf,"paused"), "mci status mode: %s, expected (pseudo)paused\n", buf);
760 /* Strange pause where Pause is rejected, unlike Play; Pause; Pause tested below */
761 err = mciSendString("pause mysound", NULL, 0, hwnd);
762 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci pause after cue returned %s\n", dbg_mcierr(err));
764 /* MCI appears to start the play thread in this border case.
765 * Guessed that from (flaky) status mode and late notification arrival. */
766 err = mciSendString("play mysound from 0 to 0 notify", NULL, 0, hwnd);
767 ok(!err,"mci play from 0 to 0 returned %s\n", dbg_mcierr(err));
768 todo_wine test_notification(hwnd, "cue aborted by play", MCI_NOTIFY_ABORTED);
769 /* play's own notification follows below */
771 err = mciSendString("play mysound from 250 to 0", NULL, 0, NULL);
772 ok(err==MCIERR_OUTOFRANGE,"mci play from 250 to 0 returned %s\n", dbg_mcierr(err));
774 Sleep(50); /* Give play from 0 to 0 time to finish. */
775 todo_wine test_notification(hwnd, "play from 0 to 0", MCI_NOTIFY_SUCCESSFUL);
777 err = mciSendString("status mysound mode", buf, sizeof(buf), hwnd);
778 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
779 ok(!strcmp(buf,"stopped"), "mci status mode: %s after play from 0 to 0\n", buf);
781 err = mciSendString("play MYSOUND from 250 to 0 notify", NULL, 0, hwnd);
782 ok(err==MCIERR_OUTOFRANGE,"mci play from 250 to 0 notify returned %s\n", dbg_mcierr(err));
783 /* No notification (checked below) sent if error */
785 /* A second play caused Wine<1.1.33 to hang */
786 err = mciSendString("play mysound from 500 to 1500 wait", NULL, 0, NULL);
787 ok(!err,"mci play from 500 to 1500 returned %s\n", dbg_mcierr(err));
789 memset(buf, 0, sizeof(buf));
790 err = mciSendString("status mysound position", buf, sizeof(buf), hwnd);
791 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
792 if(!err) ok(!strcmp(buf,"1500"), "mci status position: %s\n", buf);
794 /* mci will not play position < current */
795 err = mciSendString("play mysound to 1000", NULL, 0, NULL);
796 ok(err==MCIERR_OUTOFRANGE,"mci play to 1000 returned %s\n", dbg_mcierr(err));
798 /* mci will not play to > end */
799 err = mciSendString("play mysound TO 3000 notify", NULL, 0, hwnd);
800 ok(err==MCIERR_OUTOFRANGE,"mci play to 3000 notify returned %s\n", dbg_mcierr(err));
802 err = mciSendString("play mysound to 2000", NULL, 0, NULL);
803 ok(!err,"mci play to 2000 returned %s\n", dbg_mcierr(err));
805 /* Rejected while playing */
806 err = mciSendString("cue mysound output", NULL, 0, NULL);
807 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci cue output while playing returned %s\n", dbg_mcierr(err));
809 err = mciSendString("play mysound to 3000", NULL, 0, NULL);
810 ok(err==MCIERR_OUTOFRANGE,"mci play to 3000 returned %s\n", dbg_mcierr(err));
812 err = mciSendString("stop mysound Wait", NULL, 0, NULL);
813 ok(!err,"mci stop wait returned %s\n", dbg_mcierr(err));
814 test_notification(hwnd, "play/cue/pause/stop", 0);
816 err = mciSendString("Seek Mysound to 250 wait Notify", NULL, 0, hwnd);
817 ok(!err,"mci seek to 250 wait notify returned %s\n", dbg_mcierr(err));
818 test_notification(hwnd,"seek wait notify",MCI_NOTIFY_SUCCESSFUL);
820 memset(buf, 0, sizeof(buf));
821 err = mciSendString("status mysound position notify", buf, sizeof(buf), hwnd);
822 ok(!err,"mci status position notify returned %s\n", dbg_mcierr(err));
823 if(!err) ok(!strcmp(buf,"250"), "mci status position: %s\n", buf);
824 /* Immediate commands like status also send notifications. */
825 test_notification(hwnd,"status position",MCI_NOTIFY_SUCCESSFUL);
827 memset(buf, 0, sizeof(buf));
828 err = mciSendString("status mysound mode", buf, sizeof(buf), hwnd);
829 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
830 ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
832 /* Another play from == to testcase */
833 err = mciSendString("play mysound to 250 wait notify", NULL, 0, hwnd);
834 ok(!err,"mci play (from 250) to 250 returned %s\n", dbg_mcierr(err));
835 todo_wine test_notification(hwnd,"play to 250 wait notify",MCI_NOTIFY_SUCCESSFUL);
837 err = mciSendString("cue mysound output", NULL, 0, NULL);
838 ok(!err,"mci cue output after play returned %s\n", dbg_mcierr(err));
840 err = mciSendString("close mysound", NULL, 0, NULL);
841 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
842 test_notification(hwnd,"after close",0);
845 static void test_asyncWAVE(HWND hwnd)
847 MCIDEVICEID wDeviceID;
848 MCI_PARMS_UNION parm;
851 memset(buf, 0, sizeof(buf));
853 err = mciSendString("open tempfile.wav alias mysound notify type waveaudio", buf, sizeof(buf), hwnd);
854 ok(err==ok_saved,"mci open tempfile.wav returned %s\n", dbg_mcierr(err));
856 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err));
859 ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
860 wDeviceID = atoi(buf);
861 ok(wDeviceID,"mci open DeviceID: %d\n", wDeviceID);
862 test_notification(hwnd,"open alias notify",MCI_NOTIFY_SUCCESSFUL);
864 err = mciGetDeviceID("mysound");
865 ok(err==wDeviceID,"mciGetDeviceID alias returned %u, expected %u\n", err, wDeviceID);
867 /* Only the alias is looked up. */
868 err = mciGetDeviceID("tempfile.wav");
869 ok(err==0,"mciGetDeviceID tempfile.wav returned %u, expected 0\n", err);
871 err = mciGetDeviceID("waveaudio");
872 ok(err==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err);
874 err = mciSendString("status mysound mode", buf, sizeof(buf), hwnd);
875 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
876 ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
878 err = mciSendString("play mysound notify", NULL, 0, hwnd);
879 ok(!err,"mci play returned %s\n", dbg_mcierr(err));
881 /* Give Wine's asynchronous thread time to start up. Furthermore,
882 * it uses 3 buffers per second, so that the positions reported
883 * will be 333ms, 667ms etc. at best. */
884 Sleep(100); /* milliseconds */
886 /* Do not query time format as string because result depends on locale! */
887 parm.status.dwItem = MCI_STATUS_TIME_FORMAT;
888 err = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&parm);
889 ok(!err,"mciCommand status time format: %s\n", dbg_mcierr(err));
890 if(!err) ok(parm.status.dwReturn==MCI_FORMAT_MILLISECONDS,"status time format: %ld\n",parm.status.dwReturn);
892 parm.set.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
893 err = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)&parm);
894 ok(!err,"mciCommand set time format ms: %s\n", dbg_mcierr(err));
897 err = mciSendString("status mysound position", buf, sizeof(buf), hwnd);
898 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
899 ok(strcmp(buf,"2000"), "mci status position: %s, expected 2000\n", buf);
900 trace("position after Sleep: %sms\n",buf);
902 /* Some machines reach 79ms only during the 100ms sleep. */
903 ok(p2>=67,"not enough time elapsed %ums\n",p2);
904 test_notification(hwnd,"play (nowait)",0);
906 err = mciSendString("pause mysound wait", NULL, 0, hwnd);
907 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
910 err = mciSendString("status mysound mode notify", buf, sizeof(buf), hwnd);
911 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
912 if(!err) ok(!strcmp(buf,"paused"), "mci status mode: %s\n", buf);
913 test_notification(hwnd,"play",MCI_NOTIFY_SUPERSEDED);
914 test_notification(hwnd,"status",MCI_NOTIFY_SUCCESSFUL);
917 err = mciSendString("status mysound position", buf, sizeof(buf), hwnd);
918 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
919 trace("position while paused: %sms\n",buf);
921 ok(p1>=p2, "position not increasing: %u > %u\n", p2, p1);
923 err = mciSendString("stop mysound wait", NULL, 0, NULL);
924 ok(!err,"mci stop returned %s\n", dbg_mcierr(err));
927 err = mciSendString("info mysound file notify", buf, sizeof(buf), hwnd);
928 ok(!err,"mci info file returned %s\n", dbg_mcierr(err));
929 if(!err) { /* fully qualified name */
930 int len = strlen(buf);
931 todo_wine ok(len>2 && buf[1]==':',"Expected full pathname from info file: %s\n", buf);
932 ok(len>=12 && !strcmp(&buf[len-12],"tempfile.wav"), "info file returned: %s\n", buf);
934 test_notification(hwnd,"info file",MCI_NOTIFY_SUCCESSFUL);
937 err = mciSendString("status mysound mode", buf, sizeof(buf), hwnd);
938 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
939 ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
942 err = mciSendString("status mysound position", buf, sizeof(buf), hwnd);
943 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
944 trace("position once stopped: %sms\n",buf);
946 /* An XP machine let the position increase slightly after pause. */
947 ok(p2>=p1 && p2<=p1+16,"position changed from %ums to %ums\n",p1,p2);
949 /* No Resume once stopped (waveaudio, sequencer and cdaudio differ). */
950 err = mciSendString("resume mysound wait", NULL, 0, NULL);
951 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci resume wait returned %s\n", dbg_mcierr(err));
953 err = mciSendString("play mysound wait", NULL, 0, NULL);
954 ok(!err,"mci play wait returned %s\n", dbg_mcierr(err));
957 err = mciSendString("status mysound position", buf, sizeof(buf), hwnd);
958 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
959 todo_wine ok(!strcmp(buf,"2000"), "mci status position: %s\n", buf);
961 err = mciSendString("seek mysound to start wait", NULL, 0, NULL);
962 ok(!err,"mci seek to start wait returned %s\n", dbg_mcierr(err));
964 err = mciSendString("play mysound to 1000 notify", NULL, 0, hwnd);
965 ok(!err,"mci play returned %s\n", dbg_mcierr(err));
967 /* Sleep(200); not needed with Wine any more. */
969 err = mciSendString("pause mysound notify", NULL, 0, NULL); /* notify no callback */
970 ok(!err,"mci pause notify returned %s\n", dbg_mcierr(err));
971 /* Supersede even though pause cannot notify given no callback */
972 test_notification(hwnd,"pause aborted play #1 notification",MCI_NOTIFY_SUPERSEDED);
973 test_notification(hwnd,"impossible pause notification",0);
975 err = mciSendString("cue mysound output notify", NULL, 0, hwnd);
976 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci cue output while paused returned %s\n", dbg_mcierr(err));
977 test_notification(hwnd,"cue output notify #2",0);
979 err = mciSendString("resume mysound notify", NULL, 0, hwnd);
980 ok(!err,"mci resume notify returned %s\n", dbg_mcierr(err));
981 test_notification(hwnd, "resume notify", MCI_NOTIFY_SUCCESSFUL);
983 /* Seek or even Stop used to hang Wine<1.1.32 on MacOS. */
984 err = mciSendString("seek mysound to 0 wait", NULL, 0, NULL);
985 ok(!err,"mci seek to start returned %s\n", dbg_mcierr(err));
988 err = mciSendString("status mysound mode", buf, sizeof(buf), NULL);
989 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
990 if(!err) ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
992 err = mciSendString("seek mysound wait", NULL, 0, NULL);
993 ok(err==MCIERR_MISSING_PARAMETER,"mci seek to nowhere returned %s\n", dbg_mcierr(err));
995 /* cdaudio does not detect to start to end as error */
996 err = mciSendString("seek mysound to start to 0", NULL, 0, NULL);
997 ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"mci seek to start to 0 returned %s\n", dbg_mcierr(err));
999 err = mciSendString("PLAY mysound to 1000 notify", NULL, 0, hwnd);
1000 ok(!err,"mci play to 1000 notify returned %s\n", dbg_mcierr(err));
1002 /* Sleep(200); not needed with Wine any more. */
1003 /* Give it 400ms and resume will appear to complete below. */
1005 err = mciSendString("pause mysound wait", NULL, 0, NULL);
1006 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
1007 /* Unlike sequencer and cdaudio, waveaudio's pause does not abort. */
1008 test_notification(hwnd,"pause aborted play #2 notification",0);
1010 err = mciSendString("resume mysound wait", NULL, 0, NULL);
1011 ok(!err,"mci resume wait returned %s\n", dbg_mcierr(err));
1012 /* Resume is a short asynchronous call, something else is playing. */
1014 err = mciSendString("status mysound mode", buf, sizeof(buf), NULL);
1015 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1016 if(!err) ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
1018 /* Note extra space before alias */
1019 err = mciSendString("pause mysound wait", NULL, 0, NULL);
1020 todo_wine ok(!err,"mci pause (space) wait returned %s\n", dbg_mcierr(err));
1022 err = mciSendString("pause mysound wait", NULL, 0, NULL);
1023 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
1025 /* Better ask position only when paused, is it updated while playing? */
1027 err = mciSendString("status mysound position", buf, sizeof(buf), NULL);
1028 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
1029 /* TODO compare position < 900 */
1030 ok(strcmp(buf,"1000"), "mci resume waited\n");
1031 ok(strcmp(buf,"2000"), "mci resume played to end\n");
1032 trace("position after resume: %sms\n",buf);
1033 test_notification(hwnd,"play (aborted by pause/resume/pause)",0);
1035 err = mciSendString("close mysound wait", NULL, 0, NULL);
1036 ok(!err,"mci close wait returned %s\n", dbg_mcierr(err));
1037 test_notification(hwnd,"play (aborted by close)",MCI_NOTIFY_ABORTED);
1040 static void test_AutoOpenWAVE(HWND hwnd)
1042 /* This test used(?) to cause intermittent crashes when Wine exits, after
1043 * fixme:winmm:MMDRV_Exit Closing while ll-driver open
1045 UINT ndevs = waveOutGetNumDevs();
1046 MCIERROR err, ok_snd = ndevs ? 0 : MCIERR_HARDWARE;
1047 MCI_PARMS_UNION parm;
1048 char buf[512], path[300], command[330];
1049 DWORD intbuf[3] = { 0xDEADF00D, 99, 0xABADCAFE };
1050 memset(buf, 0, sizeof(buf)); memset(path, 0, sizeof(path));
1052 /* Do not crash on NULL buffer pointer */
1053 err = mciSendString("sysinfo waveaudio quantity open", NULL, 0, NULL);
1054 ok(err==MCIERR_PARAM_OVERFLOW,"mci sysinfo without buffer returned %s\n", dbg_mcierr(err));
1056 err = mciSendString("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
1057 ok(!err,"mci sysinfo waveaudio quantity open returned %s\n", dbg_mcierr(err));
1058 if(!err) ok(!strcmp(buf,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf);
1060 /* Who knows why some machines pass all tests but return MCIERR_HARDWARE here? */
1061 err = mciSendString("sound NoSuchSoundDefined wait", NULL, 0, NULL);
1062 todo_wine ok(err==ok_snd || broken(err==MCIERR_HARDWARE),"mci sound NoSuchSoundDefined returned %s\n", dbg_mcierr(err));
1064 err = mciSendString("sound SystemExclamation notify wait", NULL, 0, hwnd);
1065 todo_wine ok(err==ok_snd || broken(err==MCIERR_HARDWARE),"mci sound SystemExclamation returned %s\n", dbg_mcierr(err));
1066 test_notification(hwnd, "sound notify", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
1068 Sleep(16); /* time to auto-close makes sysinfo below return expected error */
1070 err = mciSendString("sysinfo waveaudio notify name 1 open", buf, sizeof(buf), hwnd);
1071 ok(err==MCIERR_OUTOFRANGE,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err));
1072 if(!err) trace("sysinfo dangling open alias: %s\n", buf);
1073 test_notification(hwnd, "sysinfo name outofrange\n", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
1075 err = mciSendString("play no-such-file-exists.wav notify", buf, sizeof(buf), NULL);
1076 todo_wine ok(err==MCIERR_NOTIFY_ON_AUTO_OPEN,"mci auto-open notify returned %s\n", dbg_mcierr(err));
1077 /* FILE_NOT_FOUND in Wine because auto-open fails before testing the notify flag */
1079 test_notification(hwnd, "-prior to auto-open-", 0);
1081 err = mciSendString("play tempfile.wav notify", buf, sizeof(buf), hwnd);
1082 ok(err==MCIERR_NOTIFY_ON_AUTO_OPEN,"mci auto-open play notify returned %s\n", dbg_mcierr(err));
1084 if(err) /* FIXME: don't open twice yet, it confuses Wine. */
1085 err = mciSendString("play tempfile.wav", buf, sizeof(buf), hwnd);
1086 ok(err==ok_saved,"mci auto-open play returned %s\n", dbg_mcierr(err));
1088 if(err==MCIERR_FILE_NOT_FOUND) {
1089 skip("Cannot open tempfile.wav for auto-play, skipping\n");
1094 err = mciSendString("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
1095 ok(!err,"mci sysinfo waveaudio quantity after auto-open returned %s\n", dbg_mcierr(err));
1096 if(!err) ok(!strcmp(buf,"1"), "sysinfo quantity open expected 1, got: %s\n", buf);
1098 parm.sys.lpstrReturn = (LPSTR)&intbuf[1];
1099 parm.sys.dwRetSize = 2*sizeof(DWORD); /* only one DWORD is used */
1100 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
1101 err = mciSendCommand(0, MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
1102 ok(!err,"mciSendCommand(0(WAVEAUDIO), MCI_SYSINFO, OPEN | MCI_NOTIFY) returned %s\n", dbg_mcierr(err));
1103 if(!err) ok(atoi(buf)==intbuf[1],"sysinfo waveaudio quantity open string and command differ\n");
1106 err = mciSendString("sysinfo waveaudio name 1 open notify", buf, sizeof(buf), hwnd);
1107 ok(!err,"mci sysinfo waveaudio name after auto-open returned %s\n", dbg_mcierr(err));
1108 /* This is the alias, not necessarily a file name. */
1109 if(!err) ok(!strcmp(buf,"tempfile.wav"), "sysinfo name 1 open: %s\n", buf);
1110 test_notification(hwnd, "sysinfo name notify\n", MCI_NOTIFY_SUCCESSFUL);
1112 err = mciGetDeviceID("tempfile.wav");
1113 ok(err==1,"mciGetDeviceID tempfile.wav returned %u, expected 1\n", err);
1115 /* Save the full pathname to the file. */
1116 err = mciSendString("info tempfile.wav file", path, sizeof(path), NULL);
1117 ok(!err,"mci info tempfile.wav file returned %s\n", dbg_mcierr(err));
1118 if(err) strcpy(path,"tempfile.wav");
1120 err = mciSendString("status tempfile.wav mode", NULL, 0, hwnd);
1121 ok(!err,"mci status tempfile.wav mode without buffer returned %s\n", dbg_mcierr(err));
1123 sprintf(command,"status \"%s\" mode",path);
1124 err = mciSendString(command, buf, sizeof(buf), hwnd);
1125 ok(!err,"mci status \"%s\" mode returned %s\n", path, dbg_mcierr(err));
1128 err = mciSendString("status tempfile.wav mode", buf, sizeof(buf), hwnd);
1129 ok(!err,"mci status tempfile.wav mode returned %s\n", dbg_mcierr(err));
1130 if(!err) ok(!strcmp(buf,"playing"), "mci auto-open status mode, got: %s\n", buf);
1132 err = mciSendString("open tempfile.wav", buf, sizeof(buf), NULL);
1133 ok(err==MCIERR_DEVICE_OPEN, "mci open from auto-open returned %s\n", dbg_mcierr(err));
1135 err = mciSendString("open foo.wav alias tempfile.wav", buf, sizeof(buf), NULL);
1136 ok(err==MCIERR_DUPLICATE_ALIAS, "mci open re-using alias returned %s\n", dbg_mcierr(err));
1138 /* w2k/xp and Wine differ. While the device is busy playing, it is
1139 * regularly open and accessible via the filename: subsequent
1140 * commands must not cause auto-open each. In Wine, a subsequent
1141 * command with notify request may cause the initial play
1142 * notification to be superseded, in turn causing MCI to close the
1143 * device. I.e. MCI uses the auto-open notification for itself,
1144 * that's why it's not available to the app. On w2k/xp,
1145 * subsequent commands with notify requests are returned with
1146 * MCIERR_NOTIFY_ON_AUTO_OPEN and thus don't abort the original
1149 err = mciSendString("status tempfile.wav mode notify", buf, sizeof(buf), hwnd);
1150 todo_wine ok(err==MCIERR_NOTIFY_ON_AUTO_OPEN, "mci status auto-open notify returned %s\n", dbg_mcierr(err));
1152 trace("Wine style MCI auto-close upon notification\n");
1154 /* "playing" because auto-close comes after the status call. */
1155 ok(!strcmp(buf,"playing"), "mci auto-open status mode notify, got: %s\n", buf);
1156 /* fixme:winmm:MMDRV_Exit Closing while ll-driver open
1157 * is explained by failure to auto-close a device. */
1158 test_notification(hwnd,"status notify",MCI_NOTIFY_SUCCESSFUL);
1159 /* MCI received NOTIFY_SUPERSEDED and auto-closed the device. */
1161 /* Until this is implemented, force closing the device */
1162 err = mciSendString("close tempfile.wav", NULL, 0, hwnd);
1163 ok(!err,"mci auto-still-open stop returned %s\n", dbg_mcierr(err));
1165 test_notification(hwnd,"auto-open",0);
1166 } else if(err==MCIERR_NOTIFY_ON_AUTO_OPEN) { /* MS style */
1167 trace("MS style MCI auto-open forbids notification\n");
1169 err = mciSendString("pause tempfile.wav", NULL, 0, hwnd);
1170 ok(!err,"mci auto-still-open pause returned %s\n", dbg_mcierr(err));
1172 err = mciSendString("status tempfile.wav mode", buf, sizeof(buf), hwnd);
1173 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1174 if(!err) ok(!strcmp(buf,"paused"), "mci auto-open status mode, got: %s\n", buf);
1177 err = mciSendString("stop tempfile.wav wait", NULL, 0, hwnd);
1178 ok(!err,"mci auto-still-open stop returned %s\n", dbg_mcierr(err));
1179 Sleep(16); /* makes sysinfo quantity open below succeed */
1182 err = mciSendString("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
1183 ok(!err,"mci sysinfo waveaudio quantity open after close returned %s\n", dbg_mcierr(err));
1184 if(!err) ok(!strcmp(buf,"0"), "sysinfo quantity open expected 0 after auto-close, got: %s\n", buf);
1186 /* w95-WinME (not w2k/XP) switch to C:\ after auto-playing once. Prevent
1187 * MCIERR_FILE_NOT_FOUND by using the full path name from the Info file command.
1189 sprintf(command,"status \"%s\" mode wait",path);
1190 err = mciSendString(command, buf, sizeof(buf), hwnd);
1191 ok(!err,"mci re-auto-open status mode returned %s\n", dbg_mcierr(err));
1192 if(!err) ok(!strcmp(buf,"stopped"), "mci re-auto-open status mode, got: %s\n", buf);
1194 buf[0]=0; /* This uses auto-open as well. */
1195 err = mciSendString("capability waveaudio outputs", buf, sizeof(buf), NULL);
1196 ok(!err,"mci capability waveaudio outputs returned %s\n", dbg_mcierr(err));
1197 /* Wine with no sound selected in winecfg's audio tab fails this test. */
1198 if(!err) ok(atoi(buf)==ndevs,"Expected %d audio outputs, got %s\n", ndevs, buf);
1200 err = mciSendString("capability waveaudio device type", buf, sizeof(buf), hwnd);
1201 ok(!err,"mci capability device type returned %s\n", dbg_mcierr(err));
1202 if(!err) ok(!strcmp(buf,"waveaudio"), "mci capability device type response: %s\n", buf);
1204 /* waveaudio forbids Pause without Play. */
1205 sprintf(command,"pause \"%s\"",path);
1206 err = mciSendString(command, NULL, 0, hwnd);
1207 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci auto-open pause returned %s\n", dbg_mcierr(err));
1209 ok(0xDEADF00D==intbuf[0] && 0xABADCAFE==intbuf[2],"DWORD buffer corruption\n");
1216 hwnd = CreateWindowExA(0, "static", "winmm test", WS_POPUP, 0,0,100,100,
1218 test_mciParser(hwnd);
1219 test_openCloseWAVE(hwnd);
1220 test_recordWAVE(hwnd);
1221 test_playWAVE(hwnd);
1222 test_asyncWAVE(hwnd);
1223 test_AutoOpenWAVE(hwnd);
1224 /* Win9X hangs when exiting with something still open. */
1225 err = mciSendString("close all", NULL, 0, hwnd);
1226 ok(!err,"final close all returned %s\n", dbg_mcierr(err));
1227 ok(DeleteFile("tempfile.wav")||ok_saved,"Delete tempfile.wav (cause auto-open?)\n");
1228 DestroyWindow(hwnd);