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