ReactOS 0.4.15-dev-5865-g640e228
mci.c
Go to the documentation of this file.
1/*
2 * Test winmm mci
3 *
4 * Copyright 2006 Jan Zerebecki
5 * 2009 Jörg Höhle
6 *
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.
11 *
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.
16 *
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
20 */
21
22#include <stdio.h>
23#include "windows.h"
24#include "mmsystem.h"
25#include "mmreg.h"
26#include "wine/test.h"
27
28/* The tests use the MCI's own save capability to create the tempfile.wav to play.
29 * To use a pre-existing file, write-protect it. */
31
32typedef union {
42
44{
45 switch (err) {
46 case 0: return "0=NOERROR";
47#define X(label) case label: return #label ;
123#undef X
124 default: {
125 static char name[20]; /* Not to be called twice in a parameter list! */
126 sprintf(name, "MMSYSERR %u", err);
127 return name;
128 }
129 }
130}
131
133{
134 /* WM_DEVICECHANGE 0x0219 appears randomly */
135 if(msg->message != MM_MCINOTIFY) {
136 trace("skipping spurious message %04x\n",msg->message);
137 return TRUE;
138 }
139 return FALSE;
140}
141
142/* A single ok() in each code path allows us to prefix this with todo_wine */
143#define test_notification(hwnd, command, type) test_notification_dbg(hwnd, command, type, __LINE__)
144static void test_notification_dbg(HWND hwnd, const char* command, WPARAM type, int line)
145{ /* Use type 0 as meaning no message */
146 MSG msg;
147 BOOL seen;
148 do { seen = PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE); }
149 while(seen && spurious_message(&msg));
150 if(type && !seen) {
151 /* We observe transient delayed notification, mostly on native.
152 * Notification is not always present right when mciSend returns. */
153 trace_(__FILE__,line)("Waiting for delayed notification from %s\n", command);
156 }
157 if(!seen)
158 ok_(__FILE__,line)(type==0, "Expect message %04lx from %s\n", type, command);
159 else if(msg.hwnd != hwnd)
160 ok_(__FILE__,line)(msg.hwnd == hwnd, "Didn't get the handle to our test window\n");
161 else if(msg.message != MM_MCINOTIFY)
162 ok_(__FILE__,line)(msg.message == MM_MCINOTIFY, "got %04x instead of MM_MCINOTIFY from command %s\n", msg.message, command);
163 else ok_(__FILE__,line)(msg.wParam == type, "got %04lx instead of MCI_NOTIFY_xyz %04lx from command %s\n", msg.wParam, type, command);
164}
165
166static int strcmp_wa(LPCWSTR strw, const char *stra)
167{
168 CHAR buf[512];
169 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
170 return lstrcmpA(buf, stra);
171}
172
174{
176 MCIDEVICEID wDeviceID;
177 MCI_PARMS_UNION parm;
178 char buf[1024];
179 memset(buf, 0, sizeof(buf));
180 test_notification(hwnd, "-prior to parser test-", 0);
181
182 /* Get a handle on an MCI device, works even without sound. */
183 parm.open.lpstrDeviceType = "waveaudio";
184 parm.open.lpstrElementName = ""; /* "new" at the command level */
185 parm.open.lpstrAlias = "x"; /* to enable mciSendStringA */
189 ok(!err,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err));
190 wDeviceID = parm.open.wDeviceID;
191 ok(!strcmp(parm.open.lpstrDeviceType,"waveaudio"), "open modified device type\n");
192
194 test_notification(hwnd, "MCI_OPEN no #2", 0);
195
196 err = mciSendStringA("open avivideo alias a", buf, sizeof(buf), hwnd);
197 ok(!err,"open another: %s\n", dbg_mcierr(err));
198
199 buf[0]='z';
200 err = mciSendStringA("", buf, sizeof(buf), NULL);
201 ok(err==MCIERR_MISSING_COMMAND_STRING,"empty string: %s\n", dbg_mcierr(err));
202 ok(!buf[0], "error buffer %s\n", buf);
203
204 buf[0]='d';
205 err = mciSendStringA("open", buf, sizeof(buf), NULL);
206 ok(err==MCIERR_MISSING_DEVICE_NAME,"open void: %s\n", dbg_mcierr(err));
207 ok(!buf[0], "open error buffer %s\n", buf);
208
209 err = mciSendStringA("open notify", buf, sizeof(buf), NULL);
211
212 err = mciSendStringA("open new", buf, sizeof(buf), NULL);
214
215 err = mciSendStringA("open new type waveaudio alias r shareable shareable", buf, sizeof(buf), NULL);
217 if(!err) mciSendStringA("close r", NULL, 0, NULL);
218
219 err = mciSendStringA("status x position wait wait", buf, sizeof(buf), NULL);
220 todo_wine ok(err==MCIERR_DUPLICATE_FLAGS,"status wait wait: %s\n", dbg_mcierr(err));
221
222 err = mciSendStringA("status x length length", buf, sizeof(buf), NULL);
223 todo_wine ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"status 2xlength: %s\n", dbg_mcierr(err));
224
225 err = mciSendStringA("status x length position", buf, sizeof(buf), NULL);
226 todo_wine ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"status length+position: %s\n", dbg_mcierr(err));
227
228 buf[0]='I';
229 err = mciSendStringA("set x time format milliseconds time format ms", buf, sizeof(buf), NULL);
230 todo_wine ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"status length+position: %s\n", dbg_mcierr(err));
231 ok(!buf[0], "set error buffer %s\n", buf);
232
233 /* device's response, not a parser test */
234 err = mciSendStringA("status x", buf, sizeof(buf), NULL);
235 ok(err==MCIERR_MISSING_PARAMETER,"status waveaudio nokeyword: %s\n", dbg_mcierr(err));
236
237 buf[0]='G';
238 err = mciSendStringA("status a", buf, sizeof(buf), NULL);
239 todo_wine ok(err==MCIERR_UNSUPPORTED_FUNCTION,"status avivideo nokeyword: %s\n", dbg_mcierr(err));
240 ok(!buf[0], "status error buffer %s\n", buf);
241
242 err = mciSendStringA("status x track", buf, sizeof(buf), NULL);
243 ok(err==MCIERR_BAD_INTEGER,"status waveaudio no track: %s\n", dbg_mcierr(err));
244
245 err = mciSendStringA("status x track 3", buf, sizeof(buf), NULL);
246 ok(err==MCIERR_MISSING_PARAMETER,"status waveaudio track 3: %s\n", dbg_mcierr(err));
247
248 err = mciSendStringA("status x 2 track 3", buf, sizeof(buf), NULL);
249 todo_wine ok(err==MCIERR_OUTOFRANGE,"status 2(position) track 3: %s\n", dbg_mcierr(err));
250
251 err = mciSendStringA("status x 0x4", buf, sizeof(buf), NULL);
252 todo_wine ok(err==MCIERR_BAD_CONSTANT, "status 0x4: %s\n", dbg_mcierr(err));
253
254 err = mciSendStringA("status x 4", buf, sizeof(buf), hwnd);
255 ok(!err,"status 4(mode): %s\n", dbg_mcierr(err));
256 if(!err)ok(!strcmp(buf,"stopped"), "status 4(mode), got: %s\n", buf);
257
258 err = mciSendStringA("status x 4 notify", buf, sizeof(buf), hwnd);
259 todo_wine ok(!err,"status 4(mode) notify: %s\n", dbg_mcierr(err));
260 if(!err)ok(!strcmp(buf,"stopped"), "status 4(mode), got: %s\n", buf);
261 test_notification(hwnd, "status 4 notify", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
262
263 err = mciSendStringA("set x milliseconds", buf, sizeof(buf), hwnd);
264 todo_wine ok(err==MCIERR_UNRECOGNIZED_KEYWORD,"set milliseconds: %s\n", dbg_mcierr(err));
265
266 err = mciSendStringA("set x milliseconds ms", buf, sizeof(buf), hwnd);
267 todo_wine ok(err==MCIERR_UNRECOGNIZED_KEYWORD,"set milliseconds ms: %s\n", dbg_mcierr(err));
268
269 err = mciSendStringA("capability x can save", buf, sizeof(buf), hwnd);
270 todo_wine ok(!err,"capability can (space) save: %s\n", dbg_mcierr(err));
271
272 err = mciSendStringA("status x nsa", buf, sizeof(buf), hwnd);
273 todo_wine ok(err==MCIERR_BAD_CONSTANT,"status nsa: %s\n", dbg_mcierr(err));
274
275 err = mciSendStringA("seek x to 0:0:0:0:0", buf, sizeof(buf), NULL);
276 ok(err==MCIERR_BAD_INTEGER,"seek to 0:0:0:0:0 returned %s\n", dbg_mcierr(err));
277
278 err = mciSendStringA("seek x to 0:0:0:0:", buf, sizeof(buf), NULL);
279 ok(err==MCIERR_BAD_INTEGER,"seek to 0:0:0:0: returned %s\n", dbg_mcierr(err));
280
281 err = mciSendStringA("seek x to :0:0:0:0", buf, sizeof(buf), NULL);
282 ok(err==MCIERR_BAD_INTEGER,"seek to :0:0:0:0 returned %s\n", dbg_mcierr(err));
283
284 err = mciSendStringA("seek x to 256:0:0:0", buf, sizeof(buf), NULL);
285 ok(err==MCIERR_BAD_INTEGER,"seek to 256:0:0:0 returned %s\n", dbg_mcierr(err));
286
287 err = mciSendStringA("seek x to 0:256", buf, sizeof(buf), NULL);
288 ok(err==MCIERR_BAD_INTEGER,"seek to 0:256 returned %s\n", dbg_mcierr(err));
289
290 err = mciSendStringA("status all time format", buf, sizeof(buf), hwnd);
291 ok(err==MCIERR_CANNOT_USE_ALL,"status all: %s\n", dbg_mcierr(err));
292
293 err = mciSendStringA("cue all", buf, sizeof(buf), NULL);
294 ok(err==MCIERR_UNRECOGNIZED_COMMAND,"cue all: %s\n", dbg_mcierr(err));
295
296 err = mciSendStringA("open all", buf, sizeof(buf), NULL);
297 todo_wine ok(err==MCIERR_CANNOT_USE_ALL,"open all: %s\n", dbg_mcierr(err));
298
299 /* avivideo is not a known MCI_DEVTYPE resource name */
300 err = mciSendStringA("sysinfo avivideo quantity", buf, sizeof(buf), hwnd);
301 ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo sequencer quantity: %s\n", dbg_mcierr(err));
302
303 err = mciSendStringA("sysinfo digitalvideo quantity", buf, sizeof(buf), hwnd);
304 ok(!err,"sysinfo digitalvideo quantity: %s\n", dbg_mcierr(err));
305 if(!err) ok(!strcmp(buf,"0"), "sysinfo digitalvideo quantity returned %s\n", buf);
306
307 /* quantity 0 yet open 1 (via type "avivideo"), fun */
308 err = mciSendStringA("sysinfo digitalvideo quantity open", buf, sizeof(buf), hwnd);
309 ok(!err,"sysinfo digitalvideo quantity open: %s\n", dbg_mcierr(err));
310 if(!err) ok(!strcmp(buf,"1"), "sysinfo digitalvideo quantity open returned %s\n", buf);
311
312 err = mciSendStringA("put a window at 0 0", buf, sizeof(buf), NULL);
313 ok(err==MCIERR_BAD_INTEGER,"put incomplete rect: %s\n", dbg_mcierr(err));
314
315 /*w9X-w2k report code from device last opened, newer versions compare them all
316 * and return the one error code or MCIERR_MULTIPLE if they differ. */
317 err = mciSendStringA("pause all", buf, sizeof(buf), NULL);
319 ok(!buf[0], "pause error buffer %s\n", buf);
320
321 /* MCI_STATUS' dwReturn is a DWORD_PTR, others' a plain DWORD. */
323 parm.status.dwReturn = 0xFEEDABAD;
325 ok(!err,"mciCommand status time format: %s\n", dbg_mcierr(err));
326 if(!err) ok(MCI_FORMAT_MILLISECONDS==parm.status.dwReturn,"status time format: %ld\n",parm.status.dwReturn);
327
329 parm.status.dwReturn = 0xFEEDABAD;
331 ok(!err,"mciCommand status mode: %s\n", dbg_mcierr(err));
332 if(!err) ok(MCI_MODE_STOP==parm.status.dwReturn,"STATUS mode: %ld\n",parm.status.dwReturn);
333
334 err = mciSendStringA("status x mode", buf, sizeof(buf), hwnd);
335 ok(!err,"status mode: %s\n", dbg_mcierr(err));
336 if(!err) ok(!strcmp(buf, "stopped"), "status mode is %s\n", buf);
337
339 parm.caps.dwReturn = 0xFEEDABAD;
341 ok(!err,"mciCommand getdevcaps files: %s\n", dbg_mcierr(err));
342 if(!err) ok(1==parm.caps.dwReturn,"getdevcaps files: %d\n",parm.caps.dwReturn);
343
345 parm.caps.dwReturn = 0xFEEDABAD;
347 ok(!err,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err));
348 if(!err) ok(0==parm.caps.dwReturn,"getdevcaps video: %d\n",parm.caps.dwReturn);
349
351 parm.caps.dwReturn = 0xFEEDABAD;
353 ok(!err,"mciCommand getdevcaps video: %s\n", dbg_mcierr(err));
354 if(!err) ok(MCI_DEVTYPE_WAVEFORM_AUDIO==parm.caps.dwReturn,"getdevcaps device type: %d\n",parm.caps.dwReturn);
355
356 err = mciSendStringA("capability x uses files", buf, sizeof(buf), hwnd);
357 ok(!err,"capability files: %s\n", dbg_mcierr(err));
358 if(!err) ok(!strcmp(buf, "true"), "capability files is %s\n", buf);
359
360 err = mciSendStringA("capability x has video", buf, sizeof(buf), hwnd);
361 ok(!err,"capability video: %s\n", dbg_mcierr(err));
362 if(!err) ok(!strcmp(buf, "false"), "capability video is %s\n", buf);
363
364 err = mciSendStringA("capability x device type", buf, sizeof(buf), hwnd);
365 ok(!err,"capability device type: %s\n", dbg_mcierr(err));
366 if(!err) ok(!strcmp(buf, "waveaudio"), "capability device type is %s\n", buf);
367
368 err = mciSendStringA("info a version", buf, sizeof(buf), hwnd);
369 ok(!err,"info version: %s\n", dbg_mcierr(err));
370 if(!err) ok(!strcmp(buf, "1.1"), "info version is %s\n", buf);
371
372 err = mciSendCommandA(wDeviceID, MCI_CLOSE, 0, 0);
373 ok(!err,"mciCommand close returned %s\n", dbg_mcierr(err));
374
375 err = mciSendStringA("close a", buf, sizeof(buf), hwnd);
376 ok(!err,"close avi: %s\n", dbg_mcierr(err));
377
378 test_notification(hwnd, "-end of 1st set-", 0);
379}
380
382{
384 MCI_PARMS_UNION parm;
385 const char command_open[] = "open new type waveaudio alias mysound notify";
386 const char command_close_my[] = "close mysound notify";
387 const char command_close_all[] = "close all notify";
388 const char command_sysinfo[] = "sysinfo waveaudio quantity open";
389 char buf[1024];
390 DWORD intbuf[3] = { 0xDEADF00D, 99, 0xABADCAFE };
391 memset(buf, 0, sizeof(buf));
392 test_notification(hwnd, "-prior to any command-", 0);
393
394 /* Avoid Sysinfo quantity with notify because Win9x and newer differ. */
395 err = mciSendStringA("sysinfo all quantity", buf, sizeof(buf), hwnd);
396 ok(!err,"mci sysinfo all quantity returned %s\n", dbg_mcierr(err));
397 if(!err) trace("[MCI] with %s drivers\n", buf);
398
399 parm.sys.lpstrReturn = (LPSTR)&intbuf[1];
400 parm.sys.dwRetSize = sizeof(DWORD);
401 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
403 (DWORD_PTR)&parm);
404 ok(!err, "mciCommand sysinfo all quantity returned %s\n", dbg_mcierr(err));
405 if(!err) ok(atoi(buf)==intbuf[1],"sysinfo all quantity string and command differ\n");
406
407 parm.sys.dwRetSize = sizeof(DWORD)-1;
409 ok(err == MCIERR_PARAM_OVERFLOW || broken(!err/* Win9x */),
410 "mciCommand sysinfo with too small buffer returned %s\n", dbg_mcierr(err));
411
412 err = mciSendStringA("open new type waveaudio alias r shareable", buf, sizeof(buf), NULL);
413 ok(err==MCIERR_UNSUPPORTED_FUNCTION,"mci open new shareable returned %s\n", dbg_mcierr(err));
414 if(!err) {
415 err = mciSendStringA("close r", NULL, 0, NULL);
416 ok(!err,"mci close shareable returned %s\n", dbg_mcierr(err));
417 }
418
419 err = mciGetDeviceIDA("waveaudio");
420 ok(!err, "mciGetDeviceIDA waveaudio returned %u, expected 0\n", err);
421
422 err = mciSendStringA(command_open, buf, sizeof(buf), hwnd);
423 ok(!err,"mci %s returned %s\n", command_open, dbg_mcierr(err));
424 ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
425 /* Wine<=1.1.33 used to ignore anything past alias XY */
426 test_notification(hwnd,"open new alias notify",MCI_NOTIFY_SUCCESSFUL);
427
428 err = mciSendStringA("status mysound time format", buf, sizeof(buf), hwnd);
429 ok(!err,"mci status time format returned %s\n", dbg_mcierr(err));
430 if(!err) {
432 ok(!strcmp(buf,"milliseconds"), "mci status time format: %s\n", buf);
433 else trace("locale-dependent time format: %s (ms)\n", buf);
434 }
435
436 memset(buf, 0, sizeof(buf));
437 parm.sys.dwNumber = 1;
438 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
439 parm.sys.lpstrReturn = buf;
440 parm.sys.dwRetSize = sizeof(buf);
444 ok(!err,"mciCommand MCI_SYSINFO all name 1 open notify: %s\n", dbg_mcierr(err));
445 if(!err) ok(!strcmp(buf,"mysound"), "sysinfo name returned %s\n", buf);
446 test_notification(hwnd, "SYSINFO name notify\n", MCI_NOTIFY_SUCCESSFUL);
447
448 memset(buf, 0, sizeof(buf));
449 parm.sys.dwNumber = 1;
450 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
451 parm.sys.lpstrReturn = buf;
452 parm.sys.dwRetSize = 8; /* mysound\0 */
454 (DWORD_PTR)&parm);
455 ok(!err,"mciCommand MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err));
456 if(!err) ok(!strcmp(buf,"mysound"), "sysinfo name returned %s\n", buf);
457
458 memset(buf, 0, sizeof(buf));
459 /* dwRetSize counts characters, not bytes, despite what MSDN says. */
460 parm.sys.dwNumber = 1;
461 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
462 parm.sys.lpstrReturn = buf;
463 parm.sys.dwRetSize = 8; /* mysound\0 */
464 /* MCI_..._PARMSA and PARMSW share the same layout, use one for both tests. */
466 ok(!err || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err));
467 if(!err) ok(!strcmp_wa((LPWSTR)buf,"mysound"), "sysinfo name 1 open contents\n");
468
469 memset(buf, 0, sizeof(buf));
470 buf[0] = 'Y';
471 parm.sys.dwNumber = 1;
472 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
473 parm.sys.lpstrReturn = buf;
474 parm.sys.dwRetSize = 7; /* too short for mysound\0 */
476 ok(err==MCIERR_PARAM_OVERFLOW || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err));
477 ok(!strcmp(buf,"Y"), "output buffer %s\n", buf);
478
479 /* Win9x overwrites the tiny buffer and returns success, newer versions signal overflow. */
480 memset(buf, 0, sizeof(buf));
481 buf[0] = 'Y';
482 parm.sys.dwNumber = 1;
483 parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
484 parm.sys.lpstrReturn = buf;
485 parm.sys.dwRetSize = 2; /* too short for mysound\0 */
487 (DWORD_PTR)&parm);
488 ok(err==MCIERR_PARAM_OVERFLOW || broken(!err /* Win9x */),"mciCommand MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err));
489 ok(!strcmp(buf, err ? "Y" : "mysound"), "sysinfo short name returned %s\n", buf);
490
491 err = mciSendStringA("sysinfo mysound quantity open", buf, sizeof(buf), hwnd);
492 ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo alias quantity: %s\n", dbg_mcierr(err));
493
494 err = mciSendStringA("sysinfo nosuchalias quantity open", buf, sizeof(buf), hwnd);
495 ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo unknown quantity open: %s\n", dbg_mcierr(err));
496
497 err = mciSendStringA("sysinfo all installname", buf, sizeof(buf), hwnd);
498 ok(err==MCIERR_CANNOT_USE_ALL,"sysinfo all installname: %s\n", dbg_mcierr(err));
499
500 buf[0] = 'M'; buf[1] = 0;
501 parm.sys.lpstrReturn = buf;
502 parm.sys.dwRetSize = sizeof(buf);
504 ok(err==MCIERR_CANNOT_USE_ALL,"mciCommand MCI_SYSINFO all installname: %s\n", dbg_mcierr(err));
505 ok(!strcmp(buf,"M"), "output buffer %s\n", buf);
506
507 err = mciSendStringA("sysinfo nodev installname", buf, sizeof(buf), hwnd);
508 ok(err==MCIERR_INVALID_DEVICE_NAME,"sysinfo nodev installname: %s\n", dbg_mcierr(err));
509 ok(!buf[0], "sysinfo error buffer %s\n", buf);
510
511 buf[0] = 'K';
512 parm.sys.lpstrReturn = buf;
513 parm.sys.dwRetSize = sizeof(buf);
515 ok(err==MCIERR_INVALID_DEVICE_NAME || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommand MCI_SYSINFO nodev installname: %s\n", dbg_mcierr(err));
516 ok(!strcmp(buf,"K"), "output buffer %s\n", buf);
517
518 buf[0] = 0; buf[1] = 'A'; buf[2] = 'j'; buf[3] = 0;
519 parm.info.lpstrReturn = buf;
520 parm.info.dwRetSize = 2;
522 ok(!err, "mciCommand MCI_INFO product: %s\n", dbg_mcierr(err));
523 ok(buf[0] /* && !buf[1] */ && (buf[2] == 'j' || broken(!buf[2])), "info product output buffer %s\n", buf);
524 /* Producing non-ASCII multi-byte output, native forgets to zero-terminate a too small buffer
525 * with SendStringA, while SendStringW works correctly (jap. and chin. locale): ignore buf[1] */
526 /* Bug in 64 bit Vista/w2k8/w7: mciSendStringW is used! (not in xp nor w2k3) */
527
528 buf[0] = 'K'; buf[1] = 0;
529 parm.info.dwRetSize = sizeof(buf);
530 err = mciSendCommandW(1, MCI_INFO, 0x07000000, (DWORD_PTR)&parm);
531 ok(err==MCIERR_UNRECOGNIZED_KEYWORD || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommand MCI_INFO other: %s\n", dbg_mcierr(err));
532 ok(!strcmp(buf,"K"), "info output buffer %s\n", buf);
533
534 err = mciGetDeviceIDA("all");
535 ok(err == MCI_ALL_DEVICE_ID, "mciGetDeviceIDA all returned %u, expected MCI_ALL_DEVICE_ID\n", err);
536
537 err = mciSendStringA(command_close_my, NULL, 0, hwnd);
538 ok(!err,"mci %s returned %s\n", command_close_my, dbg_mcierr(err));
539 test_notification(hwnd, command_close_my, MCI_NOTIFY_SUCCESSFUL);
540 Sleep(5);
541 test_notification(hwnd, command_close_my, 0);
542
543 err = mciSendStringA("open no-such-file-exists.wav alias y buffer 6", buf, sizeof(buf), NULL);
544 ok(err==MCIERR_FILE_NOT_FOUND,"open no-such-file.wav returned %s\n", dbg_mcierr(err));
545 if(!err) {
546 err = mciSendStringA("close y", NULL, 0, NULL);
547 ok(!err,"close y returned %s\n", dbg_mcierr(err));
548 }
549
550 err = mciSendStringA("open no-such-dir\\file.wav alias y type waveaudio", buf, sizeof(buf), NULL);
551 ok(err==MCIERR_FILE_NOT_FOUND || broken(err==MCIERR_INVALID_FILE /* Win9X */),"open no-such-dir/file.wav returned %s\n", dbg_mcierr(err));
552 if(!err) {
553 err = mciSendStringA("close y", NULL, 0, NULL);
554 ok(!err,"close y returned %s\n", dbg_mcierr(err));
555 }
556
557 err = mciSendStringA("open ! alias no", buf, sizeof(buf), NULL);
558 ok(err==MCIERR_INVALID_DEVICE_NAME,"open !(void): %s\n", dbg_mcierr(err));
559
560 err = mciSendStringA("open !no-such-file-exists.wav alias no", buf, sizeof(buf), NULL);
561 ok(err==MCIERR_FILE_NOT_FOUND || /* Win9X */err==MCIERR_INVALID_DEVICE_NAME,"open !name: %s\n", dbg_mcierr(err));
562
563 /* FILE_NOT_FOUND stems from mciwave,
564 * the complete name including ! is passed through since NT */
565 err = mciSendStringA("open nosuchdevice!tempfile.wav alias no", buf, sizeof(buf), NULL);
566 ok(err==MCIERR_FILE_NOT_FOUND || /* Win9X */err==MCIERR_INVALID_DEVICE_NAME,"open nosuchdevice!name: %s\n", dbg_mcierr(err));
567 /* FIXME? use broken(INVALID_DEVICE_NAME) and have Wine not mimic Win9X? */
568
569 err = mciSendStringA("close waveaudio", buf, sizeof(buf), NULL);
570 ok(err==MCIERR_INVALID_DEVICE_NAME,"close waveaudio: %s\n", dbg_mcierr(err));
571
572 err = mciSendStringA(command_close_all, NULL, 0, NULL);
573 ok(!err,"mci %s (without buffer) returned %s\n", command_close_all, dbg_mcierr(err));
574
575 err = mciSendStringA(command_close_all, buf, sizeof(buf), hwnd);
576 ok(!err,"mci %s (with output buffer) returned %s\n", command_close_all, dbg_mcierr(err));
577 ok(buf[0] == 0, "mci %s output buffer: %s\n", command_close_all, buf);
578 /* No notification left, everything closed already */
579 test_notification(hwnd, command_close_all, 0);
580 /* TODO test close all sends one notification per open device */
581
582 err = mciSendStringA(command_sysinfo, buf, sizeof(buf), NULL);
583 ok(!err,"mci %s returned %s\n", command_sysinfo, dbg_mcierr(err));
584 ok(buf[0] == '0' && buf[1] == 0, "mci %s, expected output buffer '0', got: '%s'\n", command_sysinfo, buf);
585
586 err = mciSendStringA("open new type waveaudio", buf, sizeof(buf), NULL);
587 ok(err==MCIERR_NEW_REQUIRES_ALIAS,"mci open new without alias returned %s\n", dbg_mcierr(err));
588
591 ok(!err,"mciCommand OPEN_TYPE_ID waveaudio: %s\n", dbg_mcierr(err));
592
593 if(!err) {
594 MCIDEVICEID wDeviceID = parm.open.wDeviceID;
597 ok(!err,"mciCommand MCI_GETDEVCAPS device type: %s\n", dbg_mcierr(err));
598 ok(MCI_DEVTYPE_WAVEFORM_AUDIO==parm.caps.dwReturn,"mciCommand GETDEVCAPS says %u, expected %u\n", parm.caps.dwReturn, MCI_DEVTYPE_WAVEFORM_AUDIO);
599 }
600
601 ok(0xDEADF00D==intbuf[0] && 0xABADCAFE==intbuf[2],"DWORD buffer corruption\n");
602
603 err = mciGetDeviceIDA("waveaudio");
604 ok(err == 1, "mciGetDeviceIDA waveaudio returned %u, expected 1\n", err);
605
606 err = mciSendStringA("open no-such-file.wav alias waveaudio", buf, sizeof(buf), NULL);
607 ok(err==MCIERR_DUPLICATE_ALIAS, "mci open alias waveaudio returned %s\n", dbg_mcierr(err));
608 /* If it were not already in use, open avivideo alias waveaudio would succeed,
609 * making for funny test cases. */
610
612 ok(!err, "mciCommand close returned %s\n", dbg_mcierr(err));
613
615 ok(!err, "mciCommand close returned %s\n", dbg_mcierr(err));
616
619 ok(!err, "mciCommand close returned %s\n", dbg_mcierr(err));
620 test_notification(hwnd, command_close_all, 0); /* None left */
621}
622
624{
625 WORD nch = 1;
626 WORD nbits = 16;
627 DWORD nsamp = 16000, expect;
628 UINT ndevs = waveInGetNumDevs();
629 MCIERROR err, ok_pcm;
630 MCIDEVICEID wDeviceID;
631 MCI_PARMS_UNION parm;
632 char buf[1024];
633 memset(buf, 0, sizeof(buf));
634 test_notification(hwnd, "-prior to recording-", 0);
635
636 parm.open.lpstrDeviceType = "waveaudio";
637 parm.open.lpstrElementName = ""; /* "new" at the command level */
638 parm.open.lpstrAlias = "x"; /* to enable mciSendStringA */
642 ok(!err,"mciCommand open new type waveaudio alias x notify: %s\n", dbg_mcierr(err));
643 wDeviceID = parm.open.wDeviceID;
644
645 err = mciGetDeviceIDA("x");
646 ok(err == wDeviceID, "mciGetDeviceIDA x returned %u, expected %u\n", err, wDeviceID);
647
648 /* Only the alias is looked up. */
649 err = mciGetDeviceIDA("waveaudio");
650 ok(!err, "mciGetDeviceIDA waveaudio returned %u, expected 0\n", err);
651
653 test_notification(hwnd, "open new no #2", 0);
654
655 /* Do not query time format as string because result depends on locale! */
658 ok(!err,"mciCommand status time format: %s\n", dbg_mcierr(err));
659 ok(parm.status.dwReturn==MCI_FORMAT_MILLISECONDS,"status time format: %ld\n",parm.status.dwReturn);
660
661 /* Info file fails until named in Open or Save. */
662 err = mciSendStringA("info x file", buf, sizeof(buf), NULL);
663 todo_wine ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci info new file returned %s\n", dbg_mcierr(err));
664 ok(!buf[0], "info error buffer %s\n", buf);
665
666 err = mciSendStringA("status x length", buf, sizeof(buf), NULL);
667 todo_wine ok(!err,"status x length initial: %s\n", dbg_mcierr(err));
668 if(!err) ok(!strcmp(buf,"0"), "mci status length expected 0, got: %s\n", buf);
669
670 /* Check the default recording: 8-bits per sample, mono, 11kHz */
671 err = mciSendStringA("status x samplespersec", buf, sizeof(buf), NULL);
672 ok(!err,"mci status samplespersec returned %s\n", dbg_mcierr(err));
673 if(!err) ok(!strcmp(buf,"11025"), "mci status samplespersec expected 11025, got: %s\n", buf);
674
675 /* MCI appears to scan the available devices for support of this format,
676 * returning MCIERR_OUTOFRANGE on machines with no sound.
677 * However some w2k8/w7 machines return no error when there's no wave
678 * input device (perhaps querying waveOutGetNumDevs instead of waveIn?),
679 * still the record command below fails with MCIERR_WAVE_INPUTSUNSUITABLE.
680 * Don't skip here, record will fail below. */
681 err = mciSendStringA("set x format tag pcm", NULL, 0, NULL);
682 ok(!err || err==MCIERR_OUTOFRANGE,"mci set format tag pcm returned %s\n", dbg_mcierr(err));
683 ok_pcm = err;
684
685 /* MSDN warns against not setting all wave format parameters.
686 * Indeed, it produces strange results, incl.
687 * inconsistent PCMWAVEFORMAT headers in the saved file.
688 */
689 err = mciSendStringA("set x bytespersec 22050 alignment 2 samplespersec 11025 channels 1 bitspersample 16", NULL, 0, NULL);
690 ok(err==ok_pcm,"mci set 5 wave parameters returned %s\n", dbg_mcierr(err));
691 /* Investigate: on w2k, set samplespersec 22050 sets nChannels to 2!
692 * err = mciSendStringA("set x samplespersec 22050", NULL, 0, NULL);
693 * ok(!err,"mci set samplespersec returned %s\n", dbg_mcierr(err));
694 */
695
696 /* Checks are generally performed immediately. */
697 err = mciSendStringA("set x bitspersample 4", NULL, 0, NULL);
698 todo_wine ok(err==MCIERR_OUTOFRANGE,"mci set bitspersample 4 returned %s\n", dbg_mcierr(err));
699
701 parm.set.nSamplesPerSec = nsamp;
702 parm.set.wBitsPerSample = nbits;
703 parm.set.nChannels = nch;
704 parm.set.nBlockAlign = parm.set.nChannels * parm.set.wBitsPerSample /8;
706 err = mciSendCommandA(wDeviceID, MCI_SET,
709 (DWORD_PTR)&parm);
710 ok(err==ok_pcm,"mciCommand set wave format: %s\n", dbg_mcierr(err));
711
715 (DWORD_PTR)&parm);
716 ok(!err,"mciCommand MCI_GETDEVCAPS inputs: %s\n", dbg_mcierr(err));
717 ok(parm.caps.dwReturn==ndevs,"mciCommand GETDEVCAPS claims %u inputs, expected %u\n", parm.caps.dwReturn, ndevs);
718 ok(!ok_pcm || !parm.caps.dwReturn,"No input device accepts PCM!?\n");
719 test_notification(hwnd, "GETDEVCAPS inputs", MCI_NOTIFY_SUCCESSFUL);
720
721 /* A few ME machines pass all tests except set format tag pcm! */
722 err = mciSendStringA("record x to 2000 wait", NULL, 0, hwnd);
723 ok(err || !ok_pcm,"can record yet set wave format pcm returned %s\n", dbg_mcierr(ok_pcm));
724 todo_wine_if (!ndevs) /* with sound disabled */
725 ok(ndevs > 0 ? !err : err == MCIERR_WAVE_INPUTSUNSUITABLE, "mci record to 2000 returned %s\n", dbg_mcierr(err));
726 if(err) {
728 skip("Please install audio driver. Everything is skipped.\n");
729 else skip("Cannot record cause %s. Everything is skipped.\n", dbg_mcierr(err));
730
731 err = mciSendStringA("close x", NULL, 0, NULL);
732 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
733 test_notification(hwnd,"record skipped",0);
734 return;
735 }
736
737 /* Query some wave format parameters depending on the time format. */
738 err = mciSendStringA("status x position", buf, sizeof(buf), NULL);
739 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
740 if(!err) todo_wine ok(!strcmp(buf,"2000"), "mci status position gave %s, expected 2000, some tests will fail\n", buf);
741
742 err = mciSendStringA("set x time format 8", NULL, 0, NULL); /* bytes */
743 ok(!err,"mci returned %s\n", dbg_mcierr(err));
744
747 ok(!err,"mciCommand status position: %s\n", dbg_mcierr(err));
748 expect = 2 * nsamp * nch * nbits/8;
749 if(!err) todo_wine ok(parm.status.dwReturn==expect,"recorded %lu bytes, expected %u\n",parm.status.dwReturn,expect);
750
753 ok(!err,"mciCommand set time format samples: %s\n", dbg_mcierr(err));
754
757 ok(!err,"mciCommand status position: %s\n", dbg_mcierr(err));
758 expect = 2 * nsamp;
759 if(!err) todo_wine ok(parm.status.dwReturn==expect,"recorded %lu samples, expected %u\n",parm.status.dwReturn,expect);
760
761 err = mciSendStringA("set x time format milliseconds", NULL, 0, NULL);
762 ok(!err,"mci set time format milliseconds returned %s\n", dbg_mcierr(err));
763
764 err = mciSendStringA("save x tempfile1.wav", NULL, 0, NULL);
765 ok(!err,"mci save returned %s\n", dbg_mcierr(err));
766
767 err = mciSendStringA("save x tempfile.wav", NULL, 0, NULL);
768 ok(!err,"mci save returned %s\n", dbg_mcierr(err));
769 if(!err) ok_saved = 0;
770
771 /* Save must not rename the original file. */
772 if (!DeleteFileA("tempfile1.wav"))
773 todo_wine ok(FALSE, "Save must not rename the original file; DeleteFileA returned %d\n",
774 GetLastError());
775
776 err = mciSendStringA("set x channels 2", NULL, 0, NULL);
777 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci set channels after saving returned %s\n", dbg_mcierr(err));
778
779 parm.seek.dwTo = 600;
780 err = mciSendCommandA(wDeviceID, MCI_SEEK, MCI_TO | MCI_WAIT, (DWORD_PTR)&parm);
781 ok(!err,"mciCommand seek to 600: %s\n", dbg_mcierr(err));
782
783 /* Truncate to current position */
784 err = mciSendStringA("delete x", NULL, 0, NULL);
785 todo_wine ok(!err,"mci delete returned %s\n", dbg_mcierr(err));
786
787 err = mciSendStringA("status x length", buf, sizeof(buf), NULL);
788 ok(!err,"mci status length returned %s\n", dbg_mcierr(err));
789 todo_wine ok(!strcmp(buf,"600"), "mci status length after delete gave %s, expected 600\n", buf);
790
791 err = mciSendStringA("close x", NULL, 0, NULL);
792 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
793 test_notification(hwnd,"record complete",0);
794}
795
797{
799 char buf[1024];
800 memset(buf, 0, sizeof(buf));
801
802 err = mciSendStringA("open waveaudio!tempfile.wav alias mysound", NULL, 0, NULL);
803 ok(err==ok_saved,"mci open waveaudio!tempfile.wav returned %s\n", dbg_mcierr(err));
804 if(err) {
805 skip("Cannot open waveaudio!tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err));
806 return;
807 }
808
809 err = mciGetDeviceIDA("mysound");
810 ok(err == 1, "mciGetDeviceIDA mysound returned %u, expected 1\n", err);
811
812 err = mciGetDeviceIDA("tempfile.wav");
813 ok(!err, "mciGetDeviceIDA tempfile.wav returned %u, expected 0\n", err);
814
815 err = mciGetDeviceIDA("waveaudio");
816 ok(!err, "mciGetDeviceIDA waveaudio returned %u, expected 0\n", err);
817
818 err = mciSendStringA("status mysound length", buf, sizeof(buf), NULL);
819 ok(!err,"mci status length returned %s\n", dbg_mcierr(err));
820 todo_wine ok(!strcmp(buf,"2000"), "mci status length gave %s, expected 2000, some tests will fail.\n", buf);
821
822 err = mciSendStringA("cue output", NULL, 0, NULL);
823 ok(err==MCIERR_UNRECOGNIZED_COMMAND,"mci incorrect cue output returned %s\n", dbg_mcierr(err));
824
825 /* Test MCI to the bones -- Some todo_wine from Cue and
826 * from Play from 0 to 0 are not worth fixing. */
827 err = mciSendStringA("cue mysound output notify", NULL, 0, hwnd);
828 ok(!err,"mci cue output after open file returned %s\n", dbg_mcierr(err));
829 /* Notification is delayed as a play thread is started. */
830 todo_wine test_notification(hwnd, "cue immediate", 0);
831
832 /* Cue pretends to put the MCI into paused state. */
833 err = mciSendStringA("status mysound mode", buf, sizeof(buf), hwnd);
834 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
835 todo_wine ok(!strcmp(buf,"paused"), "mci status mode: %s, expected (pseudo)paused\n", buf);
836
837 /* Strange pause where Pause is rejected, unlike Play; Pause; Pause tested below */
838 err = mciSendStringA("pause mysound", NULL, 0, hwnd);
839 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci pause after cue returned %s\n", dbg_mcierr(err));
840
841 /* MCI appears to start the play thread in this border case.
842 * Guessed that from (flaky) status mode and late notification arrival. */
843 err = mciSendStringA("play mysound from 0 to 0 notify", NULL, 0, hwnd);
844 ok(!err,"mci play from 0 to 0 returned %s\n", dbg_mcierr(err));
845 todo_wine test_notification(hwnd, "cue aborted by play", MCI_NOTIFY_ABORTED);
846 /* play's own notification follows below */
847
848 err = mciSendStringA("play mysound from 250 to 0", NULL, 0, NULL);
849 ok(err==MCIERR_OUTOFRANGE,"mci play from 250 to 0 returned %s\n", dbg_mcierr(err));
850
851 Sleep(100); /* Give play from 0 to 0 time to finish. */
853
854 err = mciSendStringA("status mysound mode", buf, sizeof(buf), hwnd);
855 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
856 ok(!strcmp(buf,"stopped"), "mci status mode: %s after play from 0 to 0\n", buf);
857
858 err = mciSendStringA("play MYSOUND from 250 to 0 notify", NULL, 0, hwnd);
859 ok(err==MCIERR_OUTOFRANGE,"mci play from 250 to 0 notify returned %s\n", dbg_mcierr(err));
860 /* No notification (checked below) sent if error */
861
862 /* A second play caused Wine<1.1.33 to hang */
863 err = mciSendStringA("play mysound from 500 to 220:5:0 wait", NULL, 0, NULL);
864 ok(!err,"mci play from 500 to 220:5:0 (=1500) returned %s\n", dbg_mcierr(err));
865
866 err = mciSendStringA("status mysound position", buf, sizeof(buf), hwnd);
867 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
868 if(!err) ok(!strcmp(buf,"1500"), "mci status position: %s\n", buf);
869
870 /* mci will not play position < current */
871 err = mciSendStringA("play mysound to 1000", NULL, 0, NULL);
872 ok(err==MCIERR_OUTOFRANGE,"mci play to 1000 returned %s\n", dbg_mcierr(err));
873
874 /* mci will not play to > end */
875 err = mciSendStringA("play mysound TO 3000 notify", NULL, 0, hwnd);
876 ok(err==MCIERR_OUTOFRANGE,"mci play to 3000 notify returned %s\n", dbg_mcierr(err));
877
878 err = mciSendStringA("play mysound to 2000", NULL, 0, NULL);
879 ok(!err,"mci play to 2000 returned %s\n", dbg_mcierr(err));
880
881 /* Rejected while playing */
882 err = mciSendStringA("cue mysound output", NULL, 0, NULL);
883 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci cue output while playing returned %s\n", dbg_mcierr(err));
884
885 err = mciSendStringA("play mysound to 3000", NULL, 0, NULL);
886 ok(err==MCIERR_OUTOFRANGE,"mci play to 3000 returned %s\n", dbg_mcierr(err));
887
888 err = mciSendStringA("stop mysound Wait", NULL, 0, NULL);
889 ok(!err,"mci stop wait returned %s\n", dbg_mcierr(err));
890 test_notification(hwnd, "play/cue/pause/stop", 0);
891
892 err = mciSendStringA("Seek Mysound to 250 wait Notify", NULL, 0, hwnd);
893 ok(!err,"mci seek to 250 wait notify returned %s\n", dbg_mcierr(err));
894 test_notification(hwnd,"seek wait notify",MCI_NOTIFY_SUCCESSFUL);
895
896 err = mciSendStringA("seek mysound to 0xfa", NULL, 0, NULL);
897 ok(err==MCIERR_BAD_INTEGER,"mci seek to 0xfa returned %s\n", dbg_mcierr(err));
898
899 /* MCI_INTEGER always accepts colon notation */
900 err = mciSendStringA("seek mysound to :1", NULL, 0, NULL);
901 ok(!err,"mci seek to :1 (=256) returned %s\n", dbg_mcierr(err));
902
903 err = mciSendStringA("seek mysound to 250::", NULL, 0, NULL);
904 ok(!err,"mci seek to 250:: returned %s\n", dbg_mcierr(err));
905
906 err = mciSendStringA("seek mysound to 250:0", NULL, 0, NULL);
907 ok(!err,"mci seek to 250:0 returned %s\n", dbg_mcierr(err));
908
909 err = mciSendStringA("status mysound position notify", buf, sizeof(buf), hwnd);
910 ok(!err,"mci status position notify returned %s\n", dbg_mcierr(err));
911 if(!err) ok(!strcmp(buf,"250"), "mci status position: %s\n", buf);
912 /* Immediate commands like status also send notifications. */
914
915 err = mciSendStringA("status mysound mode", buf, sizeof(buf), hwnd);
916 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
917 ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
918
919 /* Another play from == to testcase */
920 err = mciSendStringA("play mysound to 250 wait notify", NULL, 0, hwnd);
921 ok(!err,"mci play (from 250) to 250 returned %s\n", dbg_mcierr(err));
922 todo_wine test_notification(hwnd,"play to 250 wait notify",MCI_NOTIFY_SUCCESSFUL);
923
924 err = mciSendStringA("cue mysound output", NULL, 0, NULL);
925 ok(!err,"mci cue output after play returned %s\n", dbg_mcierr(err));
926
927 err = mciSendStringA("close mysound", NULL, 0, NULL);
928 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
929 test_notification(hwnd,"after close",0);
930}
931
933{
934 MCIDEVICEID wDeviceID;
935 MCI_PARMS_UNION parm;
936 int err, p1, p2;
937 char buf[1024];
938 memset(buf, 0, sizeof(buf));
939
940 err = mciSendStringA("open tempfile.wav alias mysound notify type waveaudio", buf, sizeof(buf), hwnd);
941 ok(err==ok_saved,"mci open tempfile.wav returned %s\n", dbg_mcierr(err));
942 if(err) {
943 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err));
944 return;
945 }
946 ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
947 wDeviceID = atoi(buf);
948 ok(wDeviceID,"mci open DeviceID: %d\n", wDeviceID);
949 test_notification(hwnd,"open alias notify",MCI_NOTIFY_SUCCESSFUL);
950
951 err = mciGetDeviceIDA("mysound");
952 ok(err == wDeviceID, "mciGetDeviceIDA alias returned %u, expected %u\n", err, wDeviceID);
953
954 /* Only the alias is looked up. */
955 err = mciGetDeviceIDA("tempfile.wav");
956 ok(!err, "mciGetDeviceIDA tempfile.wav returned %u, expected 0\n", err);
957
958 err = mciGetDeviceIDA("waveaudio");
959 ok(!err, "mciGetDeviceIDA waveaudio returned %u, expected 0\n", err);
960
961 err = mciSendStringA("status mysound mode", buf, sizeof(buf), hwnd);
962 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
963 ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
964
965 err = mciSendStringA("play mysound notify", NULL, 0, hwnd);
966 ok(!err,"mci play returned %s\n", dbg_mcierr(err));
967
968 Sleep(500); /* milliseconds */
969
970 /* Do not query time format as string because result depends on locale! */
973 ok(!err,"mciCommand status time format: %s\n", dbg_mcierr(err));
974 if(!err) ok(parm.status.dwReturn==MCI_FORMAT_MILLISECONDS,"status time format: %ld\n",parm.status.dwReturn);
975
978 ok(!err,"mciCommand set time format ms: %s\n", dbg_mcierr(err));
979
980 err = mciSendStringA("status mysound position", buf, sizeof(buf), hwnd);
981 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
982 trace("position after Sleep: %sms\n", buf);
983 p2 = atoi(buf);
984 /* Check that the 2s sound plays at a normal pace, giving a wide margin to
985 * account for timing granularity and small delays.
986 */
987 todo_wine ok(350 <= p2 && p2 <= 600, "%ums is not in the expected 350-600ms range\n", p2);
988 /* Wine's asynchronous thread needs some time to start up. Furthermore, it
989 * uses 3 buffers per second, so that the positions reported will be 333ms,
990 * 667ms etc. at best, which is why it fails the above test. So add a
991 * second test specifically to prevent Wine from getting even worse.
992 * FIXME: To be removed when Wine is fixed and passes the above test.
993 */
994 ok(350 <= p2 && p2 <= 1000, "%ums is not even in the expected 350-1000ms range\n", p2);
995 test_notification(hwnd,"play (nowait)",0);
996
997 err = mciSendStringA("pause mysound wait", NULL, 0, hwnd);
998 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
999
1000 err = mciSendStringA("status mysound mode notify", buf, sizeof(buf), hwnd);
1001 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1002 if(!err) ok(!strcmp(buf,"paused"), "mci status mode: %s\n", buf);
1005
1006 err = mciSendStringA("status mysound position", buf, sizeof(buf), hwnd);
1007 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
1008 trace("position while paused: %sms\n",buf);
1009 p1 = atoi(buf);
1010 ok(p1>=p2, "position not increasing: %u > %u\n", p2, p1);
1011
1012 err = mciSendStringA("stop mysound wait", NULL, 0, NULL);
1013 ok(!err,"mci stop returned %s\n", dbg_mcierr(err));
1014
1015 err = mciSendStringA("info mysound file notify", buf, sizeof(buf), hwnd);
1016 ok(!err,"mci info file returned %s\n", dbg_mcierr(err));
1017 if(!err) { /* fully qualified name */
1018 int len = strlen(buf);
1019 todo_wine ok(len>2 && buf[1]==':',"Expected full pathname from info file: %s\n", buf);
1020 ok(len>=12 && !strcmp(&buf[len-12],"tempfile.wav"), "info file returned: %s\n", buf);
1021 }
1023
1024 err = mciSendStringA("status mysound mode", buf, sizeof(buf), hwnd);
1025 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1026 ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
1027
1028 err = mciSendStringA("status mysound position", buf, sizeof(buf), hwnd);
1029 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
1030 trace("position once stopped: %sms\n",buf);
1031 p2 = atoi(buf);
1032 /* An XP machine let the position increase slightly after pause. */
1033 ok(p2>=p1 && p2<=p1+16,"position changed from %ums to %ums\n",p1,p2);
1034
1035 /* No Resume once stopped (waveaudio, sequencer and cdaudio differ). */
1036 err = mciSendStringA("resume mysound wait", NULL, 0, NULL);
1037 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci resume wait returned %s\n", dbg_mcierr(err));
1038
1039 err = mciSendStringA("play mysound wait", NULL, 0, NULL);
1040 ok(!err,"mci play wait returned %s\n", dbg_mcierr(err));
1041
1042 err = mciSendStringA("status mysound position", buf, sizeof(buf), hwnd);
1043 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
1044 todo_wine ok(!strcmp(buf,"2000"), "mci status position: %s\n", buf);
1045
1046 err = mciSendStringA("seek mysound to start wait", NULL, 0, NULL);
1047 ok(!err,"mci seek to start wait returned %s\n", dbg_mcierr(err));
1048
1049 err = mciSendStringA("play mysound to 1000 notify", NULL, 0, hwnd);
1050 ok(!err,"mci play returned %s\n", dbg_mcierr(err));
1051
1052 /* Sleep(200); not needed with Wine any more. */
1053
1054 err = mciSendStringA("pause mysound notify", NULL, 0, NULL); /* notify no callback */
1055 ok(!err,"mci pause notify returned %s\n", dbg_mcierr(err));
1056 /* Supersede even though pause cannot notify given no callback */
1057 test_notification(hwnd,"pause aborted play #1 notification",MCI_NOTIFY_SUPERSEDED);
1058 test_notification(hwnd,"impossible pause notification",0);
1059
1060 err = mciSendStringA("cue mysound output notify", NULL, 0, hwnd);
1061 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci cue output while paused returned %s\n", dbg_mcierr(err));
1062 test_notification(hwnd,"cue output notify #2",0);
1063
1064 err = mciSendStringA("resume mysound notify", NULL, 0, hwnd);
1065 ok(!err,"mci resume notify returned %s\n", dbg_mcierr(err));
1066 test_notification(hwnd, "resume notify", MCI_NOTIFY_SUCCESSFUL);
1067
1068 /* Seek or even Stop used to hang Wine<1.1.32 on MacOS. */
1069 err = mciSendStringA("seek mysound to 0 wait", NULL, 0, NULL);
1070 ok(!err,"mci seek to start returned %s\n", dbg_mcierr(err));
1071
1072 /* Seek stops. */
1073 err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
1074 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1075 if(!err) ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
1076
1077 err = mciSendStringA("seek mysound wait", NULL, 0, NULL);
1078 ok(err==MCIERR_MISSING_PARAMETER,"mci seek to nowhere returned %s\n", dbg_mcierr(err));
1079
1080 /* cdaudio does not detect to start to end as error */
1081 err = mciSendStringA("seek mysound to start to 0", NULL, 0, NULL);
1082 ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"mci seek to start to 0 returned %s\n", dbg_mcierr(err));
1083
1084 err = mciSendStringA("PLAY mysound to 1000 notify", NULL, 0, hwnd);
1085 ok(!err,"mci play to 1000 notify returned %s\n", dbg_mcierr(err));
1086
1087 /* Sleep(200); not needed with Wine any more. */
1088 /* Give it 400ms and resume will appear to complete below. */
1089
1090 err = mciSendStringA("pause mysound wait", NULL, 0, NULL);
1091 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
1092 /* Unlike sequencer and cdaudio, waveaudio's pause does not abort. */
1093 test_notification(hwnd,"pause aborted play #2 notification",0);
1094
1095 err = mciSendStringA("resume mysound wait", NULL, 0, NULL);
1096 ok(!err,"mci resume wait returned %s\n", dbg_mcierr(err));
1097 /* Resume is a short asynchronous call, something else is playing. */
1098
1099 err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
1100 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1101 if(!err) ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
1102
1103 /* Note extra space before alias */
1104 err = mciSendStringA("pause mysound wait", NULL, 0, NULL);
1105 todo_wine ok(!err,"mci pause (space) wait returned %s\n", dbg_mcierr(err));
1106
1107 err = mciSendStringA("pause mysound wait", NULL, 0, NULL);
1108 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
1109
1110 /* Better ask position only when paused, is it updated while playing? */
1111 err = mciSendStringA("status mysound position", buf, sizeof(buf), NULL);
1112 ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
1113 /* TODO compare position < 900 */
1114 ok(strcmp(buf,"1000"), "mci resume waited\n");
1115 ok(strcmp(buf,"2000"), "mci resume played to end\n");
1116 trace("position after resume: %sms\n",buf);
1117 test_notification(hwnd,"play (aborted by pause/resume/pause)",0);
1118
1119 /* A small Sleep() here prevents the notification test failing with MCI_NOTIFY_SUCCESSFUL */
1120 Sleep(10);
1121 err = mciSendStringA("close mysound wait", NULL, 0, NULL);
1122 ok(!err,"mci close wait returned %s\n", dbg_mcierr(err));
1123 test_notification(hwnd,"play (aborted by close)",MCI_NOTIFY_ABORTED);
1124}
1125
1127{
1128 /* This test used(?) to cause intermittent crashes when Wine exits, after
1129 * fixme:winmm:MMDRV_Exit Closing while ll-driver open
1130 */
1131 UINT ndevs = waveOutGetNumDevs();
1132 MCIERROR err, ok_snd = ndevs ? 0 : MCIERR_HARDWARE;
1133 MCI_PARMS_UNION parm;
1134 char buf[512], path[300], command[330];
1135 DWORD intbuf[3] = { 0xDEADF00D, 99, 0xABADCAFE };
1136 memset(buf, 0, sizeof(buf)); memset(path, 0, sizeof(path));
1137
1138 /* Do not crash on NULL buffer pointer */
1139 err = mciSendStringA("sysinfo waveaudio quantity open", NULL, 0, NULL);
1140 ok(err==MCIERR_PARAM_OVERFLOW,"mci sysinfo without buffer returned %s\n", dbg_mcierr(err));
1141
1142 err = mciSendStringA("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
1143 ok(!err,"mci sysinfo waveaudio quantity open returned %s\n", dbg_mcierr(err));
1144 if(!err) ok(!strcmp(buf,"0"), "sysinfo quantity open expected 0, got: %s, some more tests will fail.\n", buf);
1145
1146 /* Who knows why some MS machines pass all tests but return MCIERR_HARDWARE here? */
1147 /* Wine returns MCIERR_HARDWARE when no default sound is found in win.ini or the registry. */
1148 err = mciSendStringA("sound NoSuchSoundDefined wait", NULL, 0, NULL);
1149 ok(err==ok_snd || err==MCIERR_HARDWARE, "mci sound NoSuchSoundDefined returned %s\n", dbg_mcierr(err));
1150
1151 err = mciSendStringA("sound SystemExclamation notify wait", NULL, 0, hwnd);
1152 ok(err==ok_snd || err==MCIERR_HARDWARE, "mci sound SystemExclamation returned %s\n", dbg_mcierr(err));
1153 test_notification(hwnd, "sound notify", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
1154
1155 Sleep(16); /* time to auto-close makes sysinfo below return expected error */
1156 err = mciSendStringA("sysinfo waveaudio notify name 1 open", buf, sizeof(buf), hwnd);
1157 ok(err==MCIERR_OUTOFRANGE,"sysinfo waveaudio name 1 returned %s\n", dbg_mcierr(err));
1158 if(!err) trace("sysinfo dangling open alias: %s\n", buf);
1159 test_notification(hwnd, "sysinfo name outofrange\n", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
1160
1161 err = mciSendStringA("play no-such-file-exists.wav notify", buf, sizeof(buf), NULL);
1162 todo_wine ok(err==MCIERR_NOTIFY_ON_AUTO_OPEN,"mci auto-open notify returned %s\n", dbg_mcierr(err));
1163 /* FILE_NOT_FOUND in Wine because auto-open fails before testing the notify flag */
1164
1165 test_notification(hwnd, "-prior to auto-open-", 0);
1166
1167 err = mciSendStringA("play tempfile.wav notify", buf, sizeof(buf), hwnd);
1168 todo_wine_if (ok_saved == MCIERR_FILE_NOT_FOUND) /* same as above */
1169 ok(err==MCIERR_NOTIFY_ON_AUTO_OPEN,"mci auto-open play notify returned %s\n", dbg_mcierr(err));
1170
1171 if(err) /* FIXME: don't open twice yet, it confuses Wine. */
1172 err = mciSendStringA("play tempfile.wav", buf, sizeof(buf), hwnd);
1173 ok(err==ok_saved,"mci auto-open play returned %s\n", dbg_mcierr(err));
1174
1176 skip("Cannot open tempfile.wav for auto-play, skipping\n");
1177 return;
1178 }
1179
1180 err = mciSendStringA("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
1181 ok(!err,"mci sysinfo waveaudio quantity after auto-open returned %s\n", dbg_mcierr(err));
1182 if(!err) ok(!strcmp(buf,"1"), "sysinfo quantity open expected 1, got: %s\n", buf);
1183
1184 parm.sys.lpstrReturn = (LPSTR)&intbuf[1];
1185 parm.sys.dwRetSize = 2*sizeof(DWORD); /* only one DWORD is used */
1188 ok(!err, "mciCommand sysinfo waveaudio open notify returned %s\n", dbg_mcierr(err));
1189 if(!err) ok(atoi(buf)==intbuf[1],"sysinfo waveaudio quantity open string and command differ\n");
1190
1191 err = mciSendStringA("sysinfo waveaudio name 1 open notify", buf, sizeof(buf), hwnd);
1192 ok(!err,"mci sysinfo waveaudio name after auto-open returned %s\n", dbg_mcierr(err));
1193 /* This is the alias, not necessarily a file name. */
1194 if(!err) ok(!strcmp(buf,"tempfile.wav"), "sysinfo name 1 open: %s\n", buf);
1195 test_notification(hwnd, "sysinfo name notify\n", MCI_NOTIFY_SUCCESSFUL);
1196
1197 err = mciGetDeviceIDA("tempfile.wav");
1198 ok(err == 1, "mciGetDeviceIDA tempfile.wav returned %u, expected 1\n", err);
1199
1200 /* Save the full pathname to the file. */
1201 err = mciSendStringA("info tempfile.wav file", path, sizeof(path), NULL);
1202 ok(!err,"mci info tempfile.wav file returned %s\n", dbg_mcierr(err));
1203 if(err) strcpy(path,"tempfile.wav");
1204
1205 err = mciSendStringA("status tempfile.wav mode", NULL, 0, hwnd);
1206 ok(!err,"mci status tempfile.wav mode without buffer returned %s\n", dbg_mcierr(err));
1207
1208 sprintf(command,"status \"%s\" mode",path);
1209 err = mciSendStringA(command, buf, sizeof(buf), hwnd);
1210 ok(!err,"mci status \"%s\" mode returned %s\n", path, dbg_mcierr(err));
1211
1212 err = mciSendStringA("status tempfile.wav mode", buf, sizeof(buf), hwnd);
1213 ok(!err,"mci status tempfile.wav mode returned %s\n", dbg_mcierr(err));
1214 if(!err) ok(!strcmp(buf,"playing"), "mci auto-open status mode, got: %s\n", buf);
1215
1216 err = mciSendStringA("open tempfile.wav", buf, sizeof(buf), NULL);
1217 ok(err==MCIERR_DEVICE_OPEN, "mci open from auto-open returned %s\n", dbg_mcierr(err));
1218
1219 err = mciSendStringA("open foo.wav alias tempfile.wav", buf, sizeof(buf), NULL);
1220 ok(err==MCIERR_DUPLICATE_ALIAS, "mci open re-using alias returned %s\n", dbg_mcierr(err));
1221
1222 /* w2k/xp and Wine differ. While the device is busy playing, it is
1223 * regularly open and accessible via the filename: subsequent
1224 * commands must not cause auto-open each. In Wine, a subsequent
1225 * command with notify request may cause the initial play
1226 * notification to be superseded, in turn causing MCI to close the
1227 * device. I.e. MCI uses the auto-open notification for itself,
1228 * that's why it's not available to the app. On w2k/xp,
1229 * subsequent commands with notify requests are returned with
1230 * MCIERR_NOTIFY_ON_AUTO_OPEN and thus don't abort the original
1231 * command.
1232 */
1233 err = mciSendStringA("status tempfile.wav mode notify", buf, sizeof(buf), hwnd);
1234 todo_wine ok(err==MCIERR_NOTIFY_ON_AUTO_OPEN, "mci status auto-open notify returned %s\n", dbg_mcierr(err));
1235 if(!err) {
1236 trace("Wine style MCI auto-close upon notification\n");
1237
1238 /* "playing" because auto-close comes after the status call. */
1239 ok(!strcmp(buf,"playing"), "mci auto-open status mode notify, got: %s\n", buf);
1240 /* fixme:winmm:MMDRV_Exit Closing while ll-driver open
1241 * is explained by failure to auto-close a device. */
1243 /* MCI received NOTIFY_SUPERSEDED and auto-closed the device. */
1244
1245 /* Until this is implemented, force closing the device */
1246 err = mciSendStringA("close tempfile.wav", NULL, 0, hwnd);
1247 ok(!err,"mci auto-still-open stop returned %s\n", dbg_mcierr(err));
1248 Sleep(16);
1249 test_notification(hwnd,"auto-open",0);
1250 } else if(err==MCIERR_NOTIFY_ON_AUTO_OPEN) { /* MS style */
1251 trace("MS style MCI auto-open forbids notification\n");
1252
1253 err = mciSendStringA("pause tempfile.wav", NULL, 0, hwnd);
1254 ok(!err,"mci auto-still-open pause returned %s\n", dbg_mcierr(err));
1255
1256 err = mciSendStringA("status tempfile.wav mode", buf, sizeof(buf), hwnd);
1257 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1258 if(!err) ok(!strcmp(buf,"paused"), "mci auto-open status mode, got: %s\n", buf);
1259
1260 /* Auto-close */
1261 err = mciSendStringA("stop tempfile.wav wait", NULL, 0, hwnd);
1262 ok(!err,"mci auto-still-open stop returned %s\n", dbg_mcierr(err));
1263 Sleep(16); /* makes sysinfo quantity open below succeed */
1264 }
1265
1266 err = mciSendStringA("sysinfo waveaudio quantity open", buf, sizeof(buf), NULL);
1267 ok(!err,"mci sysinfo waveaudio quantity open after close returned %s\n", dbg_mcierr(err));
1268 if(!err) ok(!strcmp(buf,"0"), "sysinfo quantity open expected 0 after auto-close, got: %s\n", buf);
1269
1270 /* w95-WinME (not w2k/XP) switch to C:\ after auto-playing once. Prevent
1271 * MCIERR_FILE_NOT_FOUND by using the full path name from the Info file command.
1272 */
1273 sprintf(command,"status \"%s\" mode wait",path);
1274 err = mciSendStringA(command, buf, sizeof(buf), hwnd);
1275 ok(!err,"mci re-auto-open status mode returned %s\n", dbg_mcierr(err));
1276 if(!err) ok(!strcmp(buf,"stopped"), "mci re-auto-open status mode, got: %s\n", buf);
1277
1278 /* This uses auto-open as well. */
1279 err = mciSendStringA("capability waveaudio outputs", buf, sizeof(buf), NULL);
1280 ok(!err,"mci capability waveaudio outputs returned %s\n", dbg_mcierr(err));
1281 /* Wine with no sound selected in winecfg's audio tab fails this test. */
1282 if(!err) ok(atoi(buf)==ndevs,"Expected %d audio outputs, got %s\n", ndevs, buf);
1283
1284 err = mciSendStringA("capability waveaudio device type", buf, sizeof(buf), hwnd);
1285 ok(!err,"mci capability device type returned %s\n", dbg_mcierr(err));
1286 if(!err) ok(!strcmp(buf,"waveaudio"), "mci capability device type response: %s\n", buf);
1287
1288 /* waveaudio forbids Pause without Play. */
1289 sprintf(command,"pause \"%s\"",path);
1291 ok(err==MCIERR_NONAPPLICABLE_FUNCTION,"mci auto-open pause returned %s\n", dbg_mcierr(err));
1292
1293 ok(0xDEADF00D==intbuf[0] && 0xABADCAFE==intbuf[2],"DWORD buffer corruption\n");
1294}
1295
1297{
1298 MCIERROR err;
1299 MCIDEVICEID wDeviceID;
1300 MCI_PLAY_PARMS play_parm;
1301 MCI_STATUS_PARMS status_parm;
1302 char buf[1024];
1303 memset(buf, 0, sizeof(buf));
1304
1305 err = mciSendStringA("open tempfile.wav type MPEGVideo alias mysound", NULL, 0, NULL);
1306 ok(err==ok_saved,"mci open tempfile.wav type MPEGVideo returned %s\n", dbg_mcierr(err));
1307 if(err) {
1308 skip("Cannot open tempfile.wav type MPEGVideo for playing (%s), skipping\n", dbg_mcierr(err));
1309 return;
1310 }
1311
1312 wDeviceID = mciGetDeviceIDA("mysound");
1313 ok(wDeviceID == 1, "mciGetDeviceIDA mysound returned %u, expected 1\n", wDeviceID);
1314
1315 err = mciSendCommandA(wDeviceID, MCI_PLAY, 0, (DWORD_PTR)&play_parm);
1316 ok(!err,"mciCommand play returned %s\n", dbg_mcierr(err));
1317
1318 err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
1319 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1320 ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
1321
1322 status_parm.dwItem = MCI_STATUS_MODE;
1323 err = mciSendCommandA(wDeviceID, MCI_STATUS,
1325 (DWORD_PTR)&status_parm);
1326 ok(!err,"mciCommand status mode returned %s\n", dbg_mcierr(err));
1327 ok(status_parm.dwReturn == MCI_MODE_PLAY,
1328 "mciCommand status mode: %u\n", (DWORD)status_parm.dwReturn);
1329
1330 err = mciSendStringA("setaudio mysound volume to 1000", NULL, 0, NULL);
1331 ok(!err,"mci setaudio volume to 1000 returned %s\n", dbg_mcierr(err));
1332
1333 err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
1334 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1335 ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
1336
1337 err = mciSendStringA("setaudio mysound volume to 1001", NULL, 0, NULL);
1338 ok(err==MCIERR_OUTOFRANGE,"mci setaudio volume to 1001 returned %s\n", dbg_mcierr(err));
1339
1340 err = mciSendStringA("status mysound mode", buf, sizeof(buf), NULL);
1341 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1342 ok(!strcmp(buf,"playing"), "mci status mode: %s\n", buf);
1343
1344 err = mciSendStringA("close mysound", NULL, 0, NULL);
1345 ok(!err,"mci close returned %s\n", dbg_mcierr(err));
1346}
1347
1349{
1350 MCIDEVICEID wDeviceID;
1351 int err;
1352 char buf[1024];
1353 memset(buf, 0, sizeof(buf));
1354
1355 err = mciSendStringA("open tempfile.wav alias mysound notify type mpegvideo", buf, sizeof(buf), hwnd);
1356 ok(err==ok_saved,"mci open tempfile.wav returned %s\n", dbg_mcierr(err));
1357 if(err) {
1358 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(err));
1359 return;
1360 }
1361 ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
1362 wDeviceID = atoi(buf);
1363 ok(wDeviceID,"mci open DeviceID: %d\n", wDeviceID);
1364 test_notification(hwnd,"open alias notify",MCI_NOTIFY_SUCCESSFUL);
1365
1366 err = mciSendStringA("play mysound notify", NULL, 0, hwnd);
1367 ok(!err,"mci play returned %s\n", dbg_mcierr(err));
1368
1369 Sleep(500); /* milliseconds */
1370
1371 err = mciSendStringA("pause mysound wait", NULL, 0, hwnd);
1372 ok(!err,"mci pause wait returned %s\n", dbg_mcierr(err));
1373
1374 err = mciSendStringA("status mysound mode notify", buf, sizeof(buf), hwnd);
1375 ok(!err,"mci status mode returned %s\n", dbg_mcierr(err));
1376 if(!err) ok(!strcmp(buf,"paused"), "mci status mode: %s\n", buf);
1377 test_notification(hwnd,"play (superseded)",MCI_NOTIFY_SUPERSEDED);
1379
1380 err = mciSendStringA("seek mysound to start wait", NULL, 0, NULL);
1381 ok(!err,"mci seek to start wait returned %s\n", dbg_mcierr(err));
1382
1383 err = mciSendStringA("set mysound time format milliseconds", NULL, 0, NULL);
1384 ok(!err,"mci time format milliseconds returned %s\n", dbg_mcierr(err));
1385
1386 err = mciSendStringA("play mysound to 1500 notify", NULL, 0, hwnd);
1387 ok(!err,"mci play returned %s\n", dbg_mcierr(err));
1388 Sleep(200);
1389 test_notification(hwnd,"play",0);
1390
1391 err = mciSendStringA("close mysound wait", NULL, 0, NULL);
1392 ok(!err,"mci close wait returned %s\n", dbg_mcierr(err));
1393 test_notification(hwnd,"play (aborted by close)",MCI_NOTIFY_ABORTED);
1394}
1395
1397{
1398 HANDLE evt = p;
1399 MCIERROR mr;
1400
1401 mr = mciSendStringA("play x", NULL, 0, NULL);
1402 ok(mr == MCIERR_INVALID_DEVICE_NAME, "play gave: 0x%x\n", mr);
1403
1404 mr = mciSendStringA("close x", NULL, 0, NULL);
1405 ok(mr == MCIERR_INVALID_DEVICE_NAME, "close gave: 0x%x\n", mr);
1406
1407 SetEvent(evt);
1408
1409 return 0;
1410}
1411
1412static void test_threads(void)
1413{
1414 MCIERROR mr;
1415 HANDLE evt;
1416
1417 mr = mciSendStringA("open tempfile.wav alias x", NULL, 0, NULL);
1418 ok(mr == 0 || mr == ok_saved, "open gave: 0x%x\n", mr);
1419 if(mr){
1420 skip("Cannot open tempfile.wav for playing (%s), skipping\n", dbg_mcierr(mr));
1421 return;
1422 }
1423
1424 evt = CreateEventW( NULL, TRUE, FALSE, NULL );
1425
1426 CloseHandle(CreateThread(NULL, 0, &thread_cb, evt, 0, NULL));
1427
1429
1430 CloseHandle(evt);
1431
1432 mr = mciSendStringA("close x", NULL, 0, NULL);
1433 ok(mr == 0, "close gave: 0x%x\n", mr);
1434}
1435
1437{
1438 char curdir[MAX_PATH], tmpdir[MAX_PATH];
1439 MCIERROR err;
1440 HWND hwnd;
1441
1445
1446 hwnd = CreateWindowExA(0, "static", "winmm test", WS_POPUP, 0,0,100,100,
1447 0, 0, 0, NULL);
1451 if(waveOutGetNumDevs()){
1452 test_threads();
1458 }else
1459 skip("No output devices available, skipping all output tests\n");
1460 /* Win9X hangs when exiting with something still open. */
1461 err = mciSendStringA("close all", NULL, 0, hwnd);
1462 ok(!err,"final close all returned %s\n", dbg_mcierr(err));
1463 ok(DeleteFileA("tempfile.wav") || ok_saved, "Delete tempfile.wav (cause auto-open?)\n");
1465
1466 SetCurrentDirectoryA(curdir);
1467}
#define broken(x)
Definition: _sntprintf.h:21
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
#define msg(x)
Definition: auth_time.c:54
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define WideCharToMultiByte
Definition: compat.h:111
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2206
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
DWORD WINAPI mciSendCommandA(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: mci.c:2289
DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet, UINT uRetLen, HWND hwndCallback)
Definition: mci.c:1586
DWORD WINAPI mciSendCommandW(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
Definition: mci.c:2273
UINT WINAPI mciGetDeviceIDA(LPCSTR lpstrName)
Definition: mci.c:2312
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define trace_(file, line,...)
Definition: kmt_test.h:223
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1453
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
#define MCI_SYSINFO_OPEN
Definition: mmsystem.h:769
#define MCIERR_DEVICE_LOCKED
Definition: mmsystem.h:596
#define MCIERR_NOTIFY_ON_AUTO_OPEN
Definition: mmsystem.h:608
#define MCIERR_WAVE_INPUTSUNSUITABLE
Definition: mmsystem.h:629
#define MCIERR_WAVE_SETOUTPUTUNSUITABLE
Definition: mmsystem.h:628
#define MCIERR_FLAGS_NOT_COMPATIBLE
Definition: mmsystem.h:593
#define MCI_INFO_PRODUCT
Definition: mmsystem.h:752
#define MCIERR_UNNAMED_RESOURCE
Definition: mmsystem.h:606
#define MCI_NOTIFY_SUPERSEDED
Definition: mmsystem.h:726
#define MCIERR_NEW_REQUIRES_ALIAS
Definition: mmsystem.h:607
#define MCI_NOTIFY
Definition: mmsystem.h:729
#define MCI_TO
Definition: mmsystem.h:732
#define MCIERR_INVALID_DEVICE_NAME
Definition: mmsystem.h:573
#define MCI_WAVE_SET_SAMPLESPERSEC
Definition: mmsystem.h:824
#define MCI_SYSINFO_NAME
Definition: mmsystem.h:770
#define MCI_GETDEVCAPS_HAS_VIDEO
Definition: mmsystem.h:761
#define MCI_STATUS_POSITION
Definition: mmsystem.h:745
#define MCIERR_WAVE_SETINPUTUNSUITABLE
Definition: mmsystem.h:630
#define MCIERR_EXTRA_CHARACTERS
Definition: mmsystem.h:613
#define MCIERR_SEQ_PORTUNSPECIFIED
Definition: mmsystem.h:637
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
#define MCI_GETDEVCAPS
Definition: mmsystem.h:654
#define MCIERR_SEQ_TIMER
Definition: mmsystem.h:636
#define MCIERR_MISSING_DEVICE_NAME
Definition: mmsystem.h:600
#define MCI_OPEN_ELEMENT
Definition: mmsystem.h:735
#define MCIERR_HARDWARE
Definition: mmsystem.h:572
#define MCI_FORMAT_SAMPLES
Definition: mmsystem.h:710
#define MCI_FORMAT_MILLISECONDS
Definition: mmsystem.h:701
#define MCI_MODE_PLAY
Definition: mmsystem.h:696
#define MCIERR_FILE_NOT_FOUND
Definition: mmsystem.h:585
#define MCIERR_CANNOT_LOAD_DRIVER
Definition: mmsystem.h:576
#define MCIERR_WAVE_SETINPUTINUSE
Definition: mmsystem.h:624
#define MCIERR_DEVICE_TYPE_REQUIRED
Definition: mmsystem.h:595
#define MCI_GETDEVCAPS_DEVICE_TYPE
Definition: mmsystem.h:762
#define MCIERR_SEQ_PORT_MISCERROR
Definition: mmsystem.h:635
#define MCIERR_MULTIPLE
Definition: mmsystem.h:590
#define MCIERR_SEQ_NOMIDIPRESENT
Definition: mmsystem.h:638
#define MCIERR_ILLEGAL_FOR_AUTO_OPEN
Definition: mmsystem.h:611
#define MCIERR_NO_CLOSING_QUOTE
Definition: mmsystem.h:602
#define MCI_STATUS
Definition: mmsystem.h:662
#define MCIERR_DEVICE_NOT_READY
Definition: mmsystem.h:586
#define MCI_OPEN_TYPE_ID
Definition: mmsystem.h:738
#define MCIERR_NO_IDENTITY
Definition: mmsystem.h:643
#define MCIERR_UNRECOGNIZED_COMMAND
Definition: mmsystem.h:571
#define MCIERR_DEVICE_ORD_LENGTH
Definition: mmsystem.h:619
#define MCIERR_SEQ_PORT_MAPNODEVICE
Definition: mmsystem.h:634
#define MCIERR_DUPLICATE_FLAGS
Definition: mmsystem.h:603
#define MCI_WAVE_SET_AVGBYTESPERSEC
Definition: mmsystem.h:825
#define MCI_SET
Definition: mmsystem.h:656
#define MCIERR_FILENAME_REQUIRED
Definition: mmsystem.h:612
#define MCIERR_BAD_INTEGER
Definition: mmsystem.h:580
#define MCI_GETDEVCAPS_USES_FILES
Definition: mmsystem.h:763
#define MCIERR_EXTENSION_NOT_FOUND
Definition: mmsystem.h:591
#define MCI_ALL_DEVICE_ID
Definition: mmsystem.h:679
#define MCIERR_GET_CD
Definition: mmsystem.h:615
#define MCI_WAVE_GETDEVCAPS_INPUTS
Definition: mmsystem.h:839
#define MCIERR_WAVE_SETOUTPUTINUSE
Definition: mmsystem.h:622
DWORD MCIERROR
Definition: mmsystem.h:958
#define MCIERR_FILE_WRITE
Definition: mmsystem.h:642
#define MCIERR_WAVE_OUTPUTUNSPECIFIED
Definition: mmsystem.h:625
#define MCIERR_BAD_CONSTANT
Definition: mmsystem.h:598
#define MCIERR_PARAM_OVERFLOW
Definition: mmsystem.h:578
#define MCI_CLOSE
Definition: mmsystem.h:647
#define MCIERR_INVALID_DEVICE_ID
Definition: mmsystem.h:569
#define MCI_SET_TIME_FORMAT
Definition: mmsystem.h:774
#define MCI_SEEK
Definition: mmsystem.h:650
#define MCIERR_SEQ_PORT_NONEXISTENT
Definition: mmsystem.h:633
#define MCIERR_INVALID_FILE
Definition: mmsystem.h:604
#define MCIERR_DEVICE_OPEN
Definition: mmsystem.h:575
#define MCIERR_MISSING_PARAMETER
Definition: mmsystem.h:583
#define MCIERR_INTERNAL
Definition: mmsystem.h:587
#define MCIERR_DRIVER
Definition: mmsystem.h:588
#define MCIERR_NULL_PARAMETER_BLOCK
Definition: mmsystem.h:605
#define MCI_NOTIFY_ABORTED
Definition: mmsystem.h:727
#define MCIERR_NO_WINDOW
Definition: mmsystem.h:639
#define MCIERR_FILE_NOT_SAVED
Definition: mmsystem.h:594
#define MCIERR_DRIVER_INTERNAL
Definition: mmsystem.h:582
#define MCIERR_OUTOFRANGE
Definition: mmsystem.h:592
#define MCI_WAVE_SET_FORMATTAG
Definition: mmsystem.h:822
#define MCI_OPEN
Definition: mmsystem.h:646
#define MCIERR_CREATEWINDOW
Definition: mmsystem.h:640
#define MCIERR_CANNOT_USE_ALL
Definition: mmsystem.h:589
#define MCIERR_NO_INTEGER
Definition: mmsystem.h:620
#define MCIERR_WAVE_INPUTUNSPECIFIED
Definition: mmsystem.h:626
UINT MCIDEVICEID
Definition: mmsystem.h:959
#define MCIERR_OUT_OF_MEMORY
Definition: mmsystem.h:574
#define MCIERR_SEQ_PORT_INUSE
Definition: mmsystem.h:632
#define MCI_WAVE_SET_CHANNELS
Definition: mmsystem.h:823
#define MCI_GETDEVCAPS_ITEM
Definition: mmsystem.h:758
#define MCIERR_WAVE_OUTPUTSUNSUITABLE
Definition: mmsystem.h:627
#define MCI_STATUS_MODE
Definition: mmsystem.h:747
#define MCI_SYSINFO_INSTALLNAME
Definition: mmsystem.h:771
#define MCIERR_UNRECOGNIZED_KEYWORD
Definition: mmsystem.h:570
#define MCI_WAVE_SET_BITSPERSAMPLE
Definition: mmsystem.h:827
#define MCI_DEVTYPE_WAVEFORM_AUDIO
Definition: mmsystem.h:689
#define MCIERR_SET_CD
Definition: mmsystem.h:616
#define MCIERR_WAVE_INPUTSINUSE
Definition: mmsystem.h:623
#define MCI_WAVE_SET_BLOCKALIGN
Definition: mmsystem.h:826
#define MCIERR_DEVICE_NOT_INSTALLED
Definition: mmsystem.h:614
#define MCIERR_DUPLICATE_ALIAS
Definition: mmsystem.h:597
#define MCI_MODE_STOP
Definition: mmsystem.h:695
#define MCIERR_MUST_USE_SHAREABLE
Definition: mmsystem.h:599
#define MCIERR_WAVE_OUTPUTSINUSE
Definition: mmsystem.h:621
#define MCI_WAIT
Definition: mmsystem.h:730
#define MCI_NOTIFY_SUCCESSFUL
Definition: mmsystem.h:725
#define MCI_SYSINFO
Definition: mmsystem.h:659
#define MCIERR_MISSING_COMMAND_STRING
Definition: mmsystem.h:577
#define MCIERR_PARSER_INTERNAL
Definition: mmsystem.h:581
#define MCIERR_MISSING_STRING_ARGUMENT
Definition: mmsystem.h:579
#define MCIERR_SEQ_DIV_INCOMPATIBLE
Definition: mmsystem.h:631
#define MCI_INFO
Definition: mmsystem.h:653
#define MM_MCINOTIFY
Definition: mmsystem.h:55
#define MCIERR_DEVICE_LENGTH
Definition: mmsystem.h:618
#define MCIERR_BAD_TIME_FORMAT
Definition: mmsystem.h:601
#define MCIERR_FILE_READ
Definition: mmsystem.h:641
#define MCIERR_NONAPPLICABLE_FUNCTION
Definition: mmsystem.h:610
#define MCI_OPEN_TYPE
Definition: mmsystem.h:739
#define MCIERR_UNSUPPORTED_FUNCTION
Definition: mmsystem.h:584
#define MCI_PLAY
Definition: mmsystem.h:649
#define MCIERR_NO_ELEMENT_ALLOWED
Definition: mmsystem.h:609
#define MCI_STATUS_TIME_FORMAT
Definition: mmsystem.h:749
#define MCI_SYSINFO_QUANTITY
Definition: mmsystem.h:768
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
#define MCIERR_SET_DRIVE
Definition: mmsystem.h:617
#define MCI_OPEN_ALIAS
Definition: mmsystem.h:736
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define expect(expected, got)
Definition: combo.c:36
static const char * strw(LPCWSTR x)
Definition: actctx.c:49
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define todo_wine
Definition: custom.c:79
static void test_recordWAVE(HWND hwnd)
Definition: mci.c:623
static void test_asyncWAVE(HWND hwnd)
Definition: mci.c:932
static void test_playWaveTypeMpegvideo(void)
Definition: mci.c:1296
const char * dbg_mcierr(MCIERROR err)
Definition: mci.c:43
static void test_openCloseWAVE(HWND hwnd)
Definition: mci.c:381
static void test_asyncWaveTypeMpegvideo(HWND hwnd)
Definition: mci.c:1348
static BOOL spurious_message(LPMSG msg)
Definition: mci.c:132
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: mci.c:166
static void test_AutoOpenWAVE(HWND hwnd)
Definition: mci.c:1126
static void test_mciParser(HWND hwnd)
Definition: mci.c:173
static void test_playWAVE(HWND hwnd)
Definition: mci.c:796
#define X(label)
static void test_notification_dbg(HWND hwnd, const char *command, WPARAM type, int line)
Definition: mci.c:144
static MCIERROR ok_saved
Definition: mci.c:30
static void test_threads(void)
Definition: mci.c:1412
#define test_notification(hwnd, command, type)
Definition: mci.c:143
static DWORD CALLBACK thread_cb(void *p)
Definition: mci.c:1396
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define WS_POPUP
Definition: pedump.c:616
#define err(...)
int nch
Definition: scanf.h:135
#define LANG_ENGLISH
Definition: nls.h:52
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define memset(x, y, z)
Definition: compat.h:39
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
Definition: parser.c:49
Definition: name.c:39
DWORD_PTR dwCallback
Definition: mmsystem.h:1517
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
DWORD_PTR dwCallback
Definition: mmsystem.h:1591
MCIDEVICEID wDeviceID
Definition: mmsystem.h:1668
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define DWORD_PTR
Definition: treelist.c:76
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t DWORD_PTR
Definition: typedefs.h:65
MCI_SEEK_PARMS seek
Definition: mci.c:39
MCI_SYSINFO_PARMSA sys
Definition: mci.c:38
MCI_GETDEVCAPS_PARMS caps
Definition: mci.c:37
MCI_WAVE_SET_PARMS set
Definition: mci.c:35
MCI_GENERIC_PARMS gen
Definition: mci.c:40
MCI_WAVE_OPEN_PARMSA open
Definition: mci.c:36
MCI_STATUS_PARMS status
Definition: mci.c:34
MCI_INFO_PARMSA info
Definition: mci.c:33
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
UINT_PTR WPARAM
Definition: windef.h:207
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
UINT WINAPI waveInGetNumDevs(void)
Definition: winmm.c:2568
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1186
#define QS_POSTMESSAGE
Definition: winuser.h:871
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175