2 * Sample MCI ANIMATION Wine Driver for Linux
4 * Copyright 1994 Martin Ayotte
12 #include <sys/ioctl.h>
22 #define ANIMFRAMES_PERSEC 30
23 #define ANIMFRAMES_PERMIN 1800
24 #define SECONDS_PERMIN 60
26 #if defined(linux) || defined(__FreeBSD__)
28 int nUseCount
; /* Incremented for each shared open */
29 BOOL16 fShareable
; /* TRUE if first open was shareable */
30 WORD wNotifyDeviceID
; /* MCI device ID with a pending notification */
31 HANDLE16 hCallback
; /* Callback handle for pending notification */
32 MCI_OPEN_PARMS16 openParms
;
43 static LINUX_ANIM AnimDev
[MAX_ANIMDRV
];
47 /*-----------------------------------------------------------------------*/
49 /**************************************************************************
50 * ANIM_mciOpen [internal]
52 static DWORD
ANIM_mciOpen(UINT16 wDevID
, DWORD dwFlags
, LPMCI_OPEN_PARMS16 lpParms
)
54 #if defined(linux) || defined(__FreeBSD__)
55 LPSTR lpstrElementName
;
58 dprintf_mcianim(stddeb
,"ANIM_mciOpen(%04X, %08lX, %p);\n",
59 wDevID
, dwFlags
, lpParms
);
60 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
61 if (AnimDev
[wDevID
].nUseCount
> 0) {
62 /* The driver already open on this channel */
63 /* If the driver was opened shareable before and this open specifies */
64 /* shareable then increment the use count */
65 if (AnimDev
[wDevID
].fShareable
&& (dwFlags
& MCI_OPEN_SHAREABLE
))
66 ++AnimDev
[wDevID
].nUseCount
;
68 return MCIERR_MUST_USE_SHAREABLE
;
71 AnimDev
[wDevID
].nUseCount
= 1;
72 AnimDev
[wDevID
].fShareable
= dwFlags
& MCI_OPEN_SHAREABLE
;
74 dprintf_mcianim(stddeb
,"ANIM_mciOpen // wDevID=%04X\n", wDevID
);
75 lpParms
->wDeviceID
= wDevID
;
76 dprintf_mcianim(stddeb
,"ANIM_mciOpen // lpParms->wDevID=%04X\n", lpParms
->wDeviceID
);
77 if (dwFlags
& MCI_OPEN_ELEMENT
) {
78 lpstrElementName
= (LPSTR
)PTR_SEG_TO_LIN(lpParms
->lpstrElementName
);
79 dprintf_mcianim(stddeb
,"ANIM_mciOpen // MCI_OPEN_ELEMENT '%s' !\n",
81 if (strlen(lpstrElementName
) > 0) {
82 strcpy(str
, lpstrElementName
);
86 memcpy(&AnimDev
[wDevID
].openParms
, lpParms
, sizeof(MCI_OPEN_PARMS16
));
87 AnimDev
[wDevID
].wNotifyDeviceID
= lpParms
->wDeviceID
;
88 AnimDev
[wDevID
].mode
= 0;
89 AnimDev
[wDevID
].dwTimeFormat
= MCI_FORMAT_TMSF
;
90 AnimDev
[wDevID
].nCurTrack
= 0;
91 AnimDev
[wDevID
].nTracks
= 0;
92 AnimDev
[wDevID
].dwTotalLen
= 0;
93 AnimDev
[wDevID
].lpdwTrackLen
= NULL
;
94 AnimDev
[wDevID
].lpdwTrackPos
= NULL
;
96 Moved to mmsystem.c mciOpen routine
98 if (dwFlags & MCI_NOTIFY) {
99 dprintf_mcianim(stddeb,
100 "ANIM_mciOpen // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
101 lpParms->dwCallback);
102 mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
103 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
108 return MCIERR_HARDWARE
;
112 /**************************************************************************
113 * ANIM_mciClose [internal]
115 static DWORD
ANIM_mciClose(UINT16 wDevID
, DWORD dwParam
, LPMCI_GENERIC_PARMS lpParms
)
117 #if defined(linux) || defined(__FreeBSD__)
118 dprintf_mcianim(stddeb
,"ANIM_mciClose(%u, %08lX, %p);\n",
119 wDevID
, dwParam
, lpParms
);
120 if (AnimDev
[wDevID
].lpdwTrackLen
!= NULL
) free(AnimDev
[wDevID
].lpdwTrackLen
);
121 if (AnimDev
[wDevID
].lpdwTrackPos
!= NULL
) free(AnimDev
[wDevID
].lpdwTrackPos
);
126 /**************************************************************************
127 * ANIM_mciGetDevCaps [internal]
129 static DWORD
ANIM_mciGetDevCaps(UINT16 wDevID
, DWORD dwFlags
,
130 LPMCI_GETDEVCAPS_PARMS lpParms
)
132 #if defined(linux) || defined(__FreeBSD__)
133 dprintf_mcianim(stddeb
,"ANIM_mciGetDevCaps(%u, %08lX, %p);\n",
134 wDevID
, dwFlags
, lpParms
);
135 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
136 if (dwFlags
& MCI_GETDEVCAPS_ITEM
) {
137 dprintf_mcianim(stddeb
,
138 "ANIM_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n",
140 switch(lpParms
->dwItem
) {
141 case MCI_GETDEVCAPS_CAN_RECORD
:
142 lpParms
->dwReturn
= FALSE
;
144 case MCI_GETDEVCAPS_HAS_AUDIO
:
145 lpParms
->dwReturn
= FALSE
;
147 case MCI_GETDEVCAPS_HAS_VIDEO
:
148 lpParms
->dwReturn
= FALSE
;
150 case MCI_GETDEVCAPS_DEVICE_TYPE
:
151 lpParms
->dwReturn
= MCI_DEVTYPE_ANIMATION
;
153 case MCI_GETDEVCAPS_USES_FILES
:
154 lpParms
->dwReturn
= TRUE
;
156 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
157 lpParms
->dwReturn
= FALSE
;
159 case MCI_GETDEVCAPS_CAN_EJECT
:
160 lpParms
->dwReturn
= TRUE
;
162 case MCI_GETDEVCAPS_CAN_PLAY
:
163 lpParms
->dwReturn
= FALSE
;
165 case MCI_GETDEVCAPS_CAN_SAVE
:
166 lpParms
->dwReturn
= FALSE
;
169 return MCIERR_UNRECOGNIZED_COMMAND
;
172 dprintf_mcianim(stddeb
,
173 "ANIM_mciGetDevCaps // lpParms->dwReturn=%08lX;\n",
177 return MCIERR_INTERNAL
;
182 /**************************************************************************
183 * ANIM_CalcTime [internal]
185 static DWORD
ANIM_CalcTime(UINT16 wDevID
, DWORD dwFormatType
, DWORD dwFrame
)
188 #if defined(linux) || defined(__FreeBSD__)
193 dprintf_mcianim(stddeb
,"ANIM_CalcTime(%u, %08lX, %lu);\n",
194 wDevID
, dwFormatType
, dwFrame
);
196 switch (dwFormatType
) {
197 case MCI_FORMAT_MILLISECONDS
:
198 dwTime
= dwFrame
/ ANIMFRAMES_PERSEC
* 1000;
199 dprintf_mcianim(stddeb
,
200 "ANIM_CalcTime // MILLISECONDS %lu\n", dwTime
);
203 wMinutes
= dwFrame
/ ANIMFRAMES_PERMIN
;
204 wSeconds
= (dwFrame
- ANIMFRAMES_PERMIN
* wMinutes
) / ANIMFRAMES_PERSEC
;
205 wFrames
= dwFrame
- ANIMFRAMES_PERMIN
* wMinutes
-
206 ANIMFRAMES_PERSEC
* wSeconds
;
207 dwTime
= MCI_MAKE_MSF(wMinutes
, wSeconds
, wFrames
);
208 dprintf_mcianim(stddeb
,"ANIM_CalcTime // MSF %02u:%02u:%02u -> dwTime=%lu\n",
209 wMinutes
, wSeconds
, wFrames
, dwTime
);
212 /* unknown format ! force TMSF ! ... */
213 dwFormatType
= MCI_FORMAT_TMSF
;
214 case MCI_FORMAT_TMSF
:
215 for (wTrack
= 0; wTrack
< AnimDev
[wDevID
].nTracks
; wTrack
++) {
216 /* dwTime += AnimDev[wDevID].lpdwTrackLen[wTrack - 1];
217 printf("Adding trk#%u curpos=%u \n", dwTime);
218 if (dwTime >= dwFrame) break; */
219 if (AnimDev
[wDevID
].lpdwTrackPos
[wTrack
- 1] >= dwFrame
) break;
221 wMinutes
= dwFrame
/ ANIMFRAMES_PERMIN
;
222 wSeconds
= (dwFrame
- ANIMFRAMES_PERMIN
* wMinutes
) / ANIMFRAMES_PERSEC
;
223 wFrames
= dwFrame
- ANIMFRAMES_PERMIN
* wMinutes
-
224 ANIMFRAMES_PERSEC
* wSeconds
;
225 dwTime
= MCI_MAKE_TMSF(wTrack
, wMinutes
, wSeconds
, wFrames
);
226 dprintf_mcianim(stddeb
,
227 "ANIM_CalcTime // %02u-%02u:%02u:%02u\n",
228 wTrack
, wMinutes
, wSeconds
, wFrames
);
236 /**************************************************************************
237 * ANIM_CalcFrame [internal]
239 static DWORD
ANIM_CalcFrame(UINT16 wDevID
, DWORD dwFormatType
, DWORD dwTime
)
242 #if defined(linux) || defined(__FreeBSD__)
244 dprintf_mcianim(stddeb
,"ANIM_CalcFrame(%u, %08lX, %lu);\n",
245 wDevID
, dwFormatType
, dwTime
);
247 switch (dwFormatType
) {
248 case MCI_FORMAT_MILLISECONDS
:
249 dwFrame
= dwTime
* ANIMFRAMES_PERSEC
/ 1000;
250 dprintf_mcianim(stddeb
,
251 "ANIM_CalcFrame // MILLISECONDS %lu\n", dwFrame
);
254 dprintf_mcianim(stddeb
,
255 "ANIM_CalcFrame // MSF %02u:%02u:%02u\n",
256 MCI_MSF_MINUTE(dwTime
), MCI_MSF_SECOND(dwTime
),
257 MCI_MSF_FRAME(dwTime
));
258 dwFrame
+= ANIMFRAMES_PERMIN
* MCI_MSF_MINUTE(dwTime
);
259 dwFrame
+= ANIMFRAMES_PERSEC
* MCI_MSF_SECOND(dwTime
);
260 dwFrame
+= MCI_MSF_FRAME(dwTime
);
263 /* unknown format ! force TMSF ! ... */
264 dwFormatType
= MCI_FORMAT_TMSF
;
265 case MCI_FORMAT_TMSF
:
266 wTrack
= MCI_TMSF_TRACK(dwTime
);
267 dprintf_mcianim(stddeb
,
268 "ANIM_CalcFrame // TMSF %02u-%02u:%02u:%02u\n",
269 MCI_TMSF_TRACK(dwTime
), MCI_TMSF_MINUTE(dwTime
),
270 MCI_TMSF_SECOND(dwTime
), MCI_TMSF_FRAME(dwTime
));
271 dprintf_mcianim(stddeb
,
272 "ANIM_CalcFrame // TMSF trackpos[%u]=%lu\n",
273 wTrack
, AnimDev
[wDevID
].lpdwTrackPos
[wTrack
- 1]);
274 dwFrame
= AnimDev
[wDevID
].lpdwTrackPos
[wTrack
- 1];
275 dwFrame
+= ANIMFRAMES_PERMIN
* MCI_TMSF_MINUTE(dwTime
);
276 dwFrame
+= ANIMFRAMES_PERSEC
* MCI_TMSF_SECOND(dwTime
);
277 dwFrame
+= MCI_TMSF_FRAME(dwTime
);
285 /**************************************************************************
286 * ANIM_mciInfo [internal]
288 static DWORD
ANIM_mciInfo(UINT16 wDevID
, DWORD dwFlags
, LPMCI_INFO_PARMS16 lpParms
)
290 #if defined(linux) || defined(__FreeBSD__)
291 dprintf_mcianim(stddeb
,"ANIM_mciInfo(%u, %08lX, %p);\n",
292 wDevID
, dwFlags
, lpParms
);
293 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
294 lpParms
->lpstrReturn
= NULL
;
296 case MCI_INFO_PRODUCT
:
297 lpParms
->lpstrReturn
= "Linux ANIMATION 0.5";
300 lpParms
->lpstrReturn
=
301 (LPSTR
)AnimDev
[wDevID
].openParms
.lpstrElementName
;
303 case MCI_ANIM_INFO_TEXT
:
304 lpParms
->lpstrReturn
= "Animation Window";
307 return MCIERR_UNRECOGNIZED_COMMAND
;
309 if (lpParms
->lpstrReturn
!= NULL
)
310 lpParms
->dwRetSize
= strlen(lpParms
->lpstrReturn
);
312 lpParms
->dwRetSize
= 0;
315 return MCIERR_INTERNAL
;
319 /**************************************************************************
320 * ANIM_mciStatus [internal]
322 static DWORD
ANIM_mciStatus(UINT16 wDevID
, DWORD dwFlags
, LPMCI_STATUS_PARMS lpParms
)
324 #if defined(linux) || defined(__FreeBSD__)
325 dprintf_mcianim(stddeb
,"ANIM_mciStatus(%u, %08lX, %p);\n",
326 wDevID
, dwFlags
, lpParms
);
327 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
328 if (dwFlags
& MCI_NOTIFY
) {
329 dprintf_mcianim(stddeb
,
330 "ANIM_mciStatus // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
331 lpParms
->dwCallback
);
332 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
333 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
335 if (dwFlags
& MCI_STATUS_ITEM
) {
336 switch(lpParms
->dwItem
) {
337 case MCI_STATUS_CURRENT_TRACK
:
338 lpParms
->dwReturn
= AnimDev
[wDevID
].nCurTrack
;
339 dprintf_mcianim(stddeb
,"ANIM_mciStatus // CURRENT_TRACK=%lu!\n", lpParms
->dwReturn
);
341 case MCI_STATUS_LENGTH
:
342 if (dwFlags
& MCI_TRACK
) {
343 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_TRACK #%lu LENGTH=??? !\n",
345 if (lpParms
->dwTrack
> AnimDev
[wDevID
].nTracks
)
346 return MCIERR_OUTOFRANGE
;
347 lpParms
->dwReturn
= AnimDev
[wDevID
].lpdwTrackLen
[lpParms
->dwTrack
];
350 lpParms
->dwReturn
= AnimDev
[wDevID
].dwTotalLen
;
351 lpParms
->dwReturn
= ANIM_CalcTime(wDevID
,
352 AnimDev
[wDevID
].dwTimeFormat
, lpParms
->dwReturn
);
353 dprintf_mcianim(stddeb
,"ANIM_mciStatus // LENGTH=%lu !\n", lpParms
->dwReturn
);
355 case MCI_STATUS_MODE
:
356 lpParms
->dwReturn
= AnimDev
[wDevID
].mode
;
357 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_STATUS_MODE=%08lX !\n",
360 case MCI_STATUS_MEDIA_PRESENT
:
361 lpParms
->dwReturn
= TRUE
;
362 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n");
364 case MCI_STATUS_NUMBER_OF_TRACKS
:
365 lpParms
->dwReturn
= 1;
366 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_STATUS_NUMBER_OF_TRACKS = %lu !\n",
368 if (lpParms
->dwReturn
== (WORD
)-1) return MCIERR_INTERNAL
;
370 case MCI_STATUS_POSITION
:
371 lpParms
->dwReturn
= AnimDev
[wDevID
].dwCurFrame
;
372 if (dwFlags
& MCI_STATUS_START
) {
373 lpParms
->dwReturn
= 0;
374 dprintf_mcianim(stddeb
,"CDAUDIO_mciStatus // get MCI_STATUS_START !\n");
376 if (dwFlags
& MCI_TRACK
) {
377 if (lpParms
->dwTrack
> AnimDev
[wDevID
].nTracks
)
378 return MCIERR_OUTOFRANGE
;
379 lpParms
->dwReturn
= AnimDev
[wDevID
].lpdwTrackPos
[lpParms
->dwTrack
- 1];
380 dprintf_mcianim(stddeb
,"ANIM_mciStatus // get MCI_TRACK #%lu !\n", lpParms
->dwTrack
);
382 lpParms
->dwReturn
= ANIM_CalcTime(wDevID
,
383 AnimDev
[wDevID
].dwTimeFormat
, lpParms
->dwReturn
);
384 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_STATUS_POSITION=%08lX !\n",
387 case MCI_STATUS_READY
:
388 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_STATUS_READY !\n");
389 lpParms
->dwReturn
= TRUE
;
391 case MCI_STATUS_TIME_FORMAT
:
392 dprintf_mcianim(stddeb
,"ANIM_mciStatus // MCI_STATUS_TIME_FORMAT !\n");
393 lpParms
->dwReturn
= MCI_FORMAT_MILLISECONDS
;
396 fprintf(stderr
,"ANIM_mciStatus // unknown command %08lX !\n", lpParms
->dwItem
);
397 return MCIERR_UNRECOGNIZED_COMMAND
;
400 fprintf(stderr
,"ANIM_mciStatus // not MCI_STATUS_ITEM !\n");
403 return MMSYSERR_NOTENABLED
;
408 /**************************************************************************
409 * ANIM_mciPlay [internal]
411 static DWORD
ANIM_mciPlay(UINT16 wDevID
, DWORD dwFlags
, LPMCI_PLAY_PARMS lpParms
)
413 #if defined(linux) || defined(__FreeBSD__)
415 dprintf_mcianim(stddeb
,"ANIM_mciPlay(%u, %08lX, %p);\n",
416 wDevID
, dwFlags
, lpParms
);
417 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
418 start
= 0; end
= AnimDev
[wDevID
].dwTotalLen
;
419 AnimDev
[wDevID
].nCurTrack
= 1;
420 if (dwFlags
& MCI_FROM
) {
421 start
= ANIM_CalcFrame(wDevID
,
422 AnimDev
[wDevID
].dwTimeFormat
, lpParms
->dwFrom
);
423 dprintf_mcianim(stddeb
,"ANIM_mciPlay // MCI_FROM=%08lX -> %u \n",
424 lpParms
->dwFrom
, start
);
426 if (dwFlags
& MCI_TO
) {
427 end
= ANIM_CalcFrame(wDevID
,
428 AnimDev
[wDevID
].dwTimeFormat
, lpParms
->dwTo
);
429 dprintf_mcianim(stddeb
,
430 "ANIM_mciPlay // MCI_TO=%08lX -> %u \n",
433 AnimDev
[wDevID
].mode
= MCI_MODE_PLAY
;
434 if (dwFlags
& MCI_NOTIFY
) {
435 dprintf_mcianim(stddeb
,
436 "ANIM_mciPlay // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
437 lpParms
->dwCallback
);
438 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
439 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
443 return MCIERR_HARDWARE
;
447 /**************************************************************************
448 * ANIM_mciStop [internal]
450 static DWORD
ANIM_mciStop(UINT16 wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
452 #if defined(linux) || defined(__FreeBSD__)
453 dprintf_mcianim(stddeb
,"ANIM_mciStop(%u, %08lX, %p);\n",
454 wDevID
, dwFlags
, lpParms
);
455 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
456 AnimDev
[wDevID
].mode
= MCI_MODE_STOP
;
457 if (dwFlags
& MCI_NOTIFY
) {
458 dprintf_mcianim(stddeb
,
459 "ANIM_mciStop // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
460 lpParms
->dwCallback
);
461 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
462 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
466 return MCIERR_HARDWARE
;
470 /**************************************************************************
471 * ANIM_mciPause [internal]
473 static DWORD
ANIM_mciPause(UINT16 wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
475 #if defined(linux) || defined(__FreeBSD__)
476 dprintf_mcianim(stddeb
,"ANIM_mciPause(%u, %08lX, %p);\n",
477 wDevID
, dwFlags
, lpParms
);
478 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
479 AnimDev
[wDevID
].mode
= MCI_MODE_PAUSE
;
480 if (dwFlags
& MCI_NOTIFY
) {
481 dprintf_mcianim(stddeb
,
482 "ANIM_mciPause // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
483 lpParms
->dwCallback
);
484 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
485 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
489 return MCIERR_HARDWARE
;
493 /**************************************************************************
494 * ANIM_mciResume [internal]
496 static DWORD
ANIM_mciResume(UINT16 wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
498 #if defined(linux) || defined(__FreeBSD__)
499 dprintf_mcianim(stddeb
,"ANIM_mciResume(%u, %08lX, %p);\n",
500 wDevID
, dwFlags
, lpParms
);
501 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
502 AnimDev
[wDevID
].mode
= MCI_MODE_STOP
;
503 if (dwFlags
& MCI_NOTIFY
) {
504 dprintf_mcianim(stddeb
,
505 "ANIM_mciResume // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
506 lpParms
->dwCallback
);
507 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
508 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
512 return MCIERR_HARDWARE
;
516 /**************************************************************************
517 * ANIM_mciSeek [internal]
519 static DWORD
ANIM_mciSeek(UINT16 wDevID
, DWORD dwFlags
, LPMCI_SEEK_PARMS lpParms
)
521 #if defined(linux) || defined(__FreeBSD__)
523 MCI_PLAY_PARMS PlayParms
;
524 dprintf_mcianim(stddeb
,"ANIM_mciSeek(%u, %08lX, %p);\n",
525 wDevID
, dwFlags
, lpParms
);
526 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
527 AnimDev
[wDevID
].mode
= MCI_MODE_SEEK
;
529 case MCI_SEEK_TO_START
:
530 PlayParms
.dwFrom
= 0;
532 case MCI_SEEK_TO_END
:
533 PlayParms
.dwFrom
= AnimDev
[wDevID
].dwTotalLen
;
536 PlayParms
.dwFrom
= lpParms
->dwTo
;
539 dwRet
= ANIM_mciPlay(wDevID
, MCI_WAIT
| MCI_FROM
, &PlayParms
);
540 if (dwRet
!= 0) return dwRet
;
541 dwRet
= ANIM_mciStop(wDevID
, MCI_WAIT
, (LPMCI_GENERIC_PARMS
)&PlayParms
);
542 if (dwFlags
& MCI_NOTIFY
) {
543 dprintf_mcianim(stddeb
,
544 "ANIM_mciSeek // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
545 lpParms
->dwCallback
);
546 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
547 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
551 return MCIERR_HARDWARE
;
556 /**************************************************************************
557 * ANIM_mciSet [internal]
559 static DWORD
ANIM_mciSet(UINT16 wDevID
, DWORD dwFlags
, LPMCI_SET_PARMS lpParms
)
561 #if defined(linux) || defined(__FreeBSD__)
562 dprintf_mcianim(stddeb
,"ANIM_mciSet(%u, %08lX, %p);\n",
563 wDevID
, dwFlags
, lpParms
);
564 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
566 printf("ANIM_mciSet // dwTimeFormat=%08lX\n", lpParms->dwTimeFormat);
567 printf("ANIM_mciSet // dwAudio=%08lX\n", lpParms->dwAudio);
569 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
570 switch (lpParms
->dwTimeFormat
) {
571 case MCI_FORMAT_MILLISECONDS
:
572 dprintf_mcianim(stddeb
,
573 "ANIM_mciSet // MCI_FORMAT_MILLISECONDS !\n");
576 dprintf_mcianim(stddeb
,"ANIM_mciSet // MCI_FORMAT_MSF !\n");
578 case MCI_FORMAT_TMSF
:
579 dprintf_mcianim(stddeb
,"ANIM_mciSet // MCI_FORMAT_TMSF !\n");
582 fprintf(stderr
,"ANIM_mciSet // bad time format !\n");
583 return MCIERR_BAD_TIME_FORMAT
;
585 AnimDev
[wDevID
].dwTimeFormat
= lpParms
->dwTimeFormat
;
587 if (dwFlags
& MCI_SET_VIDEO
) return MCIERR_UNSUPPORTED_FUNCTION
;
588 if (dwFlags
& MCI_SET_ON
) return MCIERR_UNSUPPORTED_FUNCTION
;
589 if (dwFlags
& MCI_SET_OFF
) return MCIERR_UNSUPPORTED_FUNCTION
;
590 if (dwFlags
& MCI_NOTIFY
) {
591 dprintf_mcianim(stddeb
,
592 "ANIM_mciSet // MCI_NOTIFY_SUCCESSFUL %08lX !\n",
593 lpParms
->dwCallback
);
594 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
595 AnimDev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
599 return MCIERR_HARDWARE
;
604 /**************************************************************************
605 * ANIM_DriverProc [sample driver]
607 LONG
ANIM_DriverProc(DWORD dwDevID
, HDRVR16 hDriv
, WORD wMsg
,
608 DWORD dwParam1
, DWORD dwParam2
)
610 #if defined(linux) || defined(__FreeBSD__)
617 case MCI_OPEN_DRIVER
:
619 return ANIM_mciOpen(dwDevID
, dwParam1
,
620 (LPMCI_OPEN_PARMS16
)PTR_SEG_TO_LIN(dwParam2
));
622 case MCI_CLOSE_DRIVER
:
624 return ANIM_mciClose(dwDevID
, dwParam1
,
625 (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
630 case DRV_QUERYCONFIGURE
:
633 MessageBox16(0, "Sample MultiMedia Linux Driver !",
634 "MMLinux Driver", MB_OK
);
637 return DRVCNF_RESTART
;
639 return DRVCNF_RESTART
;
641 return ANIM_mciGetDevCaps(dwDevID
, dwParam1
,
642 (LPMCI_GETDEVCAPS_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
644 return ANIM_mciInfo(dwDevID
, dwParam1
,
645 (LPMCI_INFO_PARMS16
)PTR_SEG_TO_LIN(dwParam2
));
647 return ANIM_mciStatus(dwDevID
, dwParam1
,
648 (LPMCI_STATUS_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
650 return ANIM_mciSet(dwDevID
, dwParam1
,
651 (LPMCI_SET_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
653 return ANIM_mciPlay(dwDevID
, dwParam1
,
654 (LPMCI_PLAY_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
656 return ANIM_mciStop(dwDevID
, dwParam1
,
657 (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
659 return ANIM_mciPause(dwDevID
, dwParam1
,
660 (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
662 return ANIM_mciResume(dwDevID
, dwParam1
,
663 (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
665 return ANIM_mciSeek(dwDevID
, dwParam1
,
666 (LPMCI_SEEK_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
668 return DefDriverProc(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
671 return MCIERR_HARDWARE
;
676 /*-----------------------------------------------------------------------*/