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
;
34 MCI_STATUS_PARMS status
;
35 MCI_WAVE_SET_PARMS set
;
36 MCI_WAVE_OPEN_PARMS open
;
37 MCI_GETDEVCAPS_PARMS caps
;
38 MCI_SYSINFO_PARMS sys
;
40 MCI_GENERIC_PARMS gen
;
43 const char* dbg_mcierr(MCIERROR err
)
46 case 0: return "0=NOERROR";
47 #define X(label) case label: return #label ;
48 X(MCIERR_INVALID_DEVICE_ID
)
49 X(MCIERR_UNRECOGNIZED_KEYWORD
)
50 X(MCIERR_UNRECOGNIZED_COMMAND
)
52 X(MCIERR_INVALID_DEVICE_NAME
)
53 X(MCIERR_OUT_OF_MEMORY
)
55 X(MCIERR_CANNOT_LOAD_DRIVER
)
56 X(MCIERR_MISSING_COMMAND_STRING
)
57 X(MCIERR_PARAM_OVERFLOW
)
58 X(MCIERR_MISSING_STRING_ARGUMENT
)
60 X(MCIERR_PARSER_INTERNAL
)
61 X(MCIERR_DRIVER_INTERNAL
)
62 X(MCIERR_MISSING_PARAMETER
)
63 X(MCIERR_UNSUPPORTED_FUNCTION
)
64 X(MCIERR_FILE_NOT_FOUND
)
65 X(MCIERR_DEVICE_NOT_READY
)
68 X(MCIERR_CANNOT_USE_ALL
)
70 X(MCIERR_EXTENSION_NOT_FOUND
)
72 X(MCIERR_FLAGS_NOT_COMPATIBLE
)
73 X(MCIERR_FILE_NOT_SAVED
)
74 X(MCIERR_DEVICE_TYPE_REQUIRED
)
75 X(MCIERR_DEVICE_LOCKED
)
76 X(MCIERR_DUPLICATE_ALIAS
)
77 X(MCIERR_BAD_CONSTANT
)
78 X(MCIERR_MUST_USE_SHAREABLE
)
79 X(MCIERR_MISSING_DEVICE_NAME
)
80 X(MCIERR_BAD_TIME_FORMAT
)
81 X(MCIERR_NO_CLOSING_QUOTE
)
82 X(MCIERR_DUPLICATE_FLAGS
)
83 X(MCIERR_INVALID_FILE
)
84 X(MCIERR_NULL_PARAMETER_BLOCK
)
85 X(MCIERR_UNNAMED_RESOURCE
)
86 X(MCIERR_NEW_REQUIRES_ALIAS
)
87 X(MCIERR_NOTIFY_ON_AUTO_OPEN
)
88 X(MCIERR_NO_ELEMENT_ALLOWED
)
89 X(MCIERR_NONAPPLICABLE_FUNCTION
)
90 X(MCIERR_ILLEGAL_FOR_AUTO_OPEN
)
91 X(MCIERR_FILENAME_REQUIRED
)
92 X(MCIERR_EXTRA_CHARACTERS
)
93 X(MCIERR_DEVICE_NOT_INSTALLED
)
97 X(MCIERR_DEVICE_LENGTH
)
98 X(MCIERR_DEVICE_ORD_LENGTH
)
100 X(MCIERR_WAVE_OUTPUTSINUSE
)
101 X(MCIERR_WAVE_SETOUTPUTINUSE
)
102 X(MCIERR_WAVE_INPUTSINUSE
)
103 X(MCIERR_WAVE_SETINPUTINUSE
)
104 X(MCIERR_WAVE_OUTPUTUNSPECIFIED
)
105 X(MCIERR_WAVE_INPUTUNSPECIFIED
)
106 X(MCIERR_WAVE_OUTPUTSUNSUITABLE
)
107 X(MCIERR_WAVE_SETOUTPUTUNSUITABLE
)
108 X(MCIERR_WAVE_INPUTSUNSUITABLE
)
109 X(MCIERR_WAVE_SETINPUTUNSUITABLE
)
110 X(MCIERR_SEQ_DIV_INCOMPATIBLE
)
111 X(MCIERR_SEQ_PORT_INUSE
)
112 X(MCIERR_SEQ_PORT_NONEXISTENT
)
113 X(MCIERR_SEQ_PORT_MAPNODEVICE
)
114 X(MCIERR_SEQ_PORT_MISCERROR
)
116 X(MCIERR_SEQ_PORTUNSPECIFIED
)
117 X(MCIERR_SEQ_NOMIDIPRESENT
)
119 X(MCIERR_CREATEWINDOW
)
122 X(MCIERR_NO_IDENTITY
)
125 static char name
[20]; /* Not to be called twice in a parameter list! */
126 sprintf(name
, "MMSYSERR %u", err
);
132 static BOOL
spurious_message(LPMSG msg
)
134 /* WM_DEVICECHANGE 0x0219 appears randomly */
135 if(msg
->message
!= MM_MCINOTIFY
) {
136 trace("skipping spurious message %04x\n",msg
->message
);
142 /* A single ok() in each code path allows to prefix this with todo_wine */
143 #define test_notification(hwnd, command, type) test_notification_dbg(hwnd, command, type, __LINE__)
144 static void test_notification_dbg(HWND hwnd
, const char* command
, WPARAM type
, int line
)
145 { /* Use type 0 as meaning no message */
148 do { seen
= PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
); }
149 while(seen
&& spurious_message(&msg
));
151 /* We observe transient delayed notification, mostly on native.
152 * Notification is not always present right when mciSend returns. */
153 trace_(__FILE__
,line
)("Waiting for delayed notification from %s\n", command
);
154 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 3000, QS_POSTMESSAGE
);
155 seen
= PeekMessageA(&msg
, hwnd
, MM_MCINOTIFY
, MM_MCINOTIFY
, PM_REMOVE
);
158 ok_(__FILE__
,line
)(type
==0, "Expect message %04lx from %s\n", type
, command
);
159 else if(msg
.hwnd
!= hwnd
)
160 ok_(__FILE__
,line
)(msg
.hwnd
== hwnd
, "Didn't get the handle to our test window\n");
161 else if(msg
.message
!= MM_MCINOTIFY
)
162 ok_(__FILE__
,line
)(msg
.message
== MM_MCINOTIFY
, "got %04x instead of MM_MCINOTIFY from command %s\n", msg
.message
, command
);
163 else ok_(__FILE__
,line
)(msg
.wParam
== type
, "got %04lx instead of MCI_NOTIFY_xyz %04lx from command %s\n", msg
.wParam
, type
, command
);
166 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
169 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), 0, 0);
170 return lstrcmpA(buf
, stra
);
173 static void test_mciParser(HWND hwnd
)
176 MCIDEVICEID wDeviceID
;
177 MCI_PARMS_UNION parm
;
179 memset(buf
, 0, sizeof(buf
));
180 test_notification(hwnd
, "-prior to parser test-", 0);
182 /* Get a handle on an MCI device, works even without sound. */
183 parm
.open
.lpstrDeviceType
= "waveaudio";
184 parm
.open
.lpstrElementName
= ""; /* "new" at the command level */
185 parm
.open
.lpstrAlias
= "x"; /* to enable mciSendString */
186 parm
.open
.dwCallback
= (DWORD_PTR
)hwnd
;
187 err
= mciSendCommand(0, MCI_OPEN
,
188 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| MCI_OPEN_ALIAS
| MCI_NOTIFY
,
190 ok(!err
,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err
));
191 wDeviceID
= parm
.open
.wDeviceID
;
192 ok(!strcmp(parm
.open
.lpstrDeviceType
,"waveaudio"), "open modified device type\n");
194 test_notification(hwnd
, "MCI_OPEN", MCI_NOTIFY_SUCCESSFUL
);
195 test_notification(hwnd
, "MCI_OPEN no #2", 0);
197 err
= mciSendString("open avivideo alias a", buf
, sizeof(buf
), hwnd
);
198 ok(!err
,"open another: %s\n", dbg_mcierr(err
));
201 err
= mciSendString("", buf
, sizeof(buf
), NULL
);
202 todo_wine
ok(err
==MCIERR_MISSING_COMMAND_STRING
,"empty string: %s\n", dbg_mcierr(err
));
203 ok(!buf
[0], "error buffer %s\n", buf
);
206 err
= mciSendString("open", buf
, sizeof(buf
), NULL
);
207 ok(err
==MCIERR_MISSING_DEVICE_NAME
,"open void: %s\n", dbg_mcierr(err
));
208 ok(!buf
[0], "open error buffer %s\n", buf
);
210 err
= mciSendString("open notify", buf
, sizeof(buf
), NULL
);
211 todo_wine
ok(err
==MCIERR_INVALID_DEVICE_NAME
,"open notify: %s\n", dbg_mcierr(err
));
213 err
= mciSendString("open new", buf
, sizeof(buf
), NULL
);
214 todo_wine
ok(err
==MCIERR_NEW_REQUIRES_ALIAS
,"open new: %s\n", dbg_mcierr(err
));
216 err
= mciSendString("open new type waveaudio alias r shareable shareable", buf
, sizeof(buf
), NULL
);
217 todo_wine
ok(err
==MCIERR_DUPLICATE_FLAGS
,"open new: %s\n", dbg_mcierr(err
));
218 if(!err
) mciSendString("close r", NULL
, 0, NULL
);
220 err
= mciSendString("status x position wait wait", buf
, sizeof(buf
), NULL
);
221 todo_wine
ok(err
==MCIERR_DUPLICATE_FLAGS
,"status wait wait: %s\n", dbg_mcierr(err
));
223 err
= mciSendString("status x length length", buf
, sizeof(buf
), NULL
);
224 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status 2xlength: %s\n", dbg_mcierr(err
));
226 err
= mciSendString("status x length position", buf
, sizeof(buf
), NULL
);
227 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status length+position: %s\n", dbg_mcierr(err
));
230 err
= mciSendString("set x time format milliseconds time format ms", buf
, sizeof(buf
), NULL
);
231 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status length+position: %s\n", dbg_mcierr(err
));
232 ok(!buf
[0], "set error buffer %s\n", buf
);
234 /* device's response, not a parser test */
235 err
= mciSendString("status x", buf
, sizeof(buf
), NULL
);
236 ok(err
==MCIERR_MISSING_PARAMETER
,"status waveaudio nokeyword: %s\n", dbg_mcierr(err
));
239 err
= mciSendString("status a", buf
, sizeof(buf
), NULL
);
240 todo_wine
ok(err
==MCIERR_UNSUPPORTED_FUNCTION
,"status avivideo nokeyword: %s\n", dbg_mcierr(err
));
241 ok(!buf
[0], "status error buffer %s\n", buf
);
243 err
= mciSendString("status x track", buf
, sizeof(buf
), NULL
);
244 todo_wine
ok(err
==MCIERR_BAD_INTEGER
,"status waveaudio no track: %s\n", dbg_mcierr(err
));
246 err
= mciSendString("status x track 3", buf
, sizeof(buf
), NULL
);
247 ok(err
==MCIERR_MISSING_PARAMETER
,"status waveaudio track 3: %s\n", dbg_mcierr(err
));
249 err
= mciSendString("status x 2 track 3", buf
, sizeof(buf
), NULL
);
250 todo_wine
ok(err
==MCIERR_OUTOFRANGE
,"status 2(position) track 3: %s\n", dbg_mcierr(err
));
252 err
= mciSendString("status x 4", buf
, sizeof(buf
), hwnd
);
253 ok(!err
,"status 4(mode): %s\n", dbg_mcierr(err
));
254 if(!err
)ok(!strcmp(buf
,"stopped"), "status 4(mode), got: %s\n", buf
);
256 err
= mciSendString("status x 4 notify", buf
, sizeof(buf
), hwnd
);
257 todo_wine
ok(!err
,"status 4(mode) notify: %s\n", dbg_mcierr(err
));
258 if(!err
)ok(!strcmp(buf
,"stopped"), "status 4(mode), got: %s\n", buf
);
259 test_notification(hwnd
, "status 4 notify", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
261 err
= mciSendString("set x milliseconds", buf
, sizeof(buf
), hwnd
);
262 todo_wine
ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
,"set milliseconds: %s\n", dbg_mcierr(err
));
264 err
= mciSendString("set x milliseconds ms", buf
, sizeof(buf
), hwnd
);
265 todo_wine
ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
,"set milliseconds ms: %s\n", dbg_mcierr(err
));
267 err
= mciSendString("capability x can save", buf
, sizeof(buf
), hwnd
);
268 todo_wine
ok(!err
,"capability can (space) save: %s\n", dbg_mcierr(err
));
270 err
= mciSendString("status x nsa", buf
, sizeof(buf
), hwnd
);
271 todo_wine
ok(err
==MCIERR_BAD_CONSTANT
,"status nsa: %s\n", dbg_mcierr(err
));
273 err
= mciSendString("status all time format", buf
, sizeof(buf
), hwnd
);
274 ok(err
==MCIERR_CANNOT_USE_ALL
,"status all: %s\n", dbg_mcierr(err
));
276 err
= mciSendString("cue all", buf
, sizeof(buf
), NULL
);
277 ok(err
==MCIERR_UNRECOGNIZED_COMMAND
,"cue all: %s\n", dbg_mcierr(err
));
279 err
= mciSendString("open all", buf
, sizeof(buf
), NULL
);
280 todo_wine
ok(err
==MCIERR_CANNOT_USE_ALL
,"open all: %s\n", dbg_mcierr(err
));
282 /* avivideo is not a known MCI_DEVTYPE resource name */
283 err
= mciSendString("sysinfo avivideo quantity", buf
, sizeof(buf
), hwnd
);
284 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo sequencer quantity: %s\n", dbg_mcierr(err
));
286 err
= mciSendString("sysinfo digitalvideo quantity", buf
, sizeof(buf
), hwnd
);
287 ok(!err
,"sysinfo digitalvideo quantity: %s\n", dbg_mcierr(err
));
288 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo digitalvideo quantity returned %s\n", buf
);
290 /* quantity 0 yet open 1 (via type "avivideo"), fun */
291 err
= mciSendString("sysinfo digitalvideo quantity open", buf
, sizeof(buf
), hwnd
);
292 ok(!err
,"sysinfo digitalvideo quantity open: %s\n", dbg_mcierr(err
));
293 if(!err
) ok(!strcmp(buf
,"1"), "sysinfo digitalvideo quantity open returned %s\n", buf
);
295 err
= mciSendString("put a window at 0 0", buf
, sizeof(buf
), NULL
);
296 todo_wine
ok(err
==MCIERR_BAD_INTEGER
,"put incomplete rect: %s\n", dbg_mcierr(err
));
298 /*w9X-w2k report code from device last opened, newer versions compare them all
299 * and return the one error code or MCIERR_MULTIPLE if they differ. */
300 err
= mciSendString("pause all", buf
, sizeof(buf
), NULL
);
301 todo_wine
ok(err
==MCIERR_MULTIPLE
|| broken(err
==MCIERR_NONAPPLICABLE_FUNCTION
),"pause all: %s\n", dbg_mcierr(err
));
302 ok(!buf
[0], "pause error buffer %s\n", buf
);
304 /* MCI_STATUS' dwReturn is a DWORD_PTR, others' a plain DWORD. */
305 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
306 parm
.status
.dwReturn
= 0xFEEDABAD;
307 err
= mciSendCommand(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
308 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
309 if(!err
) ok(MCI_FORMAT_MILLISECONDS
==parm
.status
.dwReturn
,"status time format: %ld\n",parm
.status
.dwReturn
);
311 parm
.status
.dwItem
= MCI_STATUS_MODE
;
312 parm
.status
.dwReturn
= 0xFEEDABAD;
313 err
= mciSendCommand(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
314 ok(!err
,"mciCommand status mode: %s\n", dbg_mcierr(err
));
315 if(!err
) ok(MCI_MODE_STOP
==parm
.status
.dwReturn
,"STATUS mode: %ld\n",parm
.status
.dwReturn
);
317 err
= mciSendString("status x mode", buf
, sizeof(buf
), hwnd
);
318 ok(!err
,"status mode: %s\n", dbg_mcierr(err
));
319 if(!err
) ok(!strcmp(buf
, "stopped"), "status mode is %s\n", buf
);
321 parm
.caps
.dwItem
= MCI_GETDEVCAPS_USES_FILES
;
322 parm
.caps
.dwReturn
= 0xFEEDABAD;
323 err
= mciSendCommand(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
324 ok(!err
,"mciCommand getdevcaps files: %s\n", dbg_mcierr(err
));
325 if(!err
) ok(1==parm
.caps
.dwReturn
,"getdevcaps files: %d\n",parm
.caps
.dwReturn
);
327 parm
.caps
.dwItem
= MCI_GETDEVCAPS_HAS_VIDEO
;
328 parm
.caps
.dwReturn
= 0xFEEDABAD;
329 err
= mciSendCommand(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
330 ok(!err
,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err
));
331 if(!err
) ok(0==parm
.caps
.dwReturn
,"getdevcaps video: %d\n",parm
.caps
.dwReturn
);
333 parm
.caps
.dwItem
= MCI_GETDEVCAPS_DEVICE_TYPE
;
334 parm
.caps
.dwReturn
= 0xFEEDABAD;
335 err
= mciSendCommand(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
336 ok(!err
,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err
));
337 if(!err
) ok(MCI_DEVTYPE_WAVEFORM_AUDIO
==parm
.caps
.dwReturn
,"getdevcaps device type: %d\n",parm
.caps
.dwReturn
);
339 err
= mciSendString("capability x uses files", buf
, sizeof(buf
), hwnd
);
340 ok(!err
,"capability files: %s\n", dbg_mcierr(err
));
341 if(!err
) ok(!strcmp(buf
, "true"), "capability files is %s\n", buf
);
343 err
= mciSendString("capability x has video", buf
, sizeof(buf
), hwnd
);
344 ok(!err
,"capability video: %s\n", dbg_mcierr(err
));
345 if(!err
) ok(!strcmp(buf
, "false"), "capability video is %s\n", buf
);
347 err
= mciSendString("capability x device type", buf
, sizeof(buf
), hwnd
);
348 ok(!err
,"capability device type: %s\n", dbg_mcierr(err
));
349 if(!err
) ok(!strcmp(buf
, "waveaudio"), "capability device type is %s\n", buf
);
351 err
= mciSendCommand(wDeviceID
, MCI_CLOSE
, 0, 0);
352 ok(!err
,"mciCommand close returned %s\n", dbg_mcierr(err
));
354 err
= mciSendString("close a", buf
, sizeof(buf
), hwnd
);
355 ok(!err
,"close avi: %s\n", dbg_mcierr(err
));
357 test_notification(hwnd
, "-end of 1st set-", 0);
360 static void test_openCloseWAVE(HWND hwnd
)
363 MCI_PARMS_UNION parm
;
364 const char command_open
[] = "open new type waveaudio alias mysound notify";
365 const char command_close_my
[] = "close mysound notify";
366 const char command_close_all
[] = "close all notify";
367 const char command_sysinfo
[] = "sysinfo waveaudio quantity open";
369 DWORD intbuf
[3] = { 0xDEADF00D, 99, 0xABADCAFE };
370 memset(buf
, 0, sizeof(buf
));
371 test_notification(hwnd
, "-prior to any command-", 0);
373 /* Avoid Sysinfo quantity with notify because Win9x and newer differ. */
374 err
= mciSendString("sysinfo all quantity", buf
, sizeof(buf
), hwnd
);
375 ok(!err
,"mci sysinfo all quantity returned %s\n", dbg_mcierr(err
));
376 if(!err
) trace("[MCI] with %s drivers\n", buf
);
378 parm
.sys
.lpstrReturn
= (LPSTR
)&intbuf
[1];
379 parm
.sys
.dwRetSize
= sizeof(DWORD
);
380 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
381 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
| MCI_WAIT
, (DWORD_PTR
)&parm
);
382 ok(!err
,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO QUANTITY, MCI_WAIT, 0) returned %s\n", dbg_mcierr(err
));
383 if(!err
) ok(atoi(buf
)==intbuf
[1],"sysinfo all quantity string and command differ\n");
385 parm
.sys
.dwRetSize
= sizeof(DWORD
)-1;
386 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
, (DWORD_PTR
)&parm
);
387 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(!err
/* Win9x */),"mciSendCommand MCI_SYSINFO with too small buffer returned %s\n", dbg_mcierr(err
));
389 err
= mciSendString("open new type waveaudio alias r shareable", buf
, sizeof(buf
), NULL
);
390 ok(err
==MCIERR_UNSUPPORTED_FUNCTION
,"mci open new shareable returned %s\n", dbg_mcierr(err
));
392 err
= mciSendString("close r", NULL
, 0, NULL
);
393 ok(!err
,"mci close shareable returned %s\n", dbg_mcierr(err
));
396 err
= mciGetDeviceID("waveaudio");
397 ok(err
==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err
);
399 err
= mciSendString(command_open
, buf
, sizeof(buf
), hwnd
);
400 ok(!err
,"mci %s returned %s\n", command_open
, dbg_mcierr(err
));
401 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
402 /* Wine<=1.1.33 used to ignore anything past alias XY */
403 test_notification(hwnd
,"open new alias notify",MCI_NOTIFY_SUCCESSFUL
);
405 err
= mciSendString("status mysound time format", buf
, sizeof(buf
), hwnd
);
406 ok(!err
,"mci status time format returned %s\n", dbg_mcierr(err
));
408 if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) == LANG_ENGLISH
)
409 ok(!strcmp(buf
,"milliseconds"), "mci status time format: %s\n", buf
);
410 else trace("locale-dependent time format: %s (ms)\n", buf
);
413 memset(buf
, 0, sizeof(buf
));
414 parm
.sys
.dwNumber
= 1;
415 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
416 parm
.sys
.lpstrReturn
= buf
;
417 parm
.sys
.dwRetSize
= sizeof(buf
);
418 parm
.sys
.dwCallback
= (DWORD_PTR
)hwnd
;
419 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
420 ok(!err
,"mciCommand MCI_SYSINFO all name 1 open notify: %s\n", dbg_mcierr(err
));
421 if(!err
) ok(!strcmp(buf
,"mysound"), "sysinfo name returned %s\n", buf
);
422 test_notification(hwnd
, "SYSINFO name notify\n", MCI_NOTIFY_SUCCESSFUL
);
424 memset(buf
, 0, sizeof(buf
));
425 parm
.sys
.dwNumber
= 1;
426 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
427 parm
.sys
.lpstrReturn
= buf
;
428 parm
.sys
.dwRetSize
= 8; /* mysound\0 */
429 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
430 ok(!err
,"mciCommand MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err
));
431 if(!err
) ok(!strcmp(buf
,"mysound"), "sysinfo name returned %s\n", buf
);
433 memset(buf
, 0, sizeof(buf
));
434 /* dwRetSize counts characters, not bytes, despite what MSDN says. */
435 parm
.sys
.dwNumber
= 1;
436 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
437 parm
.sys
.lpstrReturn
= buf
;
438 parm
.sys
.dwRetSize
= 8; /* mysound\0 */
439 /* MCI_..._PARMSA and PARMSW share the same layout, use one for both tests. */
440 err
= mciSendCommandW(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
441 ok(!err
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err
));
442 if(!err
) ok(!strcmp_wa((LPWSTR
)buf
,"mysound"), "sysinfo name 1 open contents\n");
444 memset(buf
, 0, sizeof(buf
));
446 parm
.sys
.dwNumber
= 1;
447 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
448 parm
.sys
.lpstrReturn
= buf
;
449 parm
.sys
.dwRetSize
= 7; /* too short for mysound\0 */
450 err
= mciSendCommandW(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
451 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err
));
452 ok(!strcmp(buf
,"Y"), "output buffer %s\n", buf
);
454 /* Win9x overwrites the tiny buffer and returns success, newer versions signal overflow. */
455 memset(buf
, 0, sizeof(buf
));
457 parm
.sys
.dwNumber
= 1;
458 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
459 parm
.sys
.lpstrReturn
= buf
;
460 parm
.sys
.dwRetSize
= 2; /* too short for mysound\0 */
461 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
462 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(!err
/* Win9x */),"mciCommand MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err
));
463 ok(!strcmp(buf
, err
? "Y" : "mysound"), "sysinfo short name returned %s\n", buf
);
465 err
= mciSendString("sysinfo mysound quantity open", buf
, sizeof(buf
), hwnd
);
466 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo alias quantity: %s\n", dbg_mcierr(err
));
468 err
= mciSendString("sysinfo nosuchalias quantity open", buf
, sizeof(buf
), hwnd
);
469 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo unknown quantity open: %s\n", dbg_mcierr(err
));
471 err
= mciSendString("sysinfo all installname", buf
, sizeof(buf
), hwnd
);
472 ok(err
==MCIERR_CANNOT_USE_ALL
,"sysinfo all installname: %s\n", dbg_mcierr(err
));
474 buf
[0] = 'M'; buf
[1] = 0;
475 parm
.sys
.lpstrReturn
= buf
;
476 parm
.sys
.dwRetSize
= sizeof(buf
);
477 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_INSTALLNAME
, (DWORD_PTR
)&parm
);
478 ok(err
==MCIERR_CANNOT_USE_ALL
,"mciCommand MCI_SYSINFO all installname: %s\n", dbg_mcierr(err
));
479 ok(!strcmp(buf
,"M"), "output buffer %s\n", buf
);
481 err
= mciSendString("sysinfo nodev installname", buf
, sizeof(buf
), hwnd
);
482 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"sysinfo nodev installname: %s\n", dbg_mcierr(err
));
483 ok(!buf
[0], "sysinfo error buffer %s\n", buf
);
486 parm
.sys
.lpstrReturn
= buf
;
487 parm
.sys
.dwRetSize
= sizeof(buf
);
488 err
= mciSendCommandW(24000, MCI_SYSINFO
, MCI_SYSINFO_INSTALLNAME
, (DWORD_PTR
)&parm
);
489 ok(err
==MCIERR_INVALID_DEVICE_NAME
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommand MCI_SYSINFO nodev installname: %s\n", dbg_mcierr(err
));
490 ok(!strcmp(buf
,"K"), "output buffer %s\n", buf
);
492 buf
[0] = 0; buf
[1] = 'A'; buf
[2] = 'j'; buf
[3] = 0;
493 parm
.info
.lpstrReturn
= buf
;
494 parm
.info
.dwRetSize
= 2;
495 err
= mciSendCommandA(1, MCI_INFO
, MCI_INFO_PRODUCT
, (DWORD_PTR
)&parm
);
496 ok(!err
, "mciCommand MCI_INFO product: %s\n", dbg_mcierr(err
));
497 ok(buf
[0] /* && !buf[1] */ && (buf
[2] == 'j' || broken(!buf
[2])), "info product output buffer %s\n", buf
);
498 /* Producing non-ASCII multi-byte output, native forgets to zero-terminate a too small buffer
499 * with SendStringA, while SendStringW works correctly (jap. and chin. locale): ignore buf[1] */
500 /* Bug in 64 bit Vista/w2k8/w7: mciSendStringW is used! (not in xp nor w2k3) */
502 buf
[0] = 'K'; buf
[1] = 0;
503 parm
.info
.dwRetSize
= sizeof(buf
);
504 err
= mciSendCommandW(1, MCI_INFO
, 0x07000000, (DWORD_PTR
)&parm
);
505 ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommand MCI_INFO other: %s\n", dbg_mcierr(err
));
506 ok(!strcmp(buf
,"K"), "info output buffer %s\n", buf
);
508 err
= mciGetDeviceID("all");
509 ok(MCI_ALL_DEVICE_ID
==err
|| /* Win9x */(WORD
)MCI_ALL_DEVICE_ID
==err
,"mciGetDeviceID all returned %u, expected %d\n", err
, MCI_ALL_DEVICE_ID
);
511 err
= mciSendString(command_close_my
, NULL
, 0, hwnd
);
512 ok(!err
,"mci %s returned %s\n", command_close_my
, dbg_mcierr(err
));
513 test_notification(hwnd
, command_close_my
, MCI_NOTIFY_SUCCESSFUL
);
515 test_notification(hwnd
, command_close_my
, 0);
517 err
= mciSendString("open no-such-file-exists.wav alias y buffer 6", buf
, sizeof(buf
), NULL
);
518 ok(err
==MCIERR_FILE_NOT_FOUND
,"open no-such-file.wav returned %s\n", dbg_mcierr(err
));
520 err
= mciSendString("close y", NULL
, 0, NULL
);
521 ok(!err
,"close y returned %s\n", dbg_mcierr(err
));
524 err
= mciSendString("open no-such-dir\\file.wav alias y type waveaudio", buf
, sizeof(buf
), NULL
);
525 ok(err
==MCIERR_FILE_NOT_FOUND
|| broken(err
==MCIERR_INVALID_FILE
/* Win9X */),"open no-such-dir/file.wav returned %s\n", dbg_mcierr(err
));
527 err
= mciSendString("close y", NULL
, 0, NULL
);
528 ok(!err
,"close y returned %s\n", dbg_mcierr(err
));
531 err
= mciSendString("open ! alias no", buf
, sizeof(buf
), NULL
);
532 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"open !(void): %s\n", dbg_mcierr(err
));
534 err
= mciSendString("open !no-such-file-exists.wav alias no", buf
, sizeof(buf
), NULL
);
535 ok(err
==MCIERR_FILE_NOT_FOUND
|| /* Win9X */err
==MCIERR_INVALID_DEVICE_NAME
,"open !name: %s\n", dbg_mcierr(err
));
537 /* FILE_NOT_FOUND stems from mciwave,
538 * the complete name including ! is passed through since NT */
539 err
= mciSendString("open nosuchdevice!tempfile.wav alias no", buf
, sizeof(buf
), NULL
);
540 ok(err
==MCIERR_FILE_NOT_FOUND
|| /* Win9X */err
==MCIERR_INVALID_DEVICE_NAME
,"open nosuchdevice!name: %s\n", dbg_mcierr(err
));
541 /* FIXME? use broken(INVALID_DEVICE_NAME) and have Wine not mimic Win9X? */
543 err
= mciSendString("close waveaudio", buf
, sizeof(buf
), NULL
);
544 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"close waveaudio: %s\n", dbg_mcierr(err
));
546 err
= mciSendString(command_close_all
, NULL
, 0, NULL
);
547 ok(!err
,"mci %s (without buffer) returned %s\n", command_close_all
, dbg_mcierr(err
));
549 err
= mciSendString(command_close_all
, buf
, sizeof(buf
), hwnd
);
550 ok(!err
,"mci %s (with output buffer) returned %s\n", command_close_all
, dbg_mcierr(err
));
551 ok(buf
[0] == 0, "mci %s output buffer: %s\n", command_close_all
, buf
);
552 /* No notification left, everything closed already */
553 test_notification(hwnd
, command_close_all
, 0);
554 /* TODO test close all sends one notification per open device */
556 err
= mciSendString(command_sysinfo
, buf
, sizeof(buf
), NULL
);
557 ok(!err
,"mci %s returned %s\n", command_sysinfo
, dbg_mcierr(err
));
558 ok(buf
[0] == '0' && buf
[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo
, buf
);
560 err
= mciSendString("open new type waveaudio", buf
, sizeof(buf
), NULL
);
561 ok(err
==MCIERR_NEW_REQUIRES_ALIAS
,"mci open new without alias returned %s\n", dbg_mcierr(err
));
563 parm
.open
.lpstrDeviceType
= (LPSTR
)MCI_DEVTYPE_WAVEFORM_AUDIO
;
564 err
= mciSendCommand(0, MCI_OPEN
,
565 MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
,
567 ok(!err
,"mciCommand OPEN_TYPE_ID waveaudio: %s\n", dbg_mcierr(err
));
570 MCIDEVICEID wDeviceID
= parm
.open
.wDeviceID
;
571 parm
.caps
.dwItem
= MCI_GETDEVCAPS_DEVICE_TYPE
;
572 err
= mciSendCommand(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
573 ok(!err
,"mciCommand MCI_GETDEVCAPS device type: %s\n", dbg_mcierr(err
));
574 ok(MCI_DEVTYPE_WAVEFORM_AUDIO
==parm
.caps
.dwReturn
,"mciCommand GETDEVCAPS says %u, expected %u\n", parm
.caps
.dwReturn
, MCI_DEVTYPE_WAVEFORM_AUDIO
);
577 ok(0xDEADF00D==intbuf
[0] && 0xABADCAFE==intbuf
[2],"DWORD buffer corruption\n");
579 err
= mciGetDeviceID("waveaudio");
580 ok(err
==1,"mciGetDeviceID waveaudio returned %u, expected 0\n", err
);
582 err
= mciSendString("open no-such-file.wav alias waveaudio", buf
, sizeof(buf
), NULL
);
583 ok(err
==MCIERR_DUPLICATE_ALIAS
, "mci open alias waveaudio returned %s\n", dbg_mcierr(err
));
584 /* If it were not already in use, open avivideo alias waveaudio would succeed,
585 * making for funny test cases. */
587 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_WAIT
, 0); /* from MSDN */
588 ok(!err
,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0) returned %s\n", dbg_mcierr(err
));
590 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_NOTIFY
, 0);
591 ok(!err
,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_NOTIFY, 0) returned %s\n", dbg_mcierr(err
));
593 parm
.gen
.dwCallback
= (DWORD_PTR
)hwnd
;
594 err
= mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_NOTIFY
, (DWORD_PTR
)&parm
);
595 ok(!err
,"mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_NOTIFY, hwnd) returned %s\n", dbg_mcierr(err
));
596 test_notification(hwnd
, command_close_all
, 0); /* None left */
599 static void test_recordWAVE(HWND hwnd
)
603 DWORD nsamp
= 16000, expect
;
604 UINT ndevs
= waveInGetNumDevs();
605 MCIERROR err
, ok_pcm
;
606 MCIDEVICEID wDeviceID
;
607 MCI_PARMS_UNION parm
;
609 memset(buf
, 0, sizeof(buf
));
610 test_notification(hwnd
, "-prior to recording-", 0);
612 parm
.open
.lpstrDeviceType
= "waveaudio";
613 parm
.open
.lpstrElementName
= ""; /* "new" at the command level */
614 parm
.open
.lpstrAlias
= "x"; /* to enable mciSendString */
615 parm
.open
.dwCallback
= (DWORD_PTR
)hwnd
;
616 err
= mciSendCommand(0, MCI_OPEN
,
617 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| MCI_OPEN_ALIAS
| MCI_NOTIFY
,
619 ok(!err
,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err
));
620 wDeviceID
= parm
.open
.wDeviceID
;
622 err
= mciGetDeviceID("x");
623 ok(err
==wDeviceID
,"mciGetDeviceID x returned %u, expected %u\n", err
, wDeviceID
);
625 /* Only the alias is looked up. */
626 err
= mciGetDeviceID("waveaudio");
627 ok(err
==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err
);
629 test_notification(hwnd
, "open new", MCI_NOTIFY_SUCCESSFUL
);
630 test_notification(hwnd
, "open new no #2", 0);
632 /* Do not query time format as string because result depends on locale! */
633 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
634 err
= mciSendCommand(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
635 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
636 ok(parm
.status
.dwReturn
==MCI_FORMAT_MILLISECONDS
,"status time format: %ld\n",parm
.status
.dwReturn
);
638 /* Info file fails until named in Open or Save. */
639 err
= mciSendString("info x file", buf
, sizeof(buf
), NULL
);
640 todo_wine
ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci info new file returned %s\n", dbg_mcierr(err
));
641 ok(!buf
[0], "info error buffer %s\n", buf
);
643 err
= mciSendString("status x length", buf
, sizeof(buf
), NULL
);
644 todo_wine
ok(!err
,"status x length initial: %s\n", dbg_mcierr(err
));
645 if(!err
) ok(!strcmp(buf
,"0"), "mci status length expected 0, got: %s\n", buf
);
647 /* Check the default recording: 8-bits per sample, mono, 11kHz */
648 err
= mciSendString("status x samplespersec", buf
, sizeof(buf
), NULL
);
649 ok(!err
,"mci status samplespersec returned %s\n", dbg_mcierr(err
));
650 if(!err
) ok(!strcmp(buf
,"11025"), "mci status samplespersec expected 11025, got: %s\n", buf
);
652 /* MCI seems to solely support PCM, no need for ACM conversion. */
653 err
= mciSendString("set x format tag 2", NULL
, 0, NULL
);
654 ok(err
==MCIERR_OUTOFRANGE
,"mci set format tag 2 returned %s\n", dbg_mcierr(err
));
656 /* MCI appears to scan the available devices for support of this format,
657 * returning MCIERR_OUTOFRANGE on machines with no sound.
658 * However some w2k8/w7 machines return no error when there's no wave
659 * input device (perhaps querying waveOutGetNumDevs instead of waveIn?),
660 * still the record command below fails with MCIERR_WAVE_INPUTSUNSUITABLE.
661 * Don't skip here, record will fail below. */
662 err
= mciSendString("set x format tag pcm", NULL
, 0, NULL
);
663 ok(!err
|| err
==MCIERR_OUTOFRANGE
,"mci set format tag pcm returned %s\n", dbg_mcierr(err
));
666 /* MSDN warns against not setting all wave format parameters.
667 * Indeed, it produces strange results, incl.
668 * inconsistent PCMWAVEFORMAT headers in the saved file.
670 err
= mciSendString("set x bytespersec 22050 alignment 2 samplespersec 11025 channels 1 bitspersample 16", NULL
, 0, NULL
);
671 ok(err
==ok_pcm
,"mci set 5 wave parameters returned %s\n", dbg_mcierr(err
));
672 /* Investigate: on w2k, set samplespersec 22050 sets nChannels to 2!
673 * err = mciSendString("set x samplespersec 22050", NULL, 0, NULL);
674 * ok(!err,"mci set samplespersec returned %s\n", dbg_mcierr(err));
677 /* Checks are generally performed immediately. */
678 err
= mciSendString("set x bitspersample 4", NULL
, 0, NULL
);
679 todo_wine
ok(err
==MCIERR_OUTOFRANGE
,"mci set bitspersample 4 returned %s\n", dbg_mcierr(err
));
681 parm
.set
.wFormatTag
= WAVE_FORMAT_PCM
;
682 parm
.set
.nSamplesPerSec
= nsamp
;
683 parm
.set
.wBitsPerSample
= nbits
;
684 parm
.set
.nChannels
= nch
;
685 parm
.set
.nBlockAlign
= parm
.set
.nChannels
* parm
.set
.wBitsPerSample
/8;
686 parm
.set
.nAvgBytesPerSec
= parm
.set
.nSamplesPerSec
* parm
.set
.nBlockAlign
;
687 err
= mciSendCommand(wDeviceID
, MCI_SET
,
688 MCI_WAVE_SET_SAMPLESPERSEC
| MCI_WAVE_SET_CHANNELS
|
689 MCI_WAVE_SET_BITSPERSAMPLE
| MCI_WAVE_SET_BLOCKALIGN
|
690 MCI_WAVE_SET_AVGBYTESPERSEC
| MCI_WAVE_SET_FORMATTAG
, (DWORD_PTR
)&parm
);
691 ok(err
==ok_pcm
,"mciCommand set wave format: %s\n", dbg_mcierr(err
));
693 parm
.caps
.dwItem
= MCI_WAVE_GETDEVCAPS_INPUTS
;
694 parm
.caps
.dwCallback
= (DWORD_PTR
)hwnd
;
695 err
= mciSendCommand(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
696 ok(!err
,"mciCommand MCI_GETDEVCAPS inputs: %s\n", dbg_mcierr(err
));
697 ok(parm
.caps
.dwReturn
==ndevs
,"mciCommand GETDEVCAPS claims %u inputs, expected %u\n", parm
.caps
.dwReturn
, ndevs
);
698 ok(!ok_pcm
|| !parm
.caps
.dwReturn
,"No input device accepts PCM!?\n");
699 test_notification(hwnd
, "GETDEVCAPS inputs", MCI_NOTIFY_SUCCESSFUL
);
701 /* A few ME machines pass all tests except set format tag pcm! */
702 err
= mciSendString("record x to 2000 wait", NULL
, 0, hwnd
);
703 ok(err
|| !ok_pcm
,"can record yet set wave format pcm returned %s\n", dbg_mcierr(ok_pcm
));
704 if(!ndevs
) todo_wine
/* with sound disabled */
705 ok(ndevs
>0 ? !err
: err
==MCIERR_WAVE_INPUTSUNSUITABLE
,"mci record to 2000 returned %s\n", dbg_mcierr(err
));
707 ok(ndevs
>0 ? !err
: err
==MCIERR_WAVE_INPUTSUNSUITABLE
,"mci record to 2000 returned %s\n", dbg_mcierr(err
));
709 if (err
==MCIERR_WAVE_INPUTSUNSUITABLE
)
710 skip("Please install audio driver. Everything is skipped.\n");
711 else skip("Cannot record cause %s. Everything is skipped.\n", dbg_mcierr(err
));
713 err
= mciSendString("close x", NULL
, 0, NULL
);
714 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
715 test_notification(hwnd
,"record skipped",0);
719 /* Query some wave format parameters depending on the time format. */
720 err
= mciSendString("status x position", buf
, sizeof(buf
), NULL
);
721 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
722 if(!err
) todo_wine
ok(!strcmp(buf
,"2000"), "mci status position gave %s, expected 2000, some tests will fail\n", buf
);
724 err
= mciSendString("set x time format 8", NULL
, 0, NULL
); /* bytes */
725 ok(!err
,"mci returned %s\n", dbg_mcierr(err
));
727 parm
.status
.dwItem
= MCI_STATUS_POSITION
;
728 err
= mciSendCommand(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
729 ok(!err
,"mciCommand status position: %s\n", dbg_mcierr(err
));
730 expect
= 2 * nsamp
* nch
* nbits
/8;
731 if(!err
) todo_wine
ok(parm
.status
.dwReturn
==expect
,"recorded %lu bytes, expected %u\n",parm
.status
.dwReturn
,expect
);
733 parm
.set
.dwTimeFormat
= MCI_FORMAT_SAMPLES
;
734 err
= mciSendCommand(wDeviceID
, MCI_SET
, MCI_SET_TIME_FORMAT
, (DWORD_PTR
)&parm
);
735 ok(!err
,"mciCommand set time format samples: %s\n", dbg_mcierr(err
));
737 parm
.status
.dwItem
= MCI_STATUS_POSITION
;
738 err
= mciSendCommand(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
739 ok(!err
,"mciCommand status position: %s\n", dbg_mcierr(err
));
741 if(!err
) todo_wine
ok(parm
.status
.dwReturn
==expect
,"recorded %lu samples, expected %u\n",parm
.status
.dwReturn
,expect
);
743 err
= mciSendString("set x time format milliseconds", NULL
, 0, NULL
);
744 ok(!err
,"mci set time format milliseconds returned %s\n", dbg_mcierr(err
));
746 err
= mciSendString("save x tempfile1.wav", NULL
, 0, NULL
);
747 ok(!err
,"mci save returned %s\n", dbg_mcierr(err
));
749 err
= mciSendString("save x tempfile.wav", NULL
, 0, NULL
);
750 ok(!err
,"mci save returned %s\n", dbg_mcierr(err
));
751 if(!err
) ok_saved
= 0;
753 /* Save must not rename the original file. */
754 if (!DeleteFile("tempfile1.wav"))
755 todo_wine
ok(FALSE
, "Save must not rename the original file; DeleteFile returned %d\n", GetLastError());
757 err
= mciSendString("set x channels 2", NULL
, 0, NULL
);
758 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci set channels after saving returned %s\n", dbg_mcierr(err
));
760 parm
.seek
.dwTo
= 600;
761 err
= mciSendCommand(wDeviceID
, MCI_SEEK
, MCI_TO
| MCI_WAIT
, (DWORD_PTR
)&parm
);
762 ok(!err
,"mciCommand seek to 600: %s\n", dbg_mcierr(err
));
764 /* Truncate to current position */
765 err
= mciSendString("delete x", NULL
, 0, NULL
);
766 todo_wine
ok(!err
,"mci delete returned %s\n", dbg_mcierr(err
));
768 err
= mciSendString("status x length", buf
, sizeof(buf
), NULL
);
769 ok(!err
,"mci status length returned %s\n", dbg_mcierr(err
));
770 todo_wine
ok(!strcmp(buf
,"600"), "mci status length after delete gave %s, expected 600\n", buf
);
772 err
= mciSendString("close x", NULL
, 0, NULL
);
773 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
774 test_notification(hwnd
,"record complete",0);
777 static void test_playWAVE(HWND hwnd
)
781 memset(buf
, 0, sizeof(buf
));
783 err
= mciSendString("open waveaudio!tempfile.wav alias mysound", NULL
, 0, NULL
);
784 ok(err
==ok_saved
,"mci open waveaudio!tempfile.wav returned %s\n", dbg_mcierr(err
));
786 skip("Cannot open waveaudio!tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
790 err
= mciGetDeviceID("mysound");
791 ok(err
==1,"mciGetDeviceID mysound returned %u, expected 1\n", err
);
793 err
= mciGetDeviceID("tempfile.wav");
794 ok(err
==0,"mciGetDeviceID tempfile.wav returned %u, expected 0\n", err
);
796 err
= mciGetDeviceID("waveaudio");
797 ok(err
==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err
);
799 err
= mciSendString("status mysound length", buf
, sizeof(buf
), NULL
);
800 ok(!err
,"mci status length returned %s\n", dbg_mcierr(err
));
801 todo_wine
ok(!strcmp(buf
,"2000"), "mci status length gave %s, expected 2000, some tests will fail.\n", buf
);
803 err
= mciSendString("cue output", NULL
, 0, NULL
);
804 ok(err
==MCIERR_UNRECOGNIZED_COMMAND
,"mci incorrect cue output returned %s\n", dbg_mcierr(err
));
806 /* Test MCI to the bones -- Some todo_wine from Cue and
807 * from Play from 0 to 0 are not worth fixing. */
808 err
= mciSendString("cue mysound output notify", NULL
, 0, hwnd
);
809 ok(!err
,"mci cue output after open file returned %s\n", dbg_mcierr(err
));
810 /* Notification is delayed as a play thread is started. */
811 todo_wine
test_notification(hwnd
, "cue immediate", 0);
813 /* Cue pretends to put the MCI into paused state. */
814 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), hwnd
);
815 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
816 todo_wine
ok(!strcmp(buf
,"paused"), "mci status mode: %s, expected (pseudo)paused\n", buf
);
818 /* Strange pause where Pause is rejected, unlike Play; Pause; Pause tested below */
819 err
= mciSendString("pause mysound", NULL
, 0, hwnd
);
820 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci pause after cue returned %s\n", dbg_mcierr(err
));
822 /* MCI appears to start the play thread in this border case.
823 * Guessed that from (flaky) status mode and late notification arrival. */
824 err
= mciSendString("play mysound from 0 to 0 notify", NULL
, 0, hwnd
);
825 ok(!err
,"mci play from 0 to 0 returned %s\n", dbg_mcierr(err
));
826 todo_wine
test_notification(hwnd
, "cue aborted by play", MCI_NOTIFY_ABORTED
);
827 /* play's own notification follows below */
829 err
= mciSendString("play mysound from 250 to 0", NULL
, 0, NULL
);
830 ok(err
==MCIERR_OUTOFRANGE
,"mci play from 250 to 0 returned %s\n", dbg_mcierr(err
));
832 Sleep(50); /* Give play from 0 to 0 time to finish. */
833 todo_wine
test_notification(hwnd
, "play from 0 to 0", MCI_NOTIFY_SUCCESSFUL
);
835 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), hwnd
);
836 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
837 ok(!strcmp(buf
,"stopped"), "mci status mode: %s after play from 0 to 0\n", buf
);
839 err
= mciSendString("play MYSOUND from 250 to 0 notify", NULL
, 0, hwnd
);
840 ok(err
==MCIERR_OUTOFRANGE
,"mci play from 250 to 0 notify returned %s\n", dbg_mcierr(err
));
841 /* No notification (checked below) sent if error */
843 /* A second play caused Wine<1.1.33 to hang */
844 err
= mciSendString("play mysound from 500 to 1500 wait", NULL
, 0, NULL
);
845 ok(!err
,"mci play from 500 to 1500 returned %s\n", dbg_mcierr(err
));
847 err
= mciSendString("status mysound position", buf
, sizeof(buf
), hwnd
);
848 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
849 if(!err
) ok(!strcmp(buf
,"1500"), "mci status position: %s\n", buf
);
851 /* mci will not play position < current */
852 err
= mciSendString("play mysound to 1000", NULL
, 0, NULL
);
853 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 1000 returned %s\n", dbg_mcierr(err
));
855 /* mci will not play to > end */
856 err
= mciSendString("play mysound TO 3000 notify", NULL
, 0, hwnd
);
857 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 3000 notify returned %s\n", dbg_mcierr(err
));
859 err
= mciSendString("play mysound to 2000", NULL
, 0, NULL
);
860 ok(!err
,"mci play to 2000 returned %s\n", dbg_mcierr(err
));
862 /* Rejected while playing */
863 err
= mciSendString("cue mysound output", NULL
, 0, NULL
);
864 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci cue output while playing returned %s\n", dbg_mcierr(err
));
866 err
= mciSendString("play mysound to 3000", NULL
, 0, NULL
);
867 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 3000 returned %s\n", dbg_mcierr(err
));
869 err
= mciSendString("stop mysound Wait", NULL
, 0, NULL
);
870 ok(!err
,"mci stop wait returned %s\n", dbg_mcierr(err
));
871 test_notification(hwnd
, "play/cue/pause/stop", 0);
873 err
= mciSendString("Seek Mysound to 250 wait Notify", NULL
, 0, hwnd
);
874 ok(!err
,"mci seek to 250 wait notify returned %s\n", dbg_mcierr(err
));
875 test_notification(hwnd
,"seek wait notify",MCI_NOTIFY_SUCCESSFUL
);
877 err
= mciSendString("status mysound position notify", buf
, sizeof(buf
), hwnd
);
878 ok(!err
,"mci status position notify returned %s\n", dbg_mcierr(err
));
879 if(!err
) ok(!strcmp(buf
,"250"), "mci status position: %s\n", buf
);
880 /* Immediate commands like status also send notifications. */
881 test_notification(hwnd
,"status position",MCI_NOTIFY_SUCCESSFUL
);
883 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), hwnd
);
884 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
885 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
887 /* Another play from == to testcase */
888 err
= mciSendString("play mysound to 250 wait notify", NULL
, 0, hwnd
);
889 ok(!err
,"mci play (from 250) to 250 returned %s\n", dbg_mcierr(err
));
890 todo_wine
test_notification(hwnd
,"play to 250 wait notify",MCI_NOTIFY_SUCCESSFUL
);
892 err
= mciSendString("cue mysound output", NULL
, 0, NULL
);
893 ok(!err
,"mci cue output after play returned %s\n", dbg_mcierr(err
));
895 err
= mciSendString("close mysound", NULL
, 0, NULL
);
896 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
897 test_notification(hwnd
,"after close",0);
900 static void test_asyncWAVE(HWND hwnd
)
902 MCIDEVICEID wDeviceID
;
903 MCI_PARMS_UNION parm
;
906 memset(buf
, 0, sizeof(buf
));
908 err
= mciSendString("open tempfile.wav alias mysound notify type waveaudio", buf
, sizeof(buf
), hwnd
);
909 ok(err
==ok_saved
,"mci open tempfile.wav returned %s\n", dbg_mcierr(err
));
911 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
914 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
915 wDeviceID
= atoi(buf
);
916 ok(wDeviceID
,"mci open DeviceID: %d\n", wDeviceID
);
917 test_notification(hwnd
,"open alias notify",MCI_NOTIFY_SUCCESSFUL
);
919 err
= mciGetDeviceID("mysound");
920 ok(err
==wDeviceID
,"mciGetDeviceID alias returned %u, expected %u\n", err
, wDeviceID
);
922 /* Only the alias is looked up. */
923 err
= mciGetDeviceID("tempfile.wav");
924 ok(err
==0,"mciGetDeviceID tempfile.wav returned %u, expected 0\n", err
);
926 err
= mciGetDeviceID("waveaudio");
927 ok(err
==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err
);
929 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), hwnd
);
930 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
931 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
933 err
= mciSendString("play mysound notify", NULL
, 0, hwnd
);
934 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
936 /* Give Wine's asynchronous thread time to start up. Furthermore,
937 * it uses 3 buffers per second, so that the positions reported
938 * will be 333ms, 667ms etc. at best. */
939 Sleep(100); /* milliseconds */
941 /* Do not query time format as string because result depends on locale! */
942 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
943 err
= mciSendCommand(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
944 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
945 if(!err
) ok(parm
.status
.dwReturn
==MCI_FORMAT_MILLISECONDS
,"status time format: %ld\n",parm
.status
.dwReturn
);
947 parm
.set
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
948 err
= mciSendCommand(wDeviceID
, MCI_SET
, MCI_SET_TIME_FORMAT
, (DWORD_PTR
)&parm
);
949 ok(!err
,"mciCommand set time format ms: %s\n", dbg_mcierr(err
));
951 err
= mciSendString("status mysound position", buf
, sizeof(buf
), hwnd
);
952 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
953 ok(strcmp(buf
,"2000"), "mci status position: %s, expected 2000\n", buf
);
954 trace("position after Sleep: %sms\n",buf
);
956 /* Some machines reach 79ms only during the 100ms sleep. */
957 ok(p2
>=67,"not enough time elapsed %ums\n",p2
);
958 test_notification(hwnd
,"play (nowait)",0);
960 err
= mciSendString("pause mysound wait", NULL
, 0, hwnd
);
961 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
963 err
= mciSendString("status mysound mode notify", buf
, sizeof(buf
), hwnd
);
964 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
965 if(!err
) ok(!strcmp(buf
,"paused"), "mci status mode: %s\n", buf
);
966 test_notification(hwnd
,"play",MCI_NOTIFY_SUPERSEDED
);
967 test_notification(hwnd
,"status",MCI_NOTIFY_SUCCESSFUL
);
969 err
= mciSendString("status mysound position", buf
, sizeof(buf
), hwnd
);
970 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
971 trace("position while paused: %sms\n",buf
);
973 ok(p1
>=p2
, "position not increasing: %u > %u\n", p2
, p1
);
975 err
= mciSendString("stop mysound wait", NULL
, 0, NULL
);
976 ok(!err
,"mci stop returned %s\n", dbg_mcierr(err
));
978 err
= mciSendString("info mysound file notify", buf
, sizeof(buf
), hwnd
);
979 ok(!err
,"mci info file returned %s\n", dbg_mcierr(err
));
980 if(!err
) { /* fully qualified name */
981 int len
= strlen(buf
);
982 todo_wine
ok(len
>2 && buf
[1]==':',"Expected full pathname from info file: %s\n", buf
);
983 ok(len
>=12 && !strcmp(&buf
[len
-12],"tempfile.wav"), "info file returned: %s\n", buf
);
985 test_notification(hwnd
,"info file",MCI_NOTIFY_SUCCESSFUL
);
987 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), hwnd
);
988 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
989 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
991 err
= mciSendString("status mysound position", buf
, sizeof(buf
), hwnd
);
992 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
993 trace("position once stopped: %sms\n",buf
);
995 /* An XP machine let the position increase slightly after pause. */
996 ok(p2
>=p1
&& p2
<=p1
+16,"position changed from %ums to %ums\n",p1
,p2
);
998 /* No Resume once stopped (waveaudio, sequencer and cdaudio differ). */
999 err
= mciSendString("resume mysound wait", NULL
, 0, NULL
);
1000 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci resume wait returned %s\n", dbg_mcierr(err
));
1002 err
= mciSendString("play mysound wait", NULL
, 0, NULL
);
1003 ok(!err
,"mci play wait returned %s\n", dbg_mcierr(err
));
1005 err
= mciSendString("status mysound position", buf
, sizeof(buf
), hwnd
);
1006 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1007 todo_wine
ok(!strcmp(buf
,"2000"), "mci status position: %s\n", buf
);
1009 err
= mciSendString("seek mysound to start wait", NULL
, 0, NULL
);
1010 ok(!err
,"mci seek to start wait returned %s\n", dbg_mcierr(err
));
1012 err
= mciSendString("play mysound to 1000 notify", NULL
, 0, hwnd
);
1013 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1015 /* Sleep(200); not needed with Wine any more. */
1017 err
= mciSendString("pause mysound notify", NULL
, 0, NULL
); /* notify no callback */
1018 ok(!err
,"mci pause notify returned %s\n", dbg_mcierr(err
));
1019 /* Supersede even though pause cannot notify given no callback */
1020 test_notification(hwnd
,"pause aborted play #1 notification",MCI_NOTIFY_SUPERSEDED
);
1021 test_notification(hwnd
,"impossible pause notification",0);
1023 err
= mciSendString("cue mysound output notify", NULL
, 0, hwnd
);
1024 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci cue output while paused returned %s\n", dbg_mcierr(err
));
1025 test_notification(hwnd
,"cue output notify #2",0);
1027 err
= mciSendString("resume mysound notify", NULL
, 0, hwnd
);
1028 ok(!err
,"mci resume notify returned %s\n", dbg_mcierr(err
));
1029 test_notification(hwnd
, "resume notify", MCI_NOTIFY_SUCCESSFUL
);
1031 /* Seek or even Stop used to hang Wine<1.1.32 on MacOS. */
1032 err
= mciSendString("seek mysound to 0 wait", NULL
, 0, NULL
);
1033 ok(!err
,"mci seek to start returned %s\n", dbg_mcierr(err
));
1036 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), NULL
);
1037 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1038 if(!err
) ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
1040 err
= mciSendString("seek mysound wait", NULL
, 0, NULL
);
1041 ok(err
==MCIERR_MISSING_PARAMETER
,"mci seek to nowhere returned %s\n", dbg_mcierr(err
));
1043 /* cdaudio does not detect to start to end as error */
1044 err
= mciSendString("seek mysound to start to 0", NULL
, 0, NULL
);
1045 ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"mci seek to start to 0 returned %s\n", dbg_mcierr(err
));
1047 err
= mciSendString("PLAY mysound to 1000 notify", NULL
, 0, hwnd
);
1048 ok(!err
,"mci play to 1000 notify returned %s\n", dbg_mcierr(err
));
1050 /* Sleep(200); not needed with Wine any more. */
1051 /* Give it 400ms and resume will appear to complete below. */
1053 err
= mciSendString("pause mysound wait", NULL
, 0, NULL
);
1054 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1055 /* Unlike sequencer and cdaudio, waveaudio's pause does not abort. */
1056 test_notification(hwnd
,"pause aborted play #2 notification",0);
1058 err
= mciSendString("resume mysound wait", NULL
, 0, NULL
);
1059 ok(!err
,"mci resume wait returned %s\n", dbg_mcierr(err
));
1060 /* Resume is a short asynchronous call, something else is playing. */
1062 err
= mciSendString("status mysound mode", buf
, sizeof(buf
), NULL
);
1063 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1064 if(!err
) ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1066 /* Note extra space before alias */
1067 err
= mciSendString("pause mysound wait", NULL
, 0, NULL
);
1068 todo_wine
ok(!err
,"mci pause (space) wait returned %s\n", dbg_mcierr(err
));
1070 err
= mciSendString("pause mysound wait", NULL
, 0, NULL
);
1071 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1073 /* Better ask position only when paused, is it updated while playing? */
1074 err
= mciSendString("status mysound position", buf
, sizeof(buf
), NULL
);
1075 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1076 /* TODO compare position < 900 */
1077 ok(strcmp(buf
,"1000"), "mci resume waited\n");
1078 ok(strcmp(buf
,"2000"), "mci resume played to end\n");
1079 trace("position after resume: %sms\n",buf
);
1080 test_notification(hwnd
,"play (aborted by pause/resume/pause)",0);
1082 err
= mciSendString("close mysound wait", NULL
, 0, NULL
);
1083 ok(!err
,"mci close wait returned %s\n", dbg_mcierr(err
));
1084 test_notification(hwnd
,"play (aborted by close)",MCI_NOTIFY_ABORTED
);
1087 static void test_AutoOpenWAVE(HWND hwnd
)
1089 /* This test used(?) to cause intermittent crashes when Wine exits, after
1090 * fixme:winmm:MMDRV_Exit Closing while ll-driver open
1092 UINT ndevs
= waveOutGetNumDevs();
1093 MCIERROR err
, ok_snd
= ndevs
? 0 : MCIERR_HARDWARE
;
1094 MCI_PARMS_UNION parm
;
1095 char buf
[512], path
[300], command
[330];
1096 DWORD intbuf
[3] = { 0xDEADF00D, 99, 0xABADCAFE };
1097 memset(buf
, 0, sizeof(buf
)); memset(path
, 0, sizeof(path
));
1099 /* Do not crash on NULL buffer pointer */
1100 err
= mciSendString("sysinfo waveaudio quantity open", NULL
, 0, NULL
);
1101 ok(err
==MCIERR_PARAM_OVERFLOW
,"mci sysinfo without buffer returned %s\n", dbg_mcierr(err
));
1103 err
= mciSendString("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1104 ok(!err
,"mci sysinfo waveaudio quantity open returned %s\n", dbg_mcierr(err
));
1105 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf
);
1107 /* Who knows why some MS machines pass all tests but return MCIERR_HARDWARE here? */
1108 /* Wine returns MCIERR_HARDWARE when no default sound is found in win.ini or the registry. */
1109 err
= mciSendString("sound NoSuchSoundDefined wait", NULL
, 0, NULL
);
1110 ok(err
==ok_snd
|| err
==MCIERR_HARDWARE
, "mci sound NoSuchSoundDefined returned %s\n", dbg_mcierr(err
));
1112 err
= mciSendString("sound SystemExclamation notify wait", NULL
, 0, hwnd
);
1113 ok(err
==ok_snd
|| err
==MCIERR_HARDWARE
, "mci sound SystemExclamation returned %s\n", dbg_mcierr(err
));
1114 test_notification(hwnd
, "sound notify", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
1116 Sleep(16); /* time to auto-close makes sysinfo below return expected error */
1117 err
= mciSendString("sysinfo waveaudio notify name 1 open", buf
, sizeof(buf
), hwnd
);
1118 ok(err
==MCIERR_OUTOFRANGE
,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err
));
1119 if(!err
) trace("sysinfo dangling open alias: %s\n", buf
);
1120 test_notification(hwnd
, "sysinfo name outofrange\n", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
1122 err
= mciSendString("play no-such-file-exists.wav notify", buf
, sizeof(buf
), NULL
);
1123 todo_wine
ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open notify returned %s\n", dbg_mcierr(err
));
1124 /* FILE_NOT_FOUND in Wine because auto-open fails before testing the notify flag */
1126 test_notification(hwnd
, "-prior to auto-open-", 0);
1128 err
= mciSendString("play tempfile.wav notify", buf
, sizeof(buf
), hwnd
);
1129 if(ok_saved
==MCIERR_FILE_NOT_FOUND
) todo_wine
/* same as above */
1130 ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open play notify returned %s\n", dbg_mcierr(err
));
1132 ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open play notify returned %s\n", dbg_mcierr(err
));
1134 if(err
) /* FIXME: don't open twice yet, it confuses Wine. */
1135 err
= mciSendString("play tempfile.wav", buf
, sizeof(buf
), hwnd
);
1136 ok(err
==ok_saved
,"mci auto-open play returned %s\n", dbg_mcierr(err
));
1138 if(err
==MCIERR_FILE_NOT_FOUND
) {
1139 skip("Cannot open tempfile.wav for auto-play, skipping\n");
1143 err
= mciSendString("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1144 ok(!err
,"mci sysinfo waveaudio quantity after auto-open returned %s\n", dbg_mcierr(err
));
1145 if(!err
) ok(!strcmp(buf
,"1"), "sysinfo quantity open expected 1, got: %s\n", buf
);
1147 parm
.sys
.lpstrReturn
= (LPSTR
)&intbuf
[1];
1148 parm
.sys
.dwRetSize
= 2*sizeof(DWORD
); /* only one DWORD is used */
1149 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
;
1150 err
= mciSendCommand(0, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
1151 ok(!err
,"mciSendCommand(0(WAVEAUDIO), MCI_SYSINFO, OPEN | MCI_NOTIFY) returned %s\n", dbg_mcierr(err
));
1152 if(!err
) ok(atoi(buf
)==intbuf
[1],"sysinfo waveaudio quantity open string and command differ\n");
1154 err
= mciSendString("sysinfo waveaudio name 1 open notify", buf
, sizeof(buf
), hwnd
);
1155 ok(!err
,"mci sysinfo waveaudio name after auto-open returned %s\n", dbg_mcierr(err
));
1156 /* This is the alias, not necessarily a file name. */
1157 if(!err
) ok(!strcmp(buf
,"tempfile.wav"), "sysinfo name 1 open: %s\n", buf
);
1158 test_notification(hwnd
, "sysinfo name notify\n", MCI_NOTIFY_SUCCESSFUL
);
1160 err
= mciGetDeviceID("tempfile.wav");
1161 ok(err
==1,"mciGetDeviceID tempfile.wav returned %u, expected 1\n", err
);
1163 /* Save the full pathname to the file. */
1164 err
= mciSendString("info tempfile.wav file", path
, sizeof(path
), NULL
);
1165 ok(!err
,"mci info tempfile.wav file returned %s\n", dbg_mcierr(err
));
1166 if(err
) strcpy(path
,"tempfile.wav");
1168 err
= mciSendString("status tempfile.wav mode", NULL
, 0, hwnd
);
1169 ok(!err
,"mci status tempfile.wav mode without buffer returned %s\n", dbg_mcierr(err
));
1171 sprintf(command
,"status \"%s\" mode",path
);
1172 err
= mciSendString(command
, buf
, sizeof(buf
), hwnd
);
1173 ok(!err
,"mci status \"%s\" mode returned %s\n", path
, dbg_mcierr(err
));
1175 err
= mciSendString("status tempfile.wav mode", buf
, sizeof(buf
), hwnd
);
1176 ok(!err
,"mci status tempfile.wav mode returned %s\n", dbg_mcierr(err
));
1177 if(!err
) ok(!strcmp(buf
,"playing"), "mci auto-open status mode, got: %s\n", buf
);
1179 err
= mciSendString("open tempfile.wav", buf
, sizeof(buf
), NULL
);
1180 ok(err
==MCIERR_DEVICE_OPEN
, "mci open from auto-open returned %s\n", dbg_mcierr(err
));
1182 err
= mciSendString("open foo.wav alias tempfile.wav", buf
, sizeof(buf
), NULL
);
1183 ok(err
==MCIERR_DUPLICATE_ALIAS
, "mci open re-using alias returned %s\n", dbg_mcierr(err
));
1185 /* w2k/xp and Wine differ. While the device is busy playing, it is
1186 * regularly open and accessible via the filename: subsequent
1187 * commands must not cause auto-open each. In Wine, a subsequent
1188 * command with notify request may cause the initial play
1189 * notification to be superseded, in turn causing MCI to close the
1190 * device. I.e. MCI uses the auto-open notification for itself,
1191 * that's why it's not available to the app. On w2k/xp,
1192 * subsequent commands with notify requests are returned with
1193 * MCIERR_NOTIFY_ON_AUTO_OPEN and thus don't abort the original
1196 err
= mciSendString("status tempfile.wav mode notify", buf
, sizeof(buf
), hwnd
);
1197 todo_wine
ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
, "mci status auto-open notify returned %s\n", dbg_mcierr(err
));
1199 trace("Wine style MCI auto-close upon notification\n");
1201 /* "playing" because auto-close comes after the status call. */
1202 ok(!strcmp(buf
,"playing"), "mci auto-open status mode notify, got: %s\n", buf
);
1203 /* fixme:winmm:MMDRV_Exit Closing while ll-driver open
1204 * is explained by failure to auto-close a device. */
1205 test_notification(hwnd
,"status notify",MCI_NOTIFY_SUCCESSFUL
);
1206 /* MCI received NOTIFY_SUPERSEDED and auto-closed the device. */
1208 /* Until this is implemented, force closing the device */
1209 err
= mciSendString("close tempfile.wav", NULL
, 0, hwnd
);
1210 ok(!err
,"mci auto-still-open stop returned %s\n", dbg_mcierr(err
));
1212 test_notification(hwnd
,"auto-open",0);
1213 } else if(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
) { /* MS style */
1214 trace("MS style MCI auto-open forbids notification\n");
1216 err
= mciSendString("pause tempfile.wav", NULL
, 0, hwnd
);
1217 ok(!err
,"mci auto-still-open pause returned %s\n", dbg_mcierr(err
));
1219 err
= mciSendString("status tempfile.wav mode", buf
, sizeof(buf
), hwnd
);
1220 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1221 if(!err
) ok(!strcmp(buf
,"paused"), "mci auto-open status mode, got: %s\n", buf
);
1224 err
= mciSendString("stop tempfile.wav wait", NULL
, 0, hwnd
);
1225 ok(!err
,"mci auto-still-open stop returned %s\n", dbg_mcierr(err
));
1226 Sleep(16); /* makes sysinfo quantity open below succeed */
1229 err
= mciSendString("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1230 ok(!err
,"mci sysinfo waveaudio quantity open after close returned %s\n", dbg_mcierr(err
));
1231 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo quantity open expected 0 after auto-close, got: %s\n", buf
);
1233 /* w95-WinME (not w2k/XP) switch to C:\ after auto-playing once. Prevent
1234 * MCIERR_FILE_NOT_FOUND by using the full path name from the Info file command.
1236 sprintf(command
,"status \"%s\" mode wait",path
);
1237 err
= mciSendString(command
, buf
, sizeof(buf
), hwnd
);
1238 ok(!err
,"mci re-auto-open status mode returned %s\n", dbg_mcierr(err
));
1239 if(!err
) ok(!strcmp(buf
,"stopped"), "mci re-auto-open status mode, got: %s\n", buf
);
1241 /* This uses auto-open as well. */
1242 err
= mciSendString("capability waveaudio outputs", buf
, sizeof(buf
), NULL
);
1243 ok(!err
,"mci capability waveaudio outputs returned %s\n", dbg_mcierr(err
));
1244 /* Wine with no sound selected in winecfg's audio tab fails this test. */
1245 if(!err
) ok(atoi(buf
)==ndevs
,"Expected %d audio outputs, got %s\n", ndevs
, buf
);
1247 err
= mciSendString("capability waveaudio device type", buf
, sizeof(buf
), hwnd
);
1248 ok(!err
,"mci capability device type returned %s\n", dbg_mcierr(err
));
1249 if(!err
) ok(!strcmp(buf
,"waveaudio"), "mci capability device type response: %s\n", buf
);
1251 /* waveaudio forbids Pause without Play. */
1252 sprintf(command
,"pause \"%s\"",path
);
1253 err
= mciSendString(command
, NULL
, 0, hwnd
);
1254 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci auto-open pause returned %s\n", dbg_mcierr(err
));
1256 ok(0xDEADF00D==intbuf
[0] && 0xABADCAFE==intbuf
[2],"DWORD buffer corruption\n");
1263 hwnd
= CreateWindowExA(0, "static", "winmm test", WS_POPUP
, 0,0,100,100,
1265 test_mciParser(hwnd
);
1266 test_openCloseWAVE(hwnd
);
1267 test_recordWAVE(hwnd
);
1268 test_playWAVE(hwnd
);
1269 test_asyncWAVE(hwnd
);
1270 test_AutoOpenWAVE(hwnd
);
1271 /* Win9X hangs when exiting with something still open. */
1272 err
= mciSendString("close all", NULL
, 0, hwnd
);
1273 ok(!err
,"final close all returned %s\n", dbg_mcierr(err
));
1274 ok(DeleteFile("tempfile.wav")||ok_saved
,"Delete tempfile.wav (cause auto-open?)\n");
1275 DestroyWindow(hwnd
);