1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1995 Marcus Meissner
8 /* FIXME: special commands of device drivers should be handled by those drivers
11 /* FIXME: this current implementation does not allow commands like
12 * capability <filename> can play
13 * which is allowed by the MCI standard.
20 #include <sys/ioctl.h>
21 #include "multimedia.h"
30 /* FIXME the following definitions must be moved to mmsystem.c */
31 extern struct WINE_MCIDRIVER mciDrv[MAXMCIDRIVERS];
33 #define MCI_GetDrv(wDevID) (&mciDrv[MCI_DevIDToIndex(wDevID)])
34 #define MCI_GetOpenDrv(wDevID) (&(MCI_GetDrv(wDevID)->mop))
37 /* The reason why I just don't lowercase the keywords array in
38 * mciSendString is left as an exercise to the reader.
40 #define STRCMP(x,y) lstrcmpiA(x,y)
42 /* standard function parameters for all functions */
43 #define _MCISTR_PROTO_ \
44 WORD wDevID, WORD uDevTyp, LPSTR lpstrReturnString, \
45 UINT16 uReturnLength, LPCSTR dev, LPSTR *keywords, \
46 UINT16 nrofkeywords, DWORD dwFlags, HWND16 hwndCallback
48 /* copy string to return pointer including necessary checks
49 * for use in mciSendString()
53 TRACE(mci, "->returns '%s'\n", s); \
54 if (lpstrReturnString) { \
55 lstrcpynA(lpstrReturnString, s, uReturnLength); \
56 TRACE(mci, "-->'%s'\n", lpstrReturnString); \
60 /* print a DWORD in the specified timeformat */
62 _MCISTR_printtf(char *buf,UINT16 uDevType,DWORD timef,DWORD val)
66 case MCI_FORMAT_MILLISECONDS:
67 case MCI_FORMAT_FRAMES:
68 case MCI_FORMAT_BYTES:
69 case MCI_FORMAT_SAMPLES:
70 case MCI_VD_FORMAT_TRACK:
71 /*case MCI_SEQ_FORMAT_SONGPTR: sameas MCI_VD_FORMAT_TRACK */
72 sprintf(buf, "%ld",val);
75 /* well, the macros have the same content*/
78 sprintf(buf, "%d:%d:%d",
84 sprintf(buf, "%d:%d:%d:%d",
88 MCI_TMSF_FRAME(val) );
91 FIXME(mci, "missing timeformat for %ld, report.\n",timef);
92 strcpy(buf,"0"); /* hmm */
97 /* possible different return types */
99 #define _MCISTR_time 2
100 #define _MCISTR_bool 3
101 #define _MCISTR_tfname 4
102 #define _MCISTR_mode 5
103 #define _MCISTR_divtype 6
104 #define _MCISTR_seqtype 7
105 #define _MCISTR_vdmtype 8
106 #define _MCISTR_devtype 9
109 _MCISTR_convreturn(int type,DWORD dwReturn,LPSTR lpstrReturnString,
110 WORD uReturnLength,WORD uDevTyp,int timef)
113 case _MCISTR_vdmtype:
115 case MCI_VD_MEDIA_CLV: _MCI_STR("CLV"); break;
116 case MCI_VD_MEDIA_CAV: _MCI_STR("CAV"); break;
118 case MCI_VD_MEDIA_OTHER:_MCI_STR("other"); break;
121 case _MCISTR_seqtype:
123 case MCI_SEQ_NONE: _MCI_STR("none"); break;
124 case MCI_SEQ_SMPTE: _MCI_STR("smpte"); break;
125 case MCI_SEQ_FILE: _MCI_STR("file"); break;
126 case MCI_SEQ_MIDI: _MCI_STR("midi"); break;
127 default:FIXME(mci,"missing sequencer mode %ld\n",dwReturn);
132 case MCI_MODE_NOT_READY:_MCI_STR("not ready"); break;
133 case MCI_MODE_STOP: _MCI_STR("stopped"); break;
134 case MCI_MODE_PLAY: _MCI_STR("playing"); break;
135 case MCI_MODE_RECORD: _MCI_STR("recording"); break;
136 case MCI_MODE_SEEK: _MCI_STR("seeking"); break;
137 case MCI_MODE_PAUSE: _MCI_STR("paused"); break;
138 case MCI_MODE_OPEN: _MCI_STR("open"); break;
150 sprintf(buf,"%ld",dwReturn);
156 _MCISTR_printtf(buf,uDevTyp,timef,dwReturn);
162 case MCI_FORMAT_MILLISECONDS: _MCI_STR("milliseconds"); break;
163 case MCI_FORMAT_FRAMES: _MCI_STR("frames"); break;
164 case MCI_FORMAT_BYTES: _MCI_STR("bytes"); break;
165 case MCI_FORMAT_SAMPLES: _MCI_STR("samples"); break;
166 case MCI_FORMAT_HMS: _MCI_STR("hms"); break;
167 case MCI_FORMAT_MSF: _MCI_STR("msf"); break;
168 case MCI_FORMAT_TMSF: _MCI_STR("tmsf"); break;
170 FIXME(mci,"missing timefmt for %d, report.\n",timef);
174 case _MCISTR_divtype:
176 case MCI_SEQ_DIV_PPQN: _MCI_STR("PPQN"); break;
177 case MCI_SEQ_DIV_SMPTE_24: _MCI_STR("SMPTE 24 frame"); break;
178 case MCI_SEQ_DIV_SMPTE_25: _MCI_STR("SMPTE 25 frame"); break;
179 case MCI_SEQ_DIV_SMPTE_30: _MCI_STR("SMPTE 30 frame"); break;
180 case MCI_SEQ_DIV_SMPTE_30DROP: _MCI_STR("SMPTE 30 frame drop");break;
182 case _MCISTR_devtype:
184 case MCI_DEVTYPE_VCR: _MCI_STR("vcr"); break;
185 case MCI_DEVTYPE_VIDEODISC: _MCI_STR("videodisc"); break;
186 case MCI_DEVTYPE_CD_AUDIO: _MCI_STR("cd audio"); break;
187 case MCI_DEVTYPE_OVERLAY: _MCI_STR("overlay"); break;
188 case MCI_DEVTYPE_DAT: _MCI_STR("dat"); break;
189 case MCI_DEVTYPE_SCANNER: _MCI_STR("scanner"); break;
190 case MCI_DEVTYPE_ANIMATION: _MCI_STR("animation"); break;
191 case MCI_DEVTYPE_DIGITAL_VIDEO: _MCI_STR("digital video"); break;
192 case MCI_DEVTYPE_OTHER: _MCI_STR("other"); break;
193 case MCI_DEVTYPE_WAVEFORM_AUDIO:_MCI_STR("waveform audio"); break;
194 case MCI_DEVTYPE_SEQUENCER: _MCI_STR("sequencer"); break;
195 default:FIXME(mci,"unknown device type %ld, report.\n",
200 FIXME(mci,"unknown resulttype %d, report.\n",type);
205 #define FLAG1(str,flag) \
206 if (!STRCMP(keywords[i],str)) { \
212 #define FLAG2(str1,str2,flag) \
213 if (!STRCMP(keywords[i],str1) && \
214 (i+1<nrofkeywords) && \
215 !STRCMP(keywords[i+1],str2)) { \
221 /* All known subcommands are implemented in single functions to avoid
222 * bloat and a xxxx lines long mciSendString(). All commands are of the
223 * format MCISTR_Cmd(_MCISTR_PROTO_) where _MCISTR_PROTO_ is the above
224 * defined line of arguments. (This is just for easy enhanceability.)
225 * All functions return the MCIERR_ errorvalue as DWORD. Returnvalues
226 * for the calls are in lpstrReturnString (If I mention return values
227 * in function headers, I mean returnvalues in lpstrReturnString.)
228 * Integers are sprintf("%d")ed integers. Boolean values are
229 * "true" and "false".
230 * timeformat depending values are "%d" "%d:%d" "%d:%d:%d" "%d:%d:%d:%d"
231 * FIXME: is above line correct?
233 * Preceding every function is a list of implemented/known arguments.
234 * Feel free to add missing arguments.
239 * Opens the specified MCI driver.
243 * "alias <aliasname>"
244 * "element <elementname>"
247 * "buffer <nrBytesPerSec>"
249 * "nostatic" increaste nr of nonstatic colours
250 * "parent <windowhandle>"
251 * "style <mask>" bitmask of WS_xxxxx (see windows.h)
252 * "style child" WS_CHILD
253 * "style overlap" WS_OVERLAPPED
254 * "style popup" WS_POPUP
256 * "parent <windowhandle>"
257 * "style <mask>" bitmask of WS_xxxxx (see windows.h)
258 * "style child" WS_CHILD
259 * "style overlap" WS_OVERLAPPED
260 * "style popup" WS_POPUP
264 MCISTR_Open(_MCISTR_PROTO_)
269 MCI_OPEN_PARMS16 openParams;
270 MCI_WAVE_OPEN_PARMS16 waveopenParams;
271 MCI_ANIM_OPEN_PARMS16 animopenParams;
272 MCI_OVLY_OPEN_PARMS16 ovlyopenParams;
274 union U *pU = xmalloc(sizeof(union U));
276 pU->openParams.lpstrElementName = NULL;
280 pU->openParams.lpstrElementName = strdup(s);
281 dwFlags |= MCI_OPEN_ELEMENT;
283 uDevTyp = MCI_GetDevType(dev);
285 free(pU->openParams.lpstrElementName);
287 return MCIERR_INVALID_DEVICE_NAME;
290 pU->openParams.dwCallback = hwndCallback;
291 pU->openParams.wDeviceID = wDevID;
292 pU->openParams.wReserved0 = 0;
293 pU->ovlyopenParams.dwStyle = 0;
294 pU->animopenParams.dwStyle = 0;
295 pU->openParams.lpstrDeviceType = strdup(dev);
296 pU->openParams.lpstrAlias = NULL;
297 dwFlags |= MCI_OPEN_TYPE;
299 while (i < nrofkeywords) {
300 FLAG1("shareable",MCI_OPEN_SHAREABLE);
301 if (!STRCMP(keywords[i],"alias") && (i+1 < nrofkeywords)) {
302 dwFlags |= MCI_OPEN_ALIAS;
303 pU->openParams.lpstrAlias = strdup(keywords[i+1]);
307 if (!STRCMP(keywords[i],"element") && (i+1<nrofkeywords)) {
308 dwFlags |= MCI_OPEN_ELEMENT;
309 pU->openParams.lpstrElementName = strdup(keywords[i+1]);
314 case MCI_DEVTYPE_ANIMATION:
315 case MCI_DEVTYPE_DIGITAL_VIDEO:
316 FLAG1("nostatic",MCI_ANIM_OPEN_NOSTATIC);
317 if (!STRCMP(keywords[i],"parent") && (i+1 < nrofkeywords)) {
318 dwFlags |= MCI_ANIM_OPEN_PARENT;
319 sscanf(keywords[i+1], "%hu", &(pU->animopenParams.hWndParent));
323 if (!STRCMP(keywords[i], "style") && (i+1 < nrofkeywords)) {
326 dwFlags |= MCI_ANIM_OPEN_WS;
327 if (!STRCMP(keywords[i+1],"popup")) {
328 pU->animopenParams.dwStyle |= WS_POPUP;
329 } else if (!STRCMP(keywords[i+1],"overlap")) {
330 pU->animopenParams.dwStyle |= WS_OVERLAPPED;
331 } else if (!STRCMP(keywords[i+1],"child")) {
332 pU->animopenParams.dwStyle |= WS_CHILD;
333 } else if (sscanf(keywords[i+1],"%ld",&st)) {
334 pU->animopenParams.dwStyle |= st;
336 FIXME(mci, "unknown 'style' keyword %s, please report.\n", keywords[i+1]);
341 case MCI_DEVTYPE_WAVEFORM_AUDIO:
342 if (!STRCMP(keywords[i],"buffer") && (i+1 < nrofkeywords)) {
343 dwFlags |= MCI_WAVE_OPEN_BUFFER;
344 sscanf(keywords[i+1], "%ld", &(pU->waveopenParams.dwBufferSeconds));
347 case MCI_DEVTYPE_OVERLAY:
348 /* looks just like anim, but without NOSTATIC */
349 if (!STRCMP(keywords[i], "parent") && (i+1 < nrofkeywords)) {
350 dwFlags |= MCI_OVLY_OPEN_PARENT;
351 sscanf(keywords[i+1], "%hd", &(pU->ovlyopenParams.hWndParent));
355 if (!STRCMP(keywords[i],"style") && (i+1 < nrofkeywords)) {
358 dwFlags |= MCI_OVLY_OPEN_WS;
359 if (!STRCMP(keywords[i+1],"popup")) {
360 pU->ovlyopenParams.dwStyle |= WS_POPUP;
361 } else if (!STRCMP(keywords[i+1],"overlap")) {
362 pU->ovlyopenParams.dwStyle |= WS_OVERLAPPED;
363 } else if (!STRCMP(keywords[i+1],"child")) {
364 pU->ovlyopenParams.dwStyle |= WS_CHILD;
365 } else if (sscanf(keywords[i+1],"%ld",&st)) {
366 pU->ovlyopenParams.dwStyle |= st;
368 FIXME(mci,"unknown 'style' keyword %s, please report.\n",keywords[i+1]);
374 FIXME(mci,"unknown parameter passed %s, please report.\n",
378 res = mciSendCommandA(0, MCI_OPEN, dwFlags, (DWORD)pU);
380 free(pU->openParams.lpstrElementName);
381 free(pU->openParams.lpstrDeviceType);
382 free(pU->openParams.lpstrAlias);
387 /* A help function for a lot of others ...
388 * for instance status/play/record/seek etc.
391 _MCISTR_determine_timeformat(LPCSTR dev,WORD wDevID,WORD uDevTyp,int *timef)
394 DWORD dwFlags = MCI_STATUS_ITEM;
395 MCI_STATUS_PARMS *statusParams = xmalloc(sizeof(MCI_STATUS_PARMS));
397 if (!statusParams) return 0;
398 statusParams->dwItem = MCI_STATUS_TIME_FORMAT;
399 statusParams->dwReturn = 0;
400 res = mciSendCommandA(wDevID, MCI_STATUS, dwFlags, (DWORD)statusParams);
402 if (res==0) *timef = statusParams->dwReturn;
407 /* query status of MCI drivers
410 * "mode" - returns "not ready" "paused" "playing" "stopped" "open"
411 * "parked" "recording" "seeking" ....
413 * "current track" - returns current track as integer
414 * "length [track <nr>]" - returns length [of track <nr>] in current
416 * "number of tracks" - returns number of tracks as integer
417 * "position [track <nr>]" - returns position [in track <nr>] in current
419 * "ready" - checks if device is ready to play, -> bool
420 * "start position" - returns start position in timeformat
421 * "time format" - returns timeformat (list of possible values:
422 * "ms" "msf" "milliseconds" "hmsf" "tmsf" "frames"
423 * "bytes" "samples" "hms")
424 * "media present" - returns if media is present as bool
426 * "forward" - returns "true" if device is playing forwards
427 * "speed" - returns speed for device
428 * "palette handle" - returns palette handle
429 * "window handle" - returns window handle
430 * "stretch" - returns stretch bool
432 * "division type" - ? returns "PPQN" "SMPTE 24 frame"
433 * "SMPTE 25 frame" "SMPTE 30 frame" "SMPTE 30 drop frame"
434 * "tempo" - current tempo in (PPQN? speed in frames, SMPTE*? speed in hsmf)
435 * "offset" - offset in dito.
436 * "port" - midi port as integer
437 * "slave" - slave device ("midi","file","none","smpte")
438 * "master" - masterdevice (dito.)
440 * "window handle" - see animation
443 * "speed" - speed as integer
444 * "forward" - returns bool (when playing forward)
445 * "side" - returns 1 or 2
446 * "media type" - returns "CAV" "CLV" "other"
447 * "disc size" - returns "8" or "12"
449 * "input" - base queries on input set
450 * "output" - base queries on output set
451 * "format tag" - return integer format tag
452 * "channels" - return integer nr of channels
453 * "bytespersec" - return average nr of bytes/sec
454 * "samplespersec" - return nr of samples per sec
455 * "bitspersample" - return bitspersample
456 * "alignment" - return block alignment
457 * "level" - return level?
460 #define ITEM1(str,item,xtype) \
461 if (!STRCMP(keywords[i],str)) { \
462 statusParams->dwItem = item; \
467 #define ITEM2(str1,str2,item,xtype) \
468 if ( !STRCMP(keywords[i],str1) && \
469 (i+1 < nrofkeywords) && \
470 !STRCMP(keywords[i+1],str2)) { \
471 statusParams->dwItem = item; \
476 #define ITEM3(str1,str2,str3,item,xtype) \
477 if ( !STRCMP(keywords[i],str1) && \
478 (i+2 < nrofkeywords) && \
479 !STRCMP(keywords[i+1],str2) && \
480 !STRCMP(keywords[i+2],str3)) { \
481 statusParams->dwItem = item; \
488 MCISTR_Status(_MCISTR_PROTO_) {
489 MCI_STATUS_PARMS *statusParams = xmalloc(sizeof(MCI_STATUS_PARMS));
490 int type = 0,i,res,timef;
492 statusParams->dwCallback = hwndCallback;
493 dwFlags |= MCI_STATUS_ITEM;
494 res = _MCISTR_determine_timeformat(dev,wDevID,uDevTyp,&timef);
497 statusParams->dwReturn = 0;
498 statusParams->dwItem = 0;
501 while (i < nrofkeywords) {
502 if (!STRCMP(keywords[i],"track") && (i+1 < nrofkeywords)) {
503 sscanf(keywords[i+1],"%ld",&(statusParams->dwTrack));
504 dwFlags |= MCI_TRACK;
508 FLAG1("start",MCI_STATUS_START);
510 ITEM2("current","track",MCI_STATUS_CURRENT_TRACK,_MCISTR_time);
511 ITEM2("time","format",MCI_STATUS_TIME_FORMAT,_MCISTR_tfname);
512 ITEM1("ready",MCI_STATUS_READY,_MCISTR_bool);
513 ITEM1("mode",MCI_STATUS_MODE,_MCISTR_mode);
514 ITEM3("number","of","tracks",MCI_STATUS_NUMBER_OF_TRACKS,_MCISTR_int);
515 ITEM1("length",MCI_STATUS_LENGTH,_MCISTR_time);
516 ITEM1("position",MCI_STATUS_POSITION,_MCISTR_time);
517 ITEM2("media","present",MCI_STATUS_MEDIA_PRESENT,_MCISTR_bool);
520 case MCI_DEVTYPE_ANIMATION:
521 case MCI_DEVTYPE_DIGITAL_VIDEO:
522 ITEM2("palette","handle",MCI_ANIM_STATUS_HPAL,_MCISTR_int);
523 ITEM2("window","handle",MCI_ANIM_STATUS_HWND,_MCISTR_int);
524 ITEM1("stretch",MCI_ANIM_STATUS_STRETCH,_MCISTR_bool);
525 ITEM1("speed",MCI_ANIM_STATUS_SPEED,_MCISTR_int);
526 ITEM1("forward",MCI_ANIM_STATUS_FORWARD,_MCISTR_bool);
528 case MCI_DEVTYPE_SEQUENCER:
529 /* just completing the list, not working correctly */
530 ITEM2("division","type",MCI_SEQ_STATUS_DIVTYPE,_MCISTR_divtype);
531 /* tempo ... PPQN in frames/second, SMPTE in hmsf */
532 ITEM1("tempo",MCI_SEQ_STATUS_TEMPO,_MCISTR_int);
533 ITEM1("port",MCI_SEQ_STATUS_PORT,_MCISTR_int);
534 ITEM1("slave",MCI_SEQ_STATUS_SLAVE,_MCISTR_seqtype);
535 ITEM1("master",MCI_SEQ_STATUS_SLAVE,_MCISTR_seqtype);
536 /* offset ... PPQN in frames/second, SMPTE in hmsf */
537 ITEM1("offset",MCI_SEQ_STATUS_SLAVE,_MCISTR_time);
539 case MCI_DEVTYPE_OVERLAY:
540 ITEM2("window","handle",MCI_OVLY_STATUS_HWND,_MCISTR_int);
541 ITEM1("stretch",MCI_OVLY_STATUS_STRETCH,_MCISTR_bool);
543 case MCI_DEVTYPE_VIDEODISC:
544 ITEM1("speed",MCI_VD_STATUS_SPEED,_MCISTR_int);
545 ITEM1("forward",MCI_VD_STATUS_FORWARD,_MCISTR_bool);
546 ITEM1("side",MCI_VD_STATUS_SIDE,_MCISTR_int);
547 ITEM2("media","type",MCI_VD_STATUS_SIDE,_MCISTR_vdmtype);
548 /* returns 8 or 12 */
549 ITEM2("disc","size",MCI_VD_STATUS_DISC_SIZE,_MCISTR_int);
551 case MCI_DEVTYPE_WAVEFORM_AUDIO:
552 /* I am not quite sure if foll. 2 lines are right. */
553 FLAG1("input",MCI_WAVE_INPUT);
554 FLAG1("output",MCI_WAVE_OUTPUT);
556 ITEM2("format","tag",MCI_WAVE_STATUS_FORMATTAG,_MCISTR_int);
557 ITEM1("channels",MCI_WAVE_STATUS_CHANNELS,_MCISTR_int);
558 ITEM1("bytespersec",MCI_WAVE_STATUS_AVGBYTESPERSEC,_MCISTR_int);
559 ITEM1("samplespersec",MCI_WAVE_STATUS_SAMPLESPERSEC,_MCISTR_int);
560 ITEM1("bitspersample",MCI_WAVE_STATUS_BITSPERSAMPLE,_MCISTR_int);
561 ITEM1("alignment",MCI_WAVE_STATUS_BLOCKALIGN,_MCISTR_int);
562 ITEM1("level",MCI_WAVE_STATUS_LEVEL,_MCISTR_int);
565 FIXME(mci,"unknown keyword '%s'\n",keywords[i]);
568 if (!statusParams->dwItem)
569 return MCIERR_MISSING_STRING_ARGUMENT;
571 res = mciSendCommandA(wDevID, MCI_STATUS, dwFlags, (DWORD)statusParams);
574 _MCISTR_convreturn(type,statusParams->dwReturn,lpstrReturnString,uReturnLength,uDevTyp,timef);
582 /* set specified parameters in respective MCI drivers
584 * "door open" eject media or somesuch
585 * "door close" load media
586 * "time format <timeformatname>" "ms" "milliseconds" "msf" "hmsf"
587 * "tmsf" "SMPTE 24" "SMPTE 25" "SMPTE 30"
589 * "audio [all|left|right] [on|off]" sets specified audiochannel on or off
590 * "video [on|off]" sets video on/off
592 * "formattag pcm" sets format to pcm
593 * "formattag <nr>" sets integer formattag value
594 * "any input" accept input from any known source
595 * "any output" output to any known destination
596 * "input <nr>" input from source <nr>
597 * "output <nr>" output to destination <nr>
598 * "channels <nr>" sets nr of channels
599 * "bytespersec <nr>" sets average bytes per second
600 * "samplespersec <nr>" sets average samples per second (1 sample can
602 * "alignment <nr>" sets the blockalignment to <nr>
603 * "bitspersample <nr>" sets the nr of bits per sample
605 * "master [midi|file|smpte|none]" sets the midi master device
606 * "slave [midi|file|smpte|none]" sets the midi master device
607 * "port mapper" midioutput to portmapper
608 * "port <nr>" midioutput to specified port
609 * "tempo <nr>" tempo of track (depends on timeformat/divtype)
610 * "offset <nr>" start offset?
613 MCISTR_Set(_MCISTR_PROTO_) {
615 MCI_SET_PARMS setParams;
616 MCI_WAVE_SET_PARMS16 wavesetParams;
617 MCI_SEQ_SET_PARMS seqsetParams;
619 union U *pU = xmalloc(sizeof(union U));
622 pU->setParams.dwCallback = hwndCallback;
624 while (i < nrofkeywords) {
625 FLAG2("door","open",MCI_SET_DOOR_OPEN);
626 FLAG2("door","closed",MCI_SET_DOOR_CLOSED);
628 if ( !STRCMP(keywords[i],"time") &&
629 (i+2 < nrofkeywords) &&
630 !STRCMP(keywords[i+1],"format")
632 dwFlags |= MCI_SET_TIME_FORMAT;
634 /* FIXME:is this a shortcut for milliseconds or
635 * minutes:seconds? */
636 if (!STRCMP(keywords[i+2],"ms"))
637 pU->setParams.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
639 if (!STRCMP(keywords[i+2],"milliseconds"))
640 pU->setParams.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
641 if (!STRCMP(keywords[i+2],"msf"))
642 pU->setParams.dwTimeFormat = MCI_FORMAT_MSF;
643 if (!STRCMP(keywords[i+2],"hms"))
644 pU->setParams.dwTimeFormat = MCI_FORMAT_HMS;
645 if (!STRCMP(keywords[i+2],"frames"))
646 pU->setParams.dwTimeFormat = MCI_FORMAT_FRAMES;
647 if (!STRCMP(keywords[i+2],"track"))
648 pU->setParams.dwTimeFormat = MCI_VD_FORMAT_TRACK;
649 if (!STRCMP(keywords[i+2],"bytes"))
650 pU->setParams.dwTimeFormat = MCI_FORMAT_BYTES;
651 if (!STRCMP(keywords[i+2],"samples"))
652 pU->setParams.dwTimeFormat = MCI_FORMAT_SAMPLES;
653 if (!STRCMP(keywords[i+2],"tmsf"))
654 pU->setParams.dwTimeFormat = MCI_FORMAT_TMSF;
655 if ( !STRCMP(keywords[i+2],"song") &&
656 (i+3 < nrofkeywords) &&
657 !STRCMP(keywords[i+3],"pointer")
659 pU->setParams.dwTimeFormat = MCI_SEQ_FORMAT_SONGPTR;
660 if (!STRCMP(keywords[i+2],"smpte") && (i+3 < nrofkeywords)) {
661 if (!STRCMP(keywords[i+3],"24"))
662 pU->setParams.dwTimeFormat = MCI_FORMAT_SMPTE_24;
663 if (!STRCMP(keywords[i+3],"25"))
664 pU->setParams.dwTimeFormat = MCI_FORMAT_SMPTE_25;
665 if (!STRCMP(keywords[i+3],"30"))
666 pU->setParams.dwTimeFormat = MCI_FORMAT_SMPTE_30;
667 if (!STRCMP(keywords[i+3],"drop") && (i+4 < nrofkeywords) && !STRCMP(keywords[i+4],"30")) {
668 pU->setParams.dwTimeFormat = MCI_FORMAT_SMPTE_30DROP;
677 if (!STRCMP(keywords[i],"audio") && (i+1 < nrofkeywords)) {
678 dwFlags |= MCI_SET_AUDIO;
679 if (!STRCMP(keywords[i+1],"all"))
680 pU->setParams.dwAudio = MCI_SET_AUDIO_ALL;
681 if (!STRCMP(keywords[i+1],"left"))
682 pU->setParams.dwAudio = MCI_SET_AUDIO_LEFT;
683 if (!STRCMP(keywords[i+1],"right"))
684 pU->setParams.dwAudio = MCI_SET_AUDIO_RIGHT;
688 FLAG1("video",MCI_SET_VIDEO);
689 FLAG1("on",MCI_SET_ON);
690 FLAG1("off",MCI_SET_OFF);
692 case MCI_DEVTYPE_WAVEFORM_AUDIO:
693 FLAG2("any","input",MCI_WAVE_SET_ANYINPUT);
694 FLAG2("any","output",MCI_WAVE_SET_ANYOUTPUT);
696 if ( !STRCMP(keywords[i],"formattag") &&
697 (i+1 < nrofkeywords) &&
698 !STRCMP(keywords[i+1],"pcm")
700 dwFlags |= MCI_WAVE_SET_FORMATTAG;
701 pU->wavesetParams.wFormatTag = WAVE_FORMAT_PCM;
706 /* <keyword> <integer> */
707 #define WII(str,flag,fmt,element) \
708 if (!STRCMP(keywords[i],str) && \
709 (i+1 < nrofkeywords)) { \
710 sscanf(keywords[i+1], fmt, \
711 &(pU->wavesetParams. element)); \
716 WII("formattag",MCI_WAVE_SET_FORMATTAG,"%hu",wFormatTag);
717 WII("channels",MCI_WAVE_SET_CHANNELS,"%hu",nChannels);
718 WII("bytespersec",MCI_WAVE_SET_AVGBYTESPERSEC,"%lu",nAvgBytesPerSec);
719 WII("samplespersec",MCI_WAVE_SET_SAMPLESPERSEC,"%lu",nSamplesPerSec);
720 WII("alignment",MCI_WAVE_SET_BLOCKALIGN,"%hu",nBlockAlign);
721 WII("bitspersample",MCI_WAVE_SET_BITSPERSAMPLE,"%hu",wBitsPerSample);
722 WII("input",MCI_WAVE_INPUT,"%hu",wInput);
723 WII("output",MCI_WAVE_OUTPUT,"%hu",wOutput);
726 case MCI_DEVTYPE_SEQUENCER:
727 if (!STRCMP(keywords[i],"master") && (i+1 < nrofkeywords)) {
728 dwFlags |= MCI_SEQ_SET_MASTER;
729 if (!STRCMP(keywords[i+1],"midi"))
730 pU->seqsetParams.dwMaster = MCI_SEQ_MIDI;
731 if (!STRCMP(keywords[i+1],"file"))
732 pU->seqsetParams.dwMaster = MCI_SEQ_FILE;
733 if (!STRCMP(keywords[i+1],"smpte"))
734 pU->seqsetParams.dwMaster = MCI_SEQ_SMPTE;
735 if (!STRCMP(keywords[i+1],"none"))
736 pU->seqsetParams.dwMaster = MCI_SEQ_NONE;
740 if (!STRCMP(keywords[i],"slave") && (i+1 < nrofkeywords)) {
741 dwFlags |= MCI_SEQ_SET_SLAVE;
742 if (!STRCMP(keywords[i+1],"midi"))
743 pU->seqsetParams.dwMaster = MCI_SEQ_MIDI;
744 if (!STRCMP(keywords[i+1],"file"))
745 pU->seqsetParams.dwMaster = MCI_SEQ_FILE;
746 if (!STRCMP(keywords[i+1],"smpte"))
747 pU->seqsetParams.dwMaster = MCI_SEQ_SMPTE;
748 if (!STRCMP(keywords[i+1],"none"))
749 pU->seqsetParams.dwMaster = MCI_SEQ_NONE;
753 if ( !STRCMP(keywords[i],"port") &&
754 (i+1 < nrofkeywords) &&
755 !STRCMP(keywords[i+1],"mapper")
757 pU->seqsetParams.dwPort=-1;/* FIXME:not sure*/
758 dwFlags |= MCI_SEQ_SET_PORT;
762 #define SII(str,flag,element) \
763 if (!STRCMP(keywords[i],str) && (i+1 < nrofkeywords)) {\
764 sscanf(keywords[i+1],"%ld",&(pU->seqsetParams. element));\
769 SII("tempo",MCI_SEQ_SET_TEMPO,dwTempo);
770 SII("port",MCI_SEQ_SET_PORT,dwPort);
771 SII("offset",MCI_SEQ_SET_PORT,dwOffset);
776 return MCIERR_MISSING_STRING_ARGUMENT;
777 res = mciSendCommandA(wDevID, MCI_SET, dwFlags, (DWORD)pU);
784 * "off" disable break
785 * "on <keyid>" enable break on key with keyid
786 * (I strongly suspect, that there is another parameter:
788 * but I don't see it mentioned in my documentation.
792 MCISTR_Break(_MCISTR_PROTO_)
794 MCI_BREAK_PARMS16 *breakParams = xmalloc(sizeof(MCI_BREAK_PARMS16));
797 if (!breakParams) return 0;
798 /*breakParams.hwndBreak ? */
799 for (i = 0; i < nrofkeywords; i++) {
800 FLAG1("off",MCI_BREAK_OFF);
801 if (!strcmp(keywords[i],"on") && (nrofkeywords>i+1)) {
802 dwFlags&=~MCI_BREAK_OFF;
803 dwFlags|=MCI_BREAK_KEY;
804 sscanf(keywords[i+1],"%hd",&(breakParams->nVirtKey));
809 res = mciSendCommandA(wDevID, MCI_BREAK, dwFlags, (DWORD)breakParams);
814 #define ITEM1(str,item,xtype) \
815 if (!STRCMP(keywords[i],str)) { \
816 gdcParams->dwItem = item; \
821 #define ITEM2(str1,str2,item,xtype) \
822 if ( !STRCMP(keywords[i],str1) && \
823 (i+1 < nrofkeywords) && \
824 !STRCMP(keywords[i+1],str2)) { \
825 gdcParams->dwItem = item; \
830 #define ITEM3(str1,str2,str3,item,xtype) \
831 if ( !STRCMP(keywords[i],str1) && \
832 (i+2 < nrofkeywords) && \
833 !STRCMP(keywords[i+1],str2) && \
834 !STRCMP(keywords[i+2],str3)) { \
835 gdcParams->dwItem = item; \
841 /* get device capabilities of MCI drivers
844 * "device type" returns device name as string
845 * "has audio" returns bool
846 * "has video" returns bool
847 * "uses files" returns bool
848 * "compound device" returns bool
849 * "can record" returns bool
850 * "can play" returns bool
851 * "can eject" returns bool
852 * "can save" returns bool
854 * "palettes" returns nr of available palette entries
855 * "windows" returns nr of available windows
856 * "can reverse" returns bool
857 * "can stretch" returns bool
858 * "slow play rate" returns the slow playrate
859 * "fast play rate" returns the fast playrate
860 * "normal play rate" returns the normal playrate
862 * "windows" returns nr of available windows
863 * "can stretch" returns bool
864 * "can freeze" returns bool
866 * "cav" assume CAV discs (default if no disk inserted)
867 * "clv" assume CLV discs
868 * "can reverse" returns bool
869 * "slow play rate" returns the slow playrate
870 * "fast play rate" returns the fast playrate
871 * "normal play rate" returns the normal playrate
873 * "inputs" returns nr of inputdevices
874 * "outputs" returns nr of outputdevices
877 MCISTR_Capability(_MCISTR_PROTO_) {
878 MCI_GETDEVCAPS_PARMS *gdcParams = xmalloc(sizeof(MCI_GETDEVCAPS_PARMS));
881 gdcParams->dwCallback = hwndCallback;
883 return MCIERR_MISSING_STRING_ARGUMENT;
884 /* well , thats default */
885 dwFlags |= MCI_GETDEVCAPS_ITEM;
886 gdcParams->dwItem = 0;
888 while (i < nrofkeywords) {
889 ITEM2("device","type",MCI_GETDEVCAPS_DEVICE_TYPE,_MCISTR_devtype);
890 ITEM2("has","audio",MCI_GETDEVCAPS_HAS_AUDIO,_MCISTR_bool);
891 ITEM2("has","video",MCI_GETDEVCAPS_HAS_VIDEO,_MCISTR_bool);
892 ITEM2("uses","files",MCI_GETDEVCAPS_USES_FILES,_MCISTR_bool);
893 ITEM2("compound","device",MCI_GETDEVCAPS_COMPOUND_DEVICE,_MCISTR_bool);
894 ITEM2("can","record",MCI_GETDEVCAPS_CAN_RECORD,_MCISTR_bool);
895 ITEM2("can","play",MCI_GETDEVCAPS_CAN_PLAY,_MCISTR_bool);
896 ITEM2("can","eject",MCI_GETDEVCAPS_CAN_EJECT,_MCISTR_bool);
897 ITEM2("can","save",MCI_GETDEVCAPS_CAN_SAVE,_MCISTR_bool);
899 case MCI_DEVTYPE_ANIMATION:
900 ITEM1("palettes",MCI_ANIM_GETDEVCAPS_PALETTES,_MCISTR_int);
901 ITEM1("windows",MCI_ANIM_GETDEVCAPS_MAX_WINDOWS,_MCISTR_int);
902 ITEM2("can","reverse",MCI_ANIM_GETDEVCAPS_CAN_REVERSE,_MCISTR_bool);
903 ITEM2("can","stretch",MCI_ANIM_GETDEVCAPS_CAN_STRETCH,_MCISTR_bool);
904 ITEM3("slow","play","rate",MCI_ANIM_GETDEVCAPS_SLOW_RATE,_MCISTR_int);
905 ITEM3("fast","play","rate",MCI_ANIM_GETDEVCAPS_FAST_RATE,_MCISTR_int);
906 ITEM3("normal","play","rate",MCI_ANIM_GETDEVCAPS_NORMAL_RATE,_MCISTR_int);
908 case MCI_DEVTYPE_OVERLAY:
909 ITEM1("windows",MCI_OVLY_GETDEVCAPS_MAX_WINDOWS,_MCISTR_int);
910 ITEM2("can","freeze",MCI_OVLY_GETDEVCAPS_CAN_FREEZE,_MCISTR_bool);
911 ITEM2("can","stretch",MCI_OVLY_GETDEVCAPS_CAN_STRETCH,_MCISTR_bool);
913 case MCI_DEVTYPE_VIDEODISC:
914 FLAG1("cav",MCI_VD_GETDEVCAPS_CAV);
915 FLAG1("clv",MCI_VD_GETDEVCAPS_CLV);
916 ITEM2("can","reverse",MCI_VD_GETDEVCAPS_CAN_REVERSE,_MCISTR_bool);
917 ITEM3("slow","play","rate",MCI_VD_GETDEVCAPS_SLOW_RATE,_MCISTR_int);
918 ITEM3("fast","play","rate",MCI_VD_GETDEVCAPS_FAST_RATE,_MCISTR_int);
919 ITEM3("normal","play","rate",MCI_VD_GETDEVCAPS_NORMAL_RATE,_MCISTR_int);
921 case MCI_DEVTYPE_WAVEFORM_AUDIO:
922 ITEM1("inputs",MCI_WAVE_GETDEVCAPS_INPUTS,_MCISTR_int);
923 ITEM1("outputs",MCI_WAVE_GETDEVCAPS_OUTPUTS,_MCISTR_int);
928 res = mciSendCommandA(wDevID, MCI_GETDEVCAPS, dwFlags, (DWORD)gdcParams);
930 /* no timeformat needed */
932 _MCISTR_convreturn(type, gdcParams->dwReturn, lpstrReturnString,
933 uReturnLength, uDevTyp, 0);
940 /* resumes operation of device. no arguments, no return values */
942 MCISTR_Resume(_MCISTR_PROTO_)
944 MCI_GENERIC_PARMS *genParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
946 genParams->dwCallback = hwndCallback;
947 res = mciSendCommandA(wDevID, MCI_RESUME, dwFlags, (DWORD)genParams);
952 /* pauses operation of device. no arguments, no return values */
954 MCISTR_Pause(_MCISTR_PROTO_)
956 MCI_GENERIC_PARMS *genParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
958 genParams->dwCallback = hwndCallback;
959 res = mciSendCommandA(wDevID, MCI_PAUSE, dwFlags, (DWORD)genParams);
964 /* stops operation of device. no arguments, no return values */
966 MCISTR_Stop(_MCISTR_PROTO_)
968 MCI_GENERIC_PARMS *genParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
970 genParams->dwCallback = hwndCallback;
971 res = mciSendCommandA(wDevID, MCI_STOP, dwFlags, (DWORD)genParams);
978 * "overwrite" overwrite existing things
979 * "insert" insert at current position
980 * "to <time>" record up to <time> (specified in timeformat)
981 * "from <time>" record from <time> (specified in timeformat)
984 MCISTR_Record(_MCISTR_PROTO_) {
985 int i,res,timef,nrargs,j,k,a[4];
987 MCI_RECORD_PARMS *recordParams = xmalloc(sizeof(MCI_RECORD_PARMS));
989 res = _MCISTR_determine_timeformat(dev,wDevID,uDevTyp,&timef);
993 case MCI_FORMAT_MILLISECONDS:
994 case MCI_FORMAT_FRAMES:
995 case MCI_FORMAT_BYTES:
996 case MCI_FORMAT_SAMPLES:
1000 case MCI_FORMAT_HMS:
1001 case MCI_FORMAT_MSF:
1002 parsestr="%d:%d:%d";
1005 case MCI_FORMAT_TMSF:
1006 parsestr="%d:%d:%d:%d";
1009 default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
1014 recordParams->dwCallback = hwndCallback;
1016 while (i < nrofkeywords) {
1017 if (!strcmp(keywords[i],"to") && (i+1 < nrofkeywords)) {
1019 a[0]=a[1]=a[2]=a[3]=0;
1020 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1021 /* add up all integers we got, if we have more
1022 * shift them. (Well I should use the macros in
1023 * mmsystem.h, right).
1025 recordParams->dwTo=0;
1027 recordParams->dwTo+=a[k] << (8*(nrargs-k));
1031 if (!strcmp(keywords[i],"from") && (i+1 < nrofkeywords)) {
1032 dwFlags |= MCI_FROM;
1033 a[0]=a[1]=a[2]=a[3]=0;
1034 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1036 recordParams->dwFrom=0;
1038 recordParams->dwFrom+=a[k]<<(8*(nrargs-k));
1042 FLAG1("insert",MCI_RECORD_INSERT);
1043 FLAG1("overwrite",MCI_RECORD_OVERWRITE);
1046 res = mciSendCommandA(wDevID, MCI_RECORD, dwFlags, (DWORD)recordParams);
1053 * "to <time>" play up to <time> (specified in set timeformat)
1054 * "from <time>" play from <time> (specified in set timeformat)
1058 * "scan" play as fast as possible (with audio disabled perhaps)
1059 * "reverse" play reverse
1060 * "speed <fps>" play with specified frames per second
1064 * "scan" play as fast as possible (with audio disabled perhaps)
1065 * "reverse" play reverse
1066 * "speed <fps>" play with specified frames per second
1069 MCISTR_Play(_MCISTR_PROTO_) {
1070 int i,res,timef,nrargs,j,k,a[4];
1073 MCI_PLAY_PARMS playParams;
1074 MCI_VD_PLAY_PARMS vdplayParams;
1075 MCI_ANIM_PLAY_PARMS animplayParams;
1077 union U *pU = xmalloc(sizeof(union U));
1079 res = _MCISTR_determine_timeformat(dev,wDevID,uDevTyp,&timef);
1080 if (res) return res;
1082 case MCI_FORMAT_MILLISECONDS:
1083 case MCI_FORMAT_FRAMES:
1084 case MCI_FORMAT_BYTES:
1085 case MCI_FORMAT_SAMPLES:
1089 case MCI_FORMAT_HMS:
1090 case MCI_FORMAT_MSF:
1091 parsestr="%d:%d:%d";
1094 case MCI_FORMAT_TMSF:
1095 parsestr="%d:%d:%d:%d";
1098 default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
1103 pU->playParams.dwCallback=hwndCallback;
1105 while (i < nrofkeywords) {
1106 if (!strcmp(keywords[i],"to") && (i+1 < nrofkeywords)) {
1108 a[0]=a[1]=a[2]=a[3]=0;
1109 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1110 /* add up all integers we got, if we have more
1111 * shift them. (Well I should use the macros in
1112 * mmsystem.h, right).
1114 pU->playParams.dwTo=0;
1116 pU->playParams.dwTo+=a[k] << (8*(nrargs-k));
1120 if (!strcmp(keywords[i],"from") && (i+1 < nrofkeywords)) {
1121 dwFlags |= MCI_FROM;
1122 a[0]=a[1]=a[2]=a[3]=0;
1123 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1125 pU->playParams.dwFrom=0;
1127 pU->playParams.dwFrom+=a[k]<<(8*(nrargs-k));
1132 case MCI_DEVTYPE_VIDEODISC:
1133 FLAG1("slow",MCI_VD_PLAY_SLOW);
1134 FLAG1("fast",MCI_VD_PLAY_FAST);
1135 FLAG1("scan",MCI_VD_PLAY_SCAN);
1136 FLAG1("reverse",MCI_VD_PLAY_REVERSE);
1137 if (!STRCMP(keywords[i],"speed") && (i+1 < nrofkeywords)) {
1138 dwFlags |= MCI_VD_PLAY_SPEED;
1139 sscanf(keywords[i+1],"%ld",&(pU->vdplayParams.dwSpeed));
1144 case MCI_DEVTYPE_ANIMATION:
1145 FLAG1("slow",MCI_ANIM_PLAY_SLOW);
1146 FLAG1("fast",MCI_ANIM_PLAY_FAST);
1147 FLAG1("scan",MCI_ANIM_PLAY_SCAN);
1148 FLAG1("reverse",MCI_ANIM_PLAY_REVERSE);
1149 if (!STRCMP(keywords[i],"speed") && (i+1 < nrofkeywords)) {
1150 dwFlags |= MCI_ANIM_PLAY_SPEED;
1151 sscanf(keywords[i+1],"%ld",&(pU->animplayParams.dwSpeed));
1159 res = mciSendCommandA(wDevID, MCI_PLAY, dwFlags, (DWORD)pU);
1164 /* seek to a specified position
1166 * "to start" seek to start of medium
1167 * "to end" seek to end of medium
1168 * "to <time>" seek to <time> specified in current timeformat
1171 MCISTR_Seek(_MCISTR_PROTO_) {
1172 int i,res,timef,nrargs,j,k,a[4];
1174 MCI_SEEK_PARMS *seekParams = xmalloc(sizeof(MCI_SEEK_PARMS));
1176 res = _MCISTR_determine_timeformat(dev,wDevID,uDevTyp,&timef);
1177 if (res) return res;
1179 case MCI_FORMAT_MILLISECONDS:
1180 case MCI_FORMAT_FRAMES:
1181 case MCI_FORMAT_BYTES:
1182 case MCI_FORMAT_SAMPLES:
1186 case MCI_FORMAT_HMS:
1187 case MCI_FORMAT_MSF:
1188 parsestr="%d:%d:%d";
1191 case MCI_FORMAT_TMSF:
1192 parsestr="%d:%d:%d:%d";
1195 default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
1200 seekParams->dwCallback=hwndCallback;
1202 while (i < nrofkeywords) {
1203 if ( !STRCMP(keywords[i],"to") && (i+1 < nrofkeywords)) {
1204 if (!STRCMP(keywords[i+1],"start")) {
1205 dwFlags|=MCI_SEEK_TO_START;
1210 if (!STRCMP(keywords[i+1],"end")) {
1211 dwFlags|=MCI_SEEK_TO_END;
1218 a[0]=a[1]=a[2]=a[3]=0;
1219 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1222 seekParams->dwTo+=a[k] << (8*(nrargs-k));
1226 case MCI_DEVTYPE_VIDEODISC:
1227 FLAG1("reverse",MCI_VD_SEEK_REVERSE);
1232 res = mciSendCommandA(wDevID, MCI_SEEK, dwFlags, (DWORD)seekParams);
1237 /* close media/driver */
1239 MCISTR_Close(_MCISTR_PROTO_)
1241 MCI_GENERIC_PARMS* closeParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
1244 res = mciSendCommandA(wDevID, MCI_CLOSE, dwFlags, (DWORD)closeParams);
1249 /* return information.
1251 * "product" return product name (human readable)
1252 * "file" return filename
1254 * "text" returns text?
1256 * "text" returns text?
1259 MCISTR_Info(_MCISTR_PROTO_)
1261 MCI_INFO_PARMS16* infoParams = xmalloc(sizeof(MCI_INFO_PARMS16));
1267 while (i < nrofkeywords) {
1268 FLAG1("product",MCI_INFO_PRODUCT);
1269 FLAG1("file",MCI_INFO_FILE);
1271 case MCI_DEVTYPE_ANIMATION:
1272 FLAG1("text",MCI_ANIM_INFO_TEXT);
1274 case MCI_DEVTYPE_OVERLAY:
1275 FLAG1("text",MCI_OVLY_INFO_TEXT);
1280 if (dwFlags == sflags)
1281 return MCIERR_MISSING_STRING_ARGUMENT;
1282 /* MCI driver will fill in lpstrReturn, dwRetSize.
1283 * FIXME: I don't know if this is correct behaviour
1285 res = mciSendCommandA(wDevID, MCI_INFO, dwFlags, (DWORD)infoParams);
1287 _MCI_STR(infoParams->lpstrReturn);
1292 /* query MCI driver itself for information
1294 * "installname" return install name of <device> (system.ini)
1295 * "quantity" return nr of installed drivers
1296 * "open" open drivers only (additional flag)
1297 * "name <nr>" return nr of devices with <devicetyp>
1298 * "name all" return nr of all devices
1300 * FIXME: mciSysInfo16() is broken I think.
1303 MCISTR_Sysinfo(_MCISTR_PROTO_) {
1304 MCI_SYSINFO_PARMS16 sysinfoParams;
1307 sysinfoParams.lpstrReturn = lpstrReturnString;
1308 sysinfoParams.dwRetSize = uReturnLength;
1309 sysinfoParams.wDeviceType = uDevTyp;
1311 for (i = 0; i < nrofkeywords; i++) {
1312 FLAG1("installname",MCI_SYSINFO_INSTALLNAME);
1313 FLAG1("quantity",MCI_SYSINFO_INSTALLNAME);
1314 FLAG1("open",MCI_SYSINFO_OPEN);
1315 if (!strcmp(keywords[i],"name") && (i+1 < nrofkeywords)) {
1316 sscanf(keywords[i+1],"%ld",&(sysinfoParams.dwNumber));
1317 dwFlags |= MCI_SYSINFO_NAME;
1321 res = mciSendCommand16(0, MCI_SYSINFO, dwFlags, (DWORD)&sysinfoParams);
1323 if (dwFlags & MCI_SYSINFO_QUANTITY) {
1326 sprintf(buf,"%ld",*(long*)lpstrReturnString);
1329 /* no need to copy anything back, mciSysInfo did it for us */
1334 * Argument: "<filename>"
1335 * Overlay: "at <left> <top> <right> <bottom>" additional
1338 MCISTR_Load(_MCISTR_PROTO_) {
1340 MCI_LOAD_PARMS16 loadParams;
1341 MCI_OVLY_LOAD_PARMS16 ovlyloadParams;
1343 union U *pU = xmalloc(sizeof(union U));
1348 while (i < nrofkeywords) {
1350 case MCI_DEVTYPE_OVERLAY:
1351 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1352 dwFlags |= MCI_OVLY_RECT;
1353 sscanf(keywords[i+1],"%hd",&(pU->ovlyloadParams.rc.left));
1354 sscanf(keywords[i+2],"%hd",&(pU->ovlyloadParams.rc.top));
1355 sscanf(keywords[i+3],"%hd",&(pU->ovlyloadParams.rc.right));
1356 sscanf(keywords[i+4],"%hd",&(pU->ovlyloadParams.rc.bottom));
1357 memcpy(keywords+i,keywords+(i+5),nrofkeywords-(i+5));
1362 len+=strlen(keywords[i])+1;
1365 s=(char*)xmalloc(len);
1367 while (i < nrofkeywords) {
1368 strcat(s,keywords[i]);
1370 if (i < nrofkeywords) strcat(s," ");
1372 pU->loadParams.lpfilename=s;
1373 dwFlags |= MCI_LOAD_FILE;
1374 res = mciSendCommandA(wDevID, MCI_LOAD, dwFlags, (DWORD)pU);
1381 * Argument: "<filename>"
1382 * Overlay: "at <left> <top> <right> <bottom>" additional
1385 MCISTR_Save(_MCISTR_PROTO_) {
1387 MCI_SAVE_PARMS saveParams;
1388 MCI_OVLY_SAVE_PARMS16 ovlysaveParams;
1390 union U *pU = xmalloc(sizeof(union U));
1395 while (i < nrofkeywords) {
1397 case MCI_DEVTYPE_OVERLAY:
1398 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1399 dwFlags |= MCI_OVLY_RECT;
1400 sscanf(keywords[i+1],"%hd",&(pU->ovlysaveParams.rc.left));
1401 sscanf(keywords[i+2],"%hd",&(pU->ovlysaveParams.rc.top));
1402 sscanf(keywords[i+3],"%hd",&(pU->ovlysaveParams.rc.right));
1403 sscanf(keywords[i+4],"%hd",&(pU->ovlysaveParams.rc.bottom));
1404 memcpy(keywords+i,keywords+(i+5),nrofkeywords-(i+5));
1409 len+=strlen(keywords[i])+1;
1412 s=(char*)xmalloc(len);
1414 while (i < nrofkeywords) {
1415 strcat(s,keywords[i]);
1417 if (i < nrofkeywords) strcat(s," ");
1419 pU->saveParams.lpfilename=s;
1420 dwFlags |= MCI_LOAD_FILE;
1421 res = mciSendCommandA(wDevID, MCI_SAVE, dwFlags, (DWORD)pU);
1427 /* prepare device for input/output
1428 * (only applyable to waveform audio)
1431 MCISTR_Cue(_MCISTR_PROTO_) {
1432 MCI_GENERIC_PARMS *cueParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
1435 for (i = 0; i < nrofkeywords; i++) {
1437 case MCI_DEVTYPE_WAVEFORM_AUDIO:
1438 FLAG1("input", MCI_WAVE_INPUT);
1439 FLAG1("output", MCI_WAVE_OUTPUT);
1443 res = mciSendCommandA(wDevID, MCI_CUE, dwFlags, (DWORD)cueParams);
1448 /* delete information */
1450 MCISTR_Delete(_MCISTR_PROTO_) {
1451 int timef,nrargs,i,j,k,a[4],res;
1453 MCI_WAVE_DELETE_PARMS *deleteParams = xmalloc(sizeof(MCI_WAVE_DELETE_PARMS));
1455 /* only implemented for waveform audio */
1456 if (uDevTyp != MCI_DEVTYPE_WAVEFORM_AUDIO)
1457 return MCIERR_UNSUPPORTED_FUNCTION; /* well it fits */
1458 res = _MCISTR_determine_timeformat(dev,wDevID,uDevTyp,&timef);
1459 if (res) return res;
1461 case MCI_FORMAT_MILLISECONDS:
1462 case MCI_FORMAT_FRAMES:
1463 case MCI_FORMAT_BYTES:
1464 case MCI_FORMAT_SAMPLES:
1468 case MCI_FORMAT_HMS:
1469 case MCI_FORMAT_MSF:
1470 parsestr="%d:%d:%d";
1473 case MCI_FORMAT_TMSF:
1474 parsestr="%d:%d:%d:%d";
1477 default:FIXME(mci,"unknown timeformat %d, please report.\n",timef);
1483 while (i < nrofkeywords) {
1484 if (!strcmp(keywords[i],"to") && (i+1 < nrofkeywords)) {
1486 a[0]=a[1]=a[2]=a[3]=0;
1487 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1488 /* add up all integers we got, if we have more
1489 * shift them. (Well I should use the macros in
1490 * mmsystem.h, right).
1492 deleteParams->dwTo=0;
1494 deleteParams->dwTo+=a[k]<<(8*(nrargs-k));
1498 if (!strcmp(keywords[i],"from") && (i+1 < nrofkeywords)) {
1499 dwFlags |= MCI_FROM;
1500 a[0]=a[1]=a[2]=a[3]=0;
1501 j=sscanf(keywords[i+1],parsestr,&a[0],&a[1],&a[2],&a[3]);
1503 deleteParams->dwFrom=0;
1505 deleteParams->dwFrom+=a[k]<<(8*(nrargs-k));
1511 res = mciSendCommandA(wDevID, MCI_DELETE, dwFlags, (DWORD)deleteParams);
1516 /* send command to device. only applies to videodisc */
1518 MCISTR_Escape(_MCISTR_PROTO_)
1520 MCI_VD_ESCAPE_PARMS16 *escapeParams = xmalloc(sizeof(MCI_VD_ESCAPE_PARMS16));
1524 if (uDevTyp != MCI_DEVTYPE_VIDEODISC)
1525 return MCIERR_UNSUPPORTED_FUNCTION;
1527 while (i < nrofkeywords) {
1528 len+=strlen(keywords[i])+1;
1531 s=(char*)malloc(len);
1533 while (i < nrofkeywords) {
1534 strcat(s,keywords[i]);
1536 if (i < nrofkeywords) strcat(s," ");
1538 escapeParams->lpstrCommand = s;
1539 dwFlags |= MCI_VD_ESCAPE_STRING;
1540 res = mciSendCommandA(wDevID, MCI_ESCAPE, dwFlags, (DWORD)escapeParams);
1546 /* unfreeze [part of] the overlayed video
1547 * only applyable to Overlay devices
1550 MCISTR_Unfreeze(_MCISTR_PROTO_)
1552 MCI_OVLY_RECT_PARMS16 *unfreezeParams = xmalloc(sizeof(MCI_OVLY_RECT_PARMS16));
1555 if (uDevTyp != MCI_DEVTYPE_OVERLAY)
1556 return MCIERR_UNSUPPORTED_FUNCTION;
1557 i=0;while (i < nrofkeywords) {
1558 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1559 sscanf(keywords[i+1],"%hd",&(unfreezeParams->rc.left));
1560 sscanf(keywords[i+2],"%hd",&(unfreezeParams->rc.top));
1561 sscanf(keywords[i+3],"%hd",&(unfreezeParams->rc.right));
1562 sscanf(keywords[i+4],"%hd",&(unfreezeParams->rc.bottom));
1563 dwFlags |= MCI_OVLY_RECT;
1569 res = mciSendCommandA(wDevID, MCI_UNFREEZE, dwFlags, (DWORD)unfreezeParams);
1570 free(unfreezeParams);
1573 /* freeze [part of] the overlayed video
1574 * only applyable to Overlay devices
1577 MCISTR_Freeze(_MCISTR_PROTO_)
1579 MCI_OVLY_RECT_PARMS16 *freezeParams = xmalloc(sizeof(MCI_OVLY_RECT_PARMS16));
1582 if (uDevTyp != MCI_DEVTYPE_OVERLAY)
1583 return MCIERR_UNSUPPORTED_FUNCTION;
1584 i=0;while (i < nrofkeywords) {
1585 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1586 sscanf(keywords[i+1],"%hd",&(freezeParams->rc.left));
1587 sscanf(keywords[i+2],"%hd",&(freezeParams->rc.top));
1588 sscanf(keywords[i+3],"%hd",&(freezeParams->rc.right));
1589 sscanf(keywords[i+4],"%hd",&(freezeParams->rc.bottom));
1590 dwFlags |= MCI_OVLY_RECT;
1596 res = mciSendCommandA(wDevID, MCI_FREEZE, dwFlags, (DWORD)freezeParams);
1601 /* copy parts of image to somewhere else
1602 * "source [at <left> <top> <right> <bottom>]" source is framebuffer [or rect]
1603 * "destination [at <left> <top> <right> <bottom>]" destination is framebuffer [or rect]
1605 * "frame [at <left> <top> <right> <bottom>]" frame is framebuffer [or rect]
1606 * where the video input is placed
1607 * "video [at <left> <top> <right> <bottom>]" video is whole video [or rect]
1608 * (defining part of input to
1611 * FIXME: This whole junk is passing multiple rectangles.
1612 * I don't know how to do that with the present interface.
1613 * (Means code below is broken)
1616 MCISTR_Put(_MCISTR_PROTO_) {
1618 MCI_OVLY_RECT_PARMS16 ovlyputParams;
1619 MCI_ANIM_RECT_PARMS16 animputParams;
1621 union U *pU = xmalloc(sizeof(union U));
1623 i=0;while (i < nrofkeywords) {
1625 case MCI_DEVTYPE_ANIMATION:
1626 FLAG1("source",MCI_ANIM_PUT_SOURCE);
1627 FLAG1("destination",MCI_ANIM_PUT_DESTINATION);
1628 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1629 sscanf(keywords[i+1],"%hd",&(pU->animputParams.rc.left));
1630 sscanf(keywords[i+2],"%hd",&(pU->animputParams.rc.top));
1631 sscanf(keywords[i+3],"%hd",&(pU->animputParams.rc.right));
1632 sscanf(keywords[i+4],"%hd",&(pU->animputParams.rc.bottom));
1633 dwFlags |= MCI_ANIM_RECT;
1638 case MCI_DEVTYPE_OVERLAY:
1639 FLAG1("source",MCI_OVLY_PUT_SOURCE);
1640 FLAG1("destination",MCI_OVLY_PUT_DESTINATION);
1641 FLAG1("video",MCI_OVLY_PUT_VIDEO);
1642 FLAG1("frame",MCI_OVLY_PUT_FRAME);
1643 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1644 sscanf(keywords[i+1],"%hd",&(pU->ovlyputParams.rc.left));
1645 sscanf(keywords[i+2],"%hd",&(pU->ovlyputParams.rc.top));
1646 sscanf(keywords[i+3],"%hd",&(pU->ovlyputParams.rc.right));
1647 sscanf(keywords[i+4],"%hd",&(pU->ovlyputParams.rc.bottom));
1648 dwFlags |= MCI_OVLY_RECT;
1656 res = mciSendCommandA(wDevID, MCI_PUT, dwFlags, (DWORD)pU);
1661 /* palette behaviour changing
1663 * "normal" realize the palette normally
1664 * "background" realize the palette as background palette
1667 MCISTR_Realize(_MCISTR_PROTO_)
1669 MCI_GENERIC_PARMS *realizeParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
1672 if (uDevTyp != MCI_DEVTYPE_ANIMATION)
1673 return MCIERR_UNSUPPORTED_FUNCTION;
1675 while (i < nrofkeywords) {
1676 FLAG1("background",MCI_ANIM_REALIZE_BKGD);
1677 FLAG1("normal",MCI_ANIM_REALIZE_NORM);
1680 res = mciSendCommandA(wDevID, MCI_REALIZE, dwFlags, (DWORD)realizeParams);
1681 free(realizeParams);
1685 /* videodisc spinning
1690 MCISTR_Spin(_MCISTR_PROTO_)
1692 MCI_GENERIC_PARMS *spinParams = xmalloc(sizeof(MCI_GENERIC_PARMS));
1695 if (uDevTyp != MCI_DEVTYPE_VIDEODISC)
1696 return MCIERR_UNSUPPORTED_FUNCTION;
1698 while (i < nrofkeywords) {
1699 FLAG1("up",MCI_VD_SPIN_UP);
1700 FLAG1("down",MCI_VD_SPIN_UP);
1703 res = mciSendCommandA(wDevID, MCI_SPIN, dwFlags, (DWORD)spinParams);
1708 /* step single frames
1709 * "reverse" optional flag
1710 * "by <nr>" for <nr> frames
1713 MCISTR_Step(_MCISTR_PROTO_) {
1715 MCI_ANIM_STEP_PARMS animstepParams;
1716 MCI_VD_STEP_PARMS vdstepParams;
1718 union U *pU = xmalloc(sizeof(union U));
1722 while (i < nrofkeywords) {
1724 case MCI_DEVTYPE_ANIMATION:
1725 FLAG1("reverse",MCI_ANIM_STEP_REVERSE);
1726 if (!STRCMP(keywords[i],"by") && (i+1 < nrofkeywords)) {
1727 sscanf(keywords[i+1],"%ld",&(pU->animstepParams.dwFrames));
1728 dwFlags |= MCI_ANIM_STEP_FRAMES;
1733 case MCI_DEVTYPE_VIDEODISC:
1734 FLAG1("reverse",MCI_VD_STEP_REVERSE);
1735 if (!STRCMP(keywords[i],"by") && (i+1 < nrofkeywords)) {
1736 sscanf(keywords[i+1],"%ld",&(pU->vdstepParams.dwFrames));
1737 dwFlags |= MCI_VD_STEP_FRAMES;
1745 res = mciSendCommandA(wDevID, MCI_STEP, dwFlags, (DWORD)pU);
1750 /* update animation window
1752 * "at <left> <top> <right> <bottom>" only in this rectangle
1753 * "hdc" device context
1756 MCISTR_Update(_MCISTR_PROTO_) {
1758 MCI_ANIM_UPDATE_PARMS16 *updateParams = xmalloc(sizeof(MCI_ANIM_UPDATE_PARMS16));
1761 while (i<nrofkeywords) {
1762 if (!STRCMP(keywords[i],"at") && (i+4 < nrofkeywords)) {
1763 sscanf(keywords[i+1],"%hd",&(updateParams->rc.left));
1764 sscanf(keywords[i+2],"%hd",&(updateParams->rc.top));
1765 sscanf(keywords[i+3],"%hd",&(updateParams->rc.right));
1766 sscanf(keywords[i+4],"%hd",&(updateParams->rc.bottom));
1767 dwFlags |= MCI_ANIM_RECT;
1771 if (!STRCMP(keywords[i],"hdc") && (i+1 < nrofkeywords)) {
1772 dwFlags |= MCI_ANIM_UPDATE_HDC;
1773 sscanf(keywords[i+1],"%hd",&(updateParams->hDC));
1779 res = mciSendCommandA(wDevID, MCI_UPDATE, dwFlags, (DWORD)updateParams);
1784 /* where command for animation and overlay drivers.
1785 * just returns the specified rectangle as a string
1794 MCISTR_Where(_MCISTR_PROTO_) {
1796 MCI_ANIM_RECT_PARMS16 animwhereParams;
1797 MCI_OVLY_RECT_PARMS16 ovlywhereParams;
1799 union U *pU = xmalloc(sizeof(union U));
1803 while (i < nrofkeywords) {
1805 case MCI_DEVTYPE_ANIMATION:
1806 FLAG1("source",MCI_ANIM_WHERE_SOURCE);
1807 FLAG1("destination",MCI_ANIM_WHERE_DESTINATION);
1809 case MCI_DEVTYPE_OVERLAY:
1810 FLAG1("source",MCI_OVLY_WHERE_SOURCE);
1811 FLAG1("destination",MCI_OVLY_WHERE_DESTINATION);
1812 FLAG1("video",MCI_OVLY_WHERE_VIDEO);
1813 FLAG1("frame",MCI_OVLY_WHERE_FRAME);
1818 res = mciSendCommandA(wDevID, MCI_WHERE, dwFlags, (DWORD)pU);
1822 case MCI_DEVTYPE_ANIMATION:
1823 sprintf(buf,"%d %d %d %d",
1824 pU->animwhereParams.rc.left,
1825 pU->animwhereParams.rc.top,
1826 pU->animwhereParams.rc.right,
1827 pU->animwhereParams.rc.bottom
1830 case MCI_DEVTYPE_OVERLAY:
1831 sprintf(buf,"%d %d %d %d",
1832 pU->ovlywhereParams.rc.left,
1833 pU->ovlywhereParams.rc.top,
1834 pU->ovlywhereParams.rc.right,
1835 pU->ovlywhereParams.rc.bottom
1838 default:strcpy(buf,"0 0 0 0");break;
1847 MCISTR_Window(_MCISTR_PROTO_) {
1851 MCI_ANIM_WINDOW_PARMS16 animwindowParams;
1852 MCI_OVLY_WINDOW_PARMS16 ovlywindowParams;
1854 union U *pU = xmalloc(sizeof(union U));
1858 while (i < nrofkeywords) {
1860 case MCI_DEVTYPE_ANIMATION:
1861 if (!STRCMP(keywords[i],"handle") && (i+1 < nrofkeywords)) {
1862 dwFlags |= MCI_ANIM_WINDOW_HWND;
1863 if (!STRCMP(keywords[i+1],"default"))
1864 pU->animwindowParams.hWnd = MCI_OVLY_WINDOW_DEFAULT;
1866 sscanf(keywords[i+1],"%hd",&(pU->animwindowParams.hWnd));
1870 if (!STRCMP(keywords[i],"state") && (i+1 < nrofkeywords)) {
1871 dwFlags |= MCI_ANIM_WINDOW_STATE;
1872 if (!STRCMP(keywords[i+1],"hide"))
1873 pU->animwindowParams.nCmdShow = SW_HIDE;
1874 if (!STRCMP(keywords[i+1],"iconic"))
1875 pU->animwindowParams.nCmdShow = SW_SHOWMINNOACTIVE; /* correct? */
1876 if (!STRCMP(keywords[i+1],"minimized"))
1877 pU->animwindowParams.nCmdShow = SW_SHOWMINIMIZED;
1878 if (!STRCMP(keywords[i+1],"maximized"))
1879 pU->animwindowParams.nCmdShow = SW_SHOWMAXIMIZED;
1880 if (!STRCMP(keywords[i+1],"minimize"))
1881 pU->animwindowParams.nCmdShow = SW_MINIMIZE;
1882 if (!STRCMP(keywords[i+1],"normal"))
1883 pU->animwindowParams.nCmdShow = SW_NORMAL;
1884 if (!STRCMP(keywords[i+1],"show"))
1885 pU->animwindowParams.nCmdShow = SW_SHOW;
1886 if (!STRCMP(keywords[i+1],"no") && (i+2 < nrofkeywords)) {
1887 if (!STRCMP(keywords[i+2],"active"))
1888 pU->animwindowParams.nCmdShow = SW_SHOWNOACTIVATE;
1889 if (!STRCMP(keywords[i+2],"action"))
1890 pU->animwindowParams.nCmdShow = SW_SHOWNA;/* correct?*/
1896 /* text is enclosed in " ... " as it seems */
1897 if (!STRCMP(keywords[i],"text")) {
1901 if (keywords[i+1][0]!='"') {
1905 dwFlags |= MCI_ANIM_WINDOW_TEXT;
1906 len = strlen(keywords[i+1])+1;
1908 while (j < nrofkeywords) {
1909 len += strlen(keywords[j])+1;
1910 if (strchr(keywords[j],'"'))
1914 s=(char*)xmalloc(len);
1915 strcpy(s,keywords[i+1]+1);
1919 strcat(s,keywords[j]);
1921 if ((t=strchr(s,'"'))) *t='\0';
1922 /* FIXME: segmented pointer? */
1923 pU->animwindowParams.lpstrText = s;
1927 FLAG1("stretch",MCI_ANIM_WINDOW_ENABLE_STRETCH);
1929 case MCI_DEVTYPE_OVERLAY:
1930 if (!STRCMP(keywords[i],"handle") && (i+1 < nrofkeywords)) {
1931 dwFlags |= MCI_OVLY_WINDOW_HWND;
1932 if (!STRCMP(keywords[i+1],"default"))
1933 pU->ovlywindowParams.hWnd = MCI_OVLY_WINDOW_DEFAULT;
1935 sscanf(keywords[i+1],"%hd",&(pU->ovlywindowParams.hWnd));
1939 if (!STRCMP(keywords[i],"state") && (i+1 < nrofkeywords)) {
1940 dwFlags |= MCI_OVLY_WINDOW_STATE;
1941 if (!STRCMP(keywords[i+1],"hide"))
1942 pU->ovlywindowParams.nCmdShow = SW_HIDE;
1943 if (!STRCMP(keywords[i+1],"iconic"))
1944 pU->ovlywindowParams.nCmdShow = SW_SHOWMINNOACTIVE; /* correct? */
1945 if (!STRCMP(keywords[i+1],"minimized"))
1946 pU->ovlywindowParams.nCmdShow = SW_SHOWMINIMIZED;
1947 if (!STRCMP(keywords[i+1],"maximized"))
1948 pU->ovlywindowParams.nCmdShow = SW_SHOWMAXIMIZED;
1949 if (!STRCMP(keywords[i+1],"minimize"))
1950 pU->ovlywindowParams.nCmdShow = SW_MINIMIZE;
1951 if (!STRCMP(keywords[i+1],"normal"))
1952 pU->ovlywindowParams.nCmdShow = SW_NORMAL;
1953 if (!STRCMP(keywords[i+1],"show"))
1954 pU->ovlywindowParams.nCmdShow = SW_SHOW;
1955 if (!STRCMP(keywords[i+1],"no") && (i+2 < nrofkeywords)) {
1956 if (!STRCMP(keywords[i+2],"active"))
1957 pU->ovlywindowParams.nCmdShow = SW_SHOWNOACTIVATE;
1958 if (!STRCMP(keywords[i+2],"action"))
1959 pU->ovlywindowParams.nCmdShow = SW_SHOWNA;/* correct?*/
1965 /* text is enclosed in " ... " as it seems */
1966 if (!STRCMP(keywords[i],"text")) {
1970 if (keywords[i+1][0]!='"') {
1974 dwFlags |= MCI_OVLY_WINDOW_TEXT;
1975 len = strlen(keywords[i+1])+1;
1977 while (j < nrofkeywords) {
1978 len += strlen(keywords[j])+1;
1979 if (strchr(keywords[j],'"'))
1983 s=(char*)xmalloc(len);
1984 strcpy(s,keywords[i+1]+1);
1988 strcat(s,keywords[j]);
1990 if ((t=strchr(s,'"'))) *t='\0';
1991 /* FIXME: segmented pointer? */
1992 pU->ovlywindowParams.lpstrText = s;
1996 FLAG1("stretch",MCI_OVLY_WINDOW_ENABLE_STRETCH);
2001 res = mciSendCommandA(wDevID, MCI_WINDOW, dwFlags, (DWORD)pU);
2007 struct _MCISTR_cmdtable {
2009 DWORD (*fun)(_MCISTR_PROTO_);
2010 } MCISTR_cmdtable[]={
2011 {"break", MCISTR_Break},
2012 {"capability", MCISTR_Capability},
2013 {"close", MCISTR_Close},
2014 {"cue", MCISTR_Cue},
2015 {"delete", MCISTR_Delete},
2016 {"escape", MCISTR_Escape},
2017 {"freeze", MCISTR_Freeze},
2018 {"info", MCISTR_Info},
2019 {"load", MCISTR_Load},
2020 {"open", MCISTR_Open},
2021 {"pause", MCISTR_Pause},
2022 {"play", MCISTR_Play},
2023 {"put", MCISTR_Put},
2024 {"realize", MCISTR_Realize},
2025 {"record", MCISTR_Record},
2026 {"resume", MCISTR_Resume},
2027 {"save", MCISTR_Save},
2028 {"seek", MCISTR_Seek},
2029 {"set", MCISTR_Set},
2030 {"spin", MCISTR_Spin},
2031 {"status", MCISTR_Status},
2032 {"step", MCISTR_Step},
2033 {"stop", MCISTR_Stop},
2034 {"sysinfo", MCISTR_Sysinfo},
2035 {"unfreeze", MCISTR_Unfreeze},
2036 {"update", MCISTR_Update},
2037 {"where", MCISTR_Where},
2038 {"window", MCISTR_Window},
2042 /**************************************************************************
2043 * mciSendString16 [MMSYSTEM.702]
2045 /* The usercode sends a string with a command (and flags) expressed in
2046 * words in it... We do our best to call aprobiate drivers,
2047 * and return a errorcode AND a readable string (if lpstrRS!=NULL)
2048 * Info gathered by watching cool134.exe and from Borland's mcistrwh.hlp
2050 /* FIXME: "all" is a valid devicetype and we should access all devices if
2051 * it is used. (imagine "close all"). Not implemented yet.
2053 DWORD WINAPI mciSendString16(LPCSTR lpstrCommand, LPSTR lpstrReturnString,
2054 UINT16 uReturnLength, HWND16 hwndCallback)
2056 char *cmd,*dev,*args,**keywords,*filename;
2057 WORD uDevTyp=0,wDevID=0;
2059 int res=0,i,nrofkeywords;
2061 TRACE(mci,"('%s', %p, %d, %X)\n",
2062 lpstrCommand, lpstrReturnString, uReturnLength, hwndCallback);
2064 /* format is <command> <device> <optargs> */
2065 cmd=strdup(lpstrCommand);
2066 dev=strchr(cmd,' ');
2069 return MCIERR_MISSING_DEVICE_NAME;
2072 args=strchr(dev,' ');
2073 if (args!=NULL) *args++='\0';
2077 i=1;/* nrofkeywords = nrofspaces+1 */
2079 while ((s=strchr(s,' '))!=NULL) i++,s++;
2080 keywords=(char**)xmalloc(sizeof(char*)*(i+2));
2083 while (s && i < nrofkeywords) {
2091 keywords=(char**)xmalloc(sizeof(char*));
2093 dwFlags = 0; /* default flags */
2094 for (i=0;i < nrofkeywords;) {
2095 /* take care, there is also a "device type" capability */
2096 if ((!STRCMP(keywords[i],"type")) && (i < nrofkeywords-1)) {
2098 dev = keywords[i+1];
2099 memcpy(keywords+i,keywords+(i+2),(nrofkeywords-i-2)*sizeof(char *));
2103 if (!STRCMP(keywords[i],"wait")) {
2104 dwFlags |= MCI_WAIT;
2105 memcpy(keywords+i,keywords+(i+1),(nrofkeywords-i-1)*sizeof(char *));
2109 if (!STRCMP(keywords[i],"notify")) {
2110 dwFlags |= MCI_NOTIFY;
2111 memcpy(keywords+i,keywords+(i+1),(nrofkeywords-i-1)*sizeof(char *));
2118 /* FIXME: this code should be moved to mmsystem.c */
2119 /* determine wDevID and uDevTyp for all commands except "open" */
2120 if (STRCMP(cmd,"open")!=0) {
2121 wDevID = MCI_FirstDevID();
2125 dname=MCI_GetOpenDrv(wDevID)->lpstrAlias;
2127 dname=MCI_GetOpenDrv(wDevID)->lpstrDeviceType;
2128 if (dname != NULL && !STRCMP(dname,dev))
2130 wDevID = MCI_NextDevID(wDevID);
2131 if (!MCI_DevIDValid(wDevID)) {
2132 TRACE(mci, "MAXMCIDRIVERS reached!\n");
2133 free(keywords);free(cmd);
2134 return MCIERR_INVALID_DEVICE_NAME;
2137 uDevTyp=MCI_GetDrv(wDevID)->modp.wType;
2141 for (i=0;MCISTR_cmdtable[i].cmd!=NULL;i++) {
2142 if (!STRCMP(MCISTR_cmdtable[i].cmd,cmd)) {
2143 res=MCISTR_cmdtable[i].fun(
2144 wDevID,uDevTyp,lpstrReturnString,
2145 uReturnLength,dev,(LPSTR*)keywords,nrofkeywords,
2146 dwFlags,hwndCallback
2151 if (MCISTR_cmdtable[i].cmd!=NULL) {
2152 free(keywords);free(cmd);
2155 FIXME(mci,"('%s', %p, %u, %X): unimplemented, please report.\n",
2156 lpstrCommand, lpstrReturnString, uReturnLength, hwndCallback);
2157 free(keywords);free(cmd);
2158 return MCIERR_MISSING_COMMAND_STRING;
2161 /**************************************************************************
2162 * mciSendString32A [MMSYSTEM.702][WINMM.51]
2164 DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrReturnString,
2165 UINT uReturnLength, HWND hwndCallback)
2167 return mciSendString16(lpstrCommand, lpstrReturnString, uReturnLength, hwndCallback);
2170 /**************************************************************************
2171 * mciSendString32W [WINMM.52]
2173 DWORD WINAPI mciSendStringW(LPCWSTR lpwstrCommand, LPSTR lpstrReturnString,
2174 UINT uReturnLength, HWND hwndCallback)
2179 /* FIXME: is there something to do with lpstrReturnString ? */
2180 lpstrCommand = HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrCommand);
2181 ret = mciSendString16(lpstrCommand, lpstrReturnString, uReturnLength, hwndCallback);
2182 HeapFree(GetProcessHeap(), 0, lpstrCommand);