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>
27 #include "multimedia.h"
32 extern struct WINE_MCIDRIVER mciDrv
[MAXMCIDRIVERS
];
34 #define MCI_GetDrv(wDevID) (&mciDrv[MCI_DevIDToIndex(wDevID)])
35 #define MCI_GetOpenDrv(wDevID) (&(MCI_GetDrv(wDevID)->mop))
37 LONG WINAPI
DrvDefDriverProc(DWORD dwDevID
, HDRVR16 hDriv
, WORD wMsg
,
38 DWORD dwParam1
, DWORD dwParam2
);
40 /* The reason why I just don't lowercase the keywords array in
41 * mciSendString is left as an exercise to the reader.
43 #define STRCMP(x,y) lstrcmpi32A(x,y)
45 /* standard functionparameters for all functions */
46 #define _MCISTR_PROTO_ \
47 WORD wDevID,WORD uDevTyp,LPSTR lpstrReturnString,UINT16 uReturnLength,\
48 LPCSTR dev,LPSTR *keywords,UINT16 nrofkeywords,DWORD dwFlags,\
51 /* copy string to return pointer including necessary checks
52 * for use in mciSendString()
54 #define _MCI_STR(s) do {\
55 TRACE(mci,"->returns '%s'\n",s);\
56 if (lpstrReturnString) {\
57 lstrcpyn32A(lpstrReturnString,s,uReturnLength);\
58 TRACE(mci,"-->'%s'\n",lpstrReturnString);\
62 /* calling DriverProc. */
63 #define _MCI_CALL_DRIVER(cmd,params) \
65 MCIPROC32 proc = MCI_GetProc32(uDevTyp); \
66 res = (proc) ? (*proc)(MCI_GetDrv(wDevID)->modp.wDeviceID, 0, cmd, dwFlags, (DWORD)(params)) : MCIERR_DEVICE_NOT_INSTALLED; \
69 /* print a DWORD in the specified timeformat */
71 _MCISTR_printtf(char *buf
,UINT16 uDevType
,DWORD timef
,DWORD val
) {
74 case MCI_FORMAT_MILLISECONDS
:
75 case MCI_FORMAT_FRAMES
:
76 case MCI_FORMAT_BYTES
:
77 case MCI_FORMAT_SAMPLES
:
78 case MCI_VD_FORMAT_TRACK
:
79 /*case MCI_SEQ_FORMAT_SONGPTR: sameas MCI_VD_FORMAT_TRACK */
80 sprintf(buf
,"%ld",val
);
83 /* well, the macros have the same content*/
86 sprintf(buf
,"%d:%d:%d",
93 sprintf(buf
,"%d:%d:%d:%d",
101 FIXME(mci
, "missing timeformat for %ld, report.\n",timef
);
102 strcpy(buf
,"0"); /* hmm */
107 /* possible different return types */
108 #define _MCISTR_int 1
109 #define _MCISTR_time 2
110 #define _MCISTR_bool 3
111 #define _MCISTR_tfname 4
112 #define _MCISTR_mode 5
113 #define _MCISTR_divtype 6
114 #define _MCISTR_seqtype 7
115 #define _MCISTR_vdmtype 8
116 #define _MCISTR_devtype 9
119 _MCISTR_convreturn(int type
,DWORD dwReturn
,LPSTR lpstrReturnString
,
120 WORD uReturnLength
,WORD uDevTyp
,int timef
123 case _MCISTR_vdmtype
:
125 case MCI_VD_MEDIA_CLV
:_MCI_STR("CLV");break;
126 case MCI_VD_MEDIA_CAV
:_MCI_STR("CAV");break;
128 case MCI_VD_MEDIA_OTHER
:_MCI_STR("other");break;
131 case _MCISTR_seqtype
:
133 case MCI_SEQ_NONE
:_MCI_STR("none");break;
134 case MCI_SEQ_SMPTE
:_MCI_STR("smpte");break;
135 case MCI_SEQ_FILE
:_MCI_STR("file");break;
136 case MCI_SEQ_MIDI
:_MCI_STR("midi");break;
137 default:FIXME(mci
,"missing sequencer mode %ld\n",dwReturn
);
142 case MCI_MODE_NOT_READY
:_MCI_STR("not ready");break;
143 case MCI_MODE_STOP
:_MCI_STR("stopped");break;
144 case MCI_MODE_PLAY
:_MCI_STR("playing");break;
145 case MCI_MODE_RECORD
:_MCI_STR("recording");break;
146 case MCI_MODE_SEEK
:_MCI_STR("seeking");break;
147 case MCI_MODE_PAUSE
:_MCI_STR("paused");break;
148 case MCI_MODE_OPEN
:_MCI_STR("open");break;
160 sprintf(buf
,"%ld",dwReturn
);
166 _MCISTR_printtf(buf
,uDevTyp
,timef
,dwReturn
);
172 case MCI_FORMAT_MILLISECONDS
:_MCI_STR("milliseconds");break;
173 case MCI_FORMAT_FRAMES
:_MCI_STR("frames");break;
174 case MCI_FORMAT_BYTES
:_MCI_STR("bytes");break;
175 case MCI_FORMAT_SAMPLES
:_MCI_STR("samples");break;
176 case MCI_FORMAT_HMS
:_MCI_STR("hms");break;
177 case MCI_FORMAT_MSF
:_MCI_STR("msf");break;
178 case MCI_FORMAT_TMSF
:_MCI_STR("tmsf");break;
180 FIXME(mci
,"missing timefmt for %d, report.\n",timef
);
184 case _MCISTR_divtype
:
186 case MCI_SEQ_DIV_PPQN
:_MCI_STR("PPQN");break;
187 case MCI_SEQ_DIV_SMPTE_24
:_MCI_STR("SMPTE 24 frame");break;
188 case MCI_SEQ_DIV_SMPTE_25
:_MCI_STR("SMPTE 25 frame");break;
189 case MCI_SEQ_DIV_SMPTE_30
:_MCI_STR("SMPTE 30 frame");break;
190 case MCI_SEQ_DIV_SMPTE_30DROP
:_MCI_STR("SMPTE 30 frame drop");break;
192 case _MCISTR_devtype
:
194 case MCI_DEVTYPE_VCR
:_MCI_STR("vcr");break;
195 case MCI_DEVTYPE_VIDEODISC
:_MCI_STR("videodisc");break;
196 case MCI_DEVTYPE_CD_AUDIO
:_MCI_STR("cd audio");break;
197 case MCI_DEVTYPE_OVERLAY
:_MCI_STR("overlay");break;
198 case MCI_DEVTYPE_DAT
:_MCI_STR("dat");break;
199 case MCI_DEVTYPE_SCANNER
:_MCI_STR("scanner");break;
200 case MCI_DEVTYPE_ANIMATION
:_MCI_STR("animation");break;
201 case MCI_DEVTYPE_DIGITAL_VIDEO
:_MCI_STR("digital video");break;
202 case MCI_DEVTYPE_OTHER
:_MCI_STR("other");break;
203 case MCI_DEVTYPE_WAVEFORM_AUDIO
:_MCI_STR("waveform audio");break;
204 case MCI_DEVTYPE_SEQUENCER
:_MCI_STR("sequencer");break;
205 default:FIXME(mci
,"unknown device type %ld, report.\n",
210 FIXME(mci
,"unknown resulttype %d, report.\n",type
);
215 #define FLAG1(str,flag) \
216 if (!STRCMP(keywords[i],str)) {\
221 #define FLAG2(str1,str2,flag) \
222 if (!STRCMP(keywords[i],str1) && (i+1<nrofkeywords) && !STRCMP(keywords[i+1],str2)) {\
228 /* All known subcommands are implemented in single functions to avoid
229 * bloat and a xxxx lines long mciSendString(). All commands are of the
230 * format MCISTR_Cmd(_MCISTR_PROTO_) where _MCISTR_PROTO_ is the above
231 * defined line of arguments. (This is just for easy enhanceability.)
232 * All functions return the MCIERR_ errorvalue as DWORD. Returnvalues
233 * for the calls are in lpstrReturnString (If I mention return values
234 * in function headers, I mean returnvalues in lpstrReturnString.)
235 * Integers are sprintf("%d")ed integers. Boolean values are
236 * "true" and "false".
237 * timeformat depending values are "%d" "%d:%d" "%d:%d:%d" "%d:%d:%d:%d"
238 * FIXME: is above line correct?
240 * Preceding every function is a list of implemented/known arguments.
241 * Feel free to add missing arguments.
246 * Opens the specified MCI driver.
250 * "alias <aliasname>"
251 * "element <elementname>"
254 * "buffer <nrBytesPerSec>"
256 * "nostatic" increaste nr of nonstatic colours
257 * "parent <windowhandle>"
258 * "style <mask>" bitmask of WS_xxxxx (see windows.h)
259 * "style child" WS_CHILD
260 * "style overlap" WS_OVERLAPPED
261 * "style popup" WS_POPUP
263 * "parent <windowhandle>"
264 * "style <mask>" bitmask of WS_xxxxx (see windows.h)
265 * "style child" WS_CHILD
266 * "style overlap" WS_OVERLAPPED
267 * "style popup" WS_POPUP
271 MCISTR_Open(_MCISTR_PROTO_
) {
275 MCI_OPEN_PARMS16 openParams
;
276 MCI_WAVE_OPEN_PARMS16 waveopenParams
;
277 MCI_ANIM_OPEN_PARMS16 animopenParams
;
278 MCI_OVLY_OPEN_PARMS16 ovlyopenParams
;
280 union U
*pU
= xmalloc(sizeof(union U
));
282 pU
->openParams
.lpstrElementName
= NULL
;
286 pU
->openParams
.lpstrElementName
=strdup(s
);
287 dwFlags
|= MCI_OPEN_ELEMENT
;
289 uDevTyp
= MCI_GetDevType(dev
);
291 free(pU
->openParams
.lpstrElementName
);
293 return MCIERR_INVALID_DEVICE_NAME
;
295 wDevID
=MCI_FirstDevID();
296 while(MCI_GetDrv(wDevID
)->modp
.wType
) {
297 wDevID
= MCI_NextDevID(wDevID
);
298 if (!MCI_DevIDValid(wDevID
)) {
299 TRACE(mci
, "MAXMCIDRIVERS reached (%x) !\n", wDevID
);
300 free(pU
->openParams
.lpstrElementName
);
302 return MCIERR_INTERNAL
;
305 MCI_GetDrv(wDevID
)->modp
.wType
= uDevTyp
;
306 MCI_GetDrv(wDevID
)->modp
.wDeviceID
= 0; /* FIXME? for multiple devices */
307 pU
->openParams
.dwCallback
= hwndCallback
;
308 pU
->openParams
.wDeviceID
= wDevID
;
309 pU
->openParams
.wReserved0
= 0;
310 pU
->ovlyopenParams
.dwStyle
= 0;
311 pU
->animopenParams
.dwStyle
= 0;
312 pU
->openParams
.lpstrDeviceType
= strdup(dev
);
313 pU
->openParams
.lpstrAlias
= NULL
;
314 dwFlags
|= MCI_OPEN_TYPE
;
316 while (i
<nrofkeywords
) {
317 FLAG1("shareable",MCI_OPEN_SHAREABLE
);
318 if (!STRCMP(keywords
[i
],"alias") && (i
+1<nrofkeywords
)) {
319 dwFlags
|= MCI_OPEN_ALIAS
;
320 pU
->openParams
.lpstrAlias
=strdup(keywords
[i
+1]);
324 if (!STRCMP(keywords
[i
],"element") && (i
+1<nrofkeywords
)) {
325 dwFlags
|= MCI_OPEN_ELEMENT
;
326 pU
->openParams
.lpstrElementName
=strdup(keywords
[i
+1]);
331 case MCI_DEVTYPE_ANIMATION
:
332 case MCI_DEVTYPE_DIGITAL_VIDEO
:
333 FLAG1("nostatic",MCI_ANIM_OPEN_NOSTATIC
);
334 if (!STRCMP(keywords
[i
],"parent") && (i
+1<nrofkeywords
)) {
335 dwFlags
|= MCI_ANIM_OPEN_PARENT
;
336 sscanf(keywords
[i
+1],"%hu",&(pU
->animopenParams
.hWndParent
));
340 if (!STRCMP(keywords
[i
],"style") && (i
+1<nrofkeywords
)) {
343 dwFlags
|= MCI_ANIM_OPEN_WS
;
344 if (!STRCMP(keywords
[i
+1],"popup")) {
345 pU
->animopenParams
.dwStyle
|= WS_POPUP
;
346 } else if (!STRCMP(keywords
[i
+1],"overlap")) {
347 pU
->animopenParams
.dwStyle
|= WS_OVERLAPPED
;
348 } else if (!STRCMP(keywords
[i
+1],"child")) {
349 pU
->animopenParams
.dwStyle
|= WS_CHILD
;
350 } else if (sscanf(keywords
[i
+1],"%ld",&st
)) {
351 pU
->animopenParams
.dwStyle
|= st
;
353 FIXME(mci
,"unknown 'style' keyword %s, please report.\n",keywords
[i
+1]);
358 case MCI_DEVTYPE_WAVEFORM_AUDIO
:
359 if (!STRCMP(keywords
[i
],"buffer") && (i
+1<nrofkeywords
)) {
360 dwFlags
|= MCI_WAVE_OPEN_BUFFER
;
361 sscanf(keywords
[i
+1],"%ld",&(pU
->waveopenParams
.dwBufferSeconds
));
364 case MCI_DEVTYPE_OVERLAY
:
365 /* looks just like anim, but without NOSTATIC */
366 if (!STRCMP(keywords
[i
],"parent") && (i
+1<nrofkeywords
)) {
367 dwFlags
|= MCI_OVLY_OPEN_PARENT
;
368 sscanf(keywords
[i
+1],"%hd",&(pU
->ovlyopenParams
.hWndParent
));
372 if (!STRCMP(keywords
[i
],"style") && (i
+1<nrofkeywords
)) {
375 dwFlags
|= MCI_OVLY_OPEN_WS
;
376 if (!STRCMP(keywords
[i
+1],"popup")) {
377 pU
->ovlyopenParams
.dwStyle
|= WS_POPUP
;
378 } else if (!STRCMP(keywords
[i
+1],"overlap")) {
379 pU
->ovlyopenParams
.dwStyle
|= WS_OVERLAPPED
;
380 } else if (!STRCMP(keywords
[i
+1],"child")) {
381 pU
->ovlyopenParams
.dwStyle
|= WS_CHILD
;
382 } else if (sscanf(keywords
[i
+1],"%ld",&st
)) {
383 pU
->ovlyopenParams
.dwStyle
|= st
;
385 FIXME(mci
,"unknown 'style' keyword %s, please report.\n",keywords
[i
+1]);
391 FIXME(mci
,"unknown parameter passed %s, please report.\n",
395 _MCI_CALL_DRIVER(MCI_OPEN
, pU
);
397 memcpy(MCI_GetOpenDrv(wDevID
),&pU
->openParams
,sizeof(MCI_OPEN_PARMS16
));
399 free(pU
->openParams
.lpstrElementName
);
400 free(pU
->openParams
.lpstrDeviceType
);
401 free(pU
->openParams
.lpstrAlias
);
407 /* A help function for a lot of others ...
408 * for instance status/play/record/seek etc.
411 _MCISTR_determine_timeformat(LPCSTR dev
,WORD wDevID
,WORD uDevTyp
,int *timef
)
414 DWORD dwFlags
= MCI_STATUS_ITEM
;
415 MCI_STATUS_PARMS
*statusParams
= xmalloc(sizeof(MCI_STATUS_PARMS
));
417 if (!statusParams
) return 0;
418 statusParams
->dwItem
= MCI_STATUS_TIME_FORMAT
;
419 statusParams
->dwReturn
= 0;
420 _MCI_CALL_DRIVER( MCI_STATUS
, statusParams
);
421 if (res
==0) *timef
= statusParams
->dwReturn
;
426 /* query status of MCI drivers
429 * "mode" - returns "not ready" "paused" "playing" "stopped" "open"
430 * "parked" "recording" "seeking" ....
432 * "current track" - returns current track as integer
433 * "length [track <nr>]" - returns length [of track <nr>] in current
435 * "number of tracks" - returns number of tracks as integer
436 * "position [track <nr>]" - returns position [in track <nr>] in current
438 * "ready" - checks if device is ready to play, -> bool
439 * "start position" - returns start position in timeformat
440 * "time format" - returns timeformat (list of possible values:
441 * "ms" "msf" "milliseconds" "hmsf" "tmsf" "frames"
442 * "bytes" "samples" "hms")
443 * "media present" - returns if media is present as bool
445 * "forward" - returns "true" if device is playing forwards
446 * "speed" - returns speed for device
447 * "palette handle" - returns palette handle
448 * "window handle" - returns window handle
449 * "stretch" - returns stretch bool
451 * "division type" - ? returns "PPQN" "SMPTE 24 frame"
452 * "SMPTE 25 frame" "SMPTE 30 frame" "SMPTE 30 drop frame"
453 * "tempo" - current tempo in (PPQN? speed in frames, SMPTE*? speed in hsmf)
454 * "offset" - offset in dito.
455 * "port" - midi port as integer
456 * "slave" - slave device ("midi","file","none","smpte")
457 * "master" - masterdevice (dito.)
459 * "window handle" - see animation
462 * "speed" - speed as integer
463 * "forward" - returns bool (when playing forward)
464 * "side" - returns 1 or 2
465 * "media type" - returns "CAV" "CLV" "other"
466 * "disc size" - returns "8" or "12"
468 * "input" - base queries on input set
469 * "output" - base queries on output set
470 * "format tag" - return integer format tag
471 * "channels" - return integer nr of channels
472 * "bytespersec" - return average nr of bytes/sec
473 * "samplespersec" - return nr of samples per sec
474 * "bitspersample" - return bitspersample
475 * "alignment" - return block alignment
476 * "level" - return level?
479 #define ITEM1(str,item,xtype) \
480 if (!STRCMP(keywords[i],str)) {\
481 statusParams->dwItem = item;\
486 #define ITEM2(str1,str2,item,xtype) \
487 if ( !STRCMP(keywords[i],str1) &&\
488 (i+1<nrofkeywords) &&\
489 !STRCMP(keywords[i+1],str2)\
491 statusParams->dwItem = item;\
496 #define ITEM3(str1,str2,str3,item,xtype) \
497 if ( !STRCMP(keywords[i],str1) &&\
498 (i+2<nrofkeywords) &&\
499 !STRCMP(keywords[i+1],str2) &&\
500 !STRCMP(keywords[i+2],str3)\
502 statusParams->dwItem = item;\
508 MCISTR_Status(_MCISTR_PROTO_
) {
509 MCI_STATUS_PARMS
*statusParams
= xmalloc(sizeof(MCI_STATUS_PARMS
));
510 int type
= 0,i
,res
,timef
;
512 statusParams
->dwCallback
= hwndCallback
;
513 dwFlags
|= MCI_STATUS_ITEM
;
514 res
= _MCISTR_determine_timeformat(dev
,wDevID
,uDevTyp
,&timef
);
517 statusParams
->dwReturn
= 0;
518 statusParams
->dwItem
= 0;
521 while (i
<nrofkeywords
) {
522 if (!STRCMP(keywords
[i
],"track") && (i
+1<nrofkeywords
)) {
523 sscanf(keywords
[i
+1],"%ld",&(statusParams
->dwTrack
));
524 dwFlags
|= MCI_TRACK
;
528 FLAG1("start",MCI_STATUS_START
);
530 ITEM2("current","track",MCI_STATUS_CURRENT_TRACK
,_MCISTR_time
);
531 ITEM2("time","format",MCI_STATUS_TIME_FORMAT
,_MCISTR_tfname
);
532 ITEM1("ready",MCI_STATUS_READY
,_MCISTR_bool
);
533 ITEM1("mode",MCI_STATUS_MODE
,_MCISTR_mode
);
534 ITEM3("number","of","tracks",MCI_STATUS_NUMBER_OF_TRACKS
,_MCISTR_int
);
535 ITEM1("length",MCI_STATUS_LENGTH
,_MCISTR_time
);
536 ITEM1("position",MCI_STATUS_POSITION
,_MCISTR_time
);
537 ITEM2("media","present",MCI_STATUS_MEDIA_PRESENT
,_MCISTR_bool
);
540 case MCI_DEVTYPE_ANIMATION
:
541 case MCI_DEVTYPE_DIGITAL_VIDEO
:
542 ITEM2("palette","handle",MCI_ANIM_STATUS_HPAL
,_MCISTR_int
);
543 ITEM2("window","handle",MCI_ANIM_STATUS_HWND
,_MCISTR_int
);
544 ITEM1("stretch",MCI_ANIM_STATUS_STRETCH
,_MCISTR_bool
);
545 ITEM1("speed",MCI_ANIM_STATUS_SPEED
,_MCISTR_int
);
546 ITEM1("forward",MCI_ANIM_STATUS_FORWARD
,_MCISTR_bool
);
548 case MCI_DEVTYPE_SEQUENCER
:
549 /* just completing the list, not working correctly */
550 ITEM2("division","type",MCI_SEQ_STATUS_DIVTYPE
,_MCISTR_divtype
);
551 /* tempo ... PPQN in frames/second, SMPTE in hmsf */
552 ITEM1("tempo",MCI_SEQ_STATUS_TEMPO
,_MCISTR_int
);
553 ITEM1("port",MCI_SEQ_STATUS_PORT
,_MCISTR_int
);
554 ITEM1("slave",MCI_SEQ_STATUS_SLAVE
,_MCISTR_seqtype
);
555 ITEM1("master",MCI_SEQ_STATUS_SLAVE
,_MCISTR_seqtype
);
556 /* offset ... PPQN in frames/second, SMPTE in hmsf */
557 ITEM1("offset",MCI_SEQ_STATUS_SLAVE
,_MCISTR_time
);
559 case MCI_DEVTYPE_OVERLAY
:
560 ITEM2("window","handle",MCI_OVLY_STATUS_HWND
,_MCISTR_int
);
561 ITEM1("stretch",MCI_OVLY_STATUS_STRETCH
,_MCISTR_bool
);
563 case MCI_DEVTYPE_VIDEODISC
:
564 ITEM1("speed",MCI_VD_STATUS_SPEED
,_MCISTR_int
);
565 ITEM1("forward",MCI_VD_STATUS_FORWARD
,_MCISTR_bool
);
566 ITEM1("side",MCI_VD_STATUS_SIDE
,_MCISTR_int
);
567 ITEM2("media","type",MCI_VD_STATUS_SIDE
,_MCISTR_vdmtype
);
568 /* returns 8 or 12 */
569 ITEM2("disc","size",MCI_VD_STATUS_DISC_SIZE
,_MCISTR_int
);
571 case MCI_DEVTYPE_WAVEFORM_AUDIO
:
572 /* I am not quite sure if foll. 2 lines are right. */
573 FLAG1("input",MCI_WAVE_INPUT
);
574 FLAG1("output",MCI_WAVE_OUTPUT
);
576 ITEM2("format","tag",MCI_WAVE_STATUS_FORMATTAG
,_MCISTR_int
);
577 ITEM1("channels",MCI_WAVE_STATUS_CHANNELS
,_MCISTR_int
);
578 ITEM1("bytespersec",MCI_WAVE_STATUS_AVGBYTESPERSEC
,_MCISTR_int
);
579 ITEM1("samplespersec",MCI_WAVE_STATUS_SAMPLESPERSEC
,_MCISTR_int
);
580 ITEM1("bitspersample",MCI_WAVE_STATUS_BITSPERSAMPLE
,_MCISTR_int
);
581 ITEM1("alignment",MCI_WAVE_STATUS_BLOCKALIGN
,_MCISTR_int
);
582 ITEM1("level",MCI_WAVE_STATUS_LEVEL
,_MCISTR_int
);
585 FIXME(mci
,"unknown keyword '%s'\n",keywords
[i
]);
588 if (!statusParams
->dwItem
)
589 return MCIERR_MISSING_STRING_ARGUMENT
;
591 _MCI_CALL_DRIVER( MCI_STATUS
, statusParams
);
593 _MCISTR_convreturn(type
,statusParams
->dwReturn
,lpstrReturnString
,uReturnLength
,uDevTyp
,timef
);
601 /* set specified parameters in respective MCI drivers
603 * "door open" eject media or somesuch
604 * "door close" load media
605 * "time format <timeformatname>" "ms" "milliseconds" "msf" "hmsf"
606 * "tmsf" "SMPTE 24" "SMPTE 25" "SMPTE 30"
608 * "audio [all|left|right] [on|off]" sets specified audiochannel on or off
609 * "video [on|off]" sets video on/off
611 * "formattag pcm" sets format to pcm
612 * "formattag <nr>" sets integer formattag value
613 * "any input" accept input from any known source
614 * "any output" output to any known destination
615 * "input <nr>" input from source <nr>
616 * "output <nr>" output to destination <nr>
617 * "channels <nr>" sets nr of channels
618 * "bytespersec <nr>" sets average bytes per second
619 * "samplespersec <nr>" sets average samples per second (1 sample can
621 * "alignment <nr>" sets the blockalignment to <nr>
622 * "bitspersample <nr>" sets the nr of bits per sample
624 * "master [midi|file|smpte|none]" sets the midi master device
625 * "slave [midi|file|smpte|none]" sets the midi master device
626 * "port mapper" midioutput to portmapper
627 * "port <nr>" midioutput to specified port
628 * "tempo <nr>" tempo of track (depends on timeformat/divtype)
629 * "offset <nr>" start offset?
632 MCISTR_Set(_MCISTR_PROTO_
) {
634 MCI_SET_PARMS setParams
;
635 MCI_WAVE_SET_PARMS16 wavesetParams
;
636 MCI_SEQ_SET_PARMS seqsetParams
;
638 union U
*pU
= xmalloc(sizeof(union U
));
641 pU
->setParams
.dwCallback
= hwndCallback
;
643 while (i
<nrofkeywords
) {
644 FLAG2("door","open",MCI_SET_DOOR_OPEN
);
645 FLAG2("door","closed",MCI_SET_DOOR_CLOSED
);
647 if ( !STRCMP(keywords
[i
],"time") &&
648 (i
+2<nrofkeywords
) &&
649 !STRCMP(keywords
[i
+1],"format")
651 dwFlags
|= MCI_SET_TIME_FORMAT
;
653 /* FIXME:is this a shortcut for milliseconds or
654 * minutes:seconds? */
655 if (!STRCMP(keywords
[i
+2],"ms"))
656 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
658 if (!STRCMP(keywords
[i
+2],"milliseconds"))
659 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
660 if (!STRCMP(keywords
[i
+2],"msf"))
661 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_MSF
;
662 if (!STRCMP(keywords
[i
+2],"hms"))
663 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_HMS
;
664 if (!STRCMP(keywords
[i
+2],"frames"))
665 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_FRAMES
;
666 if (!STRCMP(keywords
[i
+2],"track"))
667 pU
->setParams
.dwTimeFormat
= MCI_VD_FORMAT_TRACK
;
668 if (!STRCMP(keywords
[i
+2],"bytes"))
669 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_BYTES
;
670 if (!STRCMP(keywords
[i
+2],"samples"))
671 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_SAMPLES
;
672 if (!STRCMP(keywords
[i
+2],"tmsf"))
673 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_TMSF
;
674 if ( !STRCMP(keywords
[i
+2],"song") &&
675 (i
+3<nrofkeywords
) &&
676 !STRCMP(keywords
[i
+3],"pointer")
678 pU
->setParams
.dwTimeFormat
= MCI_SEQ_FORMAT_SONGPTR
;
679 if (!STRCMP(keywords
[i
+2],"smpte") && (i
+3<nrofkeywords
)) {
680 if (!STRCMP(keywords
[i
+3],"24"))
681 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_SMPTE_24
;
682 if (!STRCMP(keywords
[i
+3],"25"))
683 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_SMPTE_25
;
684 if (!STRCMP(keywords
[i
+3],"30"))
685 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_SMPTE_30
;
686 if (!STRCMP(keywords
[i
+3],"drop") && (i
+4<nrofkeywords
) && !STRCMP(keywords
[i
+4],"30")) {
687 pU
->setParams
.dwTimeFormat
= MCI_FORMAT_SMPTE_30DROP
;
696 if (!STRCMP(keywords
[i
],"audio") && (i
+1<nrofkeywords
)) {
697 dwFlags
|= MCI_SET_AUDIO
;
698 if (!STRCMP(keywords
[i
+1],"all"))
699 pU
->setParams
.dwAudio
= MCI_SET_AUDIO_ALL
;
700 if (!STRCMP(keywords
[i
+1],"left"))
701 pU
->setParams
.dwAudio
= MCI_SET_AUDIO_LEFT
;
702 if (!STRCMP(keywords
[i
+1],"right"))
703 pU
->setParams
.dwAudio
= MCI_SET_AUDIO_RIGHT
;
707 FLAG1("video",MCI_SET_VIDEO
);
708 FLAG1("on",MCI_SET_ON
);
709 FLAG1("off",MCI_SET_OFF
);
711 case MCI_DEVTYPE_WAVEFORM_AUDIO
:
712 FLAG2("any","input",MCI_WAVE_SET_ANYINPUT
);
713 FLAG2("any","output",MCI_WAVE_SET_ANYOUTPUT
);
715 if ( !STRCMP(keywords
[i
],"formattag") &&
716 (i
+1<nrofkeywords
) &&
717 !STRCMP(keywords
[i
+1],"pcm")
719 dwFlags
|= MCI_WAVE_SET_FORMATTAG
;
720 pU
->wavesetParams
.wFormatTag
= WAVE_FORMAT_PCM
;
725 /* <keyword> <integer> */
726 #define WII(str,flag,fmt,element) \
727 if (!STRCMP(keywords[i],str) && (i+1<nrofkeywords)) {\
728 sscanf(keywords[i+1],fmt,&(pU->wavesetParams. element ));\
733 WII("formattag",MCI_WAVE_SET_FORMATTAG
,"%hu",wFormatTag
);
734 WII("channels",MCI_WAVE_SET_CHANNELS
,"%hu",nChannels
);
735 WII("bytespersec",MCI_WAVE_SET_AVGBYTESPERSEC
,"%lu",nAvgBytesPerSec
);
736 WII("samplespersec",MCI_WAVE_SET_SAMPLESPERSEC
,"%lu",nSamplesPerSec
);
737 WII("alignment",MCI_WAVE_SET_BLOCKALIGN
,"%hu",nBlockAlign
);
738 WII("bitspersample",MCI_WAVE_SET_BITSPERSAMPLE
,"%hu",wBitsPerSample
);
739 WII("input",MCI_WAVE_INPUT
,"%hu",wInput
);
740 WII("output",MCI_WAVE_OUTPUT
,"%hu",wOutput
);
743 case MCI_DEVTYPE_SEQUENCER
:
744 if (!STRCMP(keywords
[i
],"master") && (i
+1<nrofkeywords
)) {
745 dwFlags
|= MCI_SEQ_SET_MASTER
;
746 if (!STRCMP(keywords
[i
+1],"midi"))
747 pU
->seqsetParams
.dwMaster
= MCI_SEQ_MIDI
;
748 if (!STRCMP(keywords
[i
+1],"file"))
749 pU
->seqsetParams
.dwMaster
= MCI_SEQ_FILE
;
750 if (!STRCMP(keywords
[i
+1],"smpte"))
751 pU
->seqsetParams
.dwMaster
= MCI_SEQ_SMPTE
;
752 if (!STRCMP(keywords
[i
+1],"none"))
753 pU
->seqsetParams
.dwMaster
= MCI_SEQ_NONE
;
757 if (!STRCMP(keywords
[i
],"slave") && (i
+1<nrofkeywords
)) {
758 dwFlags
|= MCI_SEQ_SET_SLAVE
;
759 if (!STRCMP(keywords
[i
+1],"midi"))
760 pU
->seqsetParams
.dwMaster
= MCI_SEQ_MIDI
;
761 if (!STRCMP(keywords
[i
+1],"file"))
762 pU
->seqsetParams
.dwMaster
= MCI_SEQ_FILE
;
763 if (!STRCMP(keywords
[i
+1],"smpte"))
764 pU
->seqsetParams
.dwMaster
= MCI_SEQ_SMPTE
;
765 if (!STRCMP(keywords
[i
+1],"none"))
766 pU
->seqsetParams
.dwMaster
= MCI_SEQ_NONE
;
770 if ( !STRCMP(keywords
[i
],"port") &&
771 (i
+1<nrofkeywords
) &&
772 !STRCMP(keywords
[i
+1],"mapper")
774 pU
->seqsetParams
.dwPort
=-1;/* FIXME:not sure*/
775 dwFlags
|= MCI_SEQ_SET_PORT
;
779 #define SII(str,flag,element) \
780 if (!STRCMP(keywords[i],str) && (i+1<nrofkeywords)) {\
781 sscanf(keywords[i+1],"%ld",&(pU->seqsetParams. element ));\
786 SII("tempo",MCI_SEQ_SET_TEMPO
,dwTempo
);
787 SII("port",MCI_SEQ_SET_PORT
,dwPort
);
788 SII("offset",MCI_SEQ_SET_PORT
,dwOffset
);
793 return MCIERR_MISSING_STRING_ARGUMENT
;
794 _MCI_CALL_DRIVER( MCI_SET
, pU
);
801 * "off" disable break
802 * "on <keyid>" enable break on key with keyid
803 * (I strongly suspect, that there is another parameter:
805 * but I don't see it mentioned in my documentation.
809 MCISTR_Break(_MCISTR_PROTO_
)
811 MCI_BREAK_PARMS16
*breakParams
= xmalloc(sizeof(MCI_BREAK_PARMS16
));
814 if (!breakParams
) return 0;
815 /*breakParams.hwndBreak ? */
816 for (i
= 0; i
< nrofkeywords
; i
++) {
817 FLAG1("off",MCI_BREAK_OFF
);
818 if (!strcmp(keywords
[i
],"on") && (nrofkeywords
>i
+1)) {
819 dwFlags
&=~MCI_BREAK_OFF
;
820 dwFlags
|=MCI_BREAK_KEY
;
821 sscanf(keywords
[i
+1],"%hd",&(breakParams
->nVirtKey
));
826 _MCI_CALL_DRIVER( MCI_BREAK
, breakParams
);
831 #define ITEM1(str,item,xtype) \
832 if (!STRCMP(keywords[i],str)) {\
833 gdcParams->dwItem = item;\
838 #define ITEM2(str1,str2,item,xtype) \
839 if ( !STRCMP(keywords[i],str1) &&\
840 (i+1<nrofkeywords) &&\
841 !STRCMP(keywords[i+1],str2)\
843 gdcParams->dwItem = item;\
848 #define ITEM3(str1,str2,str3,item,xtype) \
849 if ( !STRCMP(keywords[i],str1) &&\
850 (i+2<nrofkeywords) &&\
851 !STRCMP(keywords[i+1],str2) &&\
852 !STRCMP(keywords[i+2],str3)\
854 gdcParams->dwItem = item;\
859 /* get device capabilities of MCI drivers
862 * "device type" returns device name as string
863 * "has audio" returns bool
864 * "has video" returns bool
865 * "uses files" returns bool
866 * "compound device" returns bool
867 * "can record" returns bool
868 * "can play" returns bool
869 * "can eject" returns bool
870 * "can save" returns bool
872 * "palettes" returns nr of available palette entries
873 * "windows" returns nr of available windows
874 * "can reverse" returns bool
875 * "can stretch" returns bool
876 * "slow play rate" returns the slow playrate
877 * "fast play rate" returns the fast playrate
878 * "normal play rate" returns the normal playrate
880 * "windows" returns nr of available windows
881 * "can stretch" returns bool
882 * "can freeze" returns bool
884 * "cav" assume CAV discs (default if no disk inserted)
885 * "clv" assume CLV discs
886 * "can reverse" returns bool
887 * "slow play rate" returns the slow playrate
888 * "fast play rate" returns the fast playrate
889 * "normal play rate" returns the normal playrate
891 * "inputs" returns nr of inputdevices
892 * "outputs" returns nr of outputdevices
895 MCISTR_Capability(_MCISTR_PROTO_
) {
896 MCI_GETDEVCAPS_PARMS
*gdcParams
= xmalloc(sizeof(MCI_GETDEVCAPS_PARMS
));
899 gdcParams
->dwCallback
= hwndCallback
;
901 return MCIERR_MISSING_STRING_ARGUMENT
;
902 /* well , thats default */
903 dwFlags
|= MCI_GETDEVCAPS_ITEM
;
904 gdcParams
->dwItem
= 0;
906 while (i
<nrofkeywords
) {
907 ITEM2("device","type",MCI_GETDEVCAPS_DEVICE_TYPE
,_MCISTR_devtype
);
908 ITEM2("has","audio",MCI_GETDEVCAPS_HAS_AUDIO
,_MCISTR_bool
);
909 ITEM2("has","video",MCI_GETDEVCAPS_HAS_VIDEO
,_MCISTR_bool
);
910 ITEM2("uses","files",MCI_GETDEVCAPS_USES_FILES
,_MCISTR_bool
);
911 ITEM2("compound","device",MCI_GETDEVCAPS_COMPOUND_DEVICE
,_MCISTR_bool
);
912 ITEM2("can","record",MCI_GETDEVCAPS_CAN_RECORD
,_MCISTR_bool
);
913 ITEM2("can","play",MCI_GETDEVCAPS_CAN_PLAY
,_MCISTR_bool
);
914 ITEM2("can","eject",MCI_GETDEVCAPS_CAN_EJECT
,_MCISTR_bool
);
915 ITEM2("can","save",MCI_GETDEVCAPS_CAN_SAVE
,_MCISTR_bool
);
917 case MCI_DEVTYPE_ANIMATION
:
918 ITEM1("palettes",MCI_ANIM_GETDEVCAPS_PALETTES
,_MCISTR_int
);
919 ITEM1("windows",MCI_ANIM_GETDEVCAPS_MAX_WINDOWS
,_MCISTR_int
);
920 ITEM2("can","reverse",MCI_ANIM_GETDEVCAPS_CAN_REVERSE
,_MCISTR_bool
);
921 ITEM2("can","stretch",MCI_ANIM_GETDEVCAPS_CAN_STRETCH
,_MCISTR_bool
);
922 ITEM3("slow","play","rate",MCI_ANIM_GETDEVCAPS_SLOW_RATE
,_MCISTR_int
);
923 ITEM3("fast","play","rate",MCI_ANIM_GETDEVCAPS_FAST_RATE
,_MCISTR_int
);
924 ITEM3("normal","play","rate",MCI_ANIM_GETDEVCAPS_NORMAL_RATE
,_MCISTR_int
);
926 case MCI_DEVTYPE_OVERLAY
:
927 ITEM1("windows",MCI_OVLY_GETDEVCAPS_MAX_WINDOWS
,_MCISTR_int
);
928 ITEM2("can","freeze",MCI_OVLY_GETDEVCAPS_CAN_FREEZE
,_MCISTR_bool
);
929 ITEM2("can","stretch",MCI_OVLY_GETDEVCAPS_CAN_STRETCH
,_MCISTR_bool
);
931 case MCI_DEVTYPE_VIDEODISC
:
932 FLAG1("cav",MCI_VD_GETDEVCAPS_CAV
);
933 FLAG1("clv",MCI_VD_GETDEVCAPS_CLV
);
934 ITEM2("can","reverse",MCI_VD_GETDEVCAPS_CAN_REVERSE
,_MCISTR_bool
);
935 ITEM3("slow","play","rate",MCI_VD_GETDEVCAPS_SLOW_RATE
,_MCISTR_int
);
936 ITEM3("fast","play","rate",MCI_VD_GETDEVCAPS_FAST_RATE
,_MCISTR_int
);
937 ITEM3("normal","play","rate",MCI_VD_GETDEVCAPS_NORMAL_RATE
,_MCISTR_int
);
939 case MCI_DEVTYPE_WAVEFORM_AUDIO
:
940 ITEM1("inputs",MCI_WAVE_GETDEVCAPS_INPUTS
,_MCISTR_int
);
941 ITEM1("outputs",MCI_WAVE_GETDEVCAPS_OUTPUTS
,_MCISTR_int
);
946 _MCI_CALL_DRIVER( MCI_GETDEVCAPS
, gdcParams
);
947 /* no timeformat needed */
949 _MCISTR_convreturn( type
, gdcParams
->dwReturn
, lpstrReturnString
,
950 uReturnLength
, uDevTyp
, 0 );
957 /* resumes operation of device. no arguments, no return values */
959 MCISTR_Resume(_MCISTR_PROTO_
)
961 MCI_GENERIC_PARMS
*genParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
963 genParams
->dwCallback
= hwndCallback
;
964 _MCI_CALL_DRIVER( MCI_RESUME
, genParams
);
968 /* pauses operation of device. no arguments, no return values */
970 MCISTR_Pause(_MCISTR_PROTO_
)
972 MCI_GENERIC_PARMS
*genParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
974 genParams
->dwCallback
= hwndCallback
;
975 _MCI_CALL_DRIVER( MCI_PAUSE
, genParams
);
979 /* stops operation of device. no arguments, no return values */
981 MCISTR_Stop(_MCISTR_PROTO_
)
983 MCI_GENERIC_PARMS
*genParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
985 genParams
->dwCallback
= hwndCallback
;
986 _MCI_CALL_DRIVER( MCI_STOP
, genParams
);
992 * "overwrite" overwrite existing things
993 * "insert" insert at current position
994 * "to <time>" record up to <time> (specified in timeformat)
995 * "from <time>" record from <time> (specified in timeformat)
998 MCISTR_Record(_MCISTR_PROTO_
) {
999 int i
,res
,timef
,nrargs
,j
,k
,a
[4];
1001 MCI_RECORD_PARMS
*recordParams
= xmalloc(sizeof(MCI_RECORD_PARMS
));
1003 res
= _MCISTR_determine_timeformat(dev
,wDevID
,uDevTyp
,&timef
);
1004 if (res
) return res
;
1007 case MCI_FORMAT_MILLISECONDS
:
1008 case MCI_FORMAT_FRAMES
:
1009 case MCI_FORMAT_BYTES
:
1010 case MCI_FORMAT_SAMPLES
:
1014 case MCI_FORMAT_HMS
:
1015 case MCI_FORMAT_MSF
:
1016 parsestr
="%d:%d:%d";
1019 case MCI_FORMAT_TMSF
:
1020 parsestr
="%d:%d:%d:%d";
1023 default:FIXME(mci
,"unknown timeformat %d, please report.\n",timef
);
1028 recordParams
->dwCallback
= hwndCallback
;
1030 while (i
<nrofkeywords
) {
1031 if (!strcmp(keywords
[i
],"to") && (i
+1<nrofkeywords
)) {
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]);
1035 /* add up all integers we got, if we have more
1036 * shift them. (Well I should use the macros in
1037 * mmsystem.h, right).
1039 recordParams
->dwTo
=0;
1041 recordParams
->dwTo
+=a
[k
]<<(8*(nrargs
-k
));
1045 if (!strcmp(keywords
[i
],"from") && (i
+1<nrofkeywords
)) {
1046 dwFlags
|= MCI_FROM
;
1047 a
[0]=a
[1]=a
[2]=a
[3]=0;
1048 j
=sscanf(keywords
[i
+1],parsestr
,&a
[0],&a
[1],&a
[2],&a
[3]);
1050 recordParams
->dwFrom
=0;
1052 recordParams
->dwFrom
+=a
[k
]<<(8*(nrargs
-k
));
1056 FLAG1("insert",MCI_RECORD_INSERT
);
1057 FLAG1("overwrite",MCI_RECORD_OVERWRITE
);
1060 _MCI_CALL_DRIVER( MCI_RECORD
, recordParams
);
1067 * "to <time>" play up to <time> (specified in set timeformat)
1068 * "from <time>" play from <time> (specified in set timeformat)
1072 * "scan" play as fast as possible (with audio disabled perhaps)
1073 * "reverse" play reverse
1074 * "speed <fps>" play with specified frames per second
1078 * "scan" play as fast as possible (with audio disabled perhaps)
1079 * "reverse" play reverse
1080 * "speed <fps>" play with specified frames per second
1083 MCISTR_Play(_MCISTR_PROTO_
) {
1084 int i
,res
,timef
,nrargs
,j
,k
,a
[4];
1087 MCI_PLAY_PARMS playParams
;
1088 MCI_VD_PLAY_PARMS vdplayParams
;
1089 MCI_ANIM_PLAY_PARMS animplayParams
;
1091 union U
*pU
= xmalloc(sizeof(union U
));
1093 res
= _MCISTR_determine_timeformat(dev
,wDevID
,uDevTyp
,&timef
);
1094 if (res
) return res
;
1096 case MCI_FORMAT_MILLISECONDS
:
1097 case MCI_FORMAT_FRAMES
:
1098 case MCI_FORMAT_BYTES
:
1099 case MCI_FORMAT_SAMPLES
:
1103 case MCI_FORMAT_HMS
:
1104 case MCI_FORMAT_MSF
:
1105 parsestr
="%d:%d:%d";
1108 case MCI_FORMAT_TMSF
:
1109 parsestr
="%d:%d:%d:%d";
1112 default:FIXME(mci
,"unknown timeformat %d, please report.\n",timef
);
1117 pU
->playParams
.dwCallback
=hwndCallback
;
1119 while (i
<nrofkeywords
) {
1120 if (!strcmp(keywords
[i
],"to") && (i
+1<nrofkeywords
)) {
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]);
1124 /* add up all integers we got, if we have more
1125 * shift them. (Well I should use the macros in
1126 * mmsystem.h, right).
1128 pU
->playParams
.dwTo
=0;
1130 pU
->playParams
.dwTo
+=a
[k
]<<(8*(nrargs
-k
));
1134 if (!strcmp(keywords
[i
],"from") && (i
+1<nrofkeywords
)) {
1135 dwFlags
|= MCI_FROM
;
1136 a
[0]=a
[1]=a
[2]=a
[3]=0;
1137 j
=sscanf(keywords
[i
+1],parsestr
,&a
[0],&a
[1],&a
[2],&a
[3]);
1139 pU
->playParams
.dwFrom
=0;
1141 pU
->playParams
.dwFrom
+=a
[k
]<<(8*(nrargs
-k
));
1146 case MCI_DEVTYPE_VIDEODISC
:
1147 FLAG1("slow",MCI_VD_PLAY_SLOW
);
1148 FLAG1("fast",MCI_VD_PLAY_FAST
);
1149 FLAG1("scan",MCI_VD_PLAY_SCAN
);
1150 FLAG1("reverse",MCI_VD_PLAY_REVERSE
);
1151 if (!STRCMP(keywords
[i
],"speed") && (i
+1<nrofkeywords
)) {
1152 dwFlags
|= MCI_VD_PLAY_SPEED
;
1153 sscanf(keywords
[i
+1],"%ld",&(pU
->vdplayParams
.dwSpeed
));
1158 case MCI_DEVTYPE_ANIMATION
:
1159 FLAG1("slow",MCI_ANIM_PLAY_SLOW
);
1160 FLAG1("fast",MCI_ANIM_PLAY_FAST
);
1161 FLAG1("scan",MCI_ANIM_PLAY_SCAN
);
1162 FLAG1("reverse",MCI_ANIM_PLAY_REVERSE
);
1163 if (!STRCMP(keywords
[i
],"speed") && (i
+1<nrofkeywords
)) {
1164 dwFlags
|= MCI_ANIM_PLAY_SPEED
;
1165 sscanf(keywords
[i
+1],"%ld",&(pU
->animplayParams
.dwSpeed
));
1173 _MCI_CALL_DRIVER( MCI_PLAY
, pU
);
1178 /* seek to a specified position
1180 * "to start" seek to start of medium
1181 * "to end" seek to end of medium
1182 * "to <time>" seek to <time> specified in current timeformat
1185 MCISTR_Seek(_MCISTR_PROTO_
) {
1186 int i
,res
,timef
,nrargs
,j
,k
,a
[4];
1188 MCI_SEEK_PARMS
*seekParams
= xmalloc(sizeof(MCI_SEEK_PARMS
));
1190 res
= _MCISTR_determine_timeformat(dev
,wDevID
,uDevTyp
,&timef
);
1191 if (res
) return res
;
1193 case MCI_FORMAT_MILLISECONDS
:
1194 case MCI_FORMAT_FRAMES
:
1195 case MCI_FORMAT_BYTES
:
1196 case MCI_FORMAT_SAMPLES
:
1200 case MCI_FORMAT_HMS
:
1201 case MCI_FORMAT_MSF
:
1202 parsestr
="%d:%d:%d";
1205 case MCI_FORMAT_TMSF
:
1206 parsestr
="%d:%d:%d:%d";
1209 default:FIXME(mci
,"unknown timeformat %d, please report.\n",timef
);
1214 seekParams
->dwCallback
=hwndCallback
;
1216 while (i
<nrofkeywords
) {
1217 if ( !STRCMP(keywords
[i
],"to") && (i
+1<nrofkeywords
)) {
1218 if (!STRCMP(keywords
[i
+1],"start")) {
1219 dwFlags
|=MCI_SEEK_TO_START
;
1224 if (!STRCMP(keywords
[i
+1],"end")) {
1225 dwFlags
|=MCI_SEEK_TO_END
;
1232 a
[0]=a
[1]=a
[2]=a
[3]=0;
1233 j
=sscanf(keywords
[i
+1],parsestr
,&a
[0],&a
[1],&a
[2],&a
[3]);
1236 seekParams
->dwTo
+=a
[k
]<<(8*(nrargs
-k
));
1240 case MCI_DEVTYPE_VIDEODISC
:
1241 FLAG1("reverse",MCI_VD_SEEK_REVERSE
);
1246 _MCI_CALL_DRIVER( MCI_SEEK
, seekParams
);
1251 /* close media/driver */
1253 MCISTR_Close(_MCISTR_PROTO_
)
1255 MCI_GENERIC_PARMS
*closeParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
1257 _MCI_CALL_DRIVER( MCI_CLOSE
, closeParams
);
1262 /* return information.
1264 * "product" return product name (human readable)
1265 * "file" return filename
1267 * "text" returns text?
1269 * "text" returns text?
1272 MCISTR_Info(_MCISTR_PROTO_
)
1274 MCI_INFO_PARMS16
*infoParams
= xmalloc(sizeof(MCI_INFO_PARMS16
));
1279 i
=0;while (i
<nrofkeywords
) {
1280 FLAG1("product",MCI_INFO_PRODUCT
);
1281 FLAG1("file",MCI_INFO_FILE
);
1283 case MCI_DEVTYPE_ANIMATION
:
1284 FLAG1("text",MCI_ANIM_INFO_TEXT
);
1286 case MCI_DEVTYPE_OVERLAY
:
1287 FLAG1("text",MCI_OVLY_INFO_TEXT
);
1292 if (dwFlags
== sflags
)
1293 return MCIERR_MISSING_STRING_ARGUMENT
;
1294 /* MCI driver will fill in lpstrReturn, dwRetSize.
1295 * FIXME: I don't know if this is correct behaviour
1297 _MCI_CALL_DRIVER( MCI_INFO
, infoParams
);
1299 _MCI_STR(infoParams
->lpstrReturn
);
1304 /* query MCI driver itself for information
1306 * "installname" return install name of <device> (system.ini)
1307 * "quantity" return nr of installed drivers
1308 * "open" open drivers only (additional flag)
1309 * "name <nr>" return nr of devices with <devicetyp>
1310 * "name all" return nr of all devices
1312 * FIXME: mciSysInfo16() is broken I think.
1315 MCISTR_Sysinfo(_MCISTR_PROTO_
) {
1316 MCI_SYSINFO_PARMS16 sysinfoParams
;
1319 sysinfoParams
.lpstrReturn
= lpstrReturnString
;
1320 sysinfoParams
.dwRetSize
= uReturnLength
;
1321 sysinfoParams
.wDeviceType
= uDevTyp
;
1323 for (i
= 0; i
< nrofkeywords
; i
++) {
1324 FLAG1("installname",MCI_SYSINFO_INSTALLNAME
);
1325 FLAG1("quantity",MCI_SYSINFO_INSTALLNAME
);
1326 FLAG1("open",MCI_SYSINFO_OPEN
);
1327 if (!strcmp(keywords
[i
],"name") && (i
+1<nrofkeywords
)) {
1328 sscanf(keywords
[i
+1],"%ld",&(sysinfoParams
.dwNumber
));
1329 dwFlags
|= MCI_SYSINFO_NAME
;
1333 res
= mciSendCommand16(0, MCI_SYSINFO
, dwFlags
, (DWORD
)&sysinfoParams
);
1335 if (dwFlags
& MCI_SYSINFO_QUANTITY
) {
1338 sprintf(buf
,"%ld",*(long*)lpstrReturnString
);
1341 /* no need to copy anything back, mciSysInfo did it for us */
1346 * Argument: "<filename>"
1347 * Overlay: "at <left> <top> <right> <bottom>" additional
1350 MCISTR_Load(_MCISTR_PROTO_
) {
1352 MCI_LOAD_PARMS16 loadParams
;
1353 MCI_OVLY_LOAD_PARMS16 ovlyloadParams
;
1355 union U
*pU
= xmalloc(sizeof(union U
));
1360 while (i
<nrofkeywords
) {
1362 case MCI_DEVTYPE_OVERLAY
:
1363 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1364 dwFlags
|= MCI_OVLY_RECT
;
1365 sscanf(keywords
[i
+1],"%hd",&(pU
->ovlyloadParams
.rc
.left
));
1366 sscanf(keywords
[i
+2],"%hd",&(pU
->ovlyloadParams
.rc
.top
));
1367 sscanf(keywords
[i
+3],"%hd",&(pU
->ovlyloadParams
.rc
.right
));
1368 sscanf(keywords
[i
+4],"%hd",&(pU
->ovlyloadParams
.rc
.bottom
));
1369 memcpy(keywords
+i
,keywords
+(i
+5),nrofkeywords
-(i
+5));
1374 len
+=strlen(keywords
[i
])+1;
1377 s
=(char*)xmalloc(len
);
1379 while (i
<nrofkeywords
) {
1380 strcat(s
,keywords
[i
]);
1382 if (i
<nrofkeywords
) strcat(s
," ");
1384 pU
->loadParams
.lpfilename
=s
;
1385 dwFlags
|= MCI_LOAD_FILE
;
1386 _MCI_CALL_DRIVER( MCI_LOAD
, pU
);
1393 * Argument: "<filename>"
1394 * Overlay: "at <left> <top> <right> <bottom>" additional
1397 MCISTR_Save(_MCISTR_PROTO_
) {
1399 MCI_SAVE_PARMS saveParams
;
1400 MCI_OVLY_SAVE_PARMS16 ovlysaveParams
;
1402 union U
*pU
= xmalloc(sizeof(union U
));
1407 while (i
<nrofkeywords
) {
1409 case MCI_DEVTYPE_OVERLAY
:
1410 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1411 dwFlags
|= MCI_OVLY_RECT
;
1412 sscanf(keywords
[i
+1],"%hd",&(pU
->ovlysaveParams
.rc
.left
));
1413 sscanf(keywords
[i
+2],"%hd",&(pU
->ovlysaveParams
.rc
.top
));
1414 sscanf(keywords
[i
+3],"%hd",&(pU
->ovlysaveParams
.rc
.right
));
1415 sscanf(keywords
[i
+4],"%hd",&(pU
->ovlysaveParams
.rc
.bottom
));
1416 memcpy(keywords
+i
,keywords
+(i
+5),nrofkeywords
-(i
+5));
1421 len
+=strlen(keywords
[i
])+1;
1424 s
=(char*)xmalloc(len
);
1426 while (i
<nrofkeywords
) {
1427 strcat(s
,keywords
[i
]);
1429 if (i
<nrofkeywords
) strcat(s
," ");
1431 pU
->saveParams
.lpfilename
=s
;
1432 dwFlags
|= MCI_LOAD_FILE
;
1433 _MCI_CALL_DRIVER( MCI_SAVE
, pU
);
1439 /* prepare device for input/output
1440 * (only applyable to waveform audio)
1443 MCISTR_Cue(_MCISTR_PROTO_
) {
1444 MCI_GENERIC_PARMS
*cueParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
1448 while (i
<nrofkeywords
) {
1450 case MCI_DEVTYPE_WAVEFORM_AUDIO
:
1451 FLAG1("input",MCI_WAVE_INPUT
);
1452 FLAG1("output",MCI_WAVE_OUTPUT
);
1457 _MCI_CALL_DRIVER( MCI_CUE
, cueParams
);
1462 /* delete information */
1464 MCISTR_Delete(_MCISTR_PROTO_
) {
1465 int timef
,nrargs
,i
,j
,k
,a
[4],res
;
1467 MCI_WAVE_DELETE_PARMS
*deleteParams
= xmalloc(sizeof(MCI_WAVE_DELETE_PARMS
));
1469 /* only implemented for waveform audio */
1470 if (uDevTyp
!= MCI_DEVTYPE_WAVEFORM_AUDIO
)
1471 return MCIERR_UNSUPPORTED_FUNCTION
; /* well it fits */
1472 res
= _MCISTR_determine_timeformat(dev
,wDevID
,uDevTyp
,&timef
);
1473 if (res
) return res
;
1475 case MCI_FORMAT_MILLISECONDS
:
1476 case MCI_FORMAT_FRAMES
:
1477 case MCI_FORMAT_BYTES
:
1478 case MCI_FORMAT_SAMPLES
:
1482 case MCI_FORMAT_HMS
:
1483 case MCI_FORMAT_MSF
:
1484 parsestr
="%d:%d:%d";
1487 case MCI_FORMAT_TMSF
:
1488 parsestr
="%d:%d:%d:%d";
1491 default:FIXME(mci
,"unknown timeformat %d, please report.\n",timef
);
1497 while (i
<nrofkeywords
) {
1498 if (!strcmp(keywords
[i
],"to") && (i
+1<nrofkeywords
)) {
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]);
1502 /* add up all integers we got, if we have more
1503 * shift them. (Well I should use the macros in
1504 * mmsystem.h, right).
1506 deleteParams
->dwTo
=0;
1508 deleteParams
->dwTo
+=a
[k
]<<(8*(nrargs
-k
));
1512 if (!strcmp(keywords
[i
],"from") && (i
+1<nrofkeywords
)) {
1513 dwFlags
|= MCI_FROM
;
1514 a
[0]=a
[1]=a
[2]=a
[3]=0;
1515 j
=sscanf(keywords
[i
+1],parsestr
,&a
[0],&a
[1],&a
[2],&a
[3]);
1517 deleteParams
->dwFrom
=0;
1519 deleteParams
->dwFrom
+=a
[k
]<<(8*(nrargs
-k
));
1525 _MCI_CALL_DRIVER( MCI_DELETE
, deleteParams
);
1530 /* send command to device. only applies to videodisc */
1532 MCISTR_Escape(_MCISTR_PROTO_
)
1534 MCI_VD_ESCAPE_PARMS16
*escapeParams
= xmalloc(sizeof(MCI_VD_ESCAPE_PARMS16
));
1538 if (uDevTyp
!= MCI_DEVTYPE_VIDEODISC
)
1539 return MCIERR_UNSUPPORTED_FUNCTION
;
1541 while (i
<nrofkeywords
) {
1542 len
+=strlen(keywords
[i
])+1;
1545 s
=(char*)malloc(len
);
1547 while (i
<nrofkeywords
) {
1548 strcat(s
,keywords
[i
]);
1550 if (i
<nrofkeywords
) strcat(s
," ");
1552 escapeParams
->lpstrCommand
= s
;
1553 dwFlags
|= MCI_VD_ESCAPE_STRING
;
1554 _MCI_CALL_DRIVER( MCI_ESCAPE
, escapeParams
);
1560 /* unfreeze [part of] the overlayed video
1561 * only applyable to Overlay devices
1564 MCISTR_Unfreeze(_MCISTR_PROTO_
)
1566 MCI_OVLY_RECT_PARMS16
*unfreezeParams
= xmalloc(sizeof(MCI_OVLY_RECT_PARMS16
));
1569 if (uDevTyp
!= MCI_DEVTYPE_OVERLAY
)
1570 return MCIERR_UNSUPPORTED_FUNCTION
;
1571 i
=0;while (i
<nrofkeywords
) {
1572 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1573 sscanf(keywords
[i
+1],"%hd",&(unfreezeParams
->rc
.left
));
1574 sscanf(keywords
[i
+2],"%hd",&(unfreezeParams
->rc
.top
));
1575 sscanf(keywords
[i
+3],"%hd",&(unfreezeParams
->rc
.right
));
1576 sscanf(keywords
[i
+4],"%hd",&(unfreezeParams
->rc
.bottom
));
1577 dwFlags
|= MCI_OVLY_RECT
;
1583 _MCI_CALL_DRIVER( MCI_UNFREEZE
, unfreezeParams
);
1584 free(unfreezeParams
);
1587 /* freeze [part of] the overlayed video
1588 * only applyable to Overlay devices
1591 MCISTR_Freeze(_MCISTR_PROTO_
)
1593 MCI_OVLY_RECT_PARMS16
*freezeParams
= xmalloc(sizeof(MCI_OVLY_RECT_PARMS16
));
1596 if (uDevTyp
!= MCI_DEVTYPE_OVERLAY
)
1597 return MCIERR_UNSUPPORTED_FUNCTION
;
1598 i
=0;while (i
<nrofkeywords
) {
1599 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1600 sscanf(keywords
[i
+1],"%hd",&(freezeParams
->rc
.left
));
1601 sscanf(keywords
[i
+2],"%hd",&(freezeParams
->rc
.top
));
1602 sscanf(keywords
[i
+3],"%hd",&(freezeParams
->rc
.right
));
1603 sscanf(keywords
[i
+4],"%hd",&(freezeParams
->rc
.bottom
));
1604 dwFlags
|= MCI_OVLY_RECT
;
1610 _MCI_CALL_DRIVER( MCI_FREEZE
, freezeParams
);
1615 /* copy parts of image to somewhere else
1616 * "source [at <left> <top> <right> <bottom>]" source is framebuffer [or rect]
1617 * "destination [at <left> <top> <right> <bottom>]" destination is framebuffer [or rect]
1619 * "frame [at <left> <top> <right> <bottom>]" frame is framebuffer [or rect]
1620 * where the video input is placed
1621 * "video [at <left> <top> <right> <bottom>]" video is whole video [or rect]
1622 * (defining part of input to
1625 * FIXME: This whole junk is passing multiple rectangles.
1626 * I don't know how to do that with the present interface.
1627 * (Means code below is broken)
1630 MCISTR_Put(_MCISTR_PROTO_
) {
1632 MCI_OVLY_RECT_PARMS16 ovlyputParams
;
1633 MCI_ANIM_RECT_PARMS16 animputParams
;
1635 union U
*pU
= xmalloc(sizeof(union U
));
1637 i
=0;while (i
<nrofkeywords
) {
1639 case MCI_DEVTYPE_ANIMATION
:
1640 FLAG1("source",MCI_ANIM_PUT_SOURCE
);
1641 FLAG1("destination",MCI_ANIM_PUT_DESTINATION
);
1642 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1643 sscanf(keywords
[i
+1],"%hd",&(pU
->animputParams
.rc
.left
));
1644 sscanf(keywords
[i
+2],"%hd",&(pU
->animputParams
.rc
.top
));
1645 sscanf(keywords
[i
+3],"%hd",&(pU
->animputParams
.rc
.right
));
1646 sscanf(keywords
[i
+4],"%hd",&(pU
->animputParams
.rc
.bottom
));
1647 dwFlags
|= MCI_ANIM_RECT
;
1652 case MCI_DEVTYPE_OVERLAY
:
1653 FLAG1("source",MCI_OVLY_PUT_SOURCE
);
1654 FLAG1("destination",MCI_OVLY_PUT_DESTINATION
);
1655 FLAG1("video",MCI_OVLY_PUT_VIDEO
);
1656 FLAG1("frame",MCI_OVLY_PUT_FRAME
);
1657 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1658 sscanf(keywords
[i
+1],"%hd",&(pU
->ovlyputParams
.rc
.left
));
1659 sscanf(keywords
[i
+2],"%hd",&(pU
->ovlyputParams
.rc
.top
));
1660 sscanf(keywords
[i
+3],"%hd",&(pU
->ovlyputParams
.rc
.right
));
1661 sscanf(keywords
[i
+4],"%hd",&(pU
->ovlyputParams
.rc
.bottom
));
1662 dwFlags
|= MCI_OVLY_RECT
;
1670 _MCI_CALL_DRIVER( MCI_PUT
, pU
);
1675 /* palette behaviour changing
1677 * "normal" realize the palette normally
1678 * "background" realize the palette as background palette
1681 MCISTR_Realize(_MCISTR_PROTO_
)
1683 MCI_GENERIC_PARMS
*realizeParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
1686 if (uDevTyp
!= MCI_DEVTYPE_ANIMATION
)
1687 return MCIERR_UNSUPPORTED_FUNCTION
;
1689 while (i
<nrofkeywords
) {
1690 FLAG1("background",MCI_ANIM_REALIZE_BKGD
);
1691 FLAG1("normal",MCI_ANIM_REALIZE_NORM
);
1694 _MCI_CALL_DRIVER( MCI_REALIZE
, realizeParams
);
1695 free(realizeParams
);
1699 /* videodisc spinning
1704 MCISTR_Spin(_MCISTR_PROTO_
)
1706 MCI_GENERIC_PARMS
*spinParams
= xmalloc(sizeof(MCI_GENERIC_PARMS
));
1709 if (uDevTyp
!= MCI_DEVTYPE_VIDEODISC
)
1710 return MCIERR_UNSUPPORTED_FUNCTION
;
1712 while (i
<nrofkeywords
) {
1713 FLAG1("up",MCI_VD_SPIN_UP
);
1714 FLAG1("down",MCI_VD_SPIN_UP
);
1717 _MCI_CALL_DRIVER( MCI_SPIN
, spinParams
);
1722 /* step single frames
1723 * "reverse" optional flag
1724 * "by <nr>" for <nr> frames
1727 MCISTR_Step(_MCISTR_PROTO_
) {
1729 MCI_ANIM_STEP_PARMS animstepParams
;
1730 MCI_VD_STEP_PARMS vdstepParams
;
1732 union U
*pU
= xmalloc(sizeof(union U
));
1736 while (i
<nrofkeywords
) {
1738 case MCI_DEVTYPE_ANIMATION
:
1739 FLAG1("reverse",MCI_ANIM_STEP_REVERSE
);
1740 if (!STRCMP(keywords
[i
],"by") && (i
+1<nrofkeywords
)) {
1741 sscanf(keywords
[i
+1],"%ld",&(pU
->animstepParams
.dwFrames
));
1742 dwFlags
|= MCI_ANIM_STEP_FRAMES
;
1747 case MCI_DEVTYPE_VIDEODISC
:
1748 FLAG1("reverse",MCI_VD_STEP_REVERSE
);
1749 if (!STRCMP(keywords
[i
],"by") && (i
+1<nrofkeywords
)) {
1750 sscanf(keywords
[i
+1],"%ld",&(pU
->vdstepParams
.dwFrames
));
1751 dwFlags
|= MCI_VD_STEP_FRAMES
;
1759 _MCI_CALL_DRIVER( MCI_STEP
, pU
);
1764 /* update animation window
1766 * "at <left> <top> <right> <bottom>" only in this rectangle
1767 * "hdc" device context
1770 MCISTR_Update(_MCISTR_PROTO_
) {
1772 MCI_ANIM_UPDATE_PARMS16
*updateParams
= xmalloc(sizeof(MCI_ANIM_UPDATE_PARMS16
));
1775 while (i
<nrofkeywords
) {
1776 if (!STRCMP(keywords
[i
],"at") && (i
+4<nrofkeywords
)) {
1777 sscanf(keywords
[i
+1],"%hd",&(updateParams
->rc
.left
));
1778 sscanf(keywords
[i
+2],"%hd",&(updateParams
->rc
.top
));
1779 sscanf(keywords
[i
+3],"%hd",&(updateParams
->rc
.right
));
1780 sscanf(keywords
[i
+4],"%hd",&(updateParams
->rc
.bottom
));
1781 dwFlags
|= MCI_ANIM_RECT
;
1785 if (!STRCMP(keywords
[i
],"hdc") && (i
+1<nrofkeywords
)) {
1786 dwFlags
|= MCI_ANIM_UPDATE_HDC
;
1787 sscanf(keywords
[i
+1],"%hd",&(updateParams
->hDC
));
1793 _MCI_CALL_DRIVER( MCI_UPDATE
, updateParams
);
1798 /* where command for animation and overlay drivers.
1799 * just returns the specified rectangle as a string
1808 MCISTR_Where(_MCISTR_PROTO_
) {
1810 MCI_ANIM_RECT_PARMS16 animwhereParams
;
1811 MCI_OVLY_RECT_PARMS16 ovlywhereParams
;
1813 union U
*pU
= xmalloc(sizeof(union U
));
1817 while (i
<nrofkeywords
) {
1819 case MCI_DEVTYPE_ANIMATION
:
1820 FLAG1("source",MCI_ANIM_WHERE_SOURCE
);
1821 FLAG1("destination",MCI_ANIM_WHERE_DESTINATION
);
1823 case MCI_DEVTYPE_OVERLAY
:
1824 FLAG1("source",MCI_OVLY_WHERE_SOURCE
);
1825 FLAG1("destination",MCI_OVLY_WHERE_DESTINATION
);
1826 FLAG1("video",MCI_OVLY_WHERE_VIDEO
);
1827 FLAG1("frame",MCI_OVLY_WHERE_FRAME
);
1832 _MCI_CALL_DRIVER( MCI_WHERE
, pU
);
1836 case MCI_DEVTYPE_ANIMATION
:
1837 sprintf(buf
,"%d %d %d %d",
1838 pU
->animwhereParams
.rc
.left
,
1839 pU
->animwhereParams
.rc
.top
,
1840 pU
->animwhereParams
.rc
.right
,
1841 pU
->animwhereParams
.rc
.bottom
1844 case MCI_DEVTYPE_OVERLAY
:
1845 sprintf(buf
,"%d %d %d %d",
1846 pU
->ovlywhereParams
.rc
.left
,
1847 pU
->ovlywhereParams
.rc
.top
,
1848 pU
->ovlywhereParams
.rc
.right
,
1849 pU
->ovlywhereParams
.rc
.bottom
1852 default:strcpy(buf
,"0 0 0 0");break;
1861 MCISTR_Window(_MCISTR_PROTO_
) {
1865 MCI_ANIM_WINDOW_PARMS16 animwindowParams
;
1866 MCI_OVLY_WINDOW_PARMS16 ovlywindowParams
;
1868 union U
*pU
= xmalloc(sizeof(union U
));
1872 while (i
<nrofkeywords
) {
1874 case MCI_DEVTYPE_ANIMATION
:
1875 if (!STRCMP(keywords
[i
],"handle") && (i
+1<nrofkeywords
)) {
1876 dwFlags
|= MCI_ANIM_WINDOW_HWND
;
1877 if (!STRCMP(keywords
[i
+1],"default"))
1878 pU
->animwindowParams
.hWnd
= MCI_OVLY_WINDOW_DEFAULT
;
1880 sscanf(keywords
[i
+1],"%hd",&(pU
->animwindowParams
.hWnd
));
1884 if (!STRCMP(keywords
[i
],"state") && (i
+1<nrofkeywords
)) {
1885 dwFlags
|= MCI_ANIM_WINDOW_STATE
;
1886 if (!STRCMP(keywords
[i
+1],"hide"))
1887 pU
->animwindowParams
.nCmdShow
= SW_HIDE
;
1888 if (!STRCMP(keywords
[i
+1],"iconic"))
1889 pU
->animwindowParams
.nCmdShow
= SW_SHOWMINNOACTIVE
; /* correct? */
1890 if (!STRCMP(keywords
[i
+1],"minimized"))
1891 pU
->animwindowParams
.nCmdShow
= SW_SHOWMINIMIZED
;
1892 if (!STRCMP(keywords
[i
+1],"maximized"))
1893 pU
->animwindowParams
.nCmdShow
= SW_SHOWMAXIMIZED
;
1894 if (!STRCMP(keywords
[i
+1],"minimize"))
1895 pU
->animwindowParams
.nCmdShow
= SW_MINIMIZE
;
1896 if (!STRCMP(keywords
[i
+1],"normal"))
1897 pU
->animwindowParams
.nCmdShow
= SW_NORMAL
;
1898 if (!STRCMP(keywords
[i
+1],"show"))
1899 pU
->animwindowParams
.nCmdShow
= SW_SHOW
;
1900 if (!STRCMP(keywords
[i
+1],"no") && (i
+2<nrofkeywords
)) {
1901 if (!STRCMP(keywords
[i
+2],"active"))
1902 pU
->animwindowParams
.nCmdShow
= SW_SHOWNOACTIVATE
;
1903 if (!STRCMP(keywords
[i
+2],"action"))
1904 pU
->animwindowParams
.nCmdShow
= SW_SHOWNA
;/* correct?*/
1910 /* text is enclosed in " ... " as it seems */
1911 if (!STRCMP(keywords
[i
],"text")) {
1915 if (keywords
[i
+1][0]!='"') {
1919 dwFlags
|= MCI_ANIM_WINDOW_TEXT
;
1920 len
= strlen(keywords
[i
+1])+1;
1922 while (j
<nrofkeywords
) {
1923 len
+= strlen(keywords
[j
])+1;
1924 if (strchr(keywords
[j
],'"'))
1928 s
=(char*)xmalloc(len
);
1929 strcpy(s
,keywords
[i
+1]+1);
1933 strcat(s
,keywords
[j
]);
1935 if ((t
=strchr(s
,'"'))) *t
='\0';
1936 /* FIXME: segmented pointer? */
1937 pU
->animwindowParams
.lpstrText
= s
;
1941 FLAG1("stretch",MCI_ANIM_WINDOW_ENABLE_STRETCH
);
1943 case MCI_DEVTYPE_OVERLAY
:
1944 if (!STRCMP(keywords
[i
],"handle") && (i
+1<nrofkeywords
)) {
1945 dwFlags
|= MCI_OVLY_WINDOW_HWND
;
1946 if (!STRCMP(keywords
[i
+1],"default"))
1947 pU
->ovlywindowParams
.hWnd
= MCI_OVLY_WINDOW_DEFAULT
;
1949 sscanf(keywords
[i
+1],"%hd",&(pU
->ovlywindowParams
.hWnd
));
1953 if (!STRCMP(keywords
[i
],"state") && (i
+1<nrofkeywords
)) {
1954 dwFlags
|= MCI_OVLY_WINDOW_STATE
;
1955 if (!STRCMP(keywords
[i
+1],"hide"))
1956 pU
->ovlywindowParams
.nCmdShow
= SW_HIDE
;
1957 if (!STRCMP(keywords
[i
+1],"iconic"))
1958 pU
->ovlywindowParams
.nCmdShow
= SW_SHOWMINNOACTIVE
; /* correct? */
1959 if (!STRCMP(keywords
[i
+1],"minimized"))
1960 pU
->ovlywindowParams
.nCmdShow
= SW_SHOWMINIMIZED
;
1961 if (!STRCMP(keywords
[i
+1],"maximized"))
1962 pU
->ovlywindowParams
.nCmdShow
= SW_SHOWMAXIMIZED
;
1963 if (!STRCMP(keywords
[i
+1],"minimize"))
1964 pU
->ovlywindowParams
.nCmdShow
= SW_MINIMIZE
;
1965 if (!STRCMP(keywords
[i
+1],"normal"))
1966 pU
->ovlywindowParams
.nCmdShow
= SW_NORMAL
;
1967 if (!STRCMP(keywords
[i
+1],"show"))
1968 pU
->ovlywindowParams
.nCmdShow
= SW_SHOW
;
1969 if (!STRCMP(keywords
[i
+1],"no") && (i
+2<nrofkeywords
)) {
1970 if (!STRCMP(keywords
[i
+2],"active"))
1971 pU
->ovlywindowParams
.nCmdShow
= SW_SHOWNOACTIVATE
;
1972 if (!STRCMP(keywords
[i
+2],"action"))
1973 pU
->ovlywindowParams
.nCmdShow
= SW_SHOWNA
;/* correct?*/
1979 /* text is enclosed in " ... " as it seems */
1980 if (!STRCMP(keywords
[i
],"text")) {
1984 if (keywords
[i
+1][0]!='"') {
1988 dwFlags
|= MCI_OVLY_WINDOW_TEXT
;
1989 len
= strlen(keywords
[i
+1])+1;
1991 while (j
<nrofkeywords
) {
1992 len
+= strlen(keywords
[j
])+1;
1993 if (strchr(keywords
[j
],'"'))
1997 s
=(char*)xmalloc(len
);
1998 strcpy(s
,keywords
[i
+1]+1);
2002 strcat(s
,keywords
[j
]);
2004 if ((t
=strchr(s
,'"'))) *t
='\0';
2005 /* FIXME: segmented pointer? */
2006 pU
->ovlywindowParams
.lpstrText
= s
;
2010 FLAG1("stretch",MCI_OVLY_WINDOW_ENABLE_STRETCH
);
2015 _MCI_CALL_DRIVER( MCI_WINDOW
, pU
);
2021 struct _MCISTR_cmdtable
{
2023 DWORD (*fun
)(_MCISTR_PROTO_
);
2024 } MCISTR_cmdtable
[]={
2025 {"break", MCISTR_Break
},
2026 {"capability", MCISTR_Capability
},
2027 {"close", MCISTR_Close
},
2028 {"cue", MCISTR_Cue
},
2029 {"delete", MCISTR_Delete
},
2030 {"escape", MCISTR_Escape
},
2031 {"freeze", MCISTR_Freeze
},
2032 {"info", MCISTR_Info
},
2033 {"load", MCISTR_Load
},
2034 {"open", MCISTR_Open
},
2035 {"pause", MCISTR_Pause
},
2036 {"play", MCISTR_Play
},
2037 {"put", MCISTR_Put
},
2038 {"realize", MCISTR_Realize
},
2039 {"record", MCISTR_Record
},
2040 {"resume", MCISTR_Resume
},
2041 {"save", MCISTR_Save
},
2042 {"seek", MCISTR_Seek
},
2043 {"set", MCISTR_Set
},
2044 {"spin", MCISTR_Spin
},
2045 {"status", MCISTR_Status
},
2046 {"step", MCISTR_Step
},
2047 {"stop", MCISTR_Stop
},
2048 {"sysinfo", MCISTR_Sysinfo
},
2049 {"unfreeze", MCISTR_Unfreeze
},
2050 {"update", MCISTR_Update
},
2051 {"where", MCISTR_Where
},
2052 {"window", MCISTR_Window
},
2056 /**************************************************************************
2057 * mciSendString16 [MMSYSTEM.702]
2059 /* The usercode sends a string with a command (and flags) expressed in
2060 * words in it... We do our best to call aprobiate drivers,
2061 * and return a errorcode AND a readable string (if lpstrRS!=NULL)
2062 * Info gathered by watching cool134.exe and from Borland's mcistrwh.hlp
2064 /* FIXME: "all" is a valid devicetype and we should access all devices if
2065 * it is used. (imagine "close all"). Not implemented yet.
2067 DWORD WINAPI
mciSendString16(LPCSTR lpstrCommand
, LPSTR lpstrReturnString
,
2068 UINT16 uReturnLength
, HWND16 hwndCallback
)
2070 char *cmd
,*dev
,*args
,**keywords
,*filename
;
2071 WORD uDevTyp
=0,wDevID
=0;
2073 int res
=0,i
,nrofkeywords
;
2075 TRACE(mci
,"('%s', %p, %d, %X)\n",
2076 lpstrCommand
, lpstrReturnString
, uReturnLength
, hwndCallback
);
2078 /* format is <command> <device> <optargs> */
2079 cmd
=strdup(lpstrCommand
);
2080 dev
=strchr(cmd
,' ');
2083 return MCIERR_MISSING_DEVICE_NAME
;
2086 args
=strchr(dev
,' ');
2087 if (args
!=NULL
) *args
++='\0';
2091 i
=1;/* nrofkeywords = nrofspaces+1 */
2093 while ((s
=strchr(s
,' '))!=NULL
) i
++,s
++;
2094 keywords
=(char**)xmalloc(sizeof(char*)*(i
+2));
2097 while (s
&& i
<nrofkeywords
) {
2105 keywords
=(char**)xmalloc(sizeof(char*));
2107 dwFlags
= 0; /* default flags */
2108 for (i
=0;i
<nrofkeywords
;) {
2109 /* take care, there is also a "device type" capability */
2110 if ((!STRCMP(keywords
[i
],"type")) && (i
<nrofkeywords
-1)) {
2112 dev
= keywords
[i
+1];
2113 memcpy(keywords
+i
,keywords
+(i
+2),(nrofkeywords
-i
-2)*sizeof(char *));
2117 if (!STRCMP(keywords
[i
],"wait")) {
2118 dwFlags
|= MCI_WAIT
;
2119 memcpy(keywords
+i
,keywords
+(i
+1),(nrofkeywords
-i
-1)*sizeof(char *));
2123 if (!STRCMP(keywords
[i
],"notify")) {
2124 dwFlags
|= MCI_NOTIFY
;
2125 memcpy(keywords
+i
,keywords
+(i
+1),(nrofkeywords
-i
-1)*sizeof(char *));
2132 /* determine wDevID and uDevTyp for all commands except "open" */
2133 if (STRCMP(cmd
,"open")!=0) {
2134 wDevID
= MCI_FirstDevID();
2138 dname
=MCI_GetOpenDrv(wDevID
)->lpstrAlias
;
2140 dname
=MCI_GetOpenDrv(wDevID
)->lpstrDeviceType
;
2141 if (dname
!= NULL
&& !STRCMP(dname
,dev
))
2143 wDevID
= MCI_NextDevID(wDevID
);
2144 if (!MCI_DevIDValid(wDevID
)) {
2145 TRACE(mci
, "MAXMCIDRIVERS reached!\n");
2146 free(keywords
);free(cmd
);
2147 return MCIERR_INVALID_DEVICE_NAME
;
2150 uDevTyp
=MCI_GetDrv(wDevID
)->modp
.wType
;
2153 for (i
=0;MCISTR_cmdtable
[i
].cmd
!=NULL
;i
++) {
2154 if (!STRCMP(MCISTR_cmdtable
[i
].cmd
,cmd
)) {
2155 res
=MCISTR_cmdtable
[i
].fun(
2156 wDevID
,uDevTyp
,lpstrReturnString
,
2157 uReturnLength
,dev
,(LPSTR
*)keywords
,nrofkeywords
,
2158 dwFlags
,hwndCallback
2163 if (MCISTR_cmdtable
[i
].cmd
!=NULL
) {
2164 free(keywords
);free(cmd
);
2167 FIXME(mci
,"('%s', %p, %u, %X): unimplemented, please report.\n",
2168 lpstrCommand
, lpstrReturnString
, uReturnLength
, hwndCallback
);
2169 free(keywords
);free(cmd
);
2170 return MCIERR_MISSING_COMMAND_STRING
;
2173 /**************************************************************************
2174 * mciSendString32A [MMSYSTEM.702][WINMM.51]
2176 DWORD WINAPI
mciSendString32A(LPCSTR lpstrCommand
, LPSTR lpstrReturnString
,
2177 UINT32 uReturnLength
, HWND32 hwndCallback
)
2179 return mciSendString16(lpstrCommand
, lpstrReturnString
, uReturnLength
, hwndCallback
);
2182 /**************************************************************************
2183 * mciSendString32W [WINMM.52]
2185 DWORD WINAPI
mciSendString32W(LPCWSTR lpwstrCommand
, LPSTR lpstrReturnString
,
2186 UINT32 uReturnLength
, HWND32 hwndCallback
)
2191 /* FIXME: is there something to do with lpstrReturnString ? */
2192 lpstrCommand
= HEAP_strdupWtoA(GetProcessHeap(), 0, lpwstrCommand
);
2193 ret
= mciSendString16(lpstrCommand
, lpstrReturnString
, uReturnLength
, hwndCallback
);
2194 HeapFree(GetProcessHeap(), 0, lpstrCommand
);