Release 941122
[wine/multimedia.git] / multimedia / mcianim.c
blob7a191d4e277b7778dd86571360650dd3dfec59a0
1 /*
2 * Sample MCI ANIMATION Wine Driver for Linux
4 * Copyright 1994 Martin Ayotte
5 */
6 static char Copyright[] = "Copyright Martin Ayotte, 1994";
8 #ifndef WINELIB
9 #define BUILTIN_MMSYSTEM
10 #endif
12 #ifdef BUILTIN_MMSYSTEM
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <string.h>
18 #include <fcntl.h>
19 #include <sys/ioctl.h>
20 #include "win.h"
21 #include "user.h"
22 #include "driver.h"
23 #include "mmsystem.h"
24 #include "stddebug.h"
25 /* #define DEBUG_MCIANIM /* */
26 /* #undef DEBUG_MCIANIM /* */
27 #define DEBUG_MCIANIM
28 #include "debug.h"
30 #define MAX_ANIMDRV 2
32 #define ANIMFRAMES_PERSEC 30
33 #define ANIMFRAMES_PERMIN 1800
34 #define SECONDS_PERMIN 60
36 #ifdef linux
37 typedef struct {
38 int nUseCount; /* Incremented for each shared open */
39 BOOL fShareable; /* TRUE if first open was shareable */
40 WORD wNotifyDeviceID; /* MCI device ID with a pending notification */
41 HANDLE hCallback; /* Callback handle for pending notification */
42 MCI_OPEN_PARMS openParms;
43 DWORD dwTimeFormat;
44 int mode;
45 UINT nCurTrack;
46 DWORD dwCurFrame;
47 UINT nTracks;
48 DWORD dwTotalLen;
49 LPDWORD lpdwTrackLen;
50 LPDWORD lpdwTrackPos;
51 } LINUX_ANIM;
53 static LINUX_ANIM AnimDev[MAX_ANIMDRV];
54 #endif
57 DWORD ANIM_CalcTime(UINT wDevID, DWORD dwFormatType, DWORD dwFrame);
58 DWORD ANIM_CalcFrame(UINT wDevID, DWORD dwFormatType, DWORD dwTime);
61 /*-----------------------------------------------------------------------*/
63 /**************************************************************************
64 * ANIM_mciOpen [internal]
66 DWORD ANIM_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms)
68 #ifdef linux
69 UINT wDevID;
70 int cdrom;
71 dprintf_mcianim(stddeb,"ANIM_mciOpen(%08X, %08X);\n",
72 dwFlags, lpParms);
73 printf("ANIM_mciOpen(%08X, %08X);\n", dwFlags, lpParms);
74 if (lpParms == NULL) return MCIERR_INTERNAL;
75 wDevID = lpParms->wDeviceID;
76 if (AnimDev[wDevID].nUseCount > 0) {
77 /* The driver already open on this channel */
78 /* If the driver was opened shareable before and this open specifies */
79 /* shareable then increment the use count */
80 if (AnimDev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
81 ++AnimDev[wDevID].nUseCount;
82 else
83 return MCIERR_MUST_USE_SHAREABLE;
85 else {
86 AnimDev[wDevID].nUseCount = 1;
87 AnimDev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE;
89 if (dwFlags & MCI_OPEN_ELEMENT) {
90 dprintf_mcianim(stddeb,"ANIM_mciOpen // MCI_OPEN_ELEMENT !\n");
91 printf("ANIM_mciOpen // MCI_OPEN_ELEMENT !\n");
92 /* return MCIERR_NO_ELEMENT_ALLOWED; */
94 memcpy(&AnimDev[wDevID].openParms, lpParms, sizeof(MCI_OPEN_PARMS));
95 AnimDev[wDevID].wNotifyDeviceID = lpParms->wDeviceID;
96 AnimDev[wDevID].mode = 0;
97 AnimDev[wDevID].dwTimeFormat = MCI_FORMAT_TMSF;
98 AnimDev[wDevID].nCurTrack = 0;
99 AnimDev[wDevID].nTracks = 0;
100 AnimDev[wDevID].dwTotalLen = 0;
101 AnimDev[wDevID].lpdwTrackLen = NULL;
102 AnimDev[wDevID].lpdwTrackPos = NULL;
103 if (dwFlags & MCI_NOTIFY) {
104 dprintf_mcianim(stddeb,
105 "ANIM_mciOpen // MCI_NOTIFY_SUCCESSFUL %08X !\n",
106 lpParms->dwCallback);
107 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
108 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
110 return 0;
111 #else
112 return MCIERR_HARDWARE;
113 #endif
116 /**************************************************************************
117 * ANIM_mciClose [internal]
119 DWORD ANIM_mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
121 #ifdef linux
122 dprintf_mcianim(stddeb,"ANIM_mciClose(%u, %08X, %08X);\n",
123 wDevID, dwParam, lpParms);
124 if (AnimDev[wDevID].lpdwTrackLen != NULL) free(AnimDev[wDevID].lpdwTrackLen);
125 if (AnimDev[wDevID].lpdwTrackPos != NULL) free(AnimDev[wDevID].lpdwTrackPos);
126 #endif
129 /**************************************************************************
130 * ANIM_mciGetDevCaps [internal]
132 DWORD ANIM_mciGetDevCaps(UINT wDevID, DWORD dwFlags,
133 LPMCI_GETDEVCAPS_PARMS lpParms)
135 #ifdef linux
136 dprintf_mcianim(stddeb,"ANIM_mciGetDevCaps(%u, %08X, %08X);\n",
137 wDevID, dwFlags, lpParms);
138 if (lpParms == NULL) return MCIERR_INTERNAL;
139 if (dwFlags & MCI_GETDEVCAPS_ITEM) {
140 dprintf_mcianim(stddeb,
141 "ANIM_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08X;\n",
142 lpParms->dwItem);
143 switch(lpParms->dwItem) {
144 case MCI_GETDEVCAPS_CAN_RECORD:
145 lpParms->dwReturn = FALSE;
146 break;
147 case MCI_GETDEVCAPS_HAS_AUDIO:
148 lpParms->dwReturn = FALSE;
149 break;
150 case MCI_GETDEVCAPS_HAS_VIDEO:
151 lpParms->dwReturn = FALSE;
152 break;
153 case MCI_GETDEVCAPS_DEVICE_TYPE:
154 lpParms->dwReturn = MCI_DEVTYPE_ANIMATION;
155 break;
156 case MCI_GETDEVCAPS_USES_FILES:
157 lpParms->dwReturn = TRUE;
158 break;
159 case MCI_GETDEVCAPS_COMPOUND_DEVICE:
160 lpParms->dwReturn = FALSE;
161 break;
162 case MCI_GETDEVCAPS_CAN_EJECT:
163 lpParms->dwReturn = TRUE;
164 break;
165 case MCI_GETDEVCAPS_CAN_PLAY:
166 lpParms->dwReturn = FALSE;
167 break;
168 case MCI_GETDEVCAPS_CAN_SAVE:
169 lpParms->dwReturn = FALSE;
170 break;
171 default:
172 return MCIERR_UNRECOGNIZED_COMMAND;
175 dprintf_mcianim(stddeb,
176 "ANIM_mciGetDevCaps // lpParms->dwReturn=%08X;\n",
177 lpParms->dwReturn);
178 return 0;
179 #else
180 return MCIERR_INTERNAL;
181 #endif
184 /**************************************************************************
185 * ANIM_mciInfo [internal]
187 DWORD ANIM_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms)
189 #ifdef linux
190 dprintf_mcianim(stddeb,"ANIM_mciInfo(%u, %08X, %08X);\n",
191 wDevID, dwFlags, lpParms);
192 if (lpParms == NULL) return MCIERR_INTERNAL;
193 lpParms->lpstrReturn = NULL;
194 switch(dwFlags) {
195 case MCI_INFO_PRODUCT:
196 lpParms->lpstrReturn = "Linux ANIMATION 0.5";
197 break;
198 case MCI_INFO_FILE:
199 lpParms->lpstrReturn =
200 (LPSTR)AnimDev[wDevID].openParms.lpstrElementName;
201 break;
202 case MCI_ANIM_INFO_TEXT:
203 lpParms->lpstrReturn = "Animation Window";
204 break;
205 default:
206 return MCIERR_UNRECOGNIZED_COMMAND;
208 if (lpParms->lpstrReturn != NULL)
209 lpParms->dwRetSize = strlen(lpParms->lpstrReturn);
210 else
211 lpParms->dwRetSize = 0;
212 return 0;
213 #else
214 return MCIERR_INTERNAL;
215 #endif
218 /**************************************************************************
219 * ANIM_mciStatus [internal]
221 DWORD ANIM_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
223 #ifdef linux
224 dprintf_mcianim(stddeb,"ANIM_mciStatus(%u, %08X, %08X);\n",
225 wDevID, dwFlags, lpParms);
226 if (lpParms == NULL) return MCIERR_INTERNAL;
227 if (dwFlags & MCI_NOTIFY) {
228 dprintf_mcianim(stddeb,
229 "ANIM_mciStatus // MCI_NOTIFY_SUCCESSFUL %08X !\n",
230 lpParms->dwCallback);
231 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
232 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
234 if (dwFlags & MCI_STATUS_ITEM) {
235 switch(lpParms->dwItem) {
236 case MCI_STATUS_CURRENT_TRACK:
237 lpParms->dwReturn = AnimDev[wDevID].nCurTrack;
238 dprintf_mcianim(stddeb,"ANIM_mciStatus // CURRENT_TRACK=%u!\n", lpParms->dwReturn);
239 return 0;
240 case MCI_STATUS_LENGTH:
241 if (dwFlags & MCI_TRACK) {
242 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_TRACK #%u LENGTH=??? !\n",
243 lpParms->dwTrack);
244 if (lpParms->dwTrack > AnimDev[wDevID].nTracks)
245 return MCIERR_OUTOFRANGE;
246 lpParms->dwReturn = AnimDev[wDevID].lpdwTrackLen[lpParms->dwTrack];
248 else
249 lpParms->dwReturn = AnimDev[wDevID].dwTotalLen;
250 lpParms->dwReturn = ANIM_CalcTime(wDevID,
251 AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn);
252 dprintf_mcianim(stddeb,"ANIM_mciStatus // LENGTH=%u !\n", lpParms->dwReturn);
253 return 0;
254 case MCI_STATUS_MODE:
255 lpParms->dwReturn = AnimDev[wDevID].mode;
256 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_MODE=%08X !\n",
257 lpParms->dwReturn);
258 return 0;
259 case MCI_STATUS_MEDIA_PRESENT:
260 lpParms->dwReturn = TRUE;
261 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n");
262 return 0;
263 case MCI_STATUS_NUMBER_OF_TRACKS:
264 lpParms->dwReturn = 1;
265 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_NUMBER_OF_TRACKS = %u !\n",
266 lpParms->dwReturn);
267 if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL;
268 return 0;
269 case MCI_STATUS_POSITION:
270 lpParms->dwReturn = AnimDev[wDevID].dwCurFrame;
271 if (dwFlags & MCI_STATUS_START) {
272 lpParms->dwReturn = 0;
273 dprintf_mcianim(stddeb,"CDAUDIO_mciStatus // get MCI_STATUS_START !\n");
275 if (dwFlags & MCI_TRACK) {
276 if (lpParms->dwTrack > AnimDev[wDevID].nTracks)
277 return MCIERR_OUTOFRANGE;
278 lpParms->dwReturn = AnimDev[wDevID].lpdwTrackPos[lpParms->dwTrack - 1];
279 dprintf_mcianim(stddeb,"ANIM_mciStatus // get MCI_TRACK #%u !\n", lpParms->dwTrack);
281 lpParms->dwReturn = ANIM_CalcTime(wDevID,
282 AnimDev[wDevID].dwTimeFormat, lpParms->dwReturn);
283 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_POSITION=%08X !\n",
284 lpParms->dwReturn);
285 return 0;
286 case MCI_STATUS_READY:
287 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_READY !\n");
288 lpParms->dwReturn = TRUE;
289 return 0;
290 case MCI_STATUS_TIME_FORMAT:
291 dprintf_mcianim(stddeb,"ANIM_mciStatus // MCI_STATUS_TIME_FORMAT !\n");
292 lpParms->dwReturn = MCI_FORMAT_MILLISECONDS;
293 return 0;
294 default:
295 fprintf(stderr,"ANIM_mciStatus // unknown command %04X !\n", lpParms->dwItem);
296 return MCIERR_UNRECOGNIZED_COMMAND;
299 fprintf(stderr,"ANIM_mciStatus // not MCI_STATUS_ITEM !\n");
300 return 0;
301 #else
302 return MMSYSERR_NOTENABLED;
303 #endif
307 /**************************************************************************
308 * ANIM_CalcTime [internal]
310 DWORD ANIM_CalcTime(UINT wDevID, DWORD dwFormatType, DWORD dwFrame)
312 DWORD dwTime = 0;
313 #ifdef linux
314 UINT wTrack;
315 UINT wMinutes;
316 UINT wSeconds;
317 UINT wFrames;
318 dprintf_mcianim(stddeb,"ANIM_CalcTime(%u, %08X, %lu);\n",
319 wDevID, dwFormatType, dwFrame);
320 TryAGAIN:
321 switch (dwFormatType) {
322 case MCI_FORMAT_MILLISECONDS:
323 dwTime = dwFrame / ANIMFRAMES_PERSEC * 1000;
324 dprintf_mcianim(stddeb,
325 "ANIM_CalcTime // MILLISECONDS %u\n", dwTime);
326 break;
327 case MCI_FORMAT_MSF:
328 wMinutes = dwFrame / ANIMFRAMES_PERMIN;
329 wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
330 wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes -
331 ANIMFRAMES_PERSEC * wSeconds;
332 dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames);
333 dprintf_mcianim(stddeb,"ANIM_CalcTime // MSF %02u:%02u:%02u -> dwTime=%u\n",
334 wMinutes, wSeconds, wFrames, dwTime);
335 break;
336 case MCI_FORMAT_TMSF:
337 for (wTrack = 0; wTrack < AnimDev[wDevID].nTracks; wTrack++) {
338 /* dwTime += AnimDev[wDevID].lpdwTrackLen[wTrack - 1];
339 printf("Adding trk#%u curpos=%u \n", dwTime);
340 if (dwTime >= dwFrame) break; */
341 if (AnimDev[wDevID].lpdwTrackPos[wTrack - 1] >= dwFrame) break;
343 wMinutes = dwFrame / ANIMFRAMES_PERMIN;
344 wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
345 wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes -
346 ANIMFRAMES_PERSEC * wSeconds;
347 dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames);
348 dprintf_mcianim(stddeb,
349 "ANIM_CalcTime // %02u-%02u:%02u:%02u\n",
350 wTrack, wMinutes, wSeconds, wFrames);
351 break;
352 default:
353 /* unknown format ! force TMSF ! ... */
354 dwFormatType = MCI_FORMAT_TMSF;
355 goto TryAGAIN;
357 #endif
358 return dwTime;
362 /**************************************************************************
363 * ANIM_CalcFrame [internal]
365 DWORD ANIM_CalcFrame(UINT wDevID, DWORD dwFormatType, DWORD dwTime)
367 DWORD dwFrame = 0;
368 #ifdef linux
369 UINT wTrack;
370 dprintf_mcianim(stddeb,"ANIM_CalcFrame(%u, %08X, %lu);\n",
371 wDevID, dwFormatType, dwTime);
372 TryAGAIN:
373 switch (dwFormatType) {
374 case MCI_FORMAT_MILLISECONDS:
375 dwFrame = dwTime * ANIMFRAMES_PERSEC / 1000;
376 dprintf_mcianim(stddeb,
377 "ANIM_CalcFrame // MILLISECONDS %u\n", dwFrame);
378 break;
379 case MCI_FORMAT_MSF:
380 dprintf_mcianim(stddeb,
381 "ANIM_CalcFrame // MSF %02u:%02u:%02u\n",
382 MCI_MSF_MINUTE(dwTime), MCI_MSF_SECOND(dwTime),
383 MCI_MSF_FRAME(dwTime));
384 dwFrame += ANIMFRAMES_PERMIN * MCI_MSF_MINUTE(dwTime);
385 dwFrame += ANIMFRAMES_PERSEC * MCI_MSF_SECOND(dwTime);
386 dwFrame += MCI_MSF_FRAME(dwTime);
387 break;
388 case MCI_FORMAT_TMSF:
389 wTrack = MCI_TMSF_TRACK(dwTime);
390 dprintf_mcianim(stddeb,
391 "ANIM_CalcFrame // TMSF %02u-%02u:%02u:%02u\n",
392 MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime),
393 MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
394 dprintf_mcianim(stddeb,
395 "ANIM_CalcFrame // TMSF trackpos[%u]=%u\n",
396 wTrack, AnimDev[wDevID].lpdwTrackPos[wTrack - 1]);
397 dwFrame = AnimDev[wDevID].lpdwTrackPos[wTrack - 1];
398 dwFrame += ANIMFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime);
399 dwFrame += ANIMFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime);
400 dwFrame += MCI_TMSF_FRAME(dwTime);
401 break;
402 default:
403 /* unknown format ! force TMSF ! ... */
404 dwFormatType = MCI_FORMAT_TMSF;
405 goto TryAGAIN;
407 #endif
408 return dwFrame;
413 /**************************************************************************
414 * ANIM_mciPlay [internal]
416 DWORD ANIM_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
418 #ifdef linux
419 int start, end;
420 dprintf_mcianim(stddeb,"ANIM_mciPlay(%u, %08X, %08X);\n",
421 wDevID, dwFlags, lpParms);
422 printf("ANIM_mciPlay(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
423 if (lpParms == NULL) return MCIERR_INTERNAL;
424 start = 0; end = AnimDev[wDevID].dwTotalLen;
425 AnimDev[wDevID].nCurTrack = 1;
426 if (dwFlags & MCI_FROM) {
427 start = ANIM_CalcFrame(wDevID,
428 AnimDev[wDevID].dwTimeFormat, lpParms->dwFrom);
429 dprintf_mcianim(stddeb,"ANIM_mciPlay // MCI_FROM=%08X -> %u \n",
430 lpParms->dwFrom, start);
432 if (dwFlags & MCI_TO) {
433 end = ANIM_CalcFrame(wDevID,
434 AnimDev[wDevID].dwTimeFormat, lpParms->dwTo);
435 dprintf_mcianim(stddeb,
436 "ANIM_mciPlay // MCI_TO=%08X -> %u \n",
437 lpParms->dwTo, end);
439 AnimDev[wDevID].mode = MCI_MODE_PLAY;
440 if (dwFlags & MCI_NOTIFY) {
441 dprintf_mcianim(stddeb,
442 "ANIM_mciPlay // MCI_NOTIFY_SUCCESSFUL %08X !\n",
443 lpParms->dwCallback);
444 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
445 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
447 return 0;
448 #else
449 return MCIERR_HARDWARE;
450 #endif
453 /**************************************************************************
454 * ANIM_mciStop [internal]
456 DWORD ANIM_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
458 #ifdef linux
459 dprintf_mcianim(stddeb,"ANIM_mciStop(%u, %08X, %08X);\n",
460 wDevID, dwFlags, lpParms);
461 if (lpParms == NULL) return MCIERR_INTERNAL;
462 AnimDev[wDevID].mode = MCI_MODE_STOP;
463 if (dwFlags & MCI_NOTIFY) {
464 dprintf_mcianim(stddeb,
465 "ANIM_mciStop // MCI_NOTIFY_SUCCESSFUL %08X !\n",
466 lpParms->dwCallback);
467 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
468 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
470 return 0;
471 #else
472 return MCIERR_HARDWARE;
473 #endif
476 /**************************************************************************
477 * ANIM_mciPause [internal]
479 DWORD ANIM_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
481 #ifdef linux
482 dprintf_mcianim(stddeb,"ANIM_mciPause(%u, %08X, %08X);\n",
483 wDevID, dwFlags, lpParms);
484 if (lpParms == NULL) return MCIERR_INTERNAL;
485 AnimDev[wDevID].mode = MCI_MODE_PAUSE;
486 if (dwFlags & MCI_NOTIFY) {
487 dprintf_mcianim(stddeb,
488 "ANIM_mciPause // MCI_NOTIFY_SUCCESSFUL %08X !\n",
489 lpParms->dwCallback);
490 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
491 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
493 return 0;
494 #else
495 return MCIERR_HARDWARE;
496 #endif
499 /**************************************************************************
500 * ANIM_mciResume [internal]
502 DWORD ANIM_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
504 #ifdef linux
505 dprintf_mcianim(stddeb,"ANIM_mciResume(%u, %08X, %08X);\n",
506 wDevID, dwFlags, lpParms);
507 if (lpParms == NULL) return MCIERR_INTERNAL;
508 AnimDev[wDevID].mode = MCI_MODE_STOP;
509 if (dwFlags & MCI_NOTIFY) {
510 dprintf_mcianim(stddeb,
511 "ANIM_mciResume // MCI_NOTIFY_SUCCESSFUL %08X !\n",
512 lpParms->dwCallback);
513 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
514 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
516 return 0;
517 #else
518 return MCIERR_HARDWARE;
519 #endif
522 /**************************************************************************
523 * ANIM_mciSeek [internal]
525 DWORD ANIM_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
527 #ifdef linux
528 DWORD dwRet;
529 MCI_PLAY_PARMS PlayParms;
530 dprintf_mcianim(stddeb,"ANIM_mciSeek(%u, %08X, %08X);\n",
531 wDevID, dwFlags, lpParms);
532 if (lpParms == NULL) return MCIERR_INTERNAL;
533 AnimDev[wDevID].mode = MCI_MODE_SEEK;
534 switch(dwFlags) {
535 case MCI_SEEK_TO_START:
536 PlayParms.dwFrom = 0;
537 break;
538 case MCI_SEEK_TO_END:
539 PlayParms.dwFrom = AnimDev[wDevID].dwTotalLen;
540 break;
541 case MCI_TO:
542 PlayParms.dwFrom = lpParms->dwTo;
543 break;
545 dwRet = ANIM_mciPlay(wDevID, MCI_WAIT | MCI_FROM, &PlayParms);
546 if (dwRet != 0) return dwRet;
547 dwRet = ANIM_mciStop(wDevID, MCI_WAIT, (LPMCI_GENERIC_PARMS)&PlayParms);
548 if (dwFlags & MCI_NOTIFY) {
549 dprintf_mcianim(stddeb,
550 "ANIM_mciSeek // MCI_NOTIFY_SUCCESSFUL %08X !\n",
551 lpParms->dwCallback);
552 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
553 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
555 return dwRet;
556 #else
557 return MCIERR_HARDWARE;
558 #endif
562 /**************************************************************************
563 * ANIM_mciSet [internal]
565 DWORD ANIM_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
567 #ifdef linux
568 dprintf_mcianim(stddeb,"ANIM_mciSet(%u, %08X, %08X);\n",
569 wDevID, dwFlags, lpParms);
570 if (lpParms == NULL) return MCIERR_INTERNAL;
572 printf("ANIM_mciSet // dwTimeFormat=%08X\n", lpParms->dwTimeFormat);
573 printf("ANIM_mciSet // dwAudio=%08X\n", lpParms->dwAudio);
575 if (dwFlags & MCI_SET_TIME_FORMAT) {
576 switch (lpParms->dwTimeFormat) {
577 case MCI_FORMAT_MILLISECONDS:
578 dprintf_mcianim(stddeb,
579 "ANIM_mciSet // MCI_FORMAT_MILLISECONDS !\n");
580 break;
581 case MCI_FORMAT_MSF:
582 dprintf_mcianim(stddeb,"ANIM_mciSet // MCI_FORMAT_MSF !\n");
583 break;
584 case MCI_FORMAT_TMSF:
585 dprintf_mcianim(stddeb,"ANIM_mciSet // MCI_FORMAT_TMSF !\n");
586 break;
587 default:
588 fprintf(stderr,"ANIM_mciSet // bad time format !\n");
589 return MCIERR_BAD_TIME_FORMAT;
591 AnimDev[wDevID].dwTimeFormat = lpParms->dwTimeFormat;
593 if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION;
594 if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION;
595 if (dwFlags & MCI_SET_OFF) return MCIERR_UNSUPPORTED_FUNCTION;
596 if (dwFlags & MCI_NOTIFY) {
597 dprintf_mcianim(stddeb,
598 "ANIM_mciSet // MCI_NOTIFY_SUCCESSFUL %08X !\n",
599 lpParms->dwCallback);
600 mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
601 AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
603 return 0;
604 #else
605 return MCIERR_HARDWARE;
606 #endif
610 /**************************************************************************
611 * ANIM_DriverProc [sample driver]
613 LRESULT ANIM_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg,
614 DWORD dwParam1, DWORD dwParam2)
616 #ifdef linux
617 switch(wMsg) {
618 case DRV_LOAD:
619 return (LRESULT)1L;
620 case DRV_FREE:
621 return (LRESULT)1L;
622 case DRV_OPEN:
623 case MCI_OPEN_DRIVER:
624 case MCI_OPEN:
625 return ANIM_mciOpen(dwParam1, (LPMCI_OPEN_PARMS)dwParam2);
626 case DRV_CLOSE:
627 case MCI_CLOSE_DRIVER:
628 case MCI_CLOSE:
629 return ANIM_mciClose(dwDevID, dwParam1,
630 (LPMCI_GENERIC_PARMS)dwParam2);
631 case DRV_ENABLE:
632 return (LRESULT)1L;
633 case DRV_DISABLE:
634 return (LRESULT)1L;
635 case DRV_QUERYCONFIGURE:
636 return (LRESULT)1L;
637 case DRV_CONFIGURE:
638 MessageBox((HWND)NULL, "Sample MultiMedia Linux Driver !",
639 "MMLinux Driver", MB_OK);
640 return (LRESULT)1L;
641 case DRV_INSTALL:
642 return (LRESULT)DRVCNF_RESTART;
643 case DRV_REMOVE:
644 return (LRESULT)DRVCNF_RESTART;
645 case MCI_GETDEVCAPS:
646 return ANIM_mciGetDevCaps(dwDevID, dwParam1,
647 (LPMCI_GETDEVCAPS_PARMS)dwParam2);
648 case MCI_INFO:
649 return ANIM_mciInfo(dwDevID, dwParam1,
650 (LPMCI_INFO_PARMS)dwParam2);
651 case MCI_STATUS:
652 return ANIM_mciStatus(dwDevID, dwParam1,
653 (LPMCI_STATUS_PARMS)dwParam2);
654 case MCI_SET:
655 return ANIM_mciSet(dwDevID, dwParam1,
656 (LPMCI_SET_PARMS)dwParam2);
657 case MCI_PLAY:
658 return ANIM_mciPlay(dwDevID, dwParam1,
659 (LPMCI_PLAY_PARMS)dwParam2);
660 case MCI_STOP:
661 return ANIM_mciStop(dwDevID, dwParam1,
662 (LPMCI_GENERIC_PARMS)dwParam2);
663 case MCI_PAUSE:
664 return ANIM_mciPause(dwDevID, dwParam1,
665 (LPMCI_GENERIC_PARMS)dwParam2);
666 case MCI_RESUME:
667 return ANIM_mciResume(dwDevID, dwParam1,
668 (LPMCI_GENERIC_PARMS)dwParam2);
669 case MCI_SEEK:
670 return ANIM_mciSeek(dwDevID, dwParam1,
671 (LPMCI_SEEK_PARMS)dwParam2);
672 default:
673 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
675 #else
676 return MCIERR_HARDWARE;
677 #endif
681 /*-----------------------------------------------------------------------*/
683 #endif /* #ifdef BUILTIN_MMSYSTEM */