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
27 #include "wine/test.h"
29 /* The tests use the MCI's own save capability to create the tempfile.wav to play.
30 * To use a pre-existing file, write-protect it. */
31 static MCIERROR ok_saved
= MCIERR_FILE_NOT_FOUND
;
35 MCI_STATUS_PARMS status
;
36 MCI_WAVE_SET_PARMS set
;
37 MCI_WAVE_OPEN_PARMSA open
;
38 MCI_GETDEVCAPS_PARMS caps
;
39 MCI_SYSINFO_PARMSA sys
;
41 MCI_DGV_OPEN_PARMSW dgv_open
;
42 MCI_GENERIC_PARMS gen
;
45 const char* dbg_mcierr(MCIERROR err
)
48 case 0: return "0=NOERROR";
49 #define X(label) case label: return #label ;
50 X(MCIERR_INVALID_DEVICE_ID
)
51 X(MCIERR_UNRECOGNIZED_KEYWORD
)
52 X(MCIERR_UNRECOGNIZED_COMMAND
)
54 X(MCIERR_INVALID_DEVICE_NAME
)
55 X(MCIERR_OUT_OF_MEMORY
)
57 X(MCIERR_CANNOT_LOAD_DRIVER
)
58 X(MCIERR_MISSING_COMMAND_STRING
)
59 X(MCIERR_PARAM_OVERFLOW
)
60 X(MCIERR_MISSING_STRING_ARGUMENT
)
62 X(MCIERR_PARSER_INTERNAL
)
63 X(MCIERR_DRIVER_INTERNAL
)
64 X(MCIERR_MISSING_PARAMETER
)
65 X(MCIERR_UNSUPPORTED_FUNCTION
)
66 X(MCIERR_FILE_NOT_FOUND
)
67 X(MCIERR_DEVICE_NOT_READY
)
70 X(MCIERR_CANNOT_USE_ALL
)
72 X(MCIERR_EXTENSION_NOT_FOUND
)
74 X(MCIERR_FLAGS_NOT_COMPATIBLE
)
75 X(MCIERR_FILE_NOT_SAVED
)
76 X(MCIERR_DEVICE_TYPE_REQUIRED
)
77 X(MCIERR_DEVICE_LOCKED
)
78 X(MCIERR_DUPLICATE_ALIAS
)
79 X(MCIERR_BAD_CONSTANT
)
80 X(MCIERR_MUST_USE_SHAREABLE
)
81 X(MCIERR_MISSING_DEVICE_NAME
)
82 X(MCIERR_BAD_TIME_FORMAT
)
83 X(MCIERR_NO_CLOSING_QUOTE
)
84 X(MCIERR_DUPLICATE_FLAGS
)
85 X(MCIERR_INVALID_FILE
)
86 X(MCIERR_NULL_PARAMETER_BLOCK
)
87 X(MCIERR_UNNAMED_RESOURCE
)
88 X(MCIERR_NEW_REQUIRES_ALIAS
)
89 X(MCIERR_NOTIFY_ON_AUTO_OPEN
)
90 X(MCIERR_NO_ELEMENT_ALLOWED
)
91 X(MCIERR_NONAPPLICABLE_FUNCTION
)
92 X(MCIERR_ILLEGAL_FOR_AUTO_OPEN
)
93 X(MCIERR_FILENAME_REQUIRED
)
94 X(MCIERR_EXTRA_CHARACTERS
)
95 X(MCIERR_DEVICE_NOT_INSTALLED
)
99 X(MCIERR_DEVICE_LENGTH
)
100 X(MCIERR_DEVICE_ORD_LENGTH
)
102 X(MCIERR_WAVE_OUTPUTSINUSE
)
103 X(MCIERR_WAVE_SETOUTPUTINUSE
)
104 X(MCIERR_WAVE_INPUTSINUSE
)
105 X(MCIERR_WAVE_SETINPUTINUSE
)
106 X(MCIERR_WAVE_OUTPUTUNSPECIFIED
)
107 X(MCIERR_WAVE_INPUTUNSPECIFIED
)
108 X(MCIERR_WAVE_OUTPUTSUNSUITABLE
)
109 X(MCIERR_WAVE_SETOUTPUTUNSUITABLE
)
110 X(MCIERR_WAVE_INPUTSUNSUITABLE
)
111 X(MCIERR_WAVE_SETINPUTUNSUITABLE
)
112 X(MCIERR_SEQ_DIV_INCOMPATIBLE
)
113 X(MCIERR_SEQ_PORT_INUSE
)
114 X(MCIERR_SEQ_PORT_NONEXISTENT
)
115 X(MCIERR_SEQ_PORT_MAPNODEVICE
)
116 X(MCIERR_SEQ_PORT_MISCERROR
)
118 X(MCIERR_SEQ_PORTUNSPECIFIED
)
119 X(MCIERR_SEQ_NOMIDIPRESENT
)
121 X(MCIERR_CREATEWINDOW
)
124 X(MCIERR_NO_IDENTITY
)
127 static char name
[20]; /* Not to be called twice in a parameter list! */
128 sprintf(name
, "MMSYSERR %lu", err
);
134 static BOOL
spurious_message(LPMSG msg
)
136 /* WM_DEVICECHANGE 0x0219 appears randomly */
137 if(msg
->message
!= MM_MCINOTIFY
) {
138 trace("skipping spurious message %04x\n",msg
->message
);
144 static WCHAR
*load_resource(const WCHAR
*name
)
146 static WCHAR pathW
[MAX_PATH
];
152 GetTempPathW(ARRAY_SIZE(pathW
), pathW
);
155 file
= CreateFileW(pathW
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
156 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to create file %s, error %lu.\n",
157 wine_dbgstr_w(pathW
), GetLastError());
159 res
= FindResourceW(NULL
, name
, (LPCWSTR
)RT_RCDATA
);
160 ok(!!res
, "Failed to load resource, error %lu.\n", GetLastError());
161 ptr
= LockResource(LoadResource(GetModuleHandleA(NULL
), res
));
162 WriteFile(file
, ptr
, SizeofResource( GetModuleHandleA(NULL
), res
), &written
, NULL
);
163 ok(written
== SizeofResource(GetModuleHandleA(NULL
), res
), "Failed to write resource.\n");
169 /* A single ok() in each code path allows us to prefix this with todo_wine */
170 #define test_notification(hwnd, command, type) test_notification_dbg(hwnd, command, type, __LINE__)
171 static void test_notification_dbg(HWND hwnd
, const char* command
, WPARAM type
, int line
)
172 { /* Use type 0 as meaning no message */
175 do { seen
= PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
); }
176 while(seen
&& spurious_message(&msg
));
178 /* We observe transient delayed notification, mostly on native.
179 * Notification is not always present right when mciSend returns. */
180 trace_(__FILE__
,line
)("Waiting for delayed notification from %s\n", command
);
181 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 3000, QS_POSTMESSAGE
);
182 seen
= PeekMessageA(&msg
, hwnd
, MM_MCINOTIFY
, MM_MCINOTIFY
, PM_REMOVE
);
185 ok_(__FILE__
,line
)(type
==0, "Expect message %04Ix from %s\n", type
, command
);
186 else if(msg
.hwnd
!= hwnd
)
187 ok_(__FILE__
,line
)(msg
.hwnd
== hwnd
, "Didn't get the handle to our test window\n");
188 else if(msg
.message
!= MM_MCINOTIFY
)
189 ok_(__FILE__
,line
)(msg
.message
== MM_MCINOTIFY
, "got %04x instead of MM_MCINOTIFY from command %s\n", msg
.message
, command
);
190 else ok_(__FILE__
,line
)(msg
.wParam
== type
, "got %04Ix instead of MCI_NOTIFY_xyz %04Ix from command %s\n", msg
.wParam
, type
, command
);
193 static void test_mciParser(HWND hwnd
)
196 MCIDEVICEID wDeviceID
;
197 MCI_PARMS_UNION parm
;
199 memset(buf
, 0, sizeof(buf
));
200 test_notification(hwnd
, "-prior to parser test-", 0);
202 /* Get a handle on an MCI device, works even without sound. */
203 parm
.open
.lpstrDeviceType
= "waveaudio";
204 parm
.open
.lpstrElementName
= ""; /* "new" at the command level */
205 parm
.open
.lpstrAlias
= "x"; /* to enable mciSendStringA */
206 parm
.open
.dwCallback
= (DWORD_PTR
)hwnd
;
207 err
= mciSendCommandA(0, MCI_OPEN
,
208 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| MCI_OPEN_ALIAS
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
209 ok(!err
,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err
));
210 wDeviceID
= parm
.open
.wDeviceID
;
211 ok(!strcmp(parm
.open
.lpstrDeviceType
,"waveaudio"), "open modified device type\n");
213 test_notification(hwnd
, "MCI_OPEN", MCI_NOTIFY_SUCCESSFUL
);
214 test_notification(hwnd
, "MCI_OPEN no #2", 0);
216 err
= mciSendStringA("open avivideo alias a", buf
, sizeof(buf
), hwnd
);
217 ok(!err
,"open another: %s\n", dbg_mcierr(err
));
220 err
= mciSendStringA("", buf
, sizeof(buf
), NULL
);
221 ok(err
==MCIERR_MISSING_COMMAND_STRING
,"empty string: %s\n", dbg_mcierr(err
));
222 ok(!buf
[0], "error buffer %s\n", buf
);
225 err
= mciSendStringA("open", buf
, sizeof(buf
), NULL
);
226 ok(err
==MCIERR_MISSING_DEVICE_NAME
,"open void: %s\n", dbg_mcierr(err
));
227 ok(!buf
[0], "open error buffer %s\n", buf
);
229 err
= mciSendStringA("open notify", buf
, sizeof(buf
), NULL
);
230 todo_wine
ok(err
==MCIERR_INVALID_DEVICE_NAME
,"open notify: %s\n", dbg_mcierr(err
));
232 err
= mciSendStringA("open new", buf
, sizeof(buf
), NULL
);
233 todo_wine
ok(err
==MCIERR_NEW_REQUIRES_ALIAS
,"open new: %s\n", dbg_mcierr(err
));
235 err
= mciSendStringA("open new type waveaudio alias r shareable shareable", buf
, sizeof(buf
), NULL
);
236 todo_wine
ok(err
==MCIERR_DUPLICATE_FLAGS
,"open new: %s\n", dbg_mcierr(err
));
237 if(!err
) mciSendStringA("close r", NULL
, 0, NULL
);
239 err
= mciSendStringA("status x position wait wait", buf
, sizeof(buf
), NULL
);
240 todo_wine
ok(err
==MCIERR_DUPLICATE_FLAGS
,"status wait wait: %s\n", dbg_mcierr(err
));
242 err
= mciSendStringA("status x length length", buf
, sizeof(buf
), NULL
);
243 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status 2xlength: %s\n", dbg_mcierr(err
));
245 err
= mciSendStringA("status x length position", buf
, sizeof(buf
), NULL
);
246 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status length+position: %s\n", dbg_mcierr(err
));
249 err
= mciSendStringA("set x time format milliseconds time format ms", buf
, sizeof(buf
), NULL
);
250 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status length+position: %s\n", dbg_mcierr(err
));
251 ok(!buf
[0], "set error buffer %s\n", buf
);
253 /* device's response, not a parser test */
254 err
= mciSendStringA("status x", buf
, sizeof(buf
), NULL
);
255 ok(err
==MCIERR_MISSING_PARAMETER
,"status waveaudio nokeyword: %s\n", dbg_mcierr(err
));
258 err
= mciSendStringA("status a", buf
, sizeof(buf
), NULL
);
259 todo_wine
ok(err
==MCIERR_UNSUPPORTED_FUNCTION
,"status avivideo nokeyword: %s\n", dbg_mcierr(err
));
260 ok(!buf
[0], "status error buffer %s\n", buf
);
262 err
= mciSendStringA("status x track", buf
, sizeof(buf
), NULL
);
263 ok(err
==MCIERR_BAD_INTEGER
,"status waveaudio no track: %s\n", dbg_mcierr(err
));
265 err
= mciSendStringA("status x track 3", buf
, sizeof(buf
), NULL
);
266 ok(err
==MCIERR_MISSING_PARAMETER
,"status waveaudio track 3: %s\n", dbg_mcierr(err
));
268 err
= mciSendStringA("status x 2 track 3", buf
, sizeof(buf
), NULL
);
269 todo_wine
ok(err
==MCIERR_OUTOFRANGE
,"status 2(position) track 3: %s\n", dbg_mcierr(err
));
271 err
= mciSendStringA("status x 0x4", buf
, sizeof(buf
), NULL
);
272 todo_wine
ok(err
==MCIERR_BAD_CONSTANT
, "status 0x4: %s\n", dbg_mcierr(err
));
274 err
= mciSendStringA("status x 4", buf
, sizeof(buf
), hwnd
);
275 ok(!err
,"status 4(mode): %s\n", dbg_mcierr(err
));
276 if(!err
)ok(!strcmp(buf
,"stopped"), "status 4(mode), got: %s\n", buf
);
278 err
= mciSendStringA("status x 4 notify", buf
, sizeof(buf
), hwnd
);
279 todo_wine
ok(!err
,"status 4(mode) notify: %s\n", dbg_mcierr(err
));
280 if(!err
)ok(!strcmp(buf
,"stopped"), "status 4(mode), got: %s\n", buf
);
281 test_notification(hwnd
, "status 4 notify", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
283 err
= mciSendStringA("set x milliseconds", buf
, sizeof(buf
), hwnd
);
284 todo_wine
ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
,"set milliseconds: %s\n", dbg_mcierr(err
));
286 err
= mciSendStringA("set x milliseconds ms", buf
, sizeof(buf
), hwnd
);
287 todo_wine
ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
,"set milliseconds ms: %s\n", dbg_mcierr(err
));
289 err
= mciSendStringA("capability x can save", buf
, sizeof(buf
), hwnd
);
290 todo_wine
ok(!err
,"capability can (space) save: %s\n", dbg_mcierr(err
));
292 err
= mciSendStringA("status x nsa", buf
, sizeof(buf
), hwnd
);
293 todo_wine
ok(err
==MCIERR_BAD_CONSTANT
,"status nsa: %s\n", dbg_mcierr(err
));
295 err
= mciSendStringA("seek x to 0:0:0:0:0", buf
, sizeof(buf
), NULL
);
296 ok(err
==MCIERR_BAD_INTEGER
,"seek to 0:0:0:0:0 returned %s\n", dbg_mcierr(err
));
298 err
= mciSendStringA("seek x to 0:0:0:0:", buf
, sizeof(buf
), NULL
);
299 ok(err
==MCIERR_BAD_INTEGER
,"seek to 0:0:0:0: returned %s\n", dbg_mcierr(err
));
301 err
= mciSendStringA("seek x to :0:0:0:0", buf
, sizeof(buf
), NULL
);
302 ok(err
==MCIERR_BAD_INTEGER
,"seek to :0:0:0:0 returned %s\n", dbg_mcierr(err
));
304 err
= mciSendStringA("seek x to 256:0:0:0", buf
, sizeof(buf
), NULL
);
305 ok(err
==MCIERR_BAD_INTEGER
,"seek to 256:0:0:0 returned %s\n", dbg_mcierr(err
));
307 err
= mciSendStringA("seek x to 0:256", buf
, sizeof(buf
), NULL
);
308 ok(err
==MCIERR_BAD_INTEGER
,"seek to 0:256 returned %s\n", dbg_mcierr(err
));
310 err
= mciSendStringA("status all time format", buf
, sizeof(buf
), hwnd
);
311 ok(err
==MCIERR_CANNOT_USE_ALL
,"status all: %s\n", dbg_mcierr(err
));
313 err
= mciSendStringA("cue all", buf
, sizeof(buf
), NULL
);
314 ok(err
==MCIERR_UNRECOGNIZED_COMMAND
,"cue all: %s\n", dbg_mcierr(err
));
316 err
= mciSendStringA("open all", buf
, sizeof(buf
), NULL
);
317 todo_wine
ok(err
==MCIERR_CANNOT_USE_ALL
,"open all: %s\n", dbg_mcierr(err
));
319 /* avivideo is not a known MCI_DEVTYPE resource name */
320 err
= mciSendStringA("sysinfo avivideo quantity", buf
, sizeof(buf
), hwnd
);
321 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo sequencer quantity: %s\n", dbg_mcierr(err
));
323 err
= mciSendStringA("sysinfo digitalvideo quantity", buf
, sizeof(buf
), hwnd
);
324 ok(!err
,"sysinfo digitalvideo quantity: %s\n", dbg_mcierr(err
));
325 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo digitalvideo quantity returned %s\n", buf
);
327 /* quantity 0 yet open 1 (via type "avivideo"), fun */
328 err
= mciSendStringA("sysinfo digitalvideo quantity open", buf
, sizeof(buf
), hwnd
);
329 ok(!err
,"sysinfo digitalvideo quantity open: %s\n", dbg_mcierr(err
));
330 if(!err
) ok(!strcmp(buf
,"1"), "sysinfo digitalvideo quantity open returned %s\n", buf
);
332 err
= mciSendStringA("put a window at 0 0", buf
, sizeof(buf
), NULL
);
333 ok(err
==MCIERR_BAD_INTEGER
,"put incomplete rect: %s\n", dbg_mcierr(err
));
335 /*w9X-w2k report code from device last opened, newer versions compare them all
336 * and return the one error code or MCIERR_MULTIPLE if they differ. */
337 err
= mciSendStringA("pause all", buf
, sizeof(buf
), NULL
);
338 todo_wine
ok(err
==MCIERR_MULTIPLE
|| broken(err
==MCIERR_NONAPPLICABLE_FUNCTION
),"pause all: %s\n", dbg_mcierr(err
));
339 ok(!buf
[0], "pause error buffer %s\n", buf
);
341 /* MCI_STATUS' dwReturn is a DWORD_PTR, others' a plain DWORD. */
342 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
343 parm
.status
.dwReturn
= 0xFEEDABAD;
344 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
345 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
346 if(!err
) ok(MCI_FORMAT_MILLISECONDS
==parm
.status
.dwReturn
,"status time format: %Id\n",parm
.status
.dwReturn
);
348 parm
.status
.dwItem
= MCI_STATUS_MODE
;
349 parm
.status
.dwReturn
= 0xFEEDABAD;
350 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
351 ok(!err
,"mciCommand status mode: %s\n", dbg_mcierr(err
));
352 if(!err
) ok(MCI_MODE_STOP
==parm
.status
.dwReturn
,"STATUS mode: %Id\n",parm
.status
.dwReturn
);
354 err
= mciSendStringA("status x mode", buf
, sizeof(buf
), hwnd
);
355 ok(!err
,"status mode: %s\n", dbg_mcierr(err
));
356 if(!err
) ok(!strcmp(buf
, "stopped"), "status mode is %s\n", buf
);
358 parm
.caps
.dwItem
= MCI_GETDEVCAPS_USES_FILES
;
359 parm
.caps
.dwReturn
= 0xFEEDABAD;
360 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
361 ok(!err
,"mciCommand getdevcaps files: %s\n", dbg_mcierr(err
));
362 if(!err
) ok(1==parm
.caps
.dwReturn
,"getdevcaps files: %ld\n",parm
.caps
.dwReturn
);
364 parm
.caps
.dwItem
= MCI_GETDEVCAPS_HAS_VIDEO
;
365 parm
.caps
.dwReturn
= 0xFEEDABAD;
366 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
367 ok(!err
,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err
));
368 if(!err
) ok(0==parm
.caps
.dwReturn
,"getdevcaps video: %ld\n",parm
.caps
.dwReturn
);
370 parm
.caps
.dwItem
= MCI_GETDEVCAPS_DEVICE_TYPE
;
371 parm
.caps
.dwReturn
= 0xFEEDABAD;
372 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
373 ok(!err
,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err
));
374 if(!err
) ok(MCI_DEVTYPE_WAVEFORM_AUDIO
==parm
.caps
.dwReturn
,"getdevcaps device type: %ld\n",parm
.caps
.dwReturn
);
376 err
= mciSendStringA("capability x uses files", buf
, sizeof(buf
), hwnd
);
377 ok(!err
,"capability files: %s\n", dbg_mcierr(err
));
378 if(!err
) ok(!strcmp(buf
, "true"), "capability files is %s\n", buf
);
380 err
= mciSendStringA("capability x has video", buf
, sizeof(buf
), hwnd
);
381 ok(!err
,"capability video: %s\n", dbg_mcierr(err
));
382 if(!err
) ok(!strcmp(buf
, "false"), "capability video is %s\n", buf
);
384 err
= mciSendStringA("capability x device type", buf
, sizeof(buf
), hwnd
);
385 ok(!err
,"capability device type: %s\n", dbg_mcierr(err
));
386 if(!err
) ok(!strcmp(buf
, "waveaudio"), "capability device type is %s\n", buf
);
388 err
= mciSendStringA("info a version", buf
, sizeof(buf
), hwnd
);
389 ok(!err
,"info version: %s\n", dbg_mcierr(err
));
390 if(!err
) ok(!strcmp(buf
, "1.1"), "info version is %s\n", buf
);
392 err
= mciSendCommandA(wDeviceID
, MCI_CLOSE
, 0, 0);
393 ok(!err
,"mciCommand close returned %s\n", dbg_mcierr(err
));
395 err
= mciSendStringA("close a", buf
, sizeof(buf
), hwnd
);
396 ok(!err
,"close avi: %s\n", dbg_mcierr(err
));
398 test_notification(hwnd
, "-end of 1st set-", 0);
401 static void test_openCloseWAVE(HWND hwnd
)
404 MCI_PARMS_UNION parm
;
405 const char command_open
[] = "open new type waveaudio alias mysound notify";
406 const char command_close_my
[] = "close mysound notify";
407 const char command_close_all
[] = "close all notify";
408 const char command_sysinfo
[] = "sysinfo waveaudio quantity open";
410 DWORD intbuf
[3] = { 0xDEADF00D, 99, 0xABADCAFE };
411 memset(buf
, 0, sizeof(buf
));
412 test_notification(hwnd
, "-prior to any command-", 0);
414 /* Avoid Sysinfo quantity with notify because Win9x and newer differ. */
415 err
= mciSendStringA("sysinfo all quantity", buf
, sizeof(buf
), hwnd
);
416 ok(!err
,"mci sysinfo all quantity returned %s\n", dbg_mcierr(err
));
417 if(!err
) trace("[MCI] with %s drivers\n", buf
);
419 parm
.sys
.lpstrReturn
= (LPSTR
)&intbuf
[1];
420 parm
.sys
.dwRetSize
= sizeof(DWORD
);
421 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
422 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
| MCI_WAIT
,
424 ok(!err
, "mciCommand sysinfo all quantity returned %s\n", dbg_mcierr(err
));
425 if(!err
) ok(atoi(buf
)==intbuf
[1],"sysinfo all quantity string and command differ\n");
427 parm
.sys
.dwRetSize
= sizeof(DWORD
)-1;
428 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
, (DWORD_PTR
)&parm
);
429 ok(err
== MCIERR_PARAM_OVERFLOW
|| broken(!err
/* Win9x */),
430 "mciCommand sysinfo with too small buffer returned %s\n", dbg_mcierr(err
));
432 err
= mciSendStringA("open new type waveaudio alias r shareable", buf
, sizeof(buf
), NULL
);
433 ok(err
==MCIERR_UNSUPPORTED_FUNCTION
,"mci open new shareable returned %s\n", dbg_mcierr(err
));
435 err
= mciSendStringA("close r", NULL
, 0, NULL
);
436 ok(!err
,"mci close shareable returned %s\n", dbg_mcierr(err
));
439 err
= mciGetDeviceIDA("waveaudio");
440 ok(!err
, "mciGetDeviceIDA waveaudio returned %lu, expected 0\n", err
);
442 err
= mciSendStringA(command_open
, buf
, sizeof(buf
), hwnd
);
443 ok(!err
,"mci %s returned %s\n", command_open
, dbg_mcierr(err
));
444 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
445 /* Wine<=1.1.33 used to ignore anything past alias XY */
446 test_notification(hwnd
,"open new alias notify",MCI_NOTIFY_SUCCESSFUL
);
448 err
= mciSendStringA("status mysound time format", buf
, sizeof(buf
), hwnd
);
449 ok(!err
,"mci status time format returned %s\n", dbg_mcierr(err
));
451 if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) == LANG_ENGLISH
)
452 ok(!strcmp(buf
,"milliseconds"), "mci status time format: %s\n", buf
);
453 else trace("locale-dependent time format: %s (ms)\n", buf
);
456 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
= sizeof(buf
);
461 parm
.sys
.dwCallback
= (DWORD_PTR
)hwnd
;
462 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
,
463 MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
464 ok(!err
,"mciCommand MCI_SYSINFO all name 1 open notify: %s\n", dbg_mcierr(err
));
465 if(!err
) ok(!strcmp(buf
,"mysound"), "sysinfo name returned %s\n", buf
);
466 test_notification(hwnd
, "SYSINFO name notify\n", MCI_NOTIFY_SUCCESSFUL
);
468 memset(buf
, 0, sizeof(buf
));
469 parm
.sys
.dwNumber
= 1;
470 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
471 parm
.sys
.lpstrReturn
= buf
;
472 parm
.sys
.dwRetSize
= 8; /* mysound\0 */
473 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
,
475 ok(!err
,"mciCommand MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err
));
476 if(!err
) ok(!strcmp(buf
,"mysound"), "sysinfo name returned %s\n", buf
);
478 memset(buf
, 0, sizeof(buf
));
479 /* dwRetSize counts characters, not bytes, despite what MSDN says. */
480 parm
.sys
.dwNumber
= 1;
481 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
482 parm
.sys
.lpstrReturn
= buf
;
483 parm
.sys
.dwRetSize
= 8; /* mysound\0 */
484 /* MCI_..._PARMSA and PARMSW share the same layout, use one for both tests. */
485 err
= mciSendCommandW(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
486 ok(!err
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err
));
487 if (!err
) ok(!lstrcmpW((LPWSTR
)buf
, L
"mysound"), "sysinfo name 1 open contents\n");
489 memset(buf
, 0, sizeof(buf
));
491 parm
.sys
.dwNumber
= 1;
492 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
493 parm
.sys
.lpstrReturn
= buf
;
494 parm
.sys
.dwRetSize
= 7; /* too short for mysound\0 */
495 err
= mciSendCommandW(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
496 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err
));
497 ok(!strcmp(buf
,"Y"), "output buffer %s\n", buf
);
499 /* Win9x overwrites the tiny buffer and returns success, newer versions signal overflow. */
500 memset(buf
, 0, sizeof(buf
));
502 parm
.sys
.dwNumber
= 1;
503 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
504 parm
.sys
.lpstrReturn
= buf
;
505 parm
.sys
.dwRetSize
= 2; /* too short for mysound\0 */
506 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
,
508 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(!err
/* Win9x */),"mciCommand MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err
));
509 ok(!strcmp(buf
, err
? "Y" : "mysound"), "sysinfo short name returned %s\n", buf
);
511 err
= mciSendStringA("sysinfo mysound quantity open", buf
, sizeof(buf
), hwnd
);
512 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo alias quantity: %s\n", dbg_mcierr(err
));
514 err
= mciSendStringA("sysinfo nosuchalias quantity open", buf
, sizeof(buf
), hwnd
);
515 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo unknown quantity open: %s\n", dbg_mcierr(err
));
517 err
= mciSendStringA("sysinfo all installname", buf
, sizeof(buf
), hwnd
);
518 ok(err
==MCIERR_CANNOT_USE_ALL
,"sysinfo all installname: %s\n", dbg_mcierr(err
));
520 buf
[0] = 'M'; buf
[1] = 0;
521 parm
.sys
.lpstrReturn
= buf
;
522 parm
.sys
.dwRetSize
= sizeof(buf
);
523 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_INSTALLNAME
, (DWORD_PTR
)&parm
);
524 ok(err
==MCIERR_CANNOT_USE_ALL
,"mciCommand MCI_SYSINFO all installname: %s\n", dbg_mcierr(err
));
525 ok(!strcmp(buf
,"M"), "output buffer %s\n", buf
);
527 err
= mciSendStringA("sysinfo nodev installname", buf
, sizeof(buf
), hwnd
);
528 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"sysinfo nodev installname: %s\n", dbg_mcierr(err
));
529 ok(!buf
[0], "sysinfo error buffer %s\n", buf
);
532 parm
.sys
.lpstrReturn
= buf
;
533 parm
.sys
.dwRetSize
= sizeof(buf
);
534 err
= mciSendCommandW(24000, MCI_SYSINFO
, MCI_SYSINFO_INSTALLNAME
, (DWORD_PTR
)&parm
);
535 ok(err
==MCIERR_INVALID_DEVICE_NAME
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommand MCI_SYSINFO nodev installname: %s\n", dbg_mcierr(err
));
536 ok(!strcmp(buf
,"K"), "output buffer %s\n", buf
);
538 buf
[0] = 0; buf
[1] = 'A'; buf
[2] = 'j'; buf
[3] = 0;
539 parm
.info
.lpstrReturn
= buf
;
540 parm
.info
.dwRetSize
= 2;
541 err
= mciSendCommandA(1, MCI_INFO
, MCI_INFO_PRODUCT
, (DWORD_PTR
)&parm
);
542 ok(!err
, "mciCommand MCI_INFO product: %s\n", dbg_mcierr(err
));
543 ok(buf
[0] /* && !buf[1] */ && (buf
[2] == 'j' || broken(!buf
[2])), "info product output buffer %s\n", buf
);
544 /* Producing non-ASCII multi-byte output, native forgets to zero-terminate a too small buffer
545 * with SendStringA, while SendStringW works correctly (jap. and chin. locale): ignore buf[1] */
546 /* Bug in 64 bit Vista/w2k8/w7: mciSendStringW is used! (not in xp nor w2k3) */
548 buf
[0] = 'K'; buf
[1] = 0;
549 parm
.info
.dwRetSize
= sizeof(buf
);
550 err
= mciSendCommandW(1, MCI_INFO
, 0x07000000, (DWORD_PTR
)&parm
);
551 ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommand MCI_INFO other: %s\n", dbg_mcierr(err
));
552 ok(!strcmp(buf
,"K"), "info output buffer %s\n", buf
);
554 err
= mciGetDeviceIDA("all");
555 ok(err
== MCI_ALL_DEVICE_ID
, "mciGetDeviceIDA all returned %lu, expected MCI_ALL_DEVICE_ID\n", err
);
557 err
= mciSendStringA(command_close_my
, NULL
, 0, hwnd
);
558 ok(!err
,"mci %s returned %s\n", command_close_my
, dbg_mcierr(err
));
559 test_notification(hwnd
, command_close_my
, MCI_NOTIFY_SUCCESSFUL
);
561 test_notification(hwnd
, command_close_my
, 0);
563 err
= mciSendStringA("open no-such-file-exists.wav alias y buffer 6", buf
, sizeof(buf
), NULL
);
564 ok(err
==MCIERR_FILE_NOT_FOUND
,"open no-such-file.wav returned %s\n", dbg_mcierr(err
));
566 err
= mciSendStringA("close y", NULL
, 0, NULL
);
567 ok(!err
,"close y returned %s\n", dbg_mcierr(err
));
570 err
= mciSendStringA("open no-such-dir\\file.wav alias y type waveaudio", buf
, sizeof(buf
), NULL
);
571 ok(err
==MCIERR_FILE_NOT_FOUND
|| broken(err
==MCIERR_INVALID_FILE
/* Win9X */),"open no-such-dir/file.wav returned %s\n", dbg_mcierr(err
));
573 err
= mciSendStringA("close y", NULL
, 0, NULL
);
574 ok(!err
,"close y returned %s\n", dbg_mcierr(err
));
577 err
= mciSendStringA("open ! alias no", buf
, sizeof(buf
), NULL
);
578 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"open !(void): %s\n", dbg_mcierr(err
));
580 err
= mciSendStringA("open !no-such-file-exists.wav alias no", buf
, sizeof(buf
), NULL
);
581 ok(err
==MCIERR_FILE_NOT_FOUND
|| /* Win9X */err
==MCIERR_INVALID_DEVICE_NAME
,"open !name: %s\n", dbg_mcierr(err
));
583 /* FILE_NOT_FOUND stems from mciwave,
584 * the complete name including ! is passed through since NT */
585 err
= mciSendStringA("open nosuchdevice!tempfile.wav alias no", buf
, sizeof(buf
), NULL
);
586 ok(err
==MCIERR_FILE_NOT_FOUND
|| /* Win9X */err
==MCIERR_INVALID_DEVICE_NAME
,"open nosuchdevice!name: %s\n", dbg_mcierr(err
));
587 /* FIXME? use broken(INVALID_DEVICE_NAME) and have Wine not mimic Win9X? */
589 err
= mciSendStringA("close waveaudio", buf
, sizeof(buf
), NULL
);
590 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"close waveaudio: %s\n", dbg_mcierr(err
));
592 err
= mciSendStringA(command_close_all
, NULL
, 0, NULL
);
593 ok(!err
,"mci %s (without buffer) returned %s\n", command_close_all
, dbg_mcierr(err
));
595 err
= mciSendStringA(command_close_all
, buf
, sizeof(buf
), hwnd
);
596 ok(!err
,"mci %s (with output buffer) returned %s\n", command_close_all
, dbg_mcierr(err
));
597 ok(buf
[0] == 0, "mci %s output buffer: %s\n", command_close_all
, buf
);
598 /* No notification left, everything closed already */
599 test_notification(hwnd
, command_close_all
, 0);
600 /* TODO test close all sends one notification per open device */
602 err
= mciSendStringA(command_sysinfo
, buf
, sizeof(buf
), NULL
);
603 ok(!err
,"mci %s returned %s\n", command_sysinfo
, dbg_mcierr(err
));
604 ok(buf
[0] == '0' && buf
[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo
, buf
);
606 err
= mciSendStringA("open new type waveaudio", buf
, sizeof(buf
), NULL
);
607 ok(err
==MCIERR_NEW_REQUIRES_ALIAS
,"mci open new without alias returned %s\n", dbg_mcierr(err
));
609 parm
.open
.lpstrDeviceType
= (LPSTR
)MCI_DEVTYPE_WAVEFORM_AUDIO
;
610 err
= mciSendCommandA(0, MCI_OPEN
, MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
, (DWORD_PTR
)&parm
);
611 ok(!err
,"mciCommand OPEN_TYPE_ID waveaudio: %s\n", dbg_mcierr(err
));
614 MCIDEVICEID wDeviceID
= parm
.open
.wDeviceID
;
615 parm
.caps
.dwItem
= MCI_GETDEVCAPS_DEVICE_TYPE
;
616 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
617 ok(!err
,"mciCommand MCI_GETDEVCAPS device type: %s\n", dbg_mcierr(err
));
618 ok(MCI_DEVTYPE_WAVEFORM_AUDIO
==parm
.caps
.dwReturn
,"mciCommand GETDEVCAPS says %lu, expected %u\n", parm
.caps
.dwReturn
, MCI_DEVTYPE_WAVEFORM_AUDIO
);
621 ok(0xDEADF00D==intbuf
[0] && 0xABADCAFE==intbuf
[2],"DWORD buffer corruption\n");
623 err
= mciGetDeviceIDA("waveaudio");
624 ok(err
== 1, "mciGetDeviceIDA waveaudio returned %lu, expected 1\n", err
);
626 err
= mciSendStringA("open no-such-file.wav alias waveaudio", buf
, sizeof(buf
), NULL
);
627 ok(err
==MCIERR_DUPLICATE_ALIAS
, "mci open alias waveaudio returned %s\n", dbg_mcierr(err
));
628 /* If it were not already in use, open avivideo alias waveaudio would succeed,
629 * making for funny test cases. */
631 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_WAIT
, 0); /* from MSDN */
632 ok(!err
, "mciCommand close returned %s\n", dbg_mcierr(err
));
634 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_NOTIFY
, 0);
635 ok(!err
, "mciCommand close returned %s\n", dbg_mcierr(err
));
637 parm
.gen
.dwCallback
= (DWORD_PTR
)hwnd
;
638 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_NOTIFY
, (DWORD_PTR
)&parm
);
639 ok(!err
, "mciCommand close returned %s\n", dbg_mcierr(err
));
640 test_notification(hwnd
, command_close_all
, 0); /* None left */
643 static void test_recordWAVE(HWND hwnd
)
647 DWORD nsamp
= 16000, expect
;
648 UINT ndevs
= waveInGetNumDevs();
649 MCIERROR err
, ok_pcm
;
650 MCIDEVICEID wDeviceID
;
651 MCI_PARMS_UNION parm
;
653 memset(buf
, 0, sizeof(buf
));
654 test_notification(hwnd
, "-prior to recording-", 0);
656 parm
.open
.lpstrDeviceType
= "waveaudio";
657 parm
.open
.lpstrElementName
= ""; /* "new" at the command level */
658 parm
.open
.lpstrAlias
= "x"; /* to enable mciSendStringA */
659 parm
.open
.dwCallback
= (DWORD_PTR
)hwnd
;
660 err
= mciSendCommandA(0, MCI_OPEN
,
661 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| MCI_OPEN_ALIAS
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
662 ok(!err
,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err
));
663 wDeviceID
= parm
.open
.wDeviceID
;
665 err
= mciGetDeviceIDA("x");
666 ok(err
== wDeviceID
, "mciGetDeviceIDA x returned %lu, expected %u\n", err
, wDeviceID
);
668 /* Only the alias is looked up. */
669 err
= mciGetDeviceIDA("waveaudio");
670 ok(!err
, "mciGetDeviceIDA waveaudio returned %lu, expected 0\n", err
);
672 test_notification(hwnd
, "open new", MCI_NOTIFY_SUCCESSFUL
);
673 test_notification(hwnd
, "open new no #2", 0);
675 /* Do not query time format as string because result depends on locale! */
676 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
677 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
678 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
679 ok(parm
.status
.dwReturn
==MCI_FORMAT_MILLISECONDS
,"status time format: %Id\n",parm
.status
.dwReturn
);
681 /* Info file fails until named in Open or Save. */
682 err
= mciSendStringA("info x file", buf
, sizeof(buf
), NULL
);
683 todo_wine
ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci info new file returned %s\n", dbg_mcierr(err
));
684 ok(!buf
[0], "info error buffer %s\n", buf
);
686 err
= mciSendStringA("status x length", buf
, sizeof(buf
), NULL
);
687 todo_wine
ok(!err
,"status x length initial: %s\n", dbg_mcierr(err
));
688 if(!err
) ok(!strcmp(buf
,"0"), "mci status length expected 0, got: %s\n", buf
);
690 /* Check the default recording: 8-bits per sample, mono, 11kHz */
691 err
= mciSendStringA("status x samplespersec", buf
, sizeof(buf
), NULL
);
692 ok(!err
,"mci status samplespersec returned %s\n", dbg_mcierr(err
));
693 if(!err
) ok(!strcmp(buf
,"11025"), "mci status samplespersec expected 11025, got: %s\n", buf
);
695 /* MCI appears to scan the available devices for support of this format,
696 * returning MCIERR_OUTOFRANGE on machines with no sound.
697 * However some w2k8/w7 machines return no error when there's no wave
698 * input device (perhaps querying waveOutGetNumDevs instead of waveIn?),
699 * still the record command below fails with MCIERR_WAVE_INPUTSUNSUITABLE.
700 * Don't skip here, record will fail below. */
701 err
= mciSendStringA("set x format tag pcm", NULL
, 0, NULL
);
702 ok(!err
|| err
==MCIERR_OUTOFRANGE
,"mci set format tag pcm returned %s\n", dbg_mcierr(err
));
705 /* MSDN warns against not setting all wave format parameters.
706 * Indeed, it produces strange results, incl.
707 * inconsistent PCMWAVEFORMAT headers in the saved file.
709 err
= mciSendStringA("set x bytespersec 22050 alignment 2 samplespersec 11025 channels 1 bitspersample 16", NULL
, 0, NULL
);
710 ok(err
==ok_pcm
,"mci set 5 wave parameters returned %s\n", dbg_mcierr(err
));
711 /* Investigate: on w2k, set samplespersec 22050 sets nChannels to 2!
712 * err = mciSendStringA("set x samplespersec 22050", NULL, 0, NULL);
713 * ok(!err,"mci set samplespersec returned %s\n", dbg_mcierr(err));
716 /* Checks are generally performed immediately. */
717 err
= mciSendStringA("set x bitspersample 4", NULL
, 0, NULL
);
718 todo_wine
ok(err
==MCIERR_OUTOFRANGE
,"mci set bitspersample 4 returned %s\n", dbg_mcierr(err
));
720 parm
.set
.wFormatTag
= WAVE_FORMAT_PCM
;
721 parm
.set
.nSamplesPerSec
= nsamp
;
722 parm
.set
.wBitsPerSample
= nbits
;
723 parm
.set
.nChannels
= nch
;
724 parm
.set
.nBlockAlign
= parm
.set
.nChannels
* parm
.set
.wBitsPerSample
/8;
725 parm
.set
.nAvgBytesPerSec
= parm
.set
.nSamplesPerSec
* parm
.set
.nBlockAlign
;
726 err
= mciSendCommandA(wDeviceID
, MCI_SET
,
727 MCI_WAVE_SET_SAMPLESPERSEC
| MCI_WAVE_SET_CHANNELS
| MCI_WAVE_SET_BITSPERSAMPLE
|
728 MCI_WAVE_SET_BLOCKALIGN
| MCI_WAVE_SET_AVGBYTESPERSEC
| MCI_WAVE_SET_FORMATTAG
,
730 ok(err
==ok_pcm
,"mciCommand set wave format: %s\n", dbg_mcierr(err
));
732 parm
.caps
.dwItem
= MCI_WAVE_GETDEVCAPS_INPUTS
;
733 parm
.caps
.dwCallback
= (DWORD_PTR
)hwnd
;
734 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
| MCI_NOTIFY
,
736 ok(!err
,"mciCommand MCI_GETDEVCAPS inputs: %s\n", dbg_mcierr(err
));
737 ok(parm
.caps
.dwReturn
==ndevs
,"mciCommand GETDEVCAPS claims %lu inputs, expected %u\n", parm
.caps
.dwReturn
, ndevs
);
738 ok(!ok_pcm
|| !parm
.caps
.dwReturn
,"No input device accepts PCM!?\n");
739 test_notification(hwnd
, "GETDEVCAPS inputs", MCI_NOTIFY_SUCCESSFUL
);
741 /* A few ME machines pass all tests except set format tag pcm! */
742 err
= mciSendStringA("record x to 2000 wait", NULL
, 0, hwnd
);
743 ok(err
|| !ok_pcm
,"can record yet set wave format pcm returned %s\n", dbg_mcierr(ok_pcm
));
744 todo_wine_if (!ndevs
) /* with sound disabled */
745 ok(ndevs
> 0 ? !err
: err
== MCIERR_WAVE_INPUTSUNSUITABLE
, "mci record to 2000 returned %s\n", dbg_mcierr(err
));
747 if (err
==MCIERR_WAVE_INPUTSUNSUITABLE
)
748 skip("Please install audio driver. Everything is skipped.\n");
749 else skip("Cannot record cause %s. Everything is skipped.\n", dbg_mcierr(err
));
751 err
= mciSendStringA("close x", NULL
, 0, NULL
);
752 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
753 test_notification(hwnd
,"record skipped",0);
757 /* Query some wave format parameters depending on the time format. */
758 err
= mciSendStringA("status x position", buf
, sizeof(buf
), NULL
);
759 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
760 if(!err
) todo_wine
ok(!strcmp(buf
,"2000"), "mci status position gave %s, expected 2000, some tests will fail\n", buf
);
762 err
= mciSendStringA("set x time format 8", NULL
, 0, NULL
); /* bytes */
763 ok(!err
,"mci returned %s\n", dbg_mcierr(err
));
765 parm
.status
.dwItem
= MCI_STATUS_POSITION
;
766 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
767 ok(!err
,"mciCommand status position: %s\n", dbg_mcierr(err
));
768 expect
= 2 * nsamp
* nch
* nbits
/8;
769 if(!err
) todo_wine
ok(parm
.status
.dwReturn
==expect
,"recorded %Iu bytes, expected %lu\n",parm
.status
.dwReturn
,expect
);
771 parm
.set
.dwTimeFormat
= MCI_FORMAT_SAMPLES
;
772 err
= mciSendCommandA(wDeviceID
, MCI_SET
, MCI_SET_TIME_FORMAT
, (DWORD_PTR
)&parm
);
773 ok(!err
,"mciCommand set time format samples: %s\n", dbg_mcierr(err
));
775 parm
.status
.dwItem
= MCI_STATUS_POSITION
;
776 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
777 ok(!err
,"mciCommand status position: %s\n", dbg_mcierr(err
));
779 if(!err
) todo_wine
ok(parm
.status
.dwReturn
==expect
,"recorded %Iu samples, expected %lu\n",parm
.status
.dwReturn
,expect
);
781 err
= mciSendStringA("set x time format milliseconds", NULL
, 0, NULL
);
782 ok(!err
,"mci set time format milliseconds returned %s\n", dbg_mcierr(err
));
784 err
= mciSendStringA("save x tempfile1.wav", NULL
, 0, NULL
);
785 ok(!err
,"mci save returned %s\n", dbg_mcierr(err
));
787 err
= mciSendStringA("save x tempfile.wav", NULL
, 0, NULL
);
788 ok(!err
,"mci save returned %s\n", dbg_mcierr(err
));
789 if(!err
) ok_saved
= 0;
791 /* Save must not rename the original file. */
792 if (!DeleteFileA("tempfile1.wav"))
793 todo_wine
ok(FALSE
, "Save must not rename the original file; DeleteFileA returned %ld\n",
796 err
= mciSendStringA("set x channels 2", NULL
, 0, NULL
);
797 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci set channels after saving returned %s\n", dbg_mcierr(err
));
799 parm
.seek
.dwTo
= 600;
800 err
= mciSendCommandA(wDeviceID
, MCI_SEEK
, MCI_TO
| MCI_WAIT
, (DWORD_PTR
)&parm
);
801 ok(!err
,"mciCommand seek to 600: %s\n", dbg_mcierr(err
));
803 /* Truncate to current position */
804 err
= mciSendStringA("delete x", NULL
, 0, NULL
);
805 todo_wine
ok(!err
,"mci delete returned %s\n", dbg_mcierr(err
));
807 err
= mciSendStringA("status x length", buf
, sizeof(buf
), NULL
);
808 ok(!err
,"mci status length returned %s\n", dbg_mcierr(err
));
809 todo_wine
ok(!strcmp(buf
,"600"), "mci status length after delete gave %s, expected 600\n", buf
);
811 err
= mciSendStringA("close x", NULL
, 0, NULL
);
812 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
813 test_notification(hwnd
,"record complete",0);
816 static void test_playWAVE(HWND hwnd
)
820 memset(buf
, 0, sizeof(buf
));
822 err
= mciSendStringA("open waveaudio!tempfile.wav alias mysound", NULL
, 0, NULL
);
823 ok(err
==ok_saved
,"mci open waveaudio!tempfile.wav returned %s\n", dbg_mcierr(err
));
825 skip("Cannot open waveaudio!tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
829 err
= mciGetDeviceIDA("mysound");
830 ok(err
== 1, "mciGetDeviceIDA mysound returned %lu, expected 1\n", err
);
832 err
= mciGetDeviceIDA("tempfile.wav");
833 ok(!err
, "mciGetDeviceIDA tempfile.wav returned %lu, expected 0\n", err
);
835 err
= mciGetDeviceIDA("waveaudio");
836 ok(!err
, "mciGetDeviceIDA waveaudio returned %lu, expected 0\n", err
);
838 err
= mciSendStringA("status mysound length", buf
, sizeof(buf
), NULL
);
839 ok(!err
,"mci status length returned %s\n", dbg_mcierr(err
));
840 todo_wine
ok(!strcmp(buf
,"2000"), "mci status length gave %s, expected 2000, some tests will fail.\n", buf
);
842 err
= mciSendStringA("cue output", NULL
, 0, NULL
);
843 ok(err
==MCIERR_UNRECOGNIZED_COMMAND
,"mci incorrect cue output returned %s\n", dbg_mcierr(err
));
845 /* Test MCI to the bones -- Some todo_wine from Cue and
846 * from Play from 0 to 0 are not worth fixing. */
847 err
= mciSendStringA("cue mysound output notify", NULL
, 0, hwnd
);
848 ok(!err
,"mci cue output after open file returned %s\n", dbg_mcierr(err
));
849 /* Notification is delayed as a play thread is started. */
850 todo_wine
test_notification(hwnd
, "cue immediate", 0);
852 /* Cue pretends to put the MCI into paused state. */
853 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
854 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
855 todo_wine
ok(!strcmp(buf
,"paused"), "mci status mode: %s, expected (pseudo)paused\n", buf
);
857 /* Strange pause where Pause is rejected, unlike Play; Pause; Pause tested below */
858 err
= mciSendStringA("pause mysound", NULL
, 0, hwnd
);
859 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci pause after cue returned %s\n", dbg_mcierr(err
));
861 /* MCI appears to start the play thread in this border case.
862 * Guessed that from (flaky) status mode and late notification arrival. */
863 err
= mciSendStringA("play mysound from 0 to 0 notify", NULL
, 0, hwnd
);
864 ok(!err
,"mci play from 0 to 0 returned %s\n", dbg_mcierr(err
));
865 todo_wine
test_notification(hwnd
, "cue aborted by play", MCI_NOTIFY_ABORTED
);
866 /* play's own notification follows below */
868 err
= mciSendStringA("play mysound from 250 to 0", NULL
, 0, NULL
);
869 ok(err
==MCIERR_OUTOFRANGE
,"mci play from 250 to 0 returned %s\n", dbg_mcierr(err
));
871 Sleep(100); /* Give play from 0 to 0 time to finish. */
872 todo_wine
test_notification(hwnd
, "play from 0 to 0", MCI_NOTIFY_SUCCESSFUL
);
874 err
= mciSendStringA("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 after play from 0 to 0\n", buf
);
878 err
= mciSendStringA("play MYSOUND from 250 to 0 notify", NULL
, 0, hwnd
);
879 ok(err
==MCIERR_OUTOFRANGE
,"mci play from 250 to 0 notify returned %s\n", dbg_mcierr(err
));
880 /* No notification (checked below) sent if error */
882 /* A second play caused Wine<1.1.33 to hang */
883 err
= mciSendStringA("play mysound from 500 to 220:5:0 wait", NULL
, 0, NULL
);
884 ok(!err
,"mci play from 500 to 220:5:0 (=1500) returned %s\n", dbg_mcierr(err
));
886 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
887 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
888 if(!err
) ok(!strcmp(buf
,"1500"), "mci status position: %s\n", buf
);
890 /* mci will not play position < current */
891 err
= mciSendStringA("play mysound to 1000", NULL
, 0, NULL
);
892 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 1000 returned %s\n", dbg_mcierr(err
));
894 /* mci will not play to > end */
895 err
= mciSendStringA("play mysound TO 3000 notify", NULL
, 0, hwnd
);
896 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 3000 notify returned %s\n", dbg_mcierr(err
));
898 err
= mciSendStringA("play mysound to 2000", NULL
, 0, NULL
);
899 ok(!err
,"mci play to 2000 returned %s\n", dbg_mcierr(err
));
901 /* Rejected while playing */
902 err
= mciSendStringA("cue mysound output", NULL
, 0, NULL
);
903 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci cue output while playing returned %s\n", dbg_mcierr(err
));
905 err
= mciSendStringA("play mysound to 3000", NULL
, 0, NULL
);
906 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 3000 returned %s\n", dbg_mcierr(err
));
908 err
= mciSendStringA("stop mysound Wait", NULL
, 0, NULL
);
909 ok(!err
,"mci stop wait returned %s\n", dbg_mcierr(err
));
910 test_notification(hwnd
, "play/cue/pause/stop", 0);
912 err
= mciSendStringA("Seek Mysound to 250 wait Notify", NULL
, 0, hwnd
);
913 ok(!err
,"mci seek to 250 wait notify returned %s\n", dbg_mcierr(err
));
914 test_notification(hwnd
,"seek wait notify",MCI_NOTIFY_SUCCESSFUL
);
916 err
= mciSendStringA("seek mysound to 0xfa", NULL
, 0, NULL
);
917 ok(err
==MCIERR_BAD_INTEGER
,"mci seek to 0xfa returned %s\n", dbg_mcierr(err
));
919 /* MCI_INTEGER always accepts colon notation */
920 err
= mciSendStringA("seek mysound to :1", NULL
, 0, NULL
);
921 ok(!err
,"mci seek to :1 (=256) returned %s\n", dbg_mcierr(err
));
923 err
= mciSendStringA("seek mysound to 250::", NULL
, 0, NULL
);
924 ok(!err
,"mci seek to 250:: returned %s\n", dbg_mcierr(err
));
926 err
= mciSendStringA("seek mysound to 250:0", NULL
, 0, NULL
);
927 ok(!err
,"mci seek to 250:0 returned %s\n", dbg_mcierr(err
));
929 err
= mciSendStringA("status mysound position notify", buf
, sizeof(buf
), hwnd
);
930 ok(!err
,"mci status position notify returned %s\n", dbg_mcierr(err
));
931 if(!err
) ok(!strcmp(buf
,"250"), "mci status position: %s\n", buf
);
932 /* Immediate commands like status also send notifications. */
933 test_notification(hwnd
,"status position",MCI_NOTIFY_SUCCESSFUL
);
935 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
936 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
937 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
939 /* Another play from == to testcase */
940 err
= mciSendStringA("play mysound to 250 wait notify", NULL
, 0, hwnd
);
941 ok(!err
,"mci play (from 250) to 250 returned %s\n", dbg_mcierr(err
));
942 todo_wine
test_notification(hwnd
,"play to 250 wait notify",MCI_NOTIFY_SUCCESSFUL
);
944 err
= mciSendStringA("cue mysound output", NULL
, 0, NULL
);
945 ok(!err
,"mci cue output after play returned %s\n", dbg_mcierr(err
));
947 err
= mciSendStringA("close mysound", NULL
, 0, NULL
);
948 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
949 test_notification(hwnd
,"after close",0);
952 static void test_asyncWAVE(HWND hwnd
)
954 MCIDEVICEID wDeviceID
;
955 MCI_PARMS_UNION parm
;
958 memset(buf
, 0, sizeof(buf
));
960 err
= mciSendStringA("open tempfile.wav alias mysound notify type waveaudio", buf
, sizeof(buf
), hwnd
);
961 ok(err
==ok_saved
,"mci open tempfile.wav returned %s\n", dbg_mcierr(err
));
963 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
966 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
967 wDeviceID
= atoi(buf
);
968 ok(wDeviceID
,"mci open DeviceID: %d\n", wDeviceID
);
969 test_notification(hwnd
,"open alias notify",MCI_NOTIFY_SUCCESSFUL
);
971 err
= mciGetDeviceIDA("mysound");
972 ok(err
== wDeviceID
, "mciGetDeviceIDA alias returned %u, expected %u\n", err
, wDeviceID
);
974 /* Only the alias is looked up. */
975 err
= mciGetDeviceIDA("tempfile.wav");
976 ok(!err
, "mciGetDeviceIDA tempfile.wav returned %u, expected 0\n", err
);
978 err
= mciGetDeviceIDA("waveaudio");
979 ok(!err
, "mciGetDeviceIDA waveaudio returned %u, expected 0\n", err
);
981 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
982 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
983 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
985 err
= mciSendStringA("play mysound notify", NULL
, 0, hwnd
);
986 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
988 Sleep(500); /* milliseconds */
990 /* Do not query time format as string because result depends on locale! */
991 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
992 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
993 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
994 if(!err
) ok(parm
.status
.dwReturn
==MCI_FORMAT_MILLISECONDS
,"status time format: %Id\n",parm
.status
.dwReturn
);
996 parm
.set
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
997 err
= mciSendCommandA(wDeviceID
, MCI_SET
, MCI_SET_TIME_FORMAT
, (DWORD_PTR
)&parm
);
998 ok(!err
,"mciCommand set time format ms: %s\n", dbg_mcierr(err
));
1000 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1001 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1002 trace("position after Sleep: %sms\n", buf
);
1004 /* Check that the 2s sound plays at a normal pace, giving a wide margin to
1005 * account for timing granularity and small delays.
1007 todo_wine
ok(350 <= p2
&& p2
<= 600, "%ums is not in the expected 350-600ms range\n", p2
);
1008 /* Wine's asynchronous thread needs some time to start up. Furthermore, it
1009 * uses 3 buffers per second, so that the positions reported will be 333ms,
1010 * 667ms etc. at best, which is why it fails the above test. So add a
1011 * second test specifically to prevent Wine from getting even worse.
1012 * FIXME: To be removed when Wine is fixed and passes the above test.
1014 ok(350 <= p2
&& p2
<= 1000, "%ums is not even in the expected 350-1000ms range\n", p2
);
1015 test_notification(hwnd
,"play (nowait)",0);
1017 err
= mciSendStringA("pause mysound wait", NULL
, 0, hwnd
);
1018 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1020 err
= mciSendStringA("status mysound mode notify", buf
, sizeof(buf
), hwnd
);
1021 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1022 if(!err
) ok(!strcmp(buf
,"paused"), "mci status mode: %s\n", buf
);
1023 test_notification(hwnd
,"play",MCI_NOTIFY_SUPERSEDED
);
1024 test_notification(hwnd
,"status",MCI_NOTIFY_SUCCESSFUL
);
1026 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1027 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1028 trace("position while paused: %sms\n",buf
);
1030 ok(p1
>=p2
, "position not increasing: %u > %u\n", p2
, p1
);
1032 err
= mciSendStringA("stop mysound wait", NULL
, 0, NULL
);
1033 ok(!err
,"mci stop returned %s\n", dbg_mcierr(err
));
1035 err
= mciSendStringA("info mysound file notify", buf
, sizeof(buf
), hwnd
);
1036 ok(!err
,"mci info file returned %s\n", dbg_mcierr(err
));
1037 if(!err
) { /* fully qualified name */
1038 int len
= strlen(buf
);
1039 todo_wine
ok(len
>2 && buf
[1]==':',"Expected full pathname from info file: %s\n", buf
);
1040 ok(len
>=12 && !strcmp(&buf
[len
-12],"tempfile.wav"), "info file returned: %s\n", buf
);
1042 test_notification(hwnd
,"info file",MCI_NOTIFY_SUCCESSFUL
);
1044 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
1045 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1046 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
1048 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1049 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1050 trace("position once stopped: %sms\n",buf
);
1052 /* An XP machine let the position increase slightly after pause. */
1053 ok(p2
>=p1
&& p2
<=p1
+16,"position changed from %ums to %ums\n",p1
,p2
);
1055 /* No Resume once stopped (waveaudio, sequencer and cdaudio differ). */
1056 err
= mciSendStringA("resume mysound wait", NULL
, 0, NULL
);
1057 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci resume wait returned %s\n", dbg_mcierr(err
));
1059 err
= mciSendStringA("play mysound wait", NULL
, 0, NULL
);
1060 ok(!err
,"mci play wait returned %s\n", dbg_mcierr(err
));
1062 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1063 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1064 todo_wine
ok(!strcmp(buf
,"2000"), "mci status position: %s\n", buf
);
1066 err
= mciSendStringA("seek mysound to start wait", NULL
, 0, NULL
);
1067 ok(!err
,"mci seek to start wait returned %s\n", dbg_mcierr(err
));
1069 err
= mciSendStringA("play mysound to 1000 notify", NULL
, 0, hwnd
);
1070 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1072 /* Sleep(200); not needed with Wine any more. */
1074 err
= mciSendStringA("pause mysound notify", NULL
, 0, NULL
); /* notify no callback */
1075 ok(!err
,"mci pause notify returned %s\n", dbg_mcierr(err
));
1076 /* Supersede even though pause cannot notify given no callback */
1077 test_notification(hwnd
,"pause aborted play #1 notification",MCI_NOTIFY_SUPERSEDED
);
1078 test_notification(hwnd
,"impossible pause notification",0);
1080 err
= mciSendStringA("cue mysound output notify", NULL
, 0, hwnd
);
1081 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci cue output while paused returned %s\n", dbg_mcierr(err
));
1082 test_notification(hwnd
,"cue output notify #2",0);
1084 err
= mciSendStringA("resume mysound notify", NULL
, 0, hwnd
);
1085 ok(!err
,"mci resume notify returned %s\n", dbg_mcierr(err
));
1086 test_notification(hwnd
, "resume notify", MCI_NOTIFY_SUCCESSFUL
);
1088 /* Seek or even Stop used to hang Wine<1.1.32 on MacOS. */
1089 err
= mciSendStringA("seek mysound to 0 wait", NULL
, 0, NULL
);
1090 ok(!err
,"mci seek to start returned %s\n", dbg_mcierr(err
));
1093 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1094 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1095 if(!err
) ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
1097 err
= mciSendStringA("seek mysound wait", NULL
, 0, NULL
);
1098 ok(err
==MCIERR_MISSING_PARAMETER
,"mci seek to nowhere returned %s\n", dbg_mcierr(err
));
1100 /* cdaudio does not detect to start to end as error */
1101 err
= mciSendStringA("seek mysound to start to 0", NULL
, 0, NULL
);
1102 ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"mci seek to start to 0 returned %s\n", dbg_mcierr(err
));
1104 err
= mciSendStringA("PLAY mysound to 1000 notify", NULL
, 0, hwnd
);
1105 ok(!err
,"mci play to 1000 notify returned %s\n", dbg_mcierr(err
));
1107 /* Sleep(200); not needed with Wine any more. */
1108 /* Give it 400ms and resume will appear to complete below. */
1110 err
= mciSendStringA("pause mysound wait", NULL
, 0, NULL
);
1111 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1112 /* Unlike sequencer and cdaudio, waveaudio's pause does not abort. */
1113 test_notification(hwnd
,"pause aborted play #2 notification",0);
1115 err
= mciSendStringA("resume mysound wait", NULL
, 0, NULL
);
1116 ok(!err
,"mci resume wait returned %s\n", dbg_mcierr(err
));
1117 /* Resume is a short asynchronous call, something else is playing. */
1119 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1120 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1121 if(!err
) ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1123 /* Note extra space before alias */
1124 err
= mciSendStringA("pause mysound wait", NULL
, 0, NULL
);
1125 todo_wine
ok(!err
,"mci pause (space) wait returned %s\n", dbg_mcierr(err
));
1127 err
= mciSendStringA("pause mysound wait", NULL
, 0, NULL
);
1128 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1130 /* Better ask position only when paused, is it updated while playing? */
1131 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), NULL
);
1132 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1133 /* TODO compare position < 900 */
1134 ok(strcmp(buf
,"1000"), "mci resume waited\n");
1135 ok(strcmp(buf
,"2000"), "mci resume played to end\n");
1136 trace("position after resume: %sms\n",buf
);
1137 test_notification(hwnd
,"play (aborted by pause/resume/pause)",0);
1139 /* A small Sleep() here prevents the notification test failing with MCI_NOTIFY_SUCCESSFUL */
1141 err
= mciSendStringA("close mysound wait", NULL
, 0, NULL
);
1142 ok(!err
,"mci close wait returned %s\n", dbg_mcierr(err
));
1143 test_notification(hwnd
,"play (aborted by close)",MCI_NOTIFY_ABORTED
);
1146 static void test_AutoOpenWAVE(HWND hwnd
)
1148 /* This test used(?) to cause intermittent crashes when Wine exits, after
1149 * fixme:winmm:MMDRV_Exit Closing while ll-driver open
1151 UINT ndevs
= waveOutGetNumDevs();
1152 MCIERROR err
, ok_snd
= ndevs
? 0 : MCIERR_HARDWARE
;
1153 MCI_PARMS_UNION parm
;
1154 char buf
[512], path
[300], command
[330];
1155 DWORD intbuf
[3] = { 0xDEADF00D, 99, 0xABADCAFE };
1156 memset(buf
, 0, sizeof(buf
)); memset(path
, 0, sizeof(path
));
1158 /* Do not crash on NULL buffer pointer */
1159 err
= mciSendStringA("sysinfo waveaudio quantity open", NULL
, 0, NULL
);
1160 ok(err
==MCIERR_PARAM_OVERFLOW
,"mci sysinfo without buffer returned %s\n", dbg_mcierr(err
));
1162 err
= mciSendStringA("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1163 ok(!err
,"mci sysinfo waveaudio quantity open returned %s\n", dbg_mcierr(err
));
1164 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf
);
1166 /* Who knows why some MS machines pass all tests but return MCIERR_HARDWARE here? */
1167 /* Wine returns MCIERR_HARDWARE when no default sound is found in win.ini or the registry. */
1168 err
= mciSendStringA("sound NoSuchSoundDefined wait", NULL
, 0, NULL
);
1169 ok(err
==ok_snd
|| err
==MCIERR_HARDWARE
, "mci sound NoSuchSoundDefined returned %s\n", dbg_mcierr(err
));
1171 err
= mciSendStringA("sound SystemExclamation notify wait", NULL
, 0, hwnd
);
1172 ok(err
==ok_snd
|| err
==MCIERR_HARDWARE
, "mci sound SystemExclamation returned %s\n", dbg_mcierr(err
));
1173 test_notification(hwnd
, "sound notify", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
1175 Sleep(16); /* time to auto-close makes sysinfo below return expected error */
1176 err
= mciSendStringA("sysinfo waveaudio notify name 1 open", buf
, sizeof(buf
), hwnd
);
1177 ok(err
==MCIERR_OUTOFRANGE
,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err
));
1178 if(!err
) trace("sysinfo dangling open alias: %s\n", buf
);
1179 test_notification(hwnd
, "sysinfo name outofrange\n", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
1181 err
= mciSendStringA("play no-such-file-exists.wav notify", buf
, sizeof(buf
), NULL
);
1182 todo_wine
ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open notify returned %s\n", dbg_mcierr(err
));
1183 /* FILE_NOT_FOUND in Wine because auto-open fails before testing the notify flag */
1185 test_notification(hwnd
, "-prior to auto-open-", 0);
1187 err
= mciSendStringA("play tempfile.wav notify", buf
, sizeof(buf
), hwnd
);
1188 todo_wine_if (ok_saved
== MCIERR_FILE_NOT_FOUND
) /* same as above */
1189 ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open play notify returned %s\n", dbg_mcierr(err
));
1191 if(err
) /* FIXME: don't open twice yet, it confuses Wine. */
1192 err
= mciSendStringA("play tempfile.wav", buf
, sizeof(buf
), hwnd
);
1193 ok(err
==ok_saved
,"mci auto-open play returned %s\n", dbg_mcierr(err
));
1195 if(err
==MCIERR_FILE_NOT_FOUND
) {
1196 skip("Cannot open tempfile.wav for auto-play, skipping\n");
1200 err
= mciSendStringA("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1201 ok(!err
,"mci sysinfo waveaudio quantity after auto-open returned %s\n", dbg_mcierr(err
));
1202 if(!err
) ok(!strcmp(buf
,"1"), "sysinfo quantity open expected 1, got: %s\n", buf
);
1204 parm
.sys
.lpstrReturn
= (LPSTR
)&intbuf
[1];
1205 parm
.sys
.dwRetSize
= 2*sizeof(DWORD
); /* only one DWORD is used */
1206 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
;
1207 err
= mciSendCommandA(0, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
1208 ok(!err
, "mciCommand sysinfo waveaudio open notify returned %s\n", dbg_mcierr(err
));
1209 if(!err
) ok(atoi(buf
)==intbuf
[1],"sysinfo waveaudio quantity open string and command differ\n");
1211 err
= mciSendStringA("sysinfo waveaudio name 1 open notify", buf
, sizeof(buf
), hwnd
);
1212 ok(!err
,"mci sysinfo waveaudio name after auto-open returned %s\n", dbg_mcierr(err
));
1213 /* This is the alias, not necessarily a file name. */
1214 if(!err
) ok(!strcmp(buf
,"tempfile.wav"), "sysinfo name 1 open: %s\n", buf
);
1215 test_notification(hwnd
, "sysinfo name notify\n", MCI_NOTIFY_SUCCESSFUL
);
1217 err
= mciGetDeviceIDA("tempfile.wav");
1218 ok(err
== 1, "mciGetDeviceIDA tempfile.wav returned %lu, expected 1\n", err
);
1220 /* Save the full pathname to the file. */
1221 err
= mciSendStringA("info tempfile.wav file", path
, sizeof(path
), NULL
);
1222 ok(!err
,"mci info tempfile.wav file returned %s\n", dbg_mcierr(err
));
1223 if(err
) strcpy(path
,"tempfile.wav");
1225 err
= mciSendStringA("status tempfile.wav mode", NULL
, 0, hwnd
);
1226 ok(!err
,"mci status tempfile.wav mode without buffer returned %s\n", dbg_mcierr(err
));
1228 sprintf(command
,"status \"%s\" mode",path
);
1229 err
= mciSendStringA(command
, buf
, sizeof(buf
), hwnd
);
1230 ok(!err
,"mci status \"%s\" mode returned %s\n", path
, dbg_mcierr(err
));
1232 err
= mciSendStringA("status tempfile.wav mode", buf
, sizeof(buf
), hwnd
);
1233 ok(!err
,"mci status tempfile.wav mode returned %s\n", dbg_mcierr(err
));
1234 if(!err
) ok(!strcmp(buf
,"playing"), "mci auto-open status mode, got: %s\n", buf
);
1236 err
= mciSendStringA("open tempfile.wav", buf
, sizeof(buf
), NULL
);
1237 ok(err
==MCIERR_DEVICE_OPEN
, "mci open from auto-open returned %s\n", dbg_mcierr(err
));
1239 err
= mciSendStringA("open foo.wav alias tempfile.wav", buf
, sizeof(buf
), NULL
);
1240 ok(err
==MCIERR_DUPLICATE_ALIAS
, "mci open re-using alias returned %s\n", dbg_mcierr(err
));
1242 /* w2k/xp and Wine differ. While the device is busy playing, it is
1243 * regularly open and accessible via the filename: subsequent
1244 * commands must not cause auto-open each. In Wine, a subsequent
1245 * command with notify request may cause the initial play
1246 * notification to be superseded, in turn causing MCI to close the
1247 * device. I.e. MCI uses the auto-open notification for itself,
1248 * that's why it's not available to the app. On w2k/xp,
1249 * subsequent commands with notify requests are returned with
1250 * MCIERR_NOTIFY_ON_AUTO_OPEN and thus don't abort the original
1253 err
= mciSendStringA("status tempfile.wav mode notify", buf
, sizeof(buf
), hwnd
);
1254 todo_wine
ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
, "mci status auto-open notify returned %s\n", dbg_mcierr(err
));
1256 trace("Wine style MCI auto-close upon notification\n");
1258 /* "playing" because auto-close comes after the status call. */
1259 ok(!strcmp(buf
,"playing"), "mci auto-open status mode notify, got: %s\n", buf
);
1260 /* fixme:winmm:MMDRV_Exit Closing while ll-driver open
1261 * is explained by failure to auto-close a device. */
1262 test_notification(hwnd
,"status notify",MCI_NOTIFY_SUCCESSFUL
);
1263 /* MCI received NOTIFY_SUPERSEDED and auto-closed the device. */
1265 /* Until this is implemented, force closing the device */
1266 err
= mciSendStringA("close tempfile.wav", NULL
, 0, hwnd
);
1267 ok(!err
,"mci auto-still-open stop returned %s\n", dbg_mcierr(err
));
1269 test_notification(hwnd
,"auto-open",0);
1270 } else if(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
) { /* MS style */
1271 trace("MS style MCI auto-open forbids notification\n");
1273 err
= mciSendStringA("pause tempfile.wav", NULL
, 0, hwnd
);
1274 ok(!err
,"mci auto-still-open pause returned %s\n", dbg_mcierr(err
));
1276 err
= mciSendStringA("status tempfile.wav mode", buf
, sizeof(buf
), hwnd
);
1277 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1278 if(!err
) ok(!strcmp(buf
,"paused"), "mci auto-open status mode, got: %s\n", buf
);
1281 err
= mciSendStringA("stop tempfile.wav wait", NULL
, 0, hwnd
);
1282 ok(!err
,"mci auto-still-open stop returned %s\n", dbg_mcierr(err
));
1283 Sleep(16); /* makes sysinfo quantity open below succeed */
1286 err
= mciSendStringA("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1287 ok(!err
,"mci sysinfo waveaudio quantity open after close returned %s\n", dbg_mcierr(err
));
1288 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo quantity open expected 0 after auto-close, got: %s\n", buf
);
1290 /* w95-WinME (not w2k/XP) switch to C:\ after auto-playing once. Prevent
1291 * MCIERR_FILE_NOT_FOUND by using the full path name from the Info file command.
1293 sprintf(command
,"status \"%s\" mode wait",path
);
1294 err
= mciSendStringA(command
, buf
, sizeof(buf
), hwnd
);
1295 ok(!err
,"mci re-auto-open status mode returned %s\n", dbg_mcierr(err
));
1296 if(!err
) ok(!strcmp(buf
,"stopped"), "mci re-auto-open status mode, got: %s\n", buf
);
1298 /* This uses auto-open as well. */
1299 err
= mciSendStringA("capability waveaudio outputs", buf
, sizeof(buf
), NULL
);
1300 ok(!err
,"mci capability waveaudio outputs returned %s\n", dbg_mcierr(err
));
1301 /* Wine with no sound selected in winecfg's audio tab fails this test. */
1302 if(!err
) ok(atoi(buf
)==ndevs
,"Expected %d audio outputs, got %s\n", ndevs
, buf
);
1304 err
= mciSendStringA("capability waveaudio device type", buf
, sizeof(buf
), hwnd
);
1305 ok(!err
,"mci capability device type returned %s\n", dbg_mcierr(err
));
1306 if(!err
) ok(!strcmp(buf
,"waveaudio"), "mci capability device type response: %s\n", buf
);
1308 /* waveaudio forbids Pause without Play. */
1309 sprintf(command
,"pause \"%s\"",path
);
1310 err
= mciSendStringA(command
, NULL
, 0, hwnd
);
1311 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci auto-open pause returned %s\n", dbg_mcierr(err
));
1313 ok(0xDEADF00D==intbuf
[0] && 0xABADCAFE==intbuf
[2],"DWORD buffer corruption\n");
1316 static void test_playWaveTypeMpegvideo(void)
1319 MCIDEVICEID wDeviceID
;
1320 MCI_PLAY_PARMS play_parm
;
1321 MCI_STATUS_PARMS status_parm
;
1323 memset(buf
, 0, sizeof(buf
));
1325 err
= mciSendStringA("open tempfile.wav type MPEGVideo alias mysound", NULL
, 0, NULL
);
1326 ok(err
==ok_saved
,"mci open tempfile.wav type MPEGVideo returned %s\n", dbg_mcierr(err
));
1328 skip("Cannot open tempfile.wav type MPEGVideo for playing (%s), skipping\n", dbg_mcierr(err
));
1332 wDeviceID
= mciGetDeviceIDA("mysound");
1333 ok(wDeviceID
== 1, "mciGetDeviceIDA mysound returned %u, expected 1\n", wDeviceID
);
1335 err
= mciSendCommandA(wDeviceID
, MCI_PLAY
, 0, (DWORD_PTR
)&play_parm
);
1336 ok(!err
,"mciCommand play returned %s\n", dbg_mcierr(err
));
1338 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1339 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1340 ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1342 status_parm
.dwItem
= MCI_STATUS_MODE
;
1343 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
,
1345 (DWORD_PTR
)&status_parm
);
1346 ok(!err
,"mciCommand status mode returned %s\n", dbg_mcierr(err
));
1347 ok(status_parm
.dwReturn
== MCI_MODE_PLAY
,
1348 "mciCommand status mode: %lu\n", (DWORD
)status_parm
.dwReturn
);
1350 err
= mciSendStringA("setaudio mysound volume to 1000", NULL
, 0, NULL
);
1351 ok(!err
,"mci setaudio volume to 1000 returned %s\n", dbg_mcierr(err
));
1353 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1354 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1355 ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1357 err
= mciSendStringA("setaudio mysound volume to 1001", NULL
, 0, NULL
);
1358 ok(err
==MCIERR_OUTOFRANGE
,"mci setaudio volume to 1001 returned %s\n", dbg_mcierr(err
));
1360 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1361 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1362 ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1364 err
= mciSendStringA("close mysound", NULL
, 0, NULL
);
1365 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
1367 /* test a second play */
1368 err
= mciSendStringA("open tempfile.wav type MPEGVideo alias mysound", NULL
, 0, NULL
);
1369 ok(err
==ok_saved
,"mci open tempfile.wav type MPEGVideo returned %s\n", dbg_mcierr(err
));
1371 err
= mciSendStringA("play mysound", NULL
, 0, NULL
);
1372 ok(!err
,"mci play retuend %s\n", dbg_mcierr(err
));
1374 err
= mciSendStringA("play mysound", NULL
, 0, NULL
);
1375 ok(!err
,"mci play retuend %s\n", dbg_mcierr(err
));
1377 err
= mciSendStringA("close mysound", NULL
, 0, NULL
);
1378 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
1381 static void test_asyncWaveTypeMpegvideo(HWND hwnd
)
1383 MCIDEVICEID wDeviceID
;
1386 memset(buf
, 0, sizeof(buf
));
1388 err
= mciSendStringA("open tempfile.wav alias mysound notify type mpegvideo", buf
, sizeof(buf
), hwnd
);
1389 ok(err
==ok_saved
,"mci open tempfile.wav returned %s\n", dbg_mcierr(err
));
1391 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
1394 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
1395 wDeviceID
= atoi(buf
);
1396 ok(wDeviceID
,"mci open DeviceID: %d\n", wDeviceID
);
1397 test_notification(hwnd
,"open alias notify",MCI_NOTIFY_SUCCESSFUL
);
1399 err
= mciSendStringA("play mysound notify", NULL
, 0, hwnd
);
1400 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1402 Sleep(500); /* milliseconds */
1404 err
= mciSendStringA("pause mysound wait", NULL
, 0, hwnd
);
1405 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1407 err
= mciSendStringA("status mysound mode notify", buf
, sizeof(buf
), hwnd
);
1408 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1409 if(!err
) ok(!strcmp(buf
,"paused"), "mci status mode: %s\n", buf
);
1410 test_notification(hwnd
,"play (superseded)",MCI_NOTIFY_SUPERSEDED
);
1411 test_notification(hwnd
,"status",MCI_NOTIFY_SUCCESSFUL
);
1413 err
= mciSendStringA("seek mysound to start wait", NULL
, 0, NULL
);
1414 ok(!err
,"mci seek to start wait returned %s\n", dbg_mcierr(err
));
1416 err
= mciSendStringA("set mysound time format milliseconds", NULL
, 0, NULL
);
1417 ok(!err
,"mci time format milliseconds returned %s\n", dbg_mcierr(err
));
1419 err
= mciSendStringA("play mysound to 1500 notify", NULL
, 0, hwnd
);
1420 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1422 test_notification(hwnd
,"play",0);
1424 err
= mciSendStringA("close mysound wait", NULL
, 0, NULL
);
1425 ok(!err
,"mci close wait returned %s\n", dbg_mcierr(err
));
1426 test_notification(hwnd
,"play (aborted by close)",MCI_NOTIFY_ABORTED
);
1429 static DWORD CALLBACK
thread_cb(void *p
)
1434 mr
= mciSendStringA("play x", NULL
, 0, NULL
);
1435 ok(mr
== MCIERR_INVALID_DEVICE_NAME
, "play gave: 0x%lx\n", mr
);
1437 mr
= mciSendStringA("close x", NULL
, 0, NULL
);
1438 ok(mr
== MCIERR_INVALID_DEVICE_NAME
, "close gave: 0x%lx\n", mr
);
1445 static void test_threads(void)
1450 mr
= mciSendStringA("open tempfile.wav alias x", NULL
, 0, NULL
);
1451 ok(mr
== 0 || mr
== ok_saved
, "open gave: 0x%lx\n", mr
);
1453 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(mr
));
1457 evt
= CreateEventW( NULL
, TRUE
, FALSE
, NULL
);
1459 CloseHandle(CreateThread(NULL
, 0, &thread_cb
, evt
, 0, NULL
));
1461 WaitForSingleObject(evt
, INFINITE
);
1465 mr
= mciSendStringA("close x", NULL
, 0, NULL
);
1466 ok(mr
== 0, "close gave: 0x%lx\n", mr
);
1469 static BOOL CALLBACK
my_visible_window_proc(HWND hwnd
, LPARAM param
)
1471 HWND
*ret
= (HWND
*)param
;
1474 GetWindowThreadProcessId(hwnd
, &pid
);
1475 if (pid
!= GetCurrentProcessId())
1478 if (GetWindowLongW(hwnd
, GWL_STYLE
) & WS_VISIBLE
)
1487 static void test_video_window(void)
1489 const WCHAR
*filename
= load_resource(L
"test.mpg");
1490 MCI_PARMS_UNION parm
;
1500 DWORD expected_style
;
1507 (WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
) & ~WS_MAXIMIZEBOX
,
1510 MCI_DGV_OPEN_PARENT
,
1512 (WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
) & ~WS_MAXIMIZEBOX
,
1517 WS_BORDER
| WS_CLIPSIBLINGS
| WS_BORDER
| WS_DLGFRAME
,
1522 WS_POPUPWINDOW
| WS_CLIPSIBLINGS
,
1525 MCI_DGV_OPEN_PARENT
| MCI_DGV_OPEN_WS
,
1526 WS_OVERLAPPEDWINDOW
,
1527 WS_OVERLAPPEDWINDOW
| WS_CLIPSIBLINGS
,
1530 MCI_DGV_OPEN_PARENT
| MCI_DGV_OPEN_WS
,
1536 for (i
= 0; i
< ARRAY_SIZE(testcase
); ++i
)
1538 HWND parent_window
= NULL
, hwnd
, video_window
;
1539 DWORD style
, expected
;
1541 winetest_push_context("%u", i
);
1543 if (testcase
[i
].open_flags
& MCI_DGV_OPEN_PARENT
)
1544 parent_window
= CreateWindowExA(0, "static", "parent",
1545 WS_POPUPWINDOW
, 0, 0, 100, 100, 0, 0, 0, NULL
);
1547 parm
.dgv_open
.lpstrDeviceType
= (WCHAR
*)L
"MPEGVideo";
1548 parm
.dgv_open
.lpstrElementName
= (WCHAR
*)filename
;
1549 parm
.dgv_open
.hWndParent
= parent_window
;
1550 parm
.dgv_open
.dwStyle
= testcase
[i
].style
;
1551 err
= mciSendCommandW(0, MCI_OPEN
,
1552 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| testcase
[i
].open_flags
, (DWORD_PTR
)&parm
);
1553 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1554 id
= parm
.dgv_open
.wDeviceID
;
1556 err
= mciSendCommandW(id
, MCI_PLAY
, 0, (DWORD_PTR
)&parm
);
1557 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1559 if (!(testcase
[i
].style
& WS_CHILD
))
1561 video_window
= NULL
;
1562 EnumWindows(my_visible_window_proc
, (LPARAM
)&video_window
);
1563 todo_wine_if (testcase
[i
].open_flags
& MCI_DGV_OPEN_PARENT
)
1564 ok(video_window
!= NULL
, "Video window should be shown.\n");
1566 /* FIXME: Remove once Wine is fixed */
1567 if (!video_window
) goto next
;
1569 hwnd
= GetWindow(video_window
, GW_OWNER
);
1570 todo_wine_if (testcase
[i
].open_flags
& MCI_DGV_OPEN_PARENT
)
1571 ok(hwnd
== parent_window
, "Got owner %p, expected %p.\n", hwnd
, parent_window
);
1575 ok(!IsWindowVisible(parent_window
), "Parent window should be hidden.\n");
1576 ShowWindow(parent_window
, SW_SHOWNA
);
1578 hwnd
= GetWindow(parent_window
, GW_CHILD
);
1579 ok(hwnd
!= NULL
, "Child video window should be shown.\n");
1580 video_window
= hwnd
;
1583 expected
= testcase
[i
].expected_style
| WS_VISIBLE
;
1584 style
= GetWindowLongW(video_window
, GWL_STYLE
);
1585 todo_wine_if (i
!= 3)
1586 ok(style
== expected
, "Got style %#lx for window %p, expected %#lx.\n", style
, video_window
, expected
);
1588 err
= mciSendCommandW(id
, MCI_STOP
, 0, (DWORD_PTR
)&parm
);
1589 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1591 ok(IsWindowVisible(video_window
), "Video window should be visible.\n");
1593 err
= mciSendCommandW(id
, MCI_PLAY
, 0, (DWORD_PTR
)&parm
);
1594 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1596 ok(IsWindowVisible(video_window
), "Video window should be visible.\n");
1598 err
= mciSendCommandW(id
, MCI_SEEK
, MCI_SEEK_TO_START
, (DWORD_PTR
)&parm
);
1599 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1601 ok(IsWindowVisible(video_window
), "Video window should be visible.\n");
1604 err
= mciSendCommandW(id
, MCI_CLOSE
, 0, 0);
1605 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1609 ret
= DestroyWindow(parent_window
);
1610 ok(ret
, "Failed to destroy parent window\n");
1613 winetest_pop_context();
1616 ret
= DeleteFileW(filename
);
1617 ok(ret
, "Failed to delete %s, error %lu.\n", debugstr_w(filename
), GetLastError());
1622 char curdir
[MAX_PATH
], tmpdir
[MAX_PATH
];
1626 GetCurrentDirectoryA(MAX_PATH
, curdir
);
1627 GetTempPathA(MAX_PATH
, tmpdir
);
1628 SetCurrentDirectoryA(tmpdir
);
1630 hwnd
= CreateWindowExA(0, "static", "winmm test", WS_POPUP
, 0,0,100,100,
1632 test_mciParser(hwnd
);
1633 test_openCloseWAVE(hwnd
);
1634 test_recordWAVE(hwnd
);
1635 if(waveOutGetNumDevs()){
1637 test_playWAVE(hwnd
);
1638 test_asyncWAVE(hwnd
);
1639 test_AutoOpenWAVE(hwnd
);
1640 test_playWaveTypeMpegvideo();
1641 test_asyncWaveTypeMpegvideo(hwnd
);
1643 skip("No output devices available, skipping all output tests\n");
1645 test_video_window();
1647 /* Win9X hangs when exiting with something still open. */
1648 err
= mciSendStringA("close all", NULL
, 0, hwnd
);
1649 ok(!err
,"final close all returned %s\n", dbg_mcierr(err
));
1650 ok(DeleteFileA("tempfile.wav") || ok_saved
, "Delete tempfile.wav (cause auto-open?)\n");
1651 DestroyWindow(hwnd
);
1653 SetCurrentDirectoryA(curdir
);