Some more pidl-types.
[wine.git] / multimedia / mcianim.c
bloba941a124460d18082f2cce38deefafba808ee782
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2 /*
3 * Sample MCI ANIMATION Wine Driver for Linux
5 * Copyright 1994 Martin Ayotte
6 */
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <string.h>
11 #include <fcntl.h>
12 #include <sys/ioctl.h>
13 #include "windef.h"
14 #include "winuser.h"
15 #include "driver.h"
16 #include "mmsystem.h"
17 #include "multimedia.h"
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(mcianim)
22 #define MAX_ANIMDRV 2
24 #define ANIMFRAMES_PERSEC 30
25 #define ANIMFRAMES_PERMIN 1800
26 #define SECONDS_PERMIN 60
28 typedef struct {
29 UINT16 wDevID;
30 int nUseCount; /* Incremented for each shared open */
31 BOOL16 fShareable; /* TRUE if first open was shareable */
32 WORD wNotifyDeviceID; /* MCI device ID with a pending notification */
33 HANDLE16 hCallback; /* Callback handle for pending notification */
34 MCI_OPEN_PARMSA openParms;
35 DWORD dwTimeFormat;
36 int mode;
37 UINT16 nCurTrack;
38 DWORD dwCurFrame;
39 UINT16 nTracks;
40 DWORD dwTotalLen;
41 LPDWORD lpdwTrackLen;
42 LPDWORD lpdwTrackPos;
43 } WINE_MCIANIM;
45 static WINE_MCIANIM MCIAnimDev[MAX_ANIMDRV];
47 /*-----------------------------------------------------------------------*/
49 /**************************************************************************
50 * ANIM_drvGetDrv [internal]
52 static WINE_MCIANIM* ANIM_drvGetDrv(UINT16 wDevID)
54 int i;
56 for (i = 0; i < MAX_ANIMDRV; i++) {
57 if (MCIAnimDev[i].wDevID == wDevID) {
58 return &MCIAnimDev[i];
61 return 0;
64 /**************************************************************************
65 * ANIM_drvOpen [internal]
67 static DWORD ANIM_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp)
69 int i;
71 for (i = 0; i < MAX_ANIMDRV; i++) {
72 if (MCIAnimDev[i].wDevID == 0) {
73 MCIAnimDev[i].wDevID = modp->wDeviceID;
74 modp->wCustomCommandTable = -1;
75 modp->wType = MCI_DEVTYPE_CD_AUDIO;
76 return modp->wDeviceID;
79 return 0;
82 /**************************************************************************
83 * ANIM_drvClose [internal]
85 static DWORD ANIM_drvClose(DWORD dwDevID)
87 WINE_MCIANIM* wma = ANIM_drvGetDrv(dwDevID);
89 if (wma) {
90 wma->wDevID = 0;
91 return 1;
93 return 0;
96 /**************************************************************************
97 * ANIM_mciGetOpenDrv [internal]
99 static WINE_MCIANIM* ANIM_mciGetOpenDrv(UINT16 wDevID)
101 WINE_MCIANIM* wma = ANIM_drvGetDrv(wDevID);
103 if (wma == NULL || wma->nUseCount == 0) {
104 WARN("Invalid wDevID=%u\n", wDevID);
105 return 0;
107 return wma;
110 /**************************************************************************
111 * ANIM_mciOpen [internal]
113 static DWORD ANIM_mciOpen(UINT16 wDevID, DWORD dwFlags, LPMCI_OPEN_PARMSA lpOpenParms)
115 DWORD dwDeviceID;
116 WINE_MCIANIM* wma = ANIM_drvGetDrv(wDevID);
118 TRACE("(%04X, %08lX, %p);\n", wDevID, dwFlags, lpOpenParms);
120 if (lpOpenParms == NULL) return MCIERR_INTERNAL;
121 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
123 if (wma->nUseCount > 0) {
124 /* The driver already open on this channel */
125 /* If the driver was opened shareable before and this open specifies */
126 /* shareable then increment the use count */
127 if (wma->fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
128 ++wma->nUseCount;
129 else
130 return MCIERR_MUST_USE_SHAREABLE;
131 } else {
132 wma->nUseCount = 1;
133 wma->fShareable = dwFlags & MCI_OPEN_SHAREABLE;
136 dwDeviceID = lpOpenParms->wDeviceID;
138 TRACE("wDevID=%04X\n", wDevID);
139 /* FIXME this is not consistent with other implementations */
140 lpOpenParms->wDeviceID = wDevID;
142 /*TRACE(mcianim,"lpParms->wDevID=%04X\n", lpParms->wDeviceID);*/
143 if (dwFlags & MCI_OPEN_ELEMENT) {
144 TRACE("MCI_OPEN_ELEMENT '%s' !\n", lpOpenParms->lpstrElementName);
145 if (lpOpenParms->lpstrElementName && strlen(lpOpenParms->lpstrElementName) > 0) {
147 FIXME("element is not opened\n");
149 memcpy(&wma->openParms, lpOpenParms, sizeof(MCI_OPEN_PARMSA));
150 wma->wNotifyDeviceID = dwDeviceID;
151 wma->mode = 0;
152 wma->dwTimeFormat = MCI_FORMAT_TMSF;
153 wma->nCurTrack = 0;
154 wma->nTracks = 0;
155 wma->dwTotalLen = 0;
156 wma->lpdwTrackLen = NULL;
157 wma->lpdwTrackPos = NULL;
159 Moved to mmsystem.c mciOpen routine
161 if (dwFlags & MCI_NOTIFY) {
162 TRACE(mcianim, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
163 lpParms->dwCallback);
164 mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
165 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
168 return 0;
171 /**************************************************************************
172 * ANIM_mciClose [internal]
174 static DWORD ANIM_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
176 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
178 TRACE("(%u, %08lX, %p);\n", wDevID, dwParam, lpParms);
180 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
182 if (--wma->nUseCount == 0) {
183 if (wma->lpdwTrackLen != NULL) free(wma->lpdwTrackLen);
184 if (wma->lpdwTrackPos != NULL) free(wma->lpdwTrackPos);
186 return 0;
189 /**************************************************************************
190 * ANIM_mciGetDevCaps [internal]
192 static DWORD ANIM_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags,
193 LPMCI_GETDEVCAPS_PARMS lpParms)
195 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
197 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
199 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
200 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
202 if (dwFlags & MCI_GETDEVCAPS_ITEM) {
203 TRACE("MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n", lpParms->dwItem);
204 switch(lpParms->dwItem) {
205 case MCI_GETDEVCAPS_CAN_RECORD:
206 lpParms->dwReturn = FALSE;
207 break;
208 case MCI_GETDEVCAPS_HAS_AUDIO:
209 lpParms->dwReturn = FALSE;
210 break;
211 case MCI_GETDEVCAPS_HAS_VIDEO:
212 lpParms->dwReturn = FALSE;
213 break;
214 case MCI_GETDEVCAPS_DEVICE_TYPE:
215 lpParms->dwReturn = MCI_DEVTYPE_ANIMATION;
216 break;
217 case MCI_GETDEVCAPS_USES_FILES:
218 lpParms->dwReturn = TRUE;
219 break;
220 case MCI_GETDEVCAPS_COMPOUND_DEVICE:
221 lpParms->dwReturn = FALSE;
222 break;
223 case MCI_GETDEVCAPS_CAN_EJECT:
224 lpParms->dwReturn = TRUE;
225 break;
226 case MCI_GETDEVCAPS_CAN_PLAY:
227 lpParms->dwReturn = FALSE;
228 break;
229 case MCI_GETDEVCAPS_CAN_SAVE:
230 lpParms->dwReturn = FALSE;
231 break;
232 default:
233 return MCIERR_UNRECOGNIZED_COMMAND;
236 TRACE("lpParms->dwReturn=%08lX;\n", lpParms->dwReturn);
237 return 0;
241 /**************************************************************************
242 * ANIM_CalcTime [internal]
244 static DWORD ANIM_CalcTime(WINE_MCIANIM* wma, DWORD dwFormatType, DWORD dwFrame)
246 DWORD dwTime = 0;
247 UINT16 wTrack;
248 UINT16 wMinutes;
249 UINT16 wSeconds;
250 UINT16 wFrames;
252 TRACE("(%p, %08lX, %lu);\n", wma, dwFormatType, dwFrame);
254 switch (dwFormatType) {
255 case MCI_FORMAT_MILLISECONDS:
256 dwTime = dwFrame / ANIMFRAMES_PERSEC * 1000;
257 TRACE("MILLISECONDS %lu\n", dwTime);
258 break;
259 case MCI_FORMAT_MSF:
260 wMinutes = dwFrame / ANIMFRAMES_PERMIN;
261 wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
262 wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes -
263 ANIMFRAMES_PERSEC * wSeconds;
264 dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames);
265 TRACE("MSF %02u:%02u:%02u -> dwTime=%lu\n",
266 wMinutes, wSeconds, wFrames, dwTime);
267 break;
268 default:
269 /* unknown format ! force TMSF ! ... */
270 dwFormatType = MCI_FORMAT_TMSF;
271 case MCI_FORMAT_TMSF:
272 for (wTrack = 0; wTrack < wma->nTracks; wTrack++) {
273 /* dwTime += wma->lpdwTrackLen[wTrack - 1];
274 TRACE(mcianim, "Adding trk#%u curpos=%u \n", dwTime);
275 if (dwTime >= dwFrame) break; */
276 if (wma->lpdwTrackPos[wTrack - 1] >= dwFrame) break;
278 wMinutes = dwFrame / ANIMFRAMES_PERMIN;
279 wSeconds = (dwFrame - ANIMFRAMES_PERMIN * wMinutes) / ANIMFRAMES_PERSEC;
280 wFrames = dwFrame - ANIMFRAMES_PERMIN * wMinutes -
281 ANIMFRAMES_PERSEC * wSeconds;
282 dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames);
283 TRACE("%02u-%02u:%02u:%02u\n",
284 wTrack, wMinutes, wSeconds, wFrames);
285 break;
287 return dwTime;
291 /**************************************************************************
292 * ANIM_CalcFrame [internal]
294 static DWORD ANIM_CalcFrame(WINE_MCIANIM* wma, DWORD dwFormatType, DWORD dwTime)
296 DWORD dwFrame = 0;
297 UINT16 wTrack;
299 TRACE("(%p, %08lX, %lu);\n", wma, dwFormatType, dwTime);
301 switch (dwFormatType) {
302 case MCI_FORMAT_MILLISECONDS:
303 dwFrame = dwTime * ANIMFRAMES_PERSEC / 1000;
304 TRACE("MILLISECONDS %lu\n", dwFrame);
305 break;
306 case MCI_FORMAT_MSF:
307 TRACE("MSF %02u:%02u:%02u\n",
308 MCI_MSF_MINUTE(dwTime), MCI_MSF_SECOND(dwTime),
309 MCI_MSF_FRAME(dwTime));
310 dwFrame += ANIMFRAMES_PERMIN * MCI_MSF_MINUTE(dwTime);
311 dwFrame += ANIMFRAMES_PERSEC * MCI_MSF_SECOND(dwTime);
312 dwFrame += MCI_MSF_FRAME(dwTime);
313 break;
314 default:
315 /* unknown format ! force TMSF ! ... */
316 dwFormatType = MCI_FORMAT_TMSF;
317 case MCI_FORMAT_TMSF:
318 wTrack = MCI_TMSF_TRACK(dwTime);
319 TRACE("TMSF %02u-%02u:%02u:%02u\n",
320 MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime),
321 MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
322 TRACE("TMSF trackpos[%u]=%lu\n",
323 wTrack, wma->lpdwTrackPos[wTrack - 1]);
324 dwFrame = wma->lpdwTrackPos[wTrack - 1];
325 dwFrame += ANIMFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime);
326 dwFrame += ANIMFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime);
327 dwFrame += MCI_TMSF_FRAME(dwTime);
328 break;
330 return dwFrame;
334 /**************************************************************************
335 * ANIM_mciInfo [internal]
337 static DWORD ANIM_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms)
339 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
340 DWORD ret = 0;
341 LPSTR str = 0;
343 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
345 if (lpParms == NULL || lpParms->lpstrReturn == NULL) {
346 ret = MCIERR_NULL_PARAMETER_BLOCK;
347 } else if (wma == NULL) {
348 ret = MCIERR_INVALID_DEVICE_ID;
349 } else {
350 TRACE("buf=%p, len=%lu\n", lpParms->lpstrReturn, lpParms->dwRetSize);
352 switch(dwFlags) {
353 case MCI_INFO_PRODUCT:
354 str = "Wine's animation";
355 break;
356 case MCI_INFO_FILE:
357 str = wma->openParms.lpstrElementName;
358 break;
359 case MCI_ANIM_INFO_TEXT:
360 str = "Animation Window";
361 break;
362 default:
363 WARN("Don't know this info command (%lu)\n", dwFlags);
364 ret = MCIERR_UNRECOGNIZED_COMMAND;
367 if (str) {
368 ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, str);
369 } else {
370 lpParms->lpstrReturn[0] = 0;
373 return ret;
376 /**************************************************************************
377 * ANIM_mciStatus [internal]
379 static DWORD ANIM_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
381 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
383 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
385 if (lpParms == NULL) return MCIERR_INTERNAL;
386 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
388 if (dwFlags & MCI_NOTIFY) {
389 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
390 lpParms->dwCallback);
391 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
392 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
394 if (dwFlags & MCI_STATUS_ITEM) {
395 switch(lpParms->dwItem) {
396 case MCI_STATUS_CURRENT_TRACK:
397 lpParms->dwReturn = wma->nCurTrack;
398 TRACE("CURRENT_TRACK=%lu!\n", lpParms->dwReturn);
399 return 0;
400 case MCI_STATUS_LENGTH:
401 if (dwFlags & MCI_TRACK) {
402 TRACE("MCI_TRACK #%lu LENGTH=??? !\n",
403 lpParms->dwTrack);
404 if (lpParms->dwTrack > wma->nTracks)
405 return MCIERR_OUTOFRANGE;
406 lpParms->dwReturn = wma->lpdwTrackLen[lpParms->dwTrack];
408 else
409 lpParms->dwReturn = wma->dwTotalLen;
410 lpParms->dwReturn = ANIM_CalcTime(wma, wma->dwTimeFormat, lpParms->dwReturn);
411 TRACE("LENGTH=%lu !\n", lpParms->dwReturn);
412 return 0;
413 case MCI_STATUS_MODE:
414 lpParms->dwReturn = wma->mode;
415 TRACE("MCI_STATUS_MODE=%08lX !\n",
416 lpParms->dwReturn);
417 return 0;
418 case MCI_STATUS_MEDIA_PRESENT:
419 lpParms->dwReturn = TRUE;
420 TRACE("MCI_STATUS_MEDIA_PRESENT !\n");
421 return 0;
422 case MCI_STATUS_NUMBER_OF_TRACKS:
423 lpParms->dwReturn = 1;
424 TRACE("MCI_STATUS_NUMBER_OF_TRACKS = %lu !\n",
425 lpParms->dwReturn);
426 if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL;
427 return 0;
428 case MCI_STATUS_POSITION:
429 lpParms->dwReturn = wma->dwCurFrame;
430 if (dwFlags & MCI_STATUS_START) {
431 lpParms->dwReturn = 0;
432 TRACE("get MCI_STATUS_START !\n");
434 if (dwFlags & MCI_TRACK) {
435 if (lpParms->dwTrack > wma->nTracks)
436 return MCIERR_OUTOFRANGE;
437 lpParms->dwReturn = wma->lpdwTrackPos[lpParms->dwTrack - 1];
438 TRACE("get MCI_TRACK #%lu !\n", lpParms->dwTrack);
440 lpParms->dwReturn = ANIM_CalcTime(wma, wma->dwTimeFormat, lpParms->dwReturn);
441 TRACE("MCI_STATUS_POSITION=%08lX !\n",
442 lpParms->dwReturn);
443 return 0;
444 case MCI_STATUS_READY:
445 TRACE("MCI_STATUS_READY !\n");
446 lpParms->dwReturn = TRUE;
447 return 0;
448 case MCI_STATUS_TIME_FORMAT:
449 TRACE("MCI_STATUS_TIME_FORMAT !\n");
450 lpParms->dwReturn = MCI_FORMAT_MILLISECONDS;
451 return 0;
452 default:
453 WARN("Unknown command %08lX !\n", lpParms->dwItem);
454 return MCIERR_UNRECOGNIZED_COMMAND;
457 WARN("Not MCI_STATUS_ITEM !\n");
458 return 0;
462 /**************************************************************************
463 * ANIM_mciPlay [internal]
465 static DWORD ANIM_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
467 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
468 int start, end;
470 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
472 if (lpParms == NULL) return MCIERR_INTERNAL;
473 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
475 start = 0; end = wma->dwTotalLen;
476 wma->nCurTrack = 1;
477 if (dwFlags & MCI_FROM) {
478 start = ANIM_CalcFrame(wma, wma->dwTimeFormat, lpParms->dwFrom);
479 TRACE("MCI_FROM=%08lX -> %u \n", lpParms->dwFrom, start);
481 if (dwFlags & MCI_TO) {
482 end = ANIM_CalcFrame(wma, wma->dwTimeFormat, lpParms->dwTo);
483 TRACE("MCI_TO=%08lX -> %u \n", lpParms->dwTo, end);
485 wma->mode = MCI_MODE_PLAY;
486 if (dwFlags & MCI_NOTIFY) {
487 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
488 lpParms->dwCallback);
489 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
490 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
492 return 0;
495 /**************************************************************************
496 * ANIM_mciStop [internal]
498 static DWORD ANIM_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
500 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
502 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
504 if (lpParms == NULL) return MCIERR_INTERNAL;
505 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
507 wma->mode = MCI_MODE_STOP;
508 if (dwFlags & MCI_NOTIFY) {
509 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
510 lpParms->dwCallback);
511 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
512 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
514 return 0;
517 /**************************************************************************
518 * ANIM_mciPause [internal]
520 static DWORD ANIM_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
522 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
524 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
525 if (lpParms == NULL) return MCIERR_INTERNAL;
526 wma->mode = MCI_MODE_PAUSE;
527 if (dwFlags & MCI_NOTIFY) {
528 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
529 lpParms->dwCallback);
530 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
531 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
533 return 0;
536 /**************************************************************************
537 * ANIM_mciResume [internal]
539 static DWORD ANIM_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
541 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
543 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
544 if (lpParms == NULL) return MCIERR_INTERNAL;
545 wma->mode = MCI_MODE_STOP;
546 if (dwFlags & MCI_NOTIFY) {
547 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
548 lpParms->dwCallback);
549 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
550 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
552 return 0;
555 /**************************************************************************
556 * ANIM_mciSeek [internal]
558 static DWORD ANIM_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
560 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
561 DWORD dwRet;
562 MCI_PLAY_PARMS PlayParms;
564 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
566 if (lpParms == NULL) return MCIERR_INTERNAL;
567 wma->mode = MCI_MODE_SEEK;
568 switch(dwFlags) {
569 case MCI_SEEK_TO_START:
570 PlayParms.dwFrom = 0;
571 break;
572 case MCI_SEEK_TO_END:
573 PlayParms.dwFrom = wma->dwTotalLen;
574 break;
575 case MCI_TO:
576 PlayParms.dwFrom = lpParms->dwTo;
577 break;
579 dwRet = ANIM_mciPlay(wDevID, MCI_WAIT | MCI_FROM, &PlayParms);
580 if (dwRet != 0) return dwRet;
581 dwRet = ANIM_mciStop(wDevID, MCI_WAIT, (LPMCI_GENERIC_PARMS)&PlayParms);
582 if (dwFlags & MCI_NOTIFY) {
583 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
584 lpParms->dwCallback);
585 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
586 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
588 return dwRet;
592 /**************************************************************************
593 * ANIM_mciSet [internal]
595 static DWORD ANIM_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
597 WINE_MCIANIM* wma = ANIM_mciGetOpenDrv(wDevID);
599 TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
600 if (lpParms == NULL) return MCIERR_INTERNAL;
601 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
603 TRACE(mcianim,"(dwTimeFormat=%08lX)\n", lpParms->dwTimeFormat);
604 TRACE(mcianim,"(dwAudio=%08lX)\n", lpParms->dwAudio);
606 if (dwFlags & MCI_SET_TIME_FORMAT) {
607 switch (lpParms->dwTimeFormat) {
608 case MCI_FORMAT_MILLISECONDS:
609 TRACE("MCI_FORMAT_MILLISECONDS !\n");
610 break;
611 case MCI_FORMAT_MSF:
612 TRACE("MCI_FORMAT_MSF !\n");
613 break;
614 case MCI_FORMAT_TMSF:
615 TRACE("MCI_FORMAT_TMSF !\n");
616 break;
617 default:
618 WARN("Bad time format !\n");
619 return MCIERR_BAD_TIME_FORMAT;
621 wma->dwTimeFormat = lpParms->dwTimeFormat;
623 if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION;
624 if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION;
625 if (dwFlags & MCI_SET_OFF) return MCIERR_UNSUPPORTED_FUNCTION;
626 if (dwFlags & MCI_NOTIFY) {
627 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n",
628 lpParms->dwCallback);
629 mciDriverNotify16((HWND16)LOWORD(lpParms->dwCallback),
630 wma->wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
632 return 0;
635 /**************************************************************************
636 * ANIM_DriverProc [sample driver]
638 LONG MCIANIM_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg,
639 DWORD dwParam1, DWORD dwParam2)
641 switch(wMsg) {
642 case DRV_LOAD: return 1;
643 case DRV_FREE: return 1;
644 case DRV_OPEN: return ANIM_drvOpen((LPSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSA)dwParam2);
645 case DRV_CLOSE: return ANIM_drvClose(dwDevID);
646 case DRV_ENABLE: return 1;
647 case DRV_DISABLE: return 1;
648 case DRV_QUERYCONFIGURE: return 1;
649 case DRV_CONFIGURE: MessageBoxA(0, "Sample MultiMedia Driver !", "Wine Driver", MB_OK); return 1;
650 case DRV_INSTALL: return DRVCNF_RESTART;
651 case DRV_REMOVE: return DRVCNF_RESTART;
653 case MCI_OPEN_DRIVER: return ANIM_mciOpen(dwDevID, dwParam1, (LPMCI_OPEN_PARMSA)dwParam2);
654 case MCI_CLOSE_DRIVER: return ANIM_mciClose(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
655 case MCI_GETDEVCAPS: return ANIM_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2);
656 case MCI_INFO: return ANIM_mciInfo(dwDevID, dwParam1, (LPMCI_INFO_PARMS16)dwParam2);
657 case MCI_STATUS: return ANIM_mciStatus(dwDevID, dwParam1, (LPMCI_STATUS_PARMS)dwParam2);
658 case MCI_SET: return ANIM_mciSet(dwDevID, dwParam1, (LPMCI_SET_PARMS)dwParam2);
659 case MCI_PLAY: return ANIM_mciPlay(dwDevID, dwParam1, (LPMCI_PLAY_PARMS)dwParam2);
660 case MCI_STOP: return ANIM_mciStop(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
661 case MCI_PAUSE: return ANIM_mciPause(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
662 case MCI_RESUME: return ANIM_mciResume(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
663 case MCI_SEEK: return ANIM_mciSeek(dwDevID, dwParam1, (LPMCI_SEEK_PARMS)dwParam2);
664 case MCI_LOAD:
665 case MCI_SAVE:
666 case MCI_FREEZE:
667 case MCI_PUT:
668 case MCI_REALIZE:
669 case MCI_UNFREEZE:
670 case MCI_UPDATE:
671 case MCI_WHERE:
672 case MCI_WINDOW:
673 case MCI_STEP:
674 case MCI_SPIN:
675 case MCI_ESCAPE:
676 case MCI_COPY:
677 case MCI_CUT:
678 case MCI_DELETE:
679 case MCI_PASTE:
680 WARN("Unsupported command=%s\n", MCI_CommandToString(wMsg));
681 break;
682 case MCI_OPEN:
683 case MCI_CLOSE:
684 FIXME("Shouldn't receive a MCI_OPEN or CLOSE message\n");
685 break;
686 default:
687 TRACE("Sending msg=%s to default driver proc\n", MCI_CommandToString(wMsg));
688 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
690 return MCIERR_UNRECOGNIZED_COMMAND;
693 /*-----------------------------------------------------------------------*/