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_DGV_WHERE_PARMS where
;
43 MCI_GENERIC_PARMS gen
;
46 const char* dbg_mcierr(MCIERROR err
)
49 case 0: return "0=NOERROR";
50 #define X(label) case label: return #label ;
51 X(MCIERR_INVALID_DEVICE_ID
)
52 X(MCIERR_UNRECOGNIZED_KEYWORD
)
53 X(MCIERR_UNRECOGNIZED_COMMAND
)
55 X(MCIERR_INVALID_DEVICE_NAME
)
56 X(MCIERR_OUT_OF_MEMORY
)
58 X(MCIERR_CANNOT_LOAD_DRIVER
)
59 X(MCIERR_MISSING_COMMAND_STRING
)
60 X(MCIERR_PARAM_OVERFLOW
)
61 X(MCIERR_MISSING_STRING_ARGUMENT
)
63 X(MCIERR_PARSER_INTERNAL
)
64 X(MCIERR_DRIVER_INTERNAL
)
65 X(MCIERR_MISSING_PARAMETER
)
66 X(MCIERR_UNSUPPORTED_FUNCTION
)
67 X(MCIERR_FILE_NOT_FOUND
)
68 X(MCIERR_DEVICE_NOT_READY
)
71 X(MCIERR_CANNOT_USE_ALL
)
73 X(MCIERR_EXTENSION_NOT_FOUND
)
75 X(MCIERR_FLAGS_NOT_COMPATIBLE
)
76 X(MCIERR_FILE_NOT_SAVED
)
77 X(MCIERR_DEVICE_TYPE_REQUIRED
)
78 X(MCIERR_DEVICE_LOCKED
)
79 X(MCIERR_DUPLICATE_ALIAS
)
80 X(MCIERR_BAD_CONSTANT
)
81 X(MCIERR_MUST_USE_SHAREABLE
)
82 X(MCIERR_MISSING_DEVICE_NAME
)
83 X(MCIERR_BAD_TIME_FORMAT
)
84 X(MCIERR_NO_CLOSING_QUOTE
)
85 X(MCIERR_DUPLICATE_FLAGS
)
86 X(MCIERR_INVALID_FILE
)
87 X(MCIERR_NULL_PARAMETER_BLOCK
)
88 X(MCIERR_UNNAMED_RESOURCE
)
89 X(MCIERR_NEW_REQUIRES_ALIAS
)
90 X(MCIERR_NOTIFY_ON_AUTO_OPEN
)
91 X(MCIERR_NO_ELEMENT_ALLOWED
)
92 X(MCIERR_NONAPPLICABLE_FUNCTION
)
93 X(MCIERR_ILLEGAL_FOR_AUTO_OPEN
)
94 X(MCIERR_FILENAME_REQUIRED
)
95 X(MCIERR_EXTRA_CHARACTERS
)
96 X(MCIERR_DEVICE_NOT_INSTALLED
)
100 X(MCIERR_DEVICE_LENGTH
)
101 X(MCIERR_DEVICE_ORD_LENGTH
)
103 X(MCIERR_WAVE_OUTPUTSINUSE
)
104 X(MCIERR_WAVE_SETOUTPUTINUSE
)
105 X(MCIERR_WAVE_INPUTSINUSE
)
106 X(MCIERR_WAVE_SETINPUTINUSE
)
107 X(MCIERR_WAVE_OUTPUTUNSPECIFIED
)
108 X(MCIERR_WAVE_INPUTUNSPECIFIED
)
109 X(MCIERR_WAVE_OUTPUTSUNSUITABLE
)
110 X(MCIERR_WAVE_SETOUTPUTUNSUITABLE
)
111 X(MCIERR_WAVE_INPUTSUNSUITABLE
)
112 X(MCIERR_WAVE_SETINPUTUNSUITABLE
)
113 X(MCIERR_SEQ_DIV_INCOMPATIBLE
)
114 X(MCIERR_SEQ_PORT_INUSE
)
115 X(MCIERR_SEQ_PORT_NONEXISTENT
)
116 X(MCIERR_SEQ_PORT_MAPNODEVICE
)
117 X(MCIERR_SEQ_PORT_MISCERROR
)
119 X(MCIERR_SEQ_PORTUNSPECIFIED
)
120 X(MCIERR_SEQ_NOMIDIPRESENT
)
122 X(MCIERR_CREATEWINDOW
)
125 X(MCIERR_NO_IDENTITY
)
128 static char name
[20]; /* Not to be called twice in a parameter list! */
129 sprintf(name
, "MMSYSERR %lu", err
);
135 static BOOL
spurious_message(LPMSG msg
)
137 /* WM_DEVICECHANGE 0x0219 appears randomly */
138 if(msg
->message
!= MM_MCINOTIFY
) {
139 trace("skipping spurious message %04x\n",msg
->message
);
145 static WCHAR
*load_resource(const WCHAR
*name
)
147 static WCHAR pathW
[MAX_PATH
];
153 GetTempPathW(ARRAY_SIZE(pathW
), pathW
);
156 file
= CreateFileW(pathW
, GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
157 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to create file %s, error %lu.\n",
158 wine_dbgstr_w(pathW
), GetLastError());
160 res
= FindResourceW(NULL
, name
, (LPCWSTR
)RT_RCDATA
);
161 ok(!!res
, "Failed to load resource, error %lu.\n", GetLastError());
162 ptr
= LockResource(LoadResource(GetModuleHandleA(NULL
), res
));
163 WriteFile(file
, ptr
, SizeofResource( GetModuleHandleA(NULL
), res
), &written
, NULL
);
164 ok(written
== SizeofResource(GetModuleHandleA(NULL
), res
), "Failed to write resource.\n");
170 /* A single ok() in each code path allows us to prefix this with todo_wine */
171 #define test_notification(hwnd, command, type) test_notification_dbg(hwnd, command, type, __LINE__)
172 static void test_notification_dbg(HWND hwnd
, const char* command
, WPARAM type
, int line
)
173 { /* Use type 0 as meaning no message */
176 do { seen
= PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
); }
177 while(seen
&& spurious_message(&msg
));
179 /* We observe transient delayed notification, mostly on native.
180 * Notification is not always present right when mciSend returns. */
181 trace_(__FILE__
,line
)("Waiting for delayed notification from %s\n", command
);
182 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 3000, QS_POSTMESSAGE
);
183 seen
= PeekMessageA(&msg
, hwnd
, MM_MCINOTIFY
, MM_MCINOTIFY
, PM_REMOVE
);
186 ok_(__FILE__
,line
)(type
==0, "Expect message %04Ix from %s\n", type
, command
);
187 else if(msg
.hwnd
!= hwnd
)
188 ok_(__FILE__
,line
)(msg
.hwnd
== hwnd
, "Didn't get the handle to our test window\n");
189 else if(msg
.message
!= MM_MCINOTIFY
)
190 ok_(__FILE__
,line
)(msg
.message
== MM_MCINOTIFY
, "got %04x instead of MM_MCINOTIFY from command %s\n", msg
.message
, command
);
191 else ok_(__FILE__
,line
)(msg
.wParam
== type
, "got %04Ix instead of MCI_NOTIFY_xyz %04Ix from command %s\n", msg
.wParam
, type
, command
);
194 static void test_mciParser(HWND hwnd
)
197 MCIDEVICEID wDeviceID
;
198 MCI_PARMS_UNION parm
;
200 memset(buf
, 0, sizeof(buf
));
201 test_notification(hwnd
, "-prior to parser test-", 0);
203 /* Get a handle on an MCI device, works even without sound. */
204 parm
.open
.lpstrDeviceType
= "waveaudio";
205 parm
.open
.lpstrElementName
= ""; /* "new" at the command level */
206 parm
.open
.lpstrAlias
= "x"; /* to enable mciSendStringA */
207 parm
.open
.dwCallback
= (DWORD_PTR
)hwnd
;
208 err
= mciSendCommandA(0, MCI_OPEN
,
209 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| MCI_OPEN_ALIAS
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
210 ok(!err
,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err
));
211 wDeviceID
= parm
.open
.wDeviceID
;
212 ok(!strcmp(parm
.open
.lpstrDeviceType
,"waveaudio"), "open modified device type\n");
214 test_notification(hwnd
, "MCI_OPEN", MCI_NOTIFY_SUCCESSFUL
);
215 test_notification(hwnd
, "MCI_OPEN no #2", 0);
217 err
= mciSendStringA("open avivideo alias a", buf
, sizeof(buf
), hwnd
);
218 ok(!err
,"open another: %s\n", dbg_mcierr(err
));
221 err
= mciSendStringA("", buf
, sizeof(buf
), NULL
);
222 ok(err
==MCIERR_MISSING_COMMAND_STRING
,"empty string: %s\n", dbg_mcierr(err
));
223 ok(!buf
[0], "error buffer %s\n", buf
);
226 err
= mciSendStringA("open", buf
, sizeof(buf
), NULL
);
227 ok(err
==MCIERR_MISSING_DEVICE_NAME
,"open void: %s\n", dbg_mcierr(err
));
228 ok(!buf
[0], "open error buffer %s\n", buf
);
230 err
= mciSendStringA("open notify", buf
, sizeof(buf
), NULL
);
231 todo_wine
ok(err
==MCIERR_INVALID_DEVICE_NAME
,"open notify: %s\n", dbg_mcierr(err
));
233 err
= mciSendStringA("open new", buf
, sizeof(buf
), NULL
);
234 todo_wine
ok(err
==MCIERR_NEW_REQUIRES_ALIAS
,"open new: %s\n", dbg_mcierr(err
));
236 err
= mciSendStringA("open new type waveaudio alias r shareable shareable", buf
, sizeof(buf
), NULL
);
237 todo_wine
ok(err
==MCIERR_DUPLICATE_FLAGS
,"open new: %s\n", dbg_mcierr(err
));
238 if(!err
) mciSendStringA("close r", NULL
, 0, NULL
);
240 err
= mciSendStringA("status x position wait wait", buf
, sizeof(buf
), NULL
);
241 todo_wine
ok(err
==MCIERR_DUPLICATE_FLAGS
,"status wait wait: %s\n", dbg_mcierr(err
));
243 err
= mciSendStringA("status x length length", buf
, sizeof(buf
), NULL
);
244 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status 2xlength: %s\n", dbg_mcierr(err
));
246 err
= mciSendStringA("status x length position", buf
, sizeof(buf
), NULL
);
247 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status length+position: %s\n", dbg_mcierr(err
));
250 err
= mciSendStringA("set x time format milliseconds time format ms", buf
, sizeof(buf
), NULL
);
251 todo_wine
ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"status length+position: %s\n", dbg_mcierr(err
));
252 ok(!buf
[0], "set error buffer %s\n", buf
);
254 /* device's response, not a parser test */
255 err
= mciSendStringA("status x", buf
, sizeof(buf
), NULL
);
256 ok(err
==MCIERR_MISSING_PARAMETER
,"status waveaudio nokeyword: %s\n", dbg_mcierr(err
));
259 err
= mciSendStringA("status a", buf
, sizeof(buf
), NULL
);
260 todo_wine
ok(err
==MCIERR_UNSUPPORTED_FUNCTION
,"status avivideo nokeyword: %s\n", dbg_mcierr(err
));
261 ok(!buf
[0], "status error buffer %s\n", buf
);
263 err
= mciSendStringA("status x track", buf
, sizeof(buf
), NULL
);
264 ok(err
==MCIERR_BAD_INTEGER
,"status waveaudio no track: %s\n", dbg_mcierr(err
));
266 err
= mciSendStringA("status x track 3", buf
, sizeof(buf
), NULL
);
267 ok(err
==MCIERR_MISSING_PARAMETER
,"status waveaudio track 3: %s\n", dbg_mcierr(err
));
269 err
= mciSendStringA("status x 2 track 3", buf
, sizeof(buf
), NULL
);
270 todo_wine
ok(err
==MCIERR_OUTOFRANGE
,"status 2(position) track 3: %s\n", dbg_mcierr(err
));
272 err
= mciSendStringA("status x 0x4", buf
, sizeof(buf
), NULL
);
273 todo_wine
ok(err
==MCIERR_BAD_CONSTANT
, "status 0x4: %s\n", dbg_mcierr(err
));
275 err
= mciSendStringA("status x 4", buf
, sizeof(buf
), hwnd
);
276 ok(!err
,"status 4(mode): %s\n", dbg_mcierr(err
));
277 if(!err
)ok(!strcmp(buf
,"stopped"), "status 4(mode), got: %s\n", buf
);
279 err
= mciSendStringA("status x 4 notify", buf
, sizeof(buf
), hwnd
);
280 todo_wine
ok(!err
,"status 4(mode) notify: %s\n", dbg_mcierr(err
));
281 if(!err
)ok(!strcmp(buf
,"stopped"), "status 4(mode), got: %s\n", buf
);
282 test_notification(hwnd
, "status 4 notify", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
284 err
= mciSendStringA("set x milliseconds", buf
, sizeof(buf
), hwnd
);
285 todo_wine
ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
,"set milliseconds: %s\n", dbg_mcierr(err
));
287 err
= mciSendStringA("set x milliseconds ms", buf
, sizeof(buf
), hwnd
);
288 todo_wine
ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
,"set milliseconds ms: %s\n", dbg_mcierr(err
));
290 err
= mciSendStringA("capability x can save", buf
, sizeof(buf
), hwnd
);
291 todo_wine
ok(!err
,"capability can (space) save: %s\n", dbg_mcierr(err
));
293 err
= mciSendStringA("status x nsa", buf
, sizeof(buf
), hwnd
);
294 todo_wine
ok(err
==MCIERR_BAD_CONSTANT
,"status nsa: %s\n", dbg_mcierr(err
));
296 err
= mciSendStringA("seek x to 0:0:0:0:0", buf
, sizeof(buf
), NULL
);
297 ok(err
==MCIERR_BAD_INTEGER
,"seek to 0:0:0:0:0 returned %s\n", dbg_mcierr(err
));
299 err
= mciSendStringA("seek x to 0:0:0:0:", buf
, sizeof(buf
), NULL
);
300 ok(err
==MCIERR_BAD_INTEGER
,"seek to 0:0:0:0: returned %s\n", dbg_mcierr(err
));
302 err
= mciSendStringA("seek x to :0:0:0:0", buf
, sizeof(buf
), NULL
);
303 ok(err
==MCIERR_BAD_INTEGER
,"seek to :0:0:0:0 returned %s\n", dbg_mcierr(err
));
305 err
= mciSendStringA("seek x to 256:0:0:0", buf
, sizeof(buf
), NULL
);
306 ok(err
==MCIERR_BAD_INTEGER
,"seek to 256:0:0:0 returned %s\n", dbg_mcierr(err
));
308 err
= mciSendStringA("seek x to 0:256", buf
, sizeof(buf
), NULL
);
309 ok(err
==MCIERR_BAD_INTEGER
,"seek to 0:256 returned %s\n", dbg_mcierr(err
));
311 err
= mciSendStringA("status all time format", buf
, sizeof(buf
), hwnd
);
312 ok(err
==MCIERR_CANNOT_USE_ALL
,"status all: %s\n", dbg_mcierr(err
));
314 err
= mciSendStringA("cue all", buf
, sizeof(buf
), NULL
);
315 ok(err
==MCIERR_UNRECOGNIZED_COMMAND
,"cue all: %s\n", dbg_mcierr(err
));
317 err
= mciSendStringA("open all", buf
, sizeof(buf
), NULL
);
318 todo_wine
ok(err
==MCIERR_CANNOT_USE_ALL
,"open all: %s\n", dbg_mcierr(err
));
320 /* avivideo is not a known MCI_DEVTYPE resource name */
321 err
= mciSendStringA("sysinfo avivideo quantity", buf
, sizeof(buf
), hwnd
);
322 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo sequencer quantity: %s\n", dbg_mcierr(err
));
324 err
= mciSendStringA("sysinfo digitalvideo quantity", buf
, sizeof(buf
), hwnd
);
325 ok(!err
,"sysinfo digitalvideo quantity: %s\n", dbg_mcierr(err
));
326 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo digitalvideo quantity returned %s\n", buf
);
328 /* quantity 0 yet open 1 (via type "avivideo"), fun */
329 err
= mciSendStringA("sysinfo digitalvideo quantity open", buf
, sizeof(buf
), hwnd
);
330 ok(!err
,"sysinfo digitalvideo quantity open: %s\n", dbg_mcierr(err
));
331 if(!err
) ok(!strcmp(buf
,"1"), "sysinfo digitalvideo quantity open returned %s\n", buf
);
333 err
= mciSendStringA("put a window at 0 0", buf
, sizeof(buf
), NULL
);
334 ok(err
==MCIERR_BAD_INTEGER
,"put incomplete rect: %s\n", dbg_mcierr(err
));
336 /*w9X-w2k report code from device last opened, newer versions compare them all
337 * and return the one error code or MCIERR_MULTIPLE if they differ. */
338 err
= mciSendStringA("pause all", buf
, sizeof(buf
), NULL
);
339 todo_wine
ok(err
==MCIERR_MULTIPLE
|| broken(err
==MCIERR_NONAPPLICABLE_FUNCTION
),"pause all: %s\n", dbg_mcierr(err
));
340 ok(!buf
[0], "pause error buffer %s\n", buf
);
342 /* MCI_STATUS' dwReturn is a DWORD_PTR, others' a plain DWORD. */
343 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
344 parm
.status
.dwReturn
= 0xFEEDABAD;
345 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
346 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
347 if(!err
) ok(MCI_FORMAT_MILLISECONDS
==parm
.status
.dwReturn
,"status time format: %Id\n",parm
.status
.dwReturn
);
349 parm
.status
.dwItem
= MCI_STATUS_MODE
;
350 parm
.status
.dwReturn
= 0xFEEDABAD;
351 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
352 ok(!err
,"mciCommand status mode: %s\n", dbg_mcierr(err
));
353 if(!err
) ok(MCI_MODE_STOP
==parm
.status
.dwReturn
,"STATUS mode: %Id\n",parm
.status
.dwReturn
);
355 err
= mciSendStringA("status x mode", buf
, sizeof(buf
), hwnd
);
356 ok(!err
,"status mode: %s\n", dbg_mcierr(err
));
357 if(!err
) ok(!strcmp(buf
, "stopped"), "status mode is %s\n", buf
);
359 parm
.caps
.dwItem
= MCI_GETDEVCAPS_USES_FILES
;
360 parm
.caps
.dwReturn
= 0xFEEDABAD;
361 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
362 ok(!err
,"mciCommand getdevcaps files: %s\n", dbg_mcierr(err
));
363 if(!err
) ok(1==parm
.caps
.dwReturn
,"getdevcaps files: %ld\n",parm
.caps
.dwReturn
);
365 parm
.caps
.dwItem
= MCI_GETDEVCAPS_HAS_VIDEO
;
366 parm
.caps
.dwReturn
= 0xFEEDABAD;
367 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
368 ok(!err
,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err
));
369 if(!err
) ok(0==parm
.caps
.dwReturn
,"getdevcaps video: %ld\n",parm
.caps
.dwReturn
);
371 parm
.caps
.dwItem
= MCI_GETDEVCAPS_DEVICE_TYPE
;
372 parm
.caps
.dwReturn
= 0xFEEDABAD;
373 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
374 ok(!err
,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err
));
375 if(!err
) ok(MCI_DEVTYPE_WAVEFORM_AUDIO
==parm
.caps
.dwReturn
,"getdevcaps device type: %ld\n",parm
.caps
.dwReturn
);
377 err
= mciSendStringA("capability x uses files", buf
, sizeof(buf
), hwnd
);
378 ok(!err
,"capability files: %s\n", dbg_mcierr(err
));
379 if(!err
) ok(!strcmp(buf
, "true"), "capability files is %s\n", buf
);
381 err
= mciSendStringA("capability x has video", buf
, sizeof(buf
), hwnd
);
382 ok(!err
,"capability video: %s\n", dbg_mcierr(err
));
383 if(!err
) ok(!strcmp(buf
, "false"), "capability video is %s\n", buf
);
385 err
= mciSendStringA("capability x device type", buf
, sizeof(buf
), hwnd
);
386 ok(!err
,"capability device type: %s\n", dbg_mcierr(err
));
387 if(!err
) ok(!strcmp(buf
, "waveaudio"), "capability device type is %s\n", buf
);
389 err
= mciSendStringA("info a version", buf
, sizeof(buf
), hwnd
);
390 ok(!err
,"info version: %s\n", dbg_mcierr(err
));
391 if(!err
) ok(!strcmp(buf
, "1.1"), "info version is %s\n", buf
);
393 err
= mciSendCommandA(wDeviceID
, MCI_CLOSE
, 0, 0);
394 ok(!err
,"mciCommand close returned %s\n", dbg_mcierr(err
));
396 err
= mciSendStringA("close a", buf
, sizeof(buf
), hwnd
);
397 ok(!err
,"close avi: %s\n", dbg_mcierr(err
));
399 test_notification(hwnd
, "-end of 1st set-", 0);
402 static void test_openCloseWAVE(HWND hwnd
)
405 MCI_PARMS_UNION parm
;
406 const char command_open
[] = "open new type waveaudio alias mysound notify";
407 const char command_close_my
[] = "close mysound notify";
408 const char command_close_all
[] = "close all notify";
409 const char command_sysinfo
[] = "sysinfo waveaudio quantity open";
411 DWORD intbuf
[3] = { 0xDEADF00D, 99, 0xABADCAFE };
412 memset(buf
, 0, sizeof(buf
));
413 test_notification(hwnd
, "-prior to any command-", 0);
415 /* Avoid Sysinfo quantity with notify because Win9x and newer differ. */
416 err
= mciSendStringA("sysinfo all quantity", buf
, sizeof(buf
), hwnd
);
417 ok(!err
,"mci sysinfo all quantity returned %s\n", dbg_mcierr(err
));
418 if(!err
) trace("[MCI] with %s drivers\n", buf
);
420 parm
.sys
.lpstrReturn
= (LPSTR
)&intbuf
[1];
421 parm
.sys
.dwRetSize
= sizeof(DWORD
);
422 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
423 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
| MCI_WAIT
,
425 ok(!err
, "mciCommand sysinfo all quantity returned %s\n", dbg_mcierr(err
));
426 if(!err
) ok(atoi(buf
)==intbuf
[1],"sysinfo all quantity string and command differ\n");
428 parm
.sys
.dwRetSize
= sizeof(DWORD
)-1;
429 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
, (DWORD_PTR
)&parm
);
430 ok(err
== MCIERR_PARAM_OVERFLOW
|| broken(!err
/* Win9x */),
431 "mciCommand sysinfo with too small buffer returned %s\n", dbg_mcierr(err
));
433 err
= mciSendStringA("open new type waveaudio alias r shareable", buf
, sizeof(buf
), NULL
);
434 ok(err
==MCIERR_UNSUPPORTED_FUNCTION
,"mci open new shareable returned %s\n", dbg_mcierr(err
));
436 err
= mciSendStringA("close r", NULL
, 0, NULL
);
437 ok(!err
,"mci close shareable returned %s\n", dbg_mcierr(err
));
440 err
= mciGetDeviceIDA("waveaudio");
441 ok(!err
, "mciGetDeviceIDA waveaudio returned %lu, expected 0\n", err
);
443 err
= mciSendStringA(command_open
, buf
, sizeof(buf
), hwnd
);
444 ok(!err
,"mci %s returned %s\n", command_open
, dbg_mcierr(err
));
445 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
446 /* Wine<=1.1.33 used to ignore anything past alias XY */
447 test_notification(hwnd
,"open new alias notify",MCI_NOTIFY_SUCCESSFUL
);
449 err
= mciSendStringA("status mysound time format", buf
, sizeof(buf
), hwnd
);
450 ok(!err
,"mci status time format returned %s\n", dbg_mcierr(err
));
452 if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) == LANG_ENGLISH
)
453 ok(!strcmp(buf
,"milliseconds"), "mci status time format: %s\n", buf
);
454 else trace("locale-dependent time format: %s (ms)\n", buf
);
457 memset(buf
, 0, sizeof(buf
));
458 parm
.sys
.dwNumber
= 1;
459 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
460 parm
.sys
.lpstrReturn
= buf
;
461 parm
.sys
.dwRetSize
= sizeof(buf
);
462 parm
.sys
.dwCallback
= (DWORD_PTR
)hwnd
;
463 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
,
464 MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
465 ok(!err
,"mciCommand MCI_SYSINFO all name 1 open notify: %s\n", dbg_mcierr(err
));
466 if(!err
) ok(!strcmp(buf
,"mysound"), "sysinfo name returned %s\n", buf
);
467 test_notification(hwnd
, "SYSINFO name notify\n", MCI_NOTIFY_SUCCESSFUL
);
469 memset(buf
, 0, sizeof(buf
));
470 parm
.sys
.dwNumber
= 1;
471 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
472 parm
.sys
.lpstrReturn
= buf
;
473 parm
.sys
.dwRetSize
= 8; /* mysound\0 */
474 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
,
476 ok(!err
,"mciCommand MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err
));
477 if(!err
) ok(!strcmp(buf
,"mysound"), "sysinfo name returned %s\n", buf
);
479 memset(buf
, 0, sizeof(buf
));
480 /* dwRetSize counts characters, not bytes, despite what MSDN says. */
481 parm
.sys
.dwNumber
= 1;
482 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
483 parm
.sys
.lpstrReturn
= buf
;
484 parm
.sys
.dwRetSize
= 8; /* mysound\0 */
485 /* MCI_..._PARMSA and PARMSW share the same layout, use one for both tests. */
486 err
= mciSendCommandW(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
487 ok(!err
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err
));
488 if (!err
) ok(!lstrcmpW((LPWSTR
)buf
, L
"mysound"), "sysinfo name 1 open contents\n");
490 memset(buf
, 0, sizeof(buf
));
492 parm
.sys
.dwNumber
= 1;
493 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
494 parm
.sys
.lpstrReturn
= buf
;
495 parm
.sys
.dwRetSize
= 7; /* too short for mysound\0 */
496 err
= mciSendCommandW(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
497 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err
));
498 ok(!strcmp(buf
,"Y"), "output buffer %s\n", buf
);
500 /* Win9x overwrites the tiny buffer and returns success, newer versions signal overflow. */
501 memset(buf
, 0, sizeof(buf
));
503 parm
.sys
.dwNumber
= 1;
504 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
; /* ignored */
505 parm
.sys
.lpstrReturn
= buf
;
506 parm
.sys
.dwRetSize
= 2; /* too short for mysound\0 */
507 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
| MCI_SYSINFO_OPEN
,
509 ok(err
==MCIERR_PARAM_OVERFLOW
|| broken(!err
/* Win9x */),"mciCommand MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err
));
510 ok(!strcmp(buf
, err
? "Y" : "mysound"), "sysinfo short name returned %s\n", buf
);
512 err
= mciSendStringA("sysinfo mysound quantity open", buf
, sizeof(buf
), hwnd
);
513 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo alias quantity: %s\n", dbg_mcierr(err
));
515 err
= mciSendStringA("sysinfo nosuchalias quantity open", buf
, sizeof(buf
), hwnd
);
516 ok(err
==MCIERR_DEVICE_TYPE_REQUIRED
,"sysinfo unknown quantity open: %s\n", dbg_mcierr(err
));
518 err
= mciSendStringA("sysinfo all installname", buf
, sizeof(buf
), hwnd
);
519 ok(err
==MCIERR_CANNOT_USE_ALL
,"sysinfo all installname: %s\n", dbg_mcierr(err
));
521 buf
[0] = 'M'; buf
[1] = 0;
522 parm
.sys
.lpstrReturn
= buf
;
523 parm
.sys
.dwRetSize
= sizeof(buf
);
524 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_INSTALLNAME
, (DWORD_PTR
)&parm
);
525 ok(err
==MCIERR_CANNOT_USE_ALL
,"mciCommand MCI_SYSINFO all installname: %s\n", dbg_mcierr(err
));
526 ok(!strcmp(buf
,"M"), "output buffer %s\n", buf
);
528 err
= mciSendStringA("sysinfo nodev installname", buf
, sizeof(buf
), hwnd
);
529 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"sysinfo nodev installname: %s\n", dbg_mcierr(err
));
530 ok(!buf
[0], "sysinfo error buffer %s\n", buf
);
533 parm
.sys
.lpstrReturn
= buf
;
534 parm
.sys
.dwRetSize
= sizeof(buf
);
535 err
= mciSendCommandW(24000, MCI_SYSINFO
, MCI_SYSINFO_INSTALLNAME
, (DWORD_PTR
)&parm
);
536 ok(err
==MCIERR_INVALID_DEVICE_NAME
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommand MCI_SYSINFO nodev installname: %s\n", dbg_mcierr(err
));
537 ok(!strcmp(buf
,"K"), "output buffer %s\n", buf
);
539 buf
[0] = 0; buf
[1] = 'A'; buf
[2] = 'j'; buf
[3] = 0;
540 parm
.info
.lpstrReturn
= buf
;
541 parm
.info
.dwRetSize
= 2;
542 err
= mciSendCommandA(1, MCI_INFO
, MCI_INFO_PRODUCT
, (DWORD_PTR
)&parm
);
543 ok(!err
, "mciCommand MCI_INFO product: %s\n", dbg_mcierr(err
));
544 ok(buf
[0] /* && !buf[1] */ && (buf
[2] == 'j' || broken(!buf
[2])), "info product output buffer %s\n", buf
);
545 /* Producing non-ASCII multi-byte output, native forgets to zero-terminate a too small buffer
546 * with SendStringA, while SendStringW works correctly (jap. and chin. locale): ignore buf[1] */
547 /* Bug in 64 bit Vista/w2k8/w7: mciSendStringW is used! (not in xp nor w2k3) */
549 buf
[0] = 'K'; buf
[1] = 0;
550 parm
.info
.dwRetSize
= sizeof(buf
);
551 err
= mciSendCommandW(1, MCI_INFO
, 0x07000000, (DWORD_PTR
)&parm
);
552 ok(err
==MCIERR_UNRECOGNIZED_KEYWORD
|| broken(err
==MMSYSERR_NOTSUPPORTED
/* Win9x */), "mciCommand MCI_INFO other: %s\n", dbg_mcierr(err
));
553 ok(!strcmp(buf
,"K"), "info output buffer %s\n", buf
);
555 err
= mciGetDeviceIDA("all");
556 ok(err
== MCI_ALL_DEVICE_ID
, "mciGetDeviceIDA all returned %lu, expected MCI_ALL_DEVICE_ID\n", err
);
558 err
= mciSendStringA(command_close_my
, NULL
, 0, hwnd
);
559 ok(!err
,"mci %s returned %s\n", command_close_my
, dbg_mcierr(err
));
560 test_notification(hwnd
, command_close_my
, MCI_NOTIFY_SUCCESSFUL
);
562 test_notification(hwnd
, command_close_my
, 0);
564 err
= mciSendStringA("open no-such-file-exists.wav alias y buffer 6", buf
, sizeof(buf
), NULL
);
565 ok(err
==MCIERR_FILE_NOT_FOUND
,"open no-such-file.wav returned %s\n", dbg_mcierr(err
));
567 err
= mciSendStringA("close y", NULL
, 0, NULL
);
568 ok(!err
,"close y returned %s\n", dbg_mcierr(err
));
571 err
= mciSendStringA("open no-such-dir\\file.wav alias y type waveaudio", buf
, sizeof(buf
), NULL
);
572 ok(err
==MCIERR_FILE_NOT_FOUND
|| broken(err
==MCIERR_INVALID_FILE
/* Win9X */),"open no-such-dir/file.wav returned %s\n", dbg_mcierr(err
));
574 err
= mciSendStringA("close y", NULL
, 0, NULL
);
575 ok(!err
,"close y returned %s\n", dbg_mcierr(err
));
578 err
= mciSendStringA("open ! alias no", buf
, sizeof(buf
), NULL
);
579 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"open !(void): %s\n", dbg_mcierr(err
));
581 err
= mciSendStringA("open !no-such-file-exists.wav alias no", buf
, sizeof(buf
), NULL
);
582 ok(err
==MCIERR_FILE_NOT_FOUND
|| /* Win9X */err
==MCIERR_INVALID_DEVICE_NAME
,"open !name: %s\n", dbg_mcierr(err
));
584 /* FILE_NOT_FOUND stems from mciwave,
585 * the complete name including ! is passed through since NT */
586 err
= mciSendStringA("open nosuchdevice!tempfile.wav alias no", buf
, sizeof(buf
), NULL
);
587 ok(err
==MCIERR_FILE_NOT_FOUND
|| /* Win9X */err
==MCIERR_INVALID_DEVICE_NAME
,"open nosuchdevice!name: %s\n", dbg_mcierr(err
));
588 /* FIXME? use broken(INVALID_DEVICE_NAME) and have Wine not mimic Win9X? */
590 err
= mciSendStringA("close waveaudio", buf
, sizeof(buf
), NULL
);
591 ok(err
==MCIERR_INVALID_DEVICE_NAME
,"close waveaudio: %s\n", dbg_mcierr(err
));
593 err
= mciSendStringA(command_close_all
, NULL
, 0, NULL
);
594 ok(!err
,"mci %s (without buffer) returned %s\n", command_close_all
, dbg_mcierr(err
));
596 err
= mciSendStringA(command_close_all
, buf
, sizeof(buf
), hwnd
);
597 ok(!err
,"mci %s (with output buffer) returned %s\n", command_close_all
, dbg_mcierr(err
));
598 ok(buf
[0] == 0, "mci %s output buffer: %s\n", command_close_all
, buf
);
599 /* No notification left, everything closed already */
600 test_notification(hwnd
, command_close_all
, 0);
601 /* TODO test close all sends one notification per open device */
603 err
= mciSendStringA(command_sysinfo
, buf
, sizeof(buf
), NULL
);
604 ok(!err
,"mci %s returned %s\n", command_sysinfo
, dbg_mcierr(err
));
605 ok(buf
[0] == '0' && buf
[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo
, buf
);
607 err
= mciSendStringA("open new type waveaudio", buf
, sizeof(buf
), NULL
);
608 ok(err
==MCIERR_NEW_REQUIRES_ALIAS
,"mci open new without alias returned %s\n", dbg_mcierr(err
));
610 parm
.open
.lpstrDeviceType
= (LPSTR
)MCI_DEVTYPE_WAVEFORM_AUDIO
;
611 err
= mciSendCommandA(0, MCI_OPEN
, MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
, (DWORD_PTR
)&parm
);
612 ok(!err
,"mciCommand OPEN_TYPE_ID waveaudio: %s\n", dbg_mcierr(err
));
615 MCIDEVICEID wDeviceID
= parm
.open
.wDeviceID
;
616 parm
.caps
.dwItem
= MCI_GETDEVCAPS_DEVICE_TYPE
;
617 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&parm
);
618 ok(!err
,"mciCommand MCI_GETDEVCAPS device type: %s\n", dbg_mcierr(err
));
619 ok(MCI_DEVTYPE_WAVEFORM_AUDIO
==parm
.caps
.dwReturn
,"mciCommand GETDEVCAPS says %lu, expected %u\n", parm
.caps
.dwReturn
, MCI_DEVTYPE_WAVEFORM_AUDIO
);
622 ok(0xDEADF00D==intbuf
[0] && 0xABADCAFE==intbuf
[2],"DWORD buffer corruption\n");
624 err
= mciGetDeviceIDA("waveaudio");
625 ok(err
== 1, "mciGetDeviceIDA waveaudio returned %lu, expected 1\n", err
);
627 err
= mciSendStringA("open no-such-file.wav alias waveaudio", buf
, sizeof(buf
), NULL
);
628 ok(err
==MCIERR_DUPLICATE_ALIAS
, "mci open alias waveaudio returned %s\n", dbg_mcierr(err
));
629 /* If it were not already in use, open avivideo alias waveaudio would succeed,
630 * making for funny test cases. */
632 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_WAIT
, 0); /* from MSDN */
633 ok(!err
, "mciCommand close returned %s\n", dbg_mcierr(err
));
635 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_NOTIFY
, 0);
636 ok(!err
, "mciCommand close returned %s\n", dbg_mcierr(err
));
638 parm
.gen
.dwCallback
= (DWORD_PTR
)hwnd
;
639 err
= mciSendCommandA(MCI_ALL_DEVICE_ID
, MCI_CLOSE
, MCI_NOTIFY
, (DWORD_PTR
)&parm
);
640 ok(!err
, "mciCommand close returned %s\n", dbg_mcierr(err
));
641 test_notification(hwnd
, command_close_all
, 0); /* None left */
644 static void test_recordWAVE(HWND hwnd
)
648 DWORD nsamp
= 16000, expect
;
649 UINT ndevs
= waveInGetNumDevs();
650 MCIERROR err
, ok_pcm
;
651 MCIDEVICEID wDeviceID
;
652 MCI_PARMS_UNION parm
;
654 memset(buf
, 0, sizeof(buf
));
655 test_notification(hwnd
, "-prior to recording-", 0);
657 parm
.open
.lpstrDeviceType
= "waveaudio";
658 parm
.open
.lpstrElementName
= ""; /* "new" at the command level */
659 parm
.open
.lpstrAlias
= "x"; /* to enable mciSendStringA */
660 parm
.open
.dwCallback
= (DWORD_PTR
)hwnd
;
661 err
= mciSendCommandA(0, MCI_OPEN
,
662 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| MCI_OPEN_ALIAS
| MCI_NOTIFY
, (DWORD_PTR
)&parm
);
663 ok(!err
,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err
));
664 wDeviceID
= parm
.open
.wDeviceID
;
666 err
= mciGetDeviceIDA("x");
667 ok(err
== wDeviceID
, "mciGetDeviceIDA x returned %lu, expected %u\n", err
, wDeviceID
);
669 /* Only the alias is looked up. */
670 err
= mciGetDeviceIDA("waveaudio");
671 ok(!err
, "mciGetDeviceIDA waveaudio returned %lu, expected 0\n", err
);
673 test_notification(hwnd
, "open new", MCI_NOTIFY_SUCCESSFUL
);
674 test_notification(hwnd
, "open new no #2", 0);
676 /* Do not query time format as string because result depends on locale! */
677 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
678 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
679 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
680 ok(parm
.status
.dwReturn
==MCI_FORMAT_MILLISECONDS
,"status time format: %Id\n",parm
.status
.dwReturn
);
682 /* Info file fails until named in Open or Save. */
683 err
= mciSendStringA("info x file", buf
, sizeof(buf
), NULL
);
684 todo_wine
ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci info new file returned %s\n", dbg_mcierr(err
));
685 ok(!buf
[0], "info error buffer %s\n", buf
);
687 err
= mciSendStringA("status x length", buf
, sizeof(buf
), NULL
);
688 todo_wine
ok(!err
,"status x length initial: %s\n", dbg_mcierr(err
));
689 if(!err
) ok(!strcmp(buf
,"0"), "mci status length expected 0, got: %s\n", buf
);
691 /* Check the default recording: 8-bits per sample, mono, 11kHz */
692 err
= mciSendStringA("status x samplespersec", buf
, sizeof(buf
), NULL
);
693 ok(!err
,"mci status samplespersec returned %s\n", dbg_mcierr(err
));
694 if(!err
) ok(!strcmp(buf
,"11025"), "mci status samplespersec expected 11025, got: %s\n", buf
);
696 /* MCI appears to scan the available devices for support of this format,
697 * returning MCIERR_OUTOFRANGE on machines with no sound.
698 * However some w2k8/w7 machines return no error when there's no wave
699 * input device (perhaps querying waveOutGetNumDevs instead of waveIn?),
700 * still the record command below fails with MCIERR_WAVE_INPUTSUNSUITABLE.
701 * Don't skip here, record will fail below. */
702 err
= mciSendStringA("set x format tag pcm", NULL
, 0, NULL
);
703 ok(!err
|| err
==MCIERR_OUTOFRANGE
,"mci set format tag pcm returned %s\n", dbg_mcierr(err
));
706 /* MSDN warns against not setting all wave format parameters.
707 * Indeed, it produces strange results, incl.
708 * inconsistent PCMWAVEFORMAT headers in the saved file.
710 err
= mciSendStringA("set x bytespersec 22050 alignment 2 samplespersec 11025 channels 1 bitspersample 16", NULL
, 0, NULL
);
711 ok(err
==ok_pcm
,"mci set 5 wave parameters returned %s\n", dbg_mcierr(err
));
712 /* Investigate: on w2k, set samplespersec 22050 sets nChannels to 2!
713 * err = mciSendStringA("set x samplespersec 22050", NULL, 0, NULL);
714 * ok(!err,"mci set samplespersec returned %s\n", dbg_mcierr(err));
717 /* Checks are generally performed immediately. */
718 err
= mciSendStringA("set x bitspersample 4", NULL
, 0, NULL
);
719 todo_wine
ok(err
==MCIERR_OUTOFRANGE
,"mci set bitspersample 4 returned %s\n", dbg_mcierr(err
));
721 parm
.set
.wFormatTag
= WAVE_FORMAT_PCM
;
722 parm
.set
.nSamplesPerSec
= nsamp
;
723 parm
.set
.wBitsPerSample
= nbits
;
724 parm
.set
.nChannels
= nch
;
725 parm
.set
.nBlockAlign
= parm
.set
.nChannels
* parm
.set
.wBitsPerSample
/8;
726 parm
.set
.nAvgBytesPerSec
= parm
.set
.nSamplesPerSec
* parm
.set
.nBlockAlign
;
727 err
= mciSendCommandA(wDeviceID
, MCI_SET
,
728 MCI_WAVE_SET_SAMPLESPERSEC
| MCI_WAVE_SET_CHANNELS
| MCI_WAVE_SET_BITSPERSAMPLE
|
729 MCI_WAVE_SET_BLOCKALIGN
| MCI_WAVE_SET_AVGBYTESPERSEC
| MCI_WAVE_SET_FORMATTAG
,
731 ok(err
==ok_pcm
,"mciCommand set wave format: %s\n", dbg_mcierr(err
));
733 parm
.caps
.dwItem
= MCI_WAVE_GETDEVCAPS_INPUTS
;
734 parm
.caps
.dwCallback
= (DWORD_PTR
)hwnd
;
735 err
= mciSendCommandA(wDeviceID
, MCI_GETDEVCAPS
, MCI_GETDEVCAPS_ITEM
| MCI_NOTIFY
,
737 ok(!err
,"mciCommand MCI_GETDEVCAPS inputs: %s\n", dbg_mcierr(err
));
738 ok(parm
.caps
.dwReturn
==ndevs
,"mciCommand GETDEVCAPS claims %lu inputs, expected %u\n", parm
.caps
.dwReturn
, ndevs
);
739 ok(!ok_pcm
|| !parm
.caps
.dwReturn
,"No input device accepts PCM!?\n");
740 test_notification(hwnd
, "GETDEVCAPS inputs", MCI_NOTIFY_SUCCESSFUL
);
742 /* A few ME machines pass all tests except set format tag pcm! */
743 err
= mciSendStringA("record x to 2000 wait", NULL
, 0, hwnd
);
744 ok(err
|| !ok_pcm
,"can record yet set wave format pcm returned %s\n", dbg_mcierr(ok_pcm
));
745 todo_wine_if (!ndevs
) /* with sound disabled */
746 ok(ndevs
> 0 ? !err
: err
== MCIERR_WAVE_INPUTSUNSUITABLE
, "mci record to 2000 returned %s\n", dbg_mcierr(err
));
748 if (err
==MCIERR_WAVE_INPUTSUNSUITABLE
)
749 skip("Please install audio driver. Everything is skipped.\n");
750 else skip("Cannot record cause %s. Everything is skipped.\n", dbg_mcierr(err
));
752 err
= mciSendStringA("close x", NULL
, 0, NULL
);
753 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
754 test_notification(hwnd
,"record skipped",0);
758 /* Query some wave format parameters depending on the time format. */
759 err
= mciSendStringA("status x position", buf
, sizeof(buf
), NULL
);
760 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
761 if(!err
) todo_wine
ok(!strcmp(buf
,"2000"), "mci status position gave %s, expected 2000, some tests will fail\n", buf
);
763 err
= mciSendStringA("set x time format 8", NULL
, 0, NULL
); /* bytes */
764 ok(!err
,"mci returned %s\n", dbg_mcierr(err
));
766 parm
.status
.dwItem
= MCI_STATUS_POSITION
;
767 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
768 ok(!err
,"mciCommand status position: %s\n", dbg_mcierr(err
));
769 expect
= 2 * nsamp
* nch
* nbits
/8;
770 if(!err
) todo_wine
ok(parm
.status
.dwReturn
==expect
,"recorded %Iu bytes, expected %lu\n",parm
.status
.dwReturn
,expect
);
772 parm
.set
.dwTimeFormat
= MCI_FORMAT_SAMPLES
;
773 err
= mciSendCommandA(wDeviceID
, MCI_SET
, MCI_SET_TIME_FORMAT
, (DWORD_PTR
)&parm
);
774 ok(!err
,"mciCommand set time format samples: %s\n", dbg_mcierr(err
));
776 parm
.status
.dwItem
= MCI_STATUS_POSITION
;
777 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
778 ok(!err
,"mciCommand status position: %s\n", dbg_mcierr(err
));
780 if(!err
) todo_wine
ok(parm
.status
.dwReturn
==expect
,"recorded %Iu samples, expected %lu\n",parm
.status
.dwReturn
,expect
);
782 err
= mciSendStringA("set x time format milliseconds", NULL
, 0, NULL
);
783 ok(!err
,"mci set time format milliseconds returned %s\n", dbg_mcierr(err
));
785 err
= mciSendStringA("save x tempfile1.wav", NULL
, 0, NULL
);
786 ok(!err
,"mci save returned %s\n", dbg_mcierr(err
));
788 err
= mciSendStringA("save x tempfile.wav", NULL
, 0, NULL
);
789 ok(!err
,"mci save returned %s\n", dbg_mcierr(err
));
790 if(!err
) ok_saved
= 0;
792 /* Save must not rename the original file. */
793 if (!DeleteFileA("tempfile1.wav"))
794 todo_wine
ok(FALSE
, "Save must not rename the original file; DeleteFileA returned %ld\n",
797 err
= mciSendStringA("set x channels 2", NULL
, 0, NULL
);
798 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci set channels after saving returned %s\n", dbg_mcierr(err
));
800 parm
.seek
.dwTo
= 600;
801 err
= mciSendCommandA(wDeviceID
, MCI_SEEK
, MCI_TO
| MCI_WAIT
, (DWORD_PTR
)&parm
);
802 ok(!err
,"mciCommand seek to 600: %s\n", dbg_mcierr(err
));
804 /* Truncate to current position */
805 err
= mciSendStringA("delete x", NULL
, 0, NULL
);
806 todo_wine
ok(!err
,"mci delete returned %s\n", dbg_mcierr(err
));
808 err
= mciSendStringA("status x length", buf
, sizeof(buf
), NULL
);
809 ok(!err
,"mci status length returned %s\n", dbg_mcierr(err
));
810 todo_wine
ok(!strcmp(buf
,"600"), "mci status length after delete gave %s, expected 600\n", buf
);
812 err
= mciSendStringA("close x", NULL
, 0, NULL
);
813 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
814 test_notification(hwnd
,"record complete",0);
817 static void test_playWAVE(HWND hwnd
)
821 memset(buf
, 0, sizeof(buf
));
823 err
= mciSendStringA("open waveaudio!tempfile.wav alias mysound", NULL
, 0, NULL
);
824 ok(err
==ok_saved
,"mci open waveaudio!tempfile.wav returned %s\n", dbg_mcierr(err
));
826 skip("Cannot open waveaudio!tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
830 err
= mciGetDeviceIDA("mysound");
831 ok(err
== 1, "mciGetDeviceIDA mysound returned %lu, expected 1\n", err
);
833 err
= mciGetDeviceIDA("tempfile.wav");
834 ok(!err
, "mciGetDeviceIDA tempfile.wav returned %lu, expected 0\n", err
);
836 err
= mciGetDeviceIDA("waveaudio");
837 ok(!err
, "mciGetDeviceIDA waveaudio returned %lu, expected 0\n", err
);
839 err
= mciSendStringA("status mysound length", buf
, sizeof(buf
), NULL
);
840 ok(!err
,"mci status length returned %s\n", dbg_mcierr(err
));
841 todo_wine
ok(!strcmp(buf
,"2000"), "mci status length gave %s, expected 2000, some tests will fail.\n", buf
);
843 err
= mciSendStringA("cue output", NULL
, 0, NULL
);
844 ok(err
==MCIERR_UNRECOGNIZED_COMMAND
,"mci incorrect cue output returned %s\n", dbg_mcierr(err
));
846 /* Test MCI to the bones -- Some todo_wine from Cue and
847 * from Play from 0 to 0 are not worth fixing. */
848 err
= mciSendStringA("cue mysound output notify", NULL
, 0, hwnd
);
849 ok(!err
,"mci cue output after open file returned %s\n", dbg_mcierr(err
));
850 /* Notification is delayed as a play thread is started. */
851 todo_wine
test_notification(hwnd
, "cue immediate", 0);
853 /* Cue pretends to put the MCI into paused state. */
854 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
855 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
856 todo_wine
ok(!strcmp(buf
,"paused"), "mci status mode: %s, expected (pseudo)paused\n", buf
);
858 /* Strange pause where Pause is rejected, unlike Play; Pause; Pause tested below */
859 err
= mciSendStringA("pause mysound", NULL
, 0, hwnd
);
860 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci pause after cue returned %s\n", dbg_mcierr(err
));
862 /* MCI appears to start the play thread in this border case.
863 * Guessed that from (flaky) status mode and late notification arrival. */
864 err
= mciSendStringA("play mysound from 0 to 0 notify", NULL
, 0, hwnd
);
865 ok(!err
,"mci play from 0 to 0 returned %s\n", dbg_mcierr(err
));
866 todo_wine
test_notification(hwnd
, "cue aborted by play", MCI_NOTIFY_ABORTED
);
867 /* play's own notification follows below */
869 err
= mciSendStringA("play mysound from 250 to 0", NULL
, 0, NULL
);
870 ok(err
==MCIERR_OUTOFRANGE
,"mci play from 250 to 0 returned %s\n", dbg_mcierr(err
));
872 Sleep(100); /* Give play from 0 to 0 time to finish. */
873 todo_wine
test_notification(hwnd
, "play from 0 to 0", MCI_NOTIFY_SUCCESSFUL
);
875 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
876 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
877 ok(!strcmp(buf
,"stopped"), "mci status mode: %s after play from 0 to 0\n", buf
);
879 err
= mciSendStringA("play MYSOUND from 250 to 0 notify", NULL
, 0, hwnd
);
880 ok(err
==MCIERR_OUTOFRANGE
,"mci play from 250 to 0 notify returned %s\n", dbg_mcierr(err
));
881 /* No notification (checked below) sent if error */
883 /* A second play caused Wine<1.1.33 to hang */
884 err
= mciSendStringA("play mysound from 500 to 220:5:0 wait", NULL
, 0, NULL
);
885 ok(!err
,"mci play from 500 to 220:5:0 (=1500) returned %s\n", dbg_mcierr(err
));
887 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
888 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
889 if(!err
) ok(!strcmp(buf
,"1500"), "mci status position: %s\n", buf
);
891 /* mci will not play position < current */
892 err
= mciSendStringA("play mysound to 1000", NULL
, 0, NULL
);
893 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 1000 returned %s\n", dbg_mcierr(err
));
895 /* mci will not play to > end */
896 err
= mciSendStringA("play mysound TO 3000 notify", NULL
, 0, hwnd
);
897 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 3000 notify returned %s\n", dbg_mcierr(err
));
899 err
= mciSendStringA("play mysound to 2000", NULL
, 0, NULL
);
900 ok(!err
,"mci play to 2000 returned %s\n", dbg_mcierr(err
));
902 /* Rejected while playing */
903 err
= mciSendStringA("cue mysound output", NULL
, 0, NULL
);
904 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci cue output while playing returned %s\n", dbg_mcierr(err
));
906 err
= mciSendStringA("play mysound to 3000", NULL
, 0, NULL
);
907 ok(err
==MCIERR_OUTOFRANGE
,"mci play to 3000 returned %s\n", dbg_mcierr(err
));
909 err
= mciSendStringA("stop mysound Wait", NULL
, 0, NULL
);
910 ok(!err
,"mci stop wait returned %s\n", dbg_mcierr(err
));
911 test_notification(hwnd
, "play/cue/pause/stop", 0);
913 err
= mciSendStringA("Seek Mysound to 250 wait Notify", NULL
, 0, hwnd
);
914 ok(!err
,"mci seek to 250 wait notify returned %s\n", dbg_mcierr(err
));
915 test_notification(hwnd
,"seek wait notify",MCI_NOTIFY_SUCCESSFUL
);
917 err
= mciSendStringA("seek mysound to 0xfa", NULL
, 0, NULL
);
918 ok(err
==MCIERR_BAD_INTEGER
,"mci seek to 0xfa returned %s\n", dbg_mcierr(err
));
920 /* MCI_INTEGER always accepts colon notation */
921 err
= mciSendStringA("seek mysound to :1", NULL
, 0, NULL
);
922 ok(!err
,"mci seek to :1 (=256) returned %s\n", dbg_mcierr(err
));
924 err
= mciSendStringA("seek mysound to 250::", NULL
, 0, NULL
);
925 ok(!err
,"mci seek to 250:: returned %s\n", dbg_mcierr(err
));
927 err
= mciSendStringA("seek mysound to 250:0", NULL
, 0, NULL
);
928 ok(!err
,"mci seek to 250:0 returned %s\n", dbg_mcierr(err
));
930 err
= mciSendStringA("status mysound position notify", buf
, sizeof(buf
), hwnd
);
931 ok(!err
,"mci status position notify returned %s\n", dbg_mcierr(err
));
932 if(!err
) ok(!strcmp(buf
,"250"), "mci status position: %s\n", buf
);
933 /* Immediate commands like status also send notifications. */
934 test_notification(hwnd
,"status position",MCI_NOTIFY_SUCCESSFUL
);
936 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
937 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
938 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
940 /* Another play from == to testcase */
941 err
= mciSendStringA("play mysound to 250 wait notify", NULL
, 0, hwnd
);
942 ok(!err
,"mci play (from 250) to 250 returned %s\n", dbg_mcierr(err
));
943 todo_wine
test_notification(hwnd
,"play to 250 wait notify",MCI_NOTIFY_SUCCESSFUL
);
945 err
= mciSendStringA("cue mysound output", NULL
, 0, NULL
);
946 ok(!err
,"mci cue output after play returned %s\n", dbg_mcierr(err
));
948 err
= mciSendStringA("close mysound", NULL
, 0, NULL
);
949 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
950 test_notification(hwnd
,"after close",0);
953 static void test_asyncWAVE(HWND hwnd
)
955 MCIDEVICEID wDeviceID
;
956 MCI_PARMS_UNION parm
;
959 memset(buf
, 0, sizeof(buf
));
961 err
= mciSendStringA("open tempfile.wav alias mysound notify type waveaudio", buf
, sizeof(buf
), hwnd
);
962 ok(err
==ok_saved
,"mci open tempfile.wav returned %s\n", dbg_mcierr(err
));
964 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
967 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
968 wDeviceID
= atoi(buf
);
969 ok(wDeviceID
,"mci open DeviceID: %d\n", wDeviceID
);
970 test_notification(hwnd
,"open alias notify",MCI_NOTIFY_SUCCESSFUL
);
972 err
= mciGetDeviceIDA("mysound");
973 ok(err
== wDeviceID
, "mciGetDeviceIDA alias returned %u, expected %u\n", err
, wDeviceID
);
975 /* Only the alias is looked up. */
976 err
= mciGetDeviceIDA("tempfile.wav");
977 ok(!err
, "mciGetDeviceIDA tempfile.wav returned %u, expected 0\n", err
);
979 err
= mciGetDeviceIDA("waveaudio");
980 ok(!err
, "mciGetDeviceIDA waveaudio returned %u, expected 0\n", err
);
982 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
983 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
984 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
986 err
= mciSendStringA("play mysound notify", NULL
, 0, hwnd
);
987 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
989 Sleep(500); /* milliseconds */
991 /* Do not query time format as string because result depends on locale! */
992 parm
.status
.dwItem
= MCI_STATUS_TIME_FORMAT
;
993 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&parm
);
994 ok(!err
,"mciCommand status time format: %s\n", dbg_mcierr(err
));
995 if(!err
) ok(parm
.status
.dwReturn
==MCI_FORMAT_MILLISECONDS
,"status time format: %Id\n",parm
.status
.dwReturn
);
997 parm
.set
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
998 err
= mciSendCommandA(wDeviceID
, MCI_SET
, MCI_SET_TIME_FORMAT
, (DWORD_PTR
)&parm
);
999 ok(!err
,"mciCommand set time format ms: %s\n", dbg_mcierr(err
));
1001 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1002 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1003 trace("position after Sleep: %sms\n", buf
);
1005 /* Check that the 2s sound plays at a normal pace, giving a wide margin to
1006 * account for timing granularity and small delays.
1008 todo_wine
ok(350 <= p2
&& p2
<= 600, "%ums is not in the expected 350-600ms range\n", p2
);
1009 /* Wine's asynchronous thread needs some time to start up. Furthermore, it
1010 * uses 3 buffers per second, so that the positions reported will be 333ms,
1011 * 667ms etc. at best, which is why it fails the above test. So add a
1012 * second test specifically to prevent Wine from getting even worse.
1013 * FIXME: To be removed when Wine is fixed and passes the above test.
1015 ok(350 <= p2
&& p2
<= 1000, "%ums is not even in the expected 350-1000ms range\n", p2
);
1016 test_notification(hwnd
,"play (nowait)",0);
1018 err
= mciSendStringA("pause mysound wait", NULL
, 0, hwnd
);
1019 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1021 err
= mciSendStringA("status mysound mode notify", buf
, sizeof(buf
), hwnd
);
1022 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1023 if(!err
) ok(!strcmp(buf
,"paused"), "mci status mode: %s\n", buf
);
1024 test_notification(hwnd
,"play",MCI_NOTIFY_SUPERSEDED
);
1025 test_notification(hwnd
,"status",MCI_NOTIFY_SUCCESSFUL
);
1027 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1028 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1029 trace("position while paused: %sms\n",buf
);
1031 ok(p1
>=p2
, "position not increasing: %u > %u\n", p2
, p1
);
1033 err
= mciSendStringA("stop mysound wait", NULL
, 0, NULL
);
1034 ok(!err
,"mci stop returned %s\n", dbg_mcierr(err
));
1036 err
= mciSendStringA("info mysound file notify", buf
, sizeof(buf
), hwnd
);
1037 ok(!err
,"mci info file returned %s\n", dbg_mcierr(err
));
1038 if(!err
) { /* fully qualified name */
1039 int len
= strlen(buf
);
1040 todo_wine
ok(len
>2 && buf
[1]==':',"Expected full pathname from info file: %s\n", buf
);
1041 ok(len
>=12 && !strcmp(&buf
[len
-12],"tempfile.wav"), "info file returned: %s\n", buf
);
1043 test_notification(hwnd
,"info file",MCI_NOTIFY_SUCCESSFUL
);
1045 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), hwnd
);
1046 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1047 ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
1049 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1050 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1051 trace("position once stopped: %sms\n",buf
);
1053 /* An XP machine let the position increase slightly after pause. */
1054 ok(p2
>=p1
&& p2
<=p1
+16,"position changed from %ums to %ums\n",p1
,p2
);
1056 /* No Resume once stopped (waveaudio, sequencer and cdaudio differ). */
1057 err
= mciSendStringA("resume mysound wait", NULL
, 0, NULL
);
1058 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci resume wait returned %s\n", dbg_mcierr(err
));
1060 err
= mciSendStringA("play mysound wait", NULL
, 0, NULL
);
1061 ok(!err
,"mci play wait returned %s\n", dbg_mcierr(err
));
1063 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), hwnd
);
1064 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1065 todo_wine
ok(!strcmp(buf
,"2000"), "mci status position: %s\n", buf
);
1067 err
= mciSendStringA("seek mysound to start wait", NULL
, 0, NULL
);
1068 ok(!err
,"mci seek to start wait returned %s\n", dbg_mcierr(err
));
1070 err
= mciSendStringA("play mysound to 1000 notify", NULL
, 0, hwnd
);
1071 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1073 /* Sleep(200); not needed with Wine any more. */
1075 err
= mciSendStringA("pause mysound notify", NULL
, 0, NULL
); /* notify no callback */
1076 ok(!err
,"mci pause notify returned %s\n", dbg_mcierr(err
));
1077 /* Supersede even though pause cannot notify given no callback */
1078 test_notification(hwnd
,"pause aborted play #1 notification",MCI_NOTIFY_SUPERSEDED
);
1079 test_notification(hwnd
,"impossible pause notification",0);
1081 err
= mciSendStringA("cue mysound output notify", NULL
, 0, hwnd
);
1082 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci cue output while paused returned %s\n", dbg_mcierr(err
));
1083 test_notification(hwnd
,"cue output notify #2",0);
1085 err
= mciSendStringA("resume mysound notify", NULL
, 0, hwnd
);
1086 ok(!err
,"mci resume notify returned %s\n", dbg_mcierr(err
));
1087 test_notification(hwnd
, "resume notify", MCI_NOTIFY_SUCCESSFUL
);
1089 /* Seek or even Stop used to hang Wine<1.1.32 on MacOS. */
1090 err
= mciSendStringA("seek mysound to 0 wait", NULL
, 0, NULL
);
1091 ok(!err
,"mci seek to start returned %s\n", dbg_mcierr(err
));
1094 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1095 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1096 if(!err
) ok(!strcmp(buf
,"stopped"), "mci status mode: %s\n", buf
);
1098 err
= mciSendStringA("seek mysound wait", NULL
, 0, NULL
);
1099 ok(err
==MCIERR_MISSING_PARAMETER
,"mci seek to nowhere returned %s\n", dbg_mcierr(err
));
1101 /* cdaudio does not detect to start to end as error */
1102 err
= mciSendStringA("seek mysound to start to 0", NULL
, 0, NULL
);
1103 ok(err
==MCIERR_FLAGS_NOT_COMPATIBLE
,"mci seek to start to 0 returned %s\n", dbg_mcierr(err
));
1105 err
= mciSendStringA("PLAY mysound to 1000 notify", NULL
, 0, hwnd
);
1106 ok(!err
,"mci play to 1000 notify returned %s\n", dbg_mcierr(err
));
1108 /* Sleep(200); not needed with Wine any more. */
1109 /* Give it 400ms and resume will appear to complete below. */
1111 err
= mciSendStringA("pause mysound wait", NULL
, 0, NULL
);
1112 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1113 /* Unlike sequencer and cdaudio, waveaudio's pause does not abort. */
1114 test_notification(hwnd
,"pause aborted play #2 notification",0);
1116 err
= mciSendStringA("resume mysound wait", NULL
, 0, NULL
);
1117 ok(!err
,"mci resume wait returned %s\n", dbg_mcierr(err
));
1118 /* Resume is a short asynchronous call, something else is playing. */
1120 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1121 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1122 if(!err
) ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1124 /* Note extra space before alias */
1125 err
= mciSendStringA("pause mysound wait", NULL
, 0, NULL
);
1126 todo_wine
ok(!err
,"mci pause (space) wait returned %s\n", dbg_mcierr(err
));
1128 err
= mciSendStringA("pause mysound wait", NULL
, 0, NULL
);
1129 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1131 /* Better ask position only when paused, is it updated while playing? */
1132 err
= mciSendStringA("status mysound position", buf
, sizeof(buf
), NULL
);
1133 ok(!err
,"mci status position returned %s\n", dbg_mcierr(err
));
1134 /* TODO compare position < 900 */
1135 ok(strcmp(buf
,"1000"), "mci resume waited\n");
1136 ok(strcmp(buf
,"2000"), "mci resume played to end\n");
1137 trace("position after resume: %sms\n",buf
);
1138 test_notification(hwnd
,"play (aborted by pause/resume/pause)",0);
1140 /* A small Sleep() here prevents the notification test failing with MCI_NOTIFY_SUCCESSFUL */
1142 err
= mciSendStringA("close mysound wait", NULL
, 0, NULL
);
1143 ok(!err
,"mci close wait returned %s\n", dbg_mcierr(err
));
1144 test_notification(hwnd
,"play (aborted by close)",MCI_NOTIFY_ABORTED
);
1147 static void test_AutoOpenWAVE(HWND hwnd
)
1149 /* This test used(?) to cause intermittent crashes when Wine exits, after
1150 * fixme:winmm:MMDRV_Exit Closing while ll-driver open
1152 UINT ndevs
= waveOutGetNumDevs();
1153 MCIERROR err
, ok_snd
= ndevs
? 0 : MCIERR_HARDWARE
;
1154 MCI_PARMS_UNION parm
;
1155 char buf
[512], path
[300], command
[330];
1156 DWORD intbuf
[3] = { 0xDEADF00D, 99, 0xABADCAFE };
1157 memset(buf
, 0, sizeof(buf
)); memset(path
, 0, sizeof(path
));
1159 /* Do not crash on NULL buffer pointer */
1160 err
= mciSendStringA("sysinfo waveaudio quantity open", NULL
, 0, NULL
);
1161 ok(err
==MCIERR_PARAM_OVERFLOW
,"mci sysinfo without buffer returned %s\n", dbg_mcierr(err
));
1163 err
= mciSendStringA("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1164 ok(!err
,"mci sysinfo waveaudio quantity open returned %s\n", dbg_mcierr(err
));
1165 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf
);
1167 /* Who knows why some MS machines pass all tests but return MCIERR_HARDWARE here? */
1168 /* Wine returns MCIERR_HARDWARE when no default sound is found in win.ini or the registry. */
1169 err
= mciSendStringA("sound NoSuchSoundDefined wait", NULL
, 0, NULL
);
1170 ok(err
==ok_snd
|| err
==MCIERR_HARDWARE
, "mci sound NoSuchSoundDefined returned %s\n", dbg_mcierr(err
));
1172 err
= mciSendStringA("sound SystemExclamation notify wait", NULL
, 0, hwnd
);
1173 ok(err
==ok_snd
|| err
==MCIERR_HARDWARE
, "mci sound SystemExclamation returned %s\n", dbg_mcierr(err
));
1174 test_notification(hwnd
, "sound notify", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
1176 Sleep(16); /* time to auto-close makes sysinfo below return expected error */
1177 err
= mciSendStringA("sysinfo waveaudio notify name 1 open", buf
, sizeof(buf
), hwnd
);
1178 ok(err
==MCIERR_OUTOFRANGE
,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err
));
1179 if(!err
) trace("sysinfo dangling open alias: %s\n", buf
);
1180 test_notification(hwnd
, "sysinfo name outofrange\n", err
? 0 : MCI_NOTIFY_SUCCESSFUL
);
1182 err
= mciSendStringA("play no-such-file-exists.wav notify", buf
, sizeof(buf
), NULL
);
1183 todo_wine
ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open notify returned %s\n", dbg_mcierr(err
));
1184 /* FILE_NOT_FOUND in Wine because auto-open fails before testing the notify flag */
1186 test_notification(hwnd
, "-prior to auto-open-", 0);
1188 err
= mciSendStringA("play tempfile.wav notify", buf
, sizeof(buf
), hwnd
);
1189 todo_wine_if (ok_saved
== MCIERR_FILE_NOT_FOUND
) /* same as above */
1190 ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
,"mci auto-open play notify returned %s\n", dbg_mcierr(err
));
1192 if(err
) /* FIXME: don't open twice yet, it confuses Wine. */
1193 err
= mciSendStringA("play tempfile.wav", buf
, sizeof(buf
), hwnd
);
1194 ok(err
==ok_saved
,"mci auto-open play returned %s\n", dbg_mcierr(err
));
1196 if(err
==MCIERR_FILE_NOT_FOUND
) {
1197 skip("Cannot open tempfile.wav for auto-play, skipping\n");
1201 err
= mciSendStringA("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1202 ok(!err
,"mci sysinfo waveaudio quantity after auto-open returned %s\n", dbg_mcierr(err
));
1203 if(!err
) ok(!strcmp(buf
,"1"), "sysinfo quantity open expected 1, got: %s\n", buf
);
1205 parm
.sys
.lpstrReturn
= (LPSTR
)&intbuf
[1];
1206 parm
.sys
.dwRetSize
= 2*sizeof(DWORD
); /* only one DWORD is used */
1207 parm
.sys
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
;
1208 err
= mciSendCommandA(0, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
| MCI_SYSINFO_OPEN
, (DWORD_PTR
)&parm
);
1209 ok(!err
, "mciCommand sysinfo waveaudio open notify returned %s\n", dbg_mcierr(err
));
1210 if(!err
) ok(atoi(buf
)==intbuf
[1],"sysinfo waveaudio quantity open string and command differ\n");
1212 err
= mciSendStringA("sysinfo waveaudio name 1 open notify", buf
, sizeof(buf
), hwnd
);
1213 ok(!err
,"mci sysinfo waveaudio name after auto-open returned %s\n", dbg_mcierr(err
));
1214 /* This is the alias, not necessarily a file name. */
1215 if(!err
) ok(!strcmp(buf
,"tempfile.wav"), "sysinfo name 1 open: %s\n", buf
);
1216 test_notification(hwnd
, "sysinfo name notify\n", MCI_NOTIFY_SUCCESSFUL
);
1218 err
= mciGetDeviceIDA("tempfile.wav");
1219 ok(err
== 1, "mciGetDeviceIDA tempfile.wav returned %lu, expected 1\n", err
);
1221 /* Save the full pathname to the file. */
1222 err
= mciSendStringA("info tempfile.wav file", path
, sizeof(path
), NULL
);
1223 ok(!err
,"mci info tempfile.wav file returned %s\n", dbg_mcierr(err
));
1224 if(err
) strcpy(path
,"tempfile.wav");
1226 err
= mciSendStringA("status tempfile.wav mode", NULL
, 0, hwnd
);
1227 ok(!err
,"mci status tempfile.wav mode without buffer returned %s\n", dbg_mcierr(err
));
1229 sprintf(command
,"status \"%s\" mode",path
);
1230 err
= mciSendStringA(command
, buf
, sizeof(buf
), hwnd
);
1231 ok(!err
,"mci status \"%s\" mode returned %s\n", path
, dbg_mcierr(err
));
1233 err
= mciSendStringA("status tempfile.wav mode", buf
, sizeof(buf
), hwnd
);
1234 ok(!err
,"mci status tempfile.wav mode returned %s\n", dbg_mcierr(err
));
1235 if(!err
) ok(!strcmp(buf
,"playing"), "mci auto-open status mode, got: %s\n", buf
);
1237 err
= mciSendStringA("open tempfile.wav", buf
, sizeof(buf
), NULL
);
1238 ok(err
==MCIERR_DEVICE_OPEN
, "mci open from auto-open returned %s\n", dbg_mcierr(err
));
1240 err
= mciSendStringA("open foo.wav alias tempfile.wav", buf
, sizeof(buf
), NULL
);
1241 ok(err
==MCIERR_DUPLICATE_ALIAS
, "mci open re-using alias returned %s\n", dbg_mcierr(err
));
1243 /* w2k/xp and Wine differ. While the device is busy playing, it is
1244 * regularly open and accessible via the filename: subsequent
1245 * commands must not cause auto-open each. In Wine, a subsequent
1246 * command with notify request may cause the initial play
1247 * notification to be superseded, in turn causing MCI to close the
1248 * device. I.e. MCI uses the auto-open notification for itself,
1249 * that's why it's not available to the app. On w2k/xp,
1250 * subsequent commands with notify requests are returned with
1251 * MCIERR_NOTIFY_ON_AUTO_OPEN and thus don't abort the original
1254 err
= mciSendStringA("status tempfile.wav mode notify", buf
, sizeof(buf
), hwnd
);
1255 todo_wine
ok(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
, "mci status auto-open notify returned %s\n", dbg_mcierr(err
));
1257 trace("Wine style MCI auto-close upon notification\n");
1259 /* "playing" because auto-close comes after the status call. */
1260 ok(!strcmp(buf
,"playing"), "mci auto-open status mode notify, got: %s\n", buf
);
1261 /* fixme:winmm:MMDRV_Exit Closing while ll-driver open
1262 * is explained by failure to auto-close a device. */
1263 test_notification(hwnd
,"status notify",MCI_NOTIFY_SUCCESSFUL
);
1264 /* MCI received NOTIFY_SUPERSEDED and auto-closed the device. */
1266 /* Until this is implemented, force closing the device */
1267 err
= mciSendStringA("close tempfile.wav", NULL
, 0, hwnd
);
1268 ok(!err
,"mci auto-still-open stop returned %s\n", dbg_mcierr(err
));
1270 test_notification(hwnd
,"auto-open",0);
1271 } else if(err
==MCIERR_NOTIFY_ON_AUTO_OPEN
) { /* MS style */
1272 trace("MS style MCI auto-open forbids notification\n");
1274 err
= mciSendStringA("pause tempfile.wav", NULL
, 0, hwnd
);
1275 ok(!err
,"mci auto-still-open pause returned %s\n", dbg_mcierr(err
));
1277 err
= mciSendStringA("status tempfile.wav mode", buf
, sizeof(buf
), hwnd
);
1278 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1279 if(!err
) ok(!strcmp(buf
,"paused"), "mci auto-open status mode, got: %s\n", buf
);
1282 err
= mciSendStringA("stop tempfile.wav wait", NULL
, 0, hwnd
);
1283 ok(!err
,"mci auto-still-open stop returned %s\n", dbg_mcierr(err
));
1284 Sleep(16); /* makes sysinfo quantity open below succeed */
1287 err
= mciSendStringA("sysinfo waveaudio quantity open", buf
, sizeof(buf
), NULL
);
1288 ok(!err
,"mci sysinfo waveaudio quantity open after close returned %s\n", dbg_mcierr(err
));
1289 if(!err
) ok(!strcmp(buf
,"0"), "sysinfo quantity open expected 0 after auto-close, got: %s\n", buf
);
1291 /* w95-WinME (not w2k/XP) switch to C:\ after auto-playing once. Prevent
1292 * MCIERR_FILE_NOT_FOUND by using the full path name from the Info file command.
1294 sprintf(command
,"status \"%s\" mode wait",path
);
1295 err
= mciSendStringA(command
, buf
, sizeof(buf
), hwnd
);
1296 ok(!err
,"mci re-auto-open status mode returned %s\n", dbg_mcierr(err
));
1297 if(!err
) ok(!strcmp(buf
,"stopped"), "mci re-auto-open status mode, got: %s\n", buf
);
1299 /* This uses auto-open as well. */
1300 err
= mciSendStringA("capability waveaudio outputs", buf
, sizeof(buf
), NULL
);
1301 ok(!err
,"mci capability waveaudio outputs returned %s\n", dbg_mcierr(err
));
1302 /* Wine with no sound selected in winecfg's audio tab fails this test. */
1303 if(!err
) ok(atoi(buf
)==ndevs
,"Expected %d audio outputs, got %s\n", ndevs
, buf
);
1305 err
= mciSendStringA("capability waveaudio device type", buf
, sizeof(buf
), hwnd
);
1306 ok(!err
,"mci capability device type returned %s\n", dbg_mcierr(err
));
1307 if(!err
) ok(!strcmp(buf
,"waveaudio"), "mci capability device type response: %s\n", buf
);
1309 /* waveaudio forbids Pause without Play. */
1310 sprintf(command
,"pause \"%s\"",path
);
1311 err
= mciSendStringA(command
, NULL
, 0, hwnd
);
1312 ok(err
==MCIERR_NONAPPLICABLE_FUNCTION
,"mci auto-open pause returned %s\n", dbg_mcierr(err
));
1314 ok(0xDEADF00D==intbuf
[0] && 0xABADCAFE==intbuf
[2],"DWORD buffer corruption\n");
1317 static void test_playWaveTypeMpegvideo(void)
1320 MCIDEVICEID wDeviceID
;
1321 MCI_PLAY_PARMS play_parm
;
1322 MCI_STATUS_PARMS status_parm
;
1324 memset(buf
, 0, sizeof(buf
));
1326 err
= mciSendStringA("open tempfile.wav type MPEGVideo alias mysound", NULL
, 0, NULL
);
1327 ok(err
==ok_saved
,"mci open tempfile.wav type MPEGVideo returned %s\n", dbg_mcierr(err
));
1329 skip("Cannot open tempfile.wav type MPEGVideo for playing (%s), skipping\n", dbg_mcierr(err
));
1333 wDeviceID
= mciGetDeviceIDA("mysound");
1334 ok(wDeviceID
== 1, "mciGetDeviceIDA mysound returned %u, expected 1\n", wDeviceID
);
1336 err
= mciSendCommandA(wDeviceID
, MCI_PLAY
, 0, (DWORD_PTR
)&play_parm
);
1337 ok(!err
,"mciCommand play returned %s\n", dbg_mcierr(err
));
1339 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1340 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1341 ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1343 status_parm
.dwItem
= MCI_STATUS_MODE
;
1344 err
= mciSendCommandA(wDeviceID
, MCI_STATUS
,
1346 (DWORD_PTR
)&status_parm
);
1347 ok(!err
,"mciCommand status mode returned %s\n", dbg_mcierr(err
));
1348 ok(status_parm
.dwReturn
== MCI_MODE_PLAY
,
1349 "mciCommand status mode: %lu\n", (DWORD
)status_parm
.dwReturn
);
1351 err
= mciSendStringA("setaudio mysound volume to 1000", NULL
, 0, NULL
);
1352 ok(!err
,"mci setaudio volume to 1000 returned %s\n", dbg_mcierr(err
));
1354 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1355 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1356 ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1358 err
= mciSendStringA("setaudio mysound volume to 1001", NULL
, 0, NULL
);
1359 ok(err
==MCIERR_OUTOFRANGE
,"mci setaudio volume to 1001 returned %s\n", dbg_mcierr(err
));
1361 err
= mciSendStringA("status mysound mode", buf
, sizeof(buf
), NULL
);
1362 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1363 ok(!strcmp(buf
,"playing"), "mci status mode: %s\n", buf
);
1365 err
= mciSendStringA("close mysound", NULL
, 0, NULL
);
1366 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
1368 /* test a second play */
1369 err
= mciSendStringA("open tempfile.wav type MPEGVideo alias mysound", NULL
, 0, NULL
);
1370 ok(err
==ok_saved
,"mci open tempfile.wav type MPEGVideo returned %s\n", dbg_mcierr(err
));
1372 err
= mciSendStringA("play mysound", NULL
, 0, NULL
);
1373 ok(!err
,"mci play retuend %s\n", dbg_mcierr(err
));
1375 err
= mciSendStringA("play mysound", NULL
, 0, NULL
);
1376 ok(!err
,"mci play retuend %s\n", dbg_mcierr(err
));
1378 err
= mciSendStringA("close mysound", NULL
, 0, NULL
);
1379 ok(!err
,"mci close returned %s\n", dbg_mcierr(err
));
1382 static void test_asyncWaveTypeMpegvideo(HWND hwnd
)
1384 MCIDEVICEID wDeviceID
;
1387 memset(buf
, 0, sizeof(buf
));
1389 err
= mciSendStringA("open tempfile.wav alias mysound notify type mpegvideo", buf
, sizeof(buf
), hwnd
);
1390 ok(err
==ok_saved
,"mci open tempfile.wav returned %s\n", dbg_mcierr(err
));
1392 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err
));
1395 ok(!strcmp(buf
,"1"), "mci open deviceId: %s, expected 1\n", buf
);
1396 wDeviceID
= atoi(buf
);
1397 ok(wDeviceID
,"mci open DeviceID: %d\n", wDeviceID
);
1398 test_notification(hwnd
,"open alias notify",MCI_NOTIFY_SUCCESSFUL
);
1400 err
= mciSendStringA("play mysound notify", NULL
, 0, hwnd
);
1401 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1403 Sleep(500); /* milliseconds */
1405 err
= mciSendStringA("pause mysound wait", NULL
, 0, hwnd
);
1406 ok(!err
,"mci pause wait returned %s\n", dbg_mcierr(err
));
1408 err
= mciSendStringA("status mysound mode notify", buf
, sizeof(buf
), hwnd
);
1409 ok(!err
,"mci status mode returned %s\n", dbg_mcierr(err
));
1410 if(!err
) ok(!strcmp(buf
,"paused"), "mci status mode: %s\n", buf
);
1411 test_notification(hwnd
,"play (superseded)",MCI_NOTIFY_SUPERSEDED
);
1412 test_notification(hwnd
,"status",MCI_NOTIFY_SUCCESSFUL
);
1414 err
= mciSendStringA("seek mysound to start wait", NULL
, 0, NULL
);
1415 ok(!err
,"mci seek to start wait returned %s\n", dbg_mcierr(err
));
1417 err
= mciSendStringA("set mysound time format milliseconds", NULL
, 0, NULL
);
1418 ok(!err
,"mci time format milliseconds returned %s\n", dbg_mcierr(err
));
1420 err
= mciSendStringA("play mysound to 1500 notify", NULL
, 0, hwnd
);
1421 ok(!err
,"mci play returned %s\n", dbg_mcierr(err
));
1423 test_notification(hwnd
,"play",0);
1425 err
= mciSendStringA("close mysound wait", NULL
, 0, NULL
);
1426 ok(!err
,"mci close wait returned %s\n", dbg_mcierr(err
));
1427 test_notification(hwnd
,"play (aborted by close)",MCI_NOTIFY_ABORTED
);
1430 static DWORD CALLBACK
thread_cb(void *p
)
1435 mr
= mciSendStringA("play x", NULL
, 0, NULL
);
1436 ok(mr
== MCIERR_INVALID_DEVICE_NAME
, "play gave: 0x%lx\n", mr
);
1438 mr
= mciSendStringA("close x", NULL
, 0, NULL
);
1439 ok(mr
== MCIERR_INVALID_DEVICE_NAME
, "close gave: 0x%lx\n", mr
);
1446 static void test_threads(void)
1451 mr
= mciSendStringA("open tempfile.wav alias x", NULL
, 0, NULL
);
1452 ok(mr
== 0 || mr
== ok_saved
, "open gave: 0x%lx\n", mr
);
1454 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(mr
));
1458 evt
= CreateEventW( NULL
, TRUE
, FALSE
, NULL
);
1460 CloseHandle(CreateThread(NULL
, 0, &thread_cb
, evt
, 0, NULL
));
1462 WaitForSingleObject(evt
, INFINITE
);
1466 mr
= mciSendStringA("close x", NULL
, 0, NULL
);
1467 ok(mr
== 0, "close gave: 0x%lx\n", mr
);
1470 static BOOL CALLBACK
my_visible_window_proc(HWND hwnd
, LPARAM param
)
1472 HWND
*ret
= (HWND
*)param
;
1475 GetWindowThreadProcessId(hwnd
, &pid
);
1476 if (pid
!= GetCurrentProcessId())
1479 if (GetWindowLongW(hwnd
, GWL_STYLE
) & WS_VISIBLE
)
1488 static void test_video_window(void)
1490 const WCHAR
*filename
= load_resource(L
"test.mpg");
1491 MCI_PARMS_UNION parm
;
1501 DWORD expected_style
;
1508 (WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
) & ~WS_MAXIMIZEBOX
,
1511 MCI_DGV_OPEN_PARENT
,
1513 (WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
) & ~WS_MAXIMIZEBOX
,
1518 WS_BORDER
| WS_CLIPSIBLINGS
| WS_BORDER
| WS_DLGFRAME
,
1523 WS_POPUPWINDOW
| WS_CLIPSIBLINGS
,
1526 MCI_DGV_OPEN_PARENT
| MCI_DGV_OPEN_WS
,
1527 WS_OVERLAPPEDWINDOW
,
1528 WS_OVERLAPPEDWINDOW
| WS_CLIPSIBLINGS
,
1531 MCI_DGV_OPEN_PARENT
| MCI_DGV_OPEN_WS
,
1537 for (i
= 0; i
< ARRAY_SIZE(testcase
); ++i
)
1539 HWND parent_window
= NULL
, hwnd
, video_window
;
1540 DWORD style
, expected
;
1541 RECT rc
, src_rc
, win_rc
;
1543 winetest_push_context("%u", i
);
1545 if (testcase
[i
].open_flags
& MCI_DGV_OPEN_PARENT
)
1546 parent_window
= CreateWindowExA(0, "static", "parent",
1547 WS_POPUPWINDOW
, 0, 0, 100, 100, 0, 0, 0, NULL
);
1549 parm
.dgv_open
.lpstrDeviceType
= (WCHAR
*)L
"MPEGVideo";
1550 parm
.dgv_open
.lpstrElementName
= (WCHAR
*)filename
;
1551 parm
.dgv_open
.hWndParent
= parent_window
;
1552 parm
.dgv_open
.dwStyle
= testcase
[i
].style
;
1553 err
= mciSendCommandW(0, MCI_OPEN
,
1554 MCI_OPEN_ELEMENT
| MCI_OPEN_TYPE
| testcase
[i
].open_flags
, (DWORD_PTR
)&parm
);
1555 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1556 id
= parm
.dgv_open
.wDeviceID
;
1558 err
= mciSendCommandW(id
, MCI_PLAY
, 0, (DWORD_PTR
)&parm
);
1559 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1561 if (!(testcase
[i
].style
& WS_CHILD
))
1563 video_window
= NULL
;
1564 EnumWindows(my_visible_window_proc
, (LPARAM
)&video_window
);
1565 todo_wine_if (testcase
[i
].open_flags
& MCI_DGV_OPEN_PARENT
)
1566 ok(video_window
!= NULL
, "Video window should be shown.\n");
1568 /* FIXME: Remove once Wine is fixed */
1569 if (!video_window
) goto next
;
1571 hwnd
= GetWindow(video_window
, GW_OWNER
);
1572 todo_wine_if (testcase
[i
].open_flags
& MCI_DGV_OPEN_PARENT
)
1573 ok(hwnd
== parent_window
, "Got owner %p, expected %p.\n", hwnd
, parent_window
);
1577 ok(!IsWindowVisible(parent_window
), "Parent window should be hidden.\n");
1578 ShowWindow(parent_window
, SW_SHOWNA
);
1580 hwnd
= GetWindow(parent_window
, GW_CHILD
);
1581 ok(hwnd
!= NULL
, "Child video window should be shown.\n");
1582 video_window
= hwnd
;
1585 expected
= testcase
[i
].expected_style
| WS_VISIBLE
;
1586 style
= GetWindowLongW(video_window
, GWL_STYLE
);
1587 todo_wine_if (i
!= 3)
1588 ok(style
== expected
, "Got style %#lx for window %p, expected %#lx.\n", style
, video_window
, expected
);
1590 /* Get the source video size. */
1591 err
= mciSendCommandW(id
, MCI_WHERE
, MCI_DGV_WHERE_SOURCE
, (DWORD_PTR
)&parm
);
1592 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1593 SetRect(&rc
, 0, 0, 32, 24);
1594 ok(EqualRect(&parm
.where
.rc
, &rc
), "Got source rect %s, expected %s.\n",
1595 wine_dbgstr_rect(&parm
.where
.rc
), wine_dbgstr_rect(&rc
));
1596 src_rc
= parm
.where
.rc
;
1598 /* Test the default video destination size. */
1599 err
= mciSendCommandW(id
, MCI_WHERE
, MCI_DGV_WHERE_DESTINATION
, (DWORD_PTR
)&parm
);
1600 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1601 if (style
& (WS_POPUP
| WS_CHILD
))
1604 /* The video destination is stretched to fit the window,
1605 * in particular if the video width is less than SM_CXMIN. */
1606 GetClientRect(video_window
, &rc
);
1608 todo_wine_if (style
& (WS_POPUP
| WS_CHILD
))
1609 ok(EqualRect(&parm
.where
.rc
, &rc
), "Got destination rect %s, expected %s.\n",
1610 wine_dbgstr_rect(&parm
.where
.rc
), wine_dbgstr_rect(&rc
));
1612 /* Test the default video window size. */
1614 /* Windows is broken and always uses WS_OVERLAPPEDWINDOW regardless of
1615 * the window's actual style. */
1616 AdjustWindowRect(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
);
1617 OffsetRect(&rc
, -rc
.left
, -rc
.top
);
1618 rc
.right
= max(rc
.right
, GetSystemMetrics(SM_CXMIN
));
1620 GetWindowRect(video_window
, &win_rc
);
1621 OffsetRect(&rc
, win_rc
.left
, win_rc
.top
);
1622 todo_wine_if (testcase
[i
].style
& WS_CHILD
)
1623 ok(EqualRect(&rc
, &win_rc
), "Got window rect %s, expected %s.\n",
1624 wine_dbgstr_rect(&win_rc
), wine_dbgstr_rect(&rc
));
1626 err
= mciSendCommandW(id
, MCI_WHERE
, MCI_DGV_WHERE_WINDOW
, (DWORD_PTR
)&parm
);
1627 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1628 win_rc
.right
-= win_rc
.left
;
1629 win_rc
.bottom
-= win_rc
.top
;
1630 ok(EqualRect(&win_rc
, &parm
.where
.rc
), "Got rect %s, expected %s.\n",
1631 wine_dbgstr_rect(&parm
.where
.rc
), wine_dbgstr_rect(&win_rc
));
1633 err
= mciSendCommandW(id
, MCI_STOP
, 0, (DWORD_PTR
)&parm
);
1634 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1636 ok(IsWindowVisible(video_window
), "Video window should be visible.\n");
1638 err
= mciSendCommandW(id
, MCI_PLAY
, 0, (DWORD_PTR
)&parm
);
1639 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1641 ok(IsWindowVisible(video_window
), "Video window should be visible.\n");
1643 err
= mciSendCommandW(id
, MCI_SEEK
, MCI_SEEK_TO_START
, (DWORD_PTR
)&parm
);
1644 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1646 ok(IsWindowVisible(video_window
), "Video window should be visible.\n");
1649 err
= mciSendCommandW(id
, MCI_CLOSE
, 0, 0);
1650 ok(!err
, "Got %s.\n", dbg_mcierr(err
));
1654 ret
= DestroyWindow(parent_window
);
1655 ok(ret
, "Failed to destroy parent window\n");
1658 winetest_pop_context();
1661 ret
= DeleteFileW(filename
);
1662 ok(ret
, "Failed to delete %s, error %lu.\n", debugstr_w(filename
), GetLastError());
1667 char curdir
[MAX_PATH
], tmpdir
[MAX_PATH
];
1671 GetCurrentDirectoryA(MAX_PATH
, curdir
);
1672 GetTempPathA(MAX_PATH
, tmpdir
);
1673 SetCurrentDirectoryA(tmpdir
);
1675 hwnd
= CreateWindowExA(0, "static", "winmm test", WS_POPUP
, 0,0,100,100,
1677 test_mciParser(hwnd
);
1678 test_openCloseWAVE(hwnd
);
1679 test_recordWAVE(hwnd
);
1680 if(waveOutGetNumDevs()){
1682 test_playWAVE(hwnd
);
1683 test_asyncWAVE(hwnd
);
1684 test_AutoOpenWAVE(hwnd
);
1685 test_playWaveTypeMpegvideo();
1686 test_asyncWaveTypeMpegvideo(hwnd
);
1688 skip("No output devices available, skipping all output tests\n");
1690 test_video_window();
1692 /* Win9X hangs when exiting with something still open. */
1693 err
= mciSendStringA("close all", NULL
, 0, hwnd
);
1694 ok(!err
,"final close all returned %s\n", dbg_mcierr(err
));
1695 ok(DeleteFileA("tempfile.wav") || ok_saved
, "Delete tempfile.wav (cause auto-open?)\n");
1696 DestroyWindow(hwnd
);
1698 SetCurrentDirectoryA(curdir
);