1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 * Sample MCI CDAUDIO Wine Driver for Linux
5 * Copyright 1994 Martin Ayotte
13 #include <sys/ioctl.h>
20 #ifdef HAVE_LINUX_CDROM_H
21 # include <linux/cdrom.h>
23 #ifdef HAVE_MACHINE_SOUNDCARD_H
24 # include <machine/soundcard.h>
26 #ifdef HAVE_SYS_CDIO_H
27 # include <sys/cdio.h>
31 # define CDAUDIO_DEV "/dev/rcd0c"
33 # define CDAUDIO_DEV "/dev/cdrom"
37 # define IOCTL(a,b,c) ioctl(a,b,&c)
39 # define IOCTL(a,b,c) (c = ioctl(a,b,c) )
42 #define MAX_CDAUDIODRV (1)
43 #define MAX_CDAUDIO_TRACKS 256
45 #define CDFRAMES_PERSEC 75
46 #define CDFRAMES_PERMIN 4500
47 #define SECONDS_PERMIN 60
49 #if defined(linux) || defined(__FreeBSD__)
51 int nUseCount
; /* Incremented for each shared open */
52 BOOL16 fShareable
; /* TRUE if first open was shareable */
53 WORD wNotifyDeviceID
; /* MCI device ID with a pending notification */
54 HANDLE16 hCallback
; /* Callback handle for pending notification */
55 MCI_OPEN_PARMS16 openParms
;
59 struct cdrom_subchnl sc
;
60 #elif defined(__FreeBSD__)
61 struct cd_sub_channel_info sc
;
73 static WINE_CDAUDIO CDADev
[MAX_CDAUDIODRV
];
76 /*-----------------------------------------------------------------------*/
79 /**************************************************************************
80 * CDAUDIO_GetNumberOfTracks [internal]
82 static UINT16
CDAUDIO_GetNumberOfTracks(UINT16 wDevID
)
84 #if defined(linux) || defined(__FreeBSD__)
86 struct cdrom_tochdr hdr
;
87 #elif defined(__FreeBSD__)
88 struct ioc_toc_header hdr
;
91 if (CDADev
[wDevID
].nTracks
== 0) {
92 if (ioctl(CDADev
[wDevID
].unixdev
,
95 #elif defined(__FreeBSD__)
99 WARN(cdaudio
, "(%04X) -- Error occured !\n",
104 CDADev
[wDevID
].nTracks
= hdr
.cdth_trk1
;
105 #elif defined(__FreeBSD__)
106 CDADev
[wDevID
].nTracks
= hdr
.ending_track
- hdr
.starting_track
+ 1;
109 return CDADev
[wDevID
].nTracks
;
116 /**************************************************************************
117 * CDAUDIO_GetTracksInfo [internal]
119 static BOOL32
CDAUDIO_GetTracksInfo(UINT16 wDevID
)
121 #if defined(linux) || defined(__FreeBSD__)
123 int start
, last_start
= 0;
124 int total_length
= 0;
126 struct cdrom_tocentry entry
;
127 #elif defined(__FreeBSD__)
128 struct ioc_read_toc_entry entry
;
129 struct cd_toc_entry toc_buffer
;
132 if (CDADev
[wDevID
].nTracks
== 0) {
133 if (CDAUDIO_GetNumberOfTracks(wDevID
) == (WORD
)-1) return FALSE
;
135 TRACE(cdaudio
,"nTracks=%u\n",
136 CDADev
[wDevID
].nTracks
);
137 if (CDADev
[wDevID
].lpdwTrackLen
!= NULL
)
138 free(CDADev
[wDevID
].lpdwTrackLen
);
139 CDADev
[wDevID
].lpdwTrackLen
= (LPDWORD
)malloc(
140 (CDADev
[wDevID
].nTracks
+ 1) * sizeof(DWORD
));
141 if (CDADev
[wDevID
].lpdwTrackPos
!= NULL
)
142 free(CDADev
[wDevID
].lpdwTrackPos
);
143 CDADev
[wDevID
].lpdwTrackPos
= (LPDWORD
)malloc(
144 (CDADev
[wDevID
].nTracks
+ 1) * sizeof(DWORD
));
145 if (CDADev
[wDevID
].lpdwTrackLen
== NULL
||
146 CDADev
[wDevID
].lpdwTrackPos
== NULL
) {
147 WARN(cdaudio
, "error allocating track table !\n");
150 memset(CDADev
[wDevID
].lpdwTrackLen
, 0,
151 (CDADev
[wDevID
].nTracks
+ 1) * sizeof(DWORD
));
152 memset(CDADev
[wDevID
].lpdwTrackPos
, 0,
153 (CDADev
[wDevID
].nTracks
+ 1) * sizeof(DWORD
));
154 for (i
= 0; i
<= CDADev
[wDevID
].nTracks
; i
++) {
155 if (i
== CDADev
[wDevID
].nTracks
)
157 entry
.cdte_track
= CDROM_LEADOUT
;
158 #elif defined(__FreeBSD__)
160 entry
.starting_track
= LEADOUT
; /* XXX */
164 entry
.cdte_track
= i
+ 1;
165 #elif defined(__FreeBSD__)
166 entry
.starting_track
= i
+ 1;
169 entry
.cdte_format
= CDROM_MSF
;
170 #elif defined(__FreeBSD__)
171 bzero((char *)&toc_buffer
, sizeof(toc_buffer
));
172 entry
.address_format
= CD_MSF_FORMAT
;
173 entry
.data_len
= sizeof(toc_buffer
);
174 entry
.data
= &toc_buffer
;
176 if (ioctl(CDADev
[wDevID
].unixdev
,
179 #elif defined(__FreeBSD__)
183 WARN(cdaudio
, "error read entry\n");
187 start
= CDFRAMES_PERSEC
* (SECONDS_PERMIN
*
188 entry
.cdte_addr
.msf
.minute
+ entry
.cdte_addr
.msf
.second
) +
189 entry
.cdte_addr
.msf
.frame
;
190 #elif defined(__FreeBSD__)
191 start
= CDFRAMES_PERSEC
* (SECONDS_PERMIN
*
192 toc_buffer
.addr
.msf
.minute
+ toc_buffer
.addr
.msf
.second
) +
193 toc_buffer
.addr
.msf
.frame
;
197 CDADev
[wDevID
].dwFirstOffset
= start
;
198 TRACE(cdaudio
, "dwFirstOffset=%u\n",
202 length
= start
- last_start
;
204 start
= last_start
- length
;
205 total_length
+= length
;
206 CDADev
[wDevID
].lpdwTrackLen
[i
- 1] = length
;
207 CDADev
[wDevID
].lpdwTrackPos
[i
- 1] = start
;
208 TRACE(cdaudio
, "track #%u start=%u len=%u\n",
212 CDADev
[wDevID
].dwTotalLen
= total_length
;
213 TRACE(cdaudio
,"total_len=%u\n",
222 /**************************************************************************
223 * CDAUDIO_mciOpen [internal]
225 static DWORD
CDAUDIO_mciOpen(UINT16 wDevID
, DWORD dwFlags
, void* lp
, BOOL32 is32
)
227 #if defined(linux) || defined(__FreeBSD__)
230 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
231 wDevID
, dwFlags
, lp
);
232 if (lp
== NULL
) return MCIERR_INTERNAL
;
234 if (is32
) dwDeviceID
= ((LPMCI_OPEN_PARMS32A
)lp
)->wDeviceID
;
235 else dwDeviceID
= ((LPMCI_OPEN_PARMS16
)lp
)->wDeviceID
;
237 if (CDADev
[wDevID
].nUseCount
> 0) {
238 /* The driver already open on this channel */
239 /* If the driver was opened shareable before and this open specifies */
240 /* shareable then increment the use count */
241 if (CDADev
[wDevID
].fShareable
&& (dwFlags
& MCI_OPEN_SHAREABLE
))
242 ++CDADev
[wDevID
].nUseCount
;
244 return MCIERR_MUST_USE_SHAREABLE
;
246 CDADev
[wDevID
].nUseCount
= 1;
247 CDADev
[wDevID
].fShareable
= dwFlags
& MCI_OPEN_SHAREABLE
;
249 if (dwFlags
& MCI_OPEN_ELEMENT
) {
250 TRACE(cdaudio
,"MCI_OPEN_ELEMENT !\n");
251 /* return MCIERR_NO_ELEMENT_ALLOWED; */
256 /* memcpy(&CDADev[wDevID].openParms, lp, sizeof(MCI_OPEN_PARMS32A)); */
257 /* This is an ugly temporary, hopefully, fix. Slap it in....*/
259 LPMCI_OPEN_PARMS32A lpOpenParams
= (LPMCI_OPEN_PARMS32A
)lp
;
261 CDADev
[wDevID
].openParms
.dwCallback
= lpOpenParams
->dwCallback
;
262 CDADev
[wDevID
].openParms
.wDeviceID
= (WORD
)lpOpenParams
->wDeviceID
;
263 CDADev
[wDevID
].openParms
.wReserved0
= 0; /*????*/
264 CDADev
[wDevID
].openParms
.lpstrDeviceType
= lpOpenParams
->lpstrDeviceType
;
265 CDADev
[wDevID
].openParms
.lpstrElementName
= lpOpenParams
->lpstrElementName
;
266 CDADev
[wDevID
].openParms
.lpstrAlias
= lpOpenParams
->lpstrAlias
;
270 memcpy(&CDADev
[wDevID
].openParms
, lp
, sizeof(MCI_OPEN_PARMS16
));
273 CDADev
[wDevID
].wNotifyDeviceID
= dwDeviceID
;
274 CDADev
[wDevID
].unixdev
= open (CDAUDIO_DEV
, O_RDONLY
, 0);
275 if (CDADev
[wDevID
].unixdev
== -1) {
276 WARN(cdaudio
,"can't open '%s'!. errno=%d\n", CDAUDIO_DEV
, errno
);
277 perror( "can't open\n" );
278 return MCIERR_HARDWARE
;
280 CDADev
[wDevID
].mode
= 0;
281 CDADev
[wDevID
].dwTimeFormat
= MCI_FORMAT_TMSF
;
282 CDADev
[wDevID
].nCurTrack
= 0;
283 CDADev
[wDevID
].nTracks
= 0;
284 CDADev
[wDevID
].dwTotalLen
= 0;
285 CDADev
[wDevID
].dwFirstOffset
= 0;
286 CDADev
[wDevID
].lpdwTrackLen
= NULL
;
287 CDADev
[wDevID
].lpdwTrackPos
= NULL
;
288 if (!CDAUDIO_GetTracksInfo(wDevID
)) {
289 WARN(cdaudio
,"error reading TracksInfo !\n");
290 /* return MCIERR_INTERNAL; */
294 Moved to mmsystem.c mciOpen routine
296 if (dwFlags & MCI_NOTIFY) {
297 TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
298 lpParms->dwCallback);
299 mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
300 CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
305 return MCIERR_HARDWARE
;
309 /**************************************************************************
310 * CDAUDIO_mciClose [internal]
312 static DWORD
CDAUDIO_mciClose(UINT16 wDevID
, DWORD dwParam
, LPMCI_GENERIC_PARMS lpParms
)
314 #if defined(linux) || defined(__FreeBSD__)
315 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
316 wDevID
, dwParam
, lpParms
);
317 if (--CDADev
[wDevID
].nUseCount
== 0) {
318 if (CDADev
[wDevID
].lpdwTrackLen
!= NULL
) free(CDADev
[wDevID
].lpdwTrackLen
);
319 if (CDADev
[wDevID
].lpdwTrackPos
!= NULL
) free(CDADev
[wDevID
].lpdwTrackPos
);
320 close(CDADev
[wDevID
].unixdev
);
326 /**************************************************************************
327 * CDAUDIO_mciGetDevCaps [internal]
329 static DWORD
CDAUDIO_mciGetDevCaps(UINT16 wDevID
, DWORD dwFlags
,
330 LPMCI_GETDEVCAPS_PARMS lpParms
)
332 #if defined(linux) || defined(__FreeBSD__)
333 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
334 wDevID
, dwFlags
, lpParms
);
335 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
336 if (dwFlags
& MCI_GETDEVCAPS_ITEM
) {
337 TRACE(cdaudio
, "MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n",
339 switch(lpParms
->dwItem
) {
340 case MCI_GETDEVCAPS_CAN_RECORD
:
341 lpParms
->dwReturn
= FALSE
;
343 case MCI_GETDEVCAPS_HAS_AUDIO
:
344 lpParms
->dwReturn
= TRUE
;
346 case MCI_GETDEVCAPS_HAS_VIDEO
:
347 lpParms
->dwReturn
= FALSE
;
349 case MCI_GETDEVCAPS_DEVICE_TYPE
:
350 lpParms
->dwReturn
= MCI_DEVTYPE_CD_AUDIO
;
352 case MCI_GETDEVCAPS_USES_FILES
:
353 lpParms
->dwReturn
= FALSE
;
355 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
356 lpParms
->dwReturn
= FALSE
;
358 case MCI_GETDEVCAPS_CAN_EJECT
:
359 lpParms
->dwReturn
= TRUE
;
361 case MCI_GETDEVCAPS_CAN_PLAY
:
362 lpParms
->dwReturn
= TRUE
;
364 case MCI_GETDEVCAPS_CAN_SAVE
:
365 lpParms
->dwReturn
= FALSE
;
368 return MCIERR_UNRECOGNIZED_COMMAND
;
371 TRACE(cdaudio
, "lpParms->dwReturn=%08lX;\n",
375 return MCIERR_INTERNAL
;
379 /**************************************************************************
380 * CDAUDIO_mciInfo [internal]
382 static DWORD
CDAUDIO_mciInfo(UINT16 wDevID
, DWORD dwFlags
, LPMCI_INFO_PARMS16 lpParms
)
384 #if defined(linux) || defined(__FreeBSD__)
385 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
386 wDevID
, dwFlags
, lpParms
);
387 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
388 lpParms
->lpstrReturn
= NULL
;
390 case MCI_INFO_PRODUCT
:
391 lpParms
->lpstrReturn
= "Linux CDROM 0.5";
394 return MCIERR_UNRECOGNIZED_COMMAND
;
396 if (lpParms
->lpstrReturn
!= NULL
)
397 lpParms
->dwRetSize
= strlen(lpParms
->lpstrReturn
);
399 lpParms
->dwRetSize
= 0;
402 return MCIERR_INTERNAL
;
407 /**************************************************************************
408 * CDAUDIO_CalcFrame [internal]
410 static DWORD
CDAUDIO_CalcFrame(UINT16 wDevID
, DWORD dwFormatType
, DWORD dwTime
)
413 #if defined(linux) || defined(__FreeBSD__)
416 TRACE(cdaudio
,"(%04X, %08lX, %lu);\n",
417 wDevID
, dwFormatType
, dwTime
);
419 switch (dwFormatType
) {
420 case MCI_FORMAT_MILLISECONDS
:
421 dwFrame
= dwTime
* CDFRAMES_PERSEC
/ 1000;
422 TRACE(cdaudio
, "MILLISECONDS %lu\n",
426 TRACE(cdaudio
, "MSF %02u:%02u:%02u\n",
427 MCI_MSF_MINUTE(dwTime
), MCI_MSF_SECOND(dwTime
),
428 MCI_MSF_FRAME(dwTime
));
429 dwFrame
+= CDFRAMES_PERMIN
* MCI_MSF_MINUTE(dwTime
);
430 dwFrame
+= CDFRAMES_PERSEC
* MCI_MSF_SECOND(dwTime
);
431 dwFrame
+= MCI_MSF_FRAME(dwTime
);
434 /* unknown format ! force TMSF ! ... */
435 dwFormatType
= MCI_FORMAT_TMSF
;
436 case MCI_FORMAT_TMSF
:
437 wTrack
= MCI_TMSF_TRACK(dwTime
);
438 TRACE(cdaudio
, "MSF %02u-%02u:%02u:%02u\n",
439 MCI_TMSF_TRACK(dwTime
), MCI_TMSF_MINUTE(dwTime
),
440 MCI_TMSF_SECOND(dwTime
), MCI_TMSF_FRAME(dwTime
));
441 TRACE(cdaudio
, "TMSF trackpos[%u]=%lu\n",
442 wTrack
, CDADev
[wDevID
].lpdwTrackPos
[wTrack
- 1]);
443 dwFrame
= CDADev
[wDevID
].lpdwTrackPos
[wTrack
- 1];
444 dwFrame
+= CDFRAMES_PERMIN
* MCI_TMSF_MINUTE(dwTime
);
445 dwFrame
+= CDFRAMES_PERSEC
* MCI_TMSF_SECOND(dwTime
);
446 dwFrame
+= MCI_TMSF_FRAME(dwTime
);
454 /**************************************************************************
455 * CDAUDIO_GetCDStatus [internal]
457 static BOOL32
CDAUDIO_GetCDStatus(UINT16 wDevID
)
459 #if defined(linux) || defined(__FreeBSD__)
460 int oldmode
= CDADev
[wDevID
].mode
;
462 struct ioc_read_subchannel read_sc
;
464 read_sc
.address_format
= CD_MSF_FORMAT
;
465 read_sc
.data_format
= CD_CURRENT_POSITION
;
467 read_sc
.data_len
= sizeof(CDADev
[wDevID
].sc
);
468 read_sc
.data
= (struct cd_sub_channel_info
*)&CDADev
[wDevID
].sc
;
470 CDADev
[wDevID
].sc
.cdsc_format
= CDROM_MSF
;
472 if (ioctl(CDADev
[wDevID
].unixdev
,
474 CDROMSUBCHNL
, &CDADev
[wDevID
].sc
475 #elif defined(__FreeBSD__)
476 CDIOCREADSUBCHANNEL
, &read_sc
479 TRACE(cdaudio
,"opened or no_media !\n");
480 CDADev
[wDevID
].mode
= MCI_MODE_NOT_READY
;
485 CDADev
[wDevID
].sc
.cdsc_audiostatus
486 #elif defined(__FreeBSD__)
487 CDADev
[wDevID
].sc
.header
.audio_status
491 case CDROM_AUDIO_INVALID
:
492 #elif defined(__FreeBSD__)
493 case CD_AS_AUDIO_INVALID
:
495 WARN(cdaudio
, "device doesn't support status, returning NOT_READY.\n");
497 CDADev
[wDevID
].mode
= MCI_MODE_NOT_READY
;
498 #elif defined(__FreeBSD__)
499 CDADev
[wDevID
].mode
= MCI_MODE_STOP
;
503 case CDROM_AUDIO_NO_STATUS
:
504 #elif defined(__FreeBSD__)
505 case CD_AS_NO_STATUS
:
507 CDADev
[wDevID
].mode
= MCI_MODE_STOP
;
508 TRACE(cdaudio
,"MCI_MODE_STOP !\n");
511 case CDROM_AUDIO_PLAY
:
512 #elif defined(__FreeBSD__)
513 case CD_AS_PLAY_IN_PROGRESS
:
515 CDADev
[wDevID
].mode
= MCI_MODE_PLAY
;
516 TRACE(cdaudio
,"MCI_MODE_PLAY !\n");
519 case CDROM_AUDIO_PAUSED
:
520 #elif defined(__FreeBSD__)
521 case CD_AS_PLAY_PAUSED
:
523 CDADev
[wDevID
].mode
= MCI_MODE_PAUSE
;
524 TRACE(cdaudio
,"MCI_MODE_PAUSE !\n");
528 TRACE(cdaudio
,"status=%02X !\n",
529 CDADev
[wDevID
].sc
.cdsc_audiostatus
);
530 #elif defined(__FreeBSD__)
531 TRACE(cdaudio
,"status=%02X !\n",
532 CDADev
[wDevID
].sc
.header
.audio_status
);
536 CDADev
[wDevID
].nCurTrack
= CDADev
[wDevID
].sc
.cdsc_trk
;
537 CDADev
[wDevID
].dwCurFrame
=
538 CDFRAMES_PERMIN
* CDADev
[wDevID
].sc
.cdsc_absaddr
.msf
.minute
+
539 CDFRAMES_PERSEC
* CDADev
[wDevID
].sc
.cdsc_absaddr
.msf
.second
+
540 CDADev
[wDevID
].sc
.cdsc_absaddr
.msf
.frame
;
541 #elif defined(__FreeBSD__)
542 CDADev
[wDevID
].nCurTrack
= CDADev
[wDevID
].sc
.what
.position
.track_number
;
543 CDADev
[wDevID
].dwCurFrame
=
544 CDFRAMES_PERMIN
* CDADev
[wDevID
].sc
.what
.position
.absaddr
.msf
.minute
+
545 CDFRAMES_PERSEC
* CDADev
[wDevID
].sc
.what
.position
.absaddr
.msf
.second
+
546 CDADev
[wDevID
].sc
.what
.position
.absaddr
.msf
.frame
;
549 TRACE(cdaudio
,"%02u-%02u:%02u:%02u \n",
550 CDADev
[wDevID
].sc
.cdsc_trk
,
551 CDADev
[wDevID
].sc
.cdsc_absaddr
.msf
.minute
,
552 CDADev
[wDevID
].sc
.cdsc_absaddr
.msf
.second
,
553 CDADev
[wDevID
].sc
.cdsc_absaddr
.msf
.frame
);
554 #elif defined(__FreeBSD__)
555 TRACE(cdaudio
,"%02u-%02u:%02u:%02u \n",
556 CDADev
[wDevID
].sc
.what
.position
.track_number
,
557 CDADev
[wDevID
].sc
.what
.position
.absaddr
.msf
.minute
,
558 CDADev
[wDevID
].sc
.what
.position
.absaddr
.msf
.second
,
559 CDADev
[wDevID
].sc
.what
.position
.absaddr
.msf
.frame
);
562 if (oldmode
!= CDADev
[wDevID
].mode
&& oldmode
== MCI_MODE_OPEN
) {
563 if (!CDAUDIO_GetTracksInfo(wDevID
)) {
564 WARN(cdaudio
, "error updating TracksInfo !\n");
565 return MCIERR_INTERNAL
;
575 /**************************************************************************
576 * CDAUDIO_CalcTime [internal]
578 static DWORD
CDAUDIO_CalcTime(UINT16 wDevID
, DWORD dwFormatType
, DWORD dwFrame
)
581 #if defined(linux) || defined(__FreeBSD__)
587 TRACE(cdaudio
,"(%04X, %08lX, %lu);\n",
588 wDevID
, dwFormatType
, dwFrame
);
590 switch (dwFormatType
) {
591 case MCI_FORMAT_MILLISECONDS
:
592 dwTime
= dwFrame
/ CDFRAMES_PERSEC
* 1000;
593 TRACE(cdaudio
, "MILLISECONDS %lu\n",
597 wMinutes
= dwFrame
/ CDFRAMES_PERMIN
;
598 wSeconds
= (dwFrame
- CDFRAMES_PERMIN
* wMinutes
) / CDFRAMES_PERSEC
;
599 wFrames
= dwFrame
- CDFRAMES_PERMIN
* wMinutes
-
600 CDFRAMES_PERSEC
* wSeconds
;
601 dwTime
= MCI_MAKE_MSF(wMinutes
, wSeconds
, wFrames
);
602 TRACE(cdaudio
,"MSF %02u:%02u:%02u -> dwTime=%lu\n",
603 wMinutes
, wSeconds
, wFrames
, dwTime
);
606 /* unknown format ! force TMSF ! ... */
607 dwFormatType
= MCI_FORMAT_TMSF
;
608 case MCI_FORMAT_TMSF
:
609 for (wTrack
= 0; wTrack
< CDADev
[wDevID
].nTracks
; wTrack
++) {
610 /* dwTime += CDADev[wDevID].lpdwTrackLen[wTrack - 1];
611 TRACE(cdaudio, "Adding trk#%u curpos=%u \n", dwTime);
612 if (dwTime >= dwFrame) break; */
613 if (CDADev
[wDevID
].lpdwTrackPos
[wTrack
- 1] >= dwFrame
) break;
615 wMinutes
= dwFrame
/ CDFRAMES_PERMIN
;
616 wSeconds
= (dwFrame
- CDFRAMES_PERMIN
* wMinutes
) / CDFRAMES_PERSEC
;
617 wFrames
= dwFrame
- CDFRAMES_PERMIN
* wMinutes
-
618 CDFRAMES_PERSEC
* wSeconds
;
619 dwTime
= MCI_MAKE_TMSF(wTrack
, wMinutes
, wSeconds
, wFrames
);
620 TRACE(cdaudio
, "%02u-%02u:%02u:%02u\n",
621 wTrack
, wMinutes
, wSeconds
, wFrames
);
629 /**************************************************************************
630 * CDAUDIO_mciStatus [internal]
632 static DWORD
CDAUDIO_mciStatus(UINT16 wDevID
, DWORD dwFlags
, LPMCI_STATUS_PARMS lpParms
)
634 #if defined(linux) || defined(__FreeBSD__)
635 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
636 wDevID
, dwFlags
, lpParms
);
637 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
638 if (CDADev
[wDevID
].unixdev
== 0) return MMSYSERR_NOTENABLED
;
639 if (dwFlags
& MCI_NOTIFY
) {
640 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
641 lpParms
->dwCallback
);
642 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
643 CDADev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
645 if (dwFlags
& MCI_STATUS_ITEM
) {
646 switch(lpParms
->dwItem
) {
647 case MCI_STATUS_CURRENT_TRACK
:
648 if (!CDAUDIO_GetCDStatus(wDevID
)) return MCIERR_INTERNAL
;
649 lpParms
->dwReturn
= CDADev
[wDevID
].nCurTrack
;
650 TRACE(cdaudio
,"CURRENT_TRACK=%lu!\n", lpParms
->dwReturn
);
652 case MCI_STATUS_LENGTH
:
653 if (CDADev
[wDevID
].nTracks
== 0) {
654 if (!CDAUDIO_GetTracksInfo(wDevID
)) {
655 WARN(cdaudio
, "error reading TracksInfo !\n");
656 return MCIERR_INTERNAL
;
659 if (dwFlags
& MCI_TRACK
) {
660 TRACE(cdaudio
,"MCI_TRACK #%lu LENGTH=??? !\n",
662 if (lpParms
->dwTrack
> CDADev
[wDevID
].nTracks
)
663 return MCIERR_OUTOFRANGE
;
664 lpParms
->dwReturn
= CDADev
[wDevID
].lpdwTrackLen
[lpParms
->dwTrack
];
667 lpParms
->dwReturn
= CDADev
[wDevID
].dwTotalLen
;
668 lpParms
->dwReturn
= CDAUDIO_CalcTime(wDevID
,
669 CDADev
[wDevID
].dwTimeFormat
, lpParms
->dwReturn
);
670 TRACE(cdaudio
,"LENGTH=%lu !\n", lpParms
->dwReturn
);
672 case MCI_STATUS_MODE
:
673 if (!CDAUDIO_GetCDStatus(wDevID
)) return MCIERR_INTERNAL
;
674 lpParms
->dwReturn
= CDADev
[wDevID
].mode
;
675 TRACE(cdaudio
,"MCI_STATUS_MODE=%08lX !\n",
678 case MCI_STATUS_MEDIA_PRESENT
:
679 lpParms
->dwReturn
= (CDADev
[wDevID
].nTracks
> 0) ? TRUE
: FALSE
;
680 if (lpParms
->dwReturn
== FALSE
)
681 TRACE(cdaudio
,"MEDIA_NOT_PRESENT !\n");
683 TRACE(cdaudio
,"MCI_STATUS_MEDIA_PRESENT !\n");
685 case MCI_STATUS_NUMBER_OF_TRACKS
:
686 lpParms
->dwReturn
= CDAUDIO_GetNumberOfTracks(wDevID
);
687 TRACE(cdaudio
,"MCI_STATUS_NUMBER_OF_TRACKS = %lu !\n",
689 if (lpParms
->dwReturn
== (WORD
)-1) return MCIERR_INTERNAL
;
691 case MCI_STATUS_POSITION
:
692 if (!CDAUDIO_GetCDStatus(wDevID
)) return MCIERR_INTERNAL
;
693 lpParms
->dwReturn
= CDADev
[wDevID
].dwCurFrame
;
694 if (dwFlags
& MCI_STATUS_START
) {
695 lpParms
->dwReturn
= CDADev
[wDevID
].dwFirstOffset
;
696 TRACE(cdaudio
,"get MCI_STATUS_START !\n");
698 if (dwFlags
& MCI_TRACK
) {
699 if (lpParms
->dwTrack
> CDADev
[wDevID
].nTracks
)
700 return MCIERR_OUTOFRANGE
;
701 lpParms
->dwReturn
= CDADev
[wDevID
].lpdwTrackPos
[lpParms
->dwTrack
- 1];
702 TRACE(cdaudio
,"get MCI_TRACK #%lu !\n", lpParms
->dwTrack
);
704 lpParms
->dwReturn
= CDAUDIO_CalcTime(wDevID
,
705 CDADev
[wDevID
].dwTimeFormat
, lpParms
->dwReturn
);
706 TRACE(cdaudio
,"MCI_STATUS_POSITION=%08lX !\n",
709 case MCI_STATUS_READY
:
710 TRACE(cdaudio
,"MCI_STATUS_READY !\n");
711 lpParms
->dwReturn
= TRUE
;
713 case MCI_STATUS_TIME_FORMAT
:
714 TRACE(cdaudio
,"MCI_STATUS_TIME_FORMAT !\n");
715 lpParms
->dwReturn
= CDADev
[wDevID
].dwTimeFormat
;
718 WARN(cdaudio
, "unknown command %08lX !\n", lpParms
->dwItem
);
719 return MCIERR_UNRECOGNIZED_COMMAND
;
722 WARN(cdaudio
, "not MCI_STATUS_ITEM !\n");
725 return MMSYSERR_NOTENABLED
;
730 /**************************************************************************
731 * CDAUDIO_mciPlay [internal]
733 static DWORD
CDAUDIO_mciPlay(UINT16 wDevID
, DWORD dwFlags
, LPMCI_PLAY_PARMS lpParms
)
735 #if defined(linux) || defined(__FreeBSD__)
738 struct cdrom_msf msf
;
739 #elif defined(__FreeBSD__)
740 struct ioc_play_msf msf
;
743 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
744 wDevID
, dwFlags
, lpParms
);
745 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
746 if (CDADev
[wDevID
].unixdev
== 0) return MMSYSERR_NOTENABLED
;
747 start
= 0; end
= CDADev
[wDevID
].dwTotalLen
;
748 CDADev
[wDevID
].nCurTrack
= 1;
749 if (dwFlags
& MCI_FROM
) {
750 start
= CDAUDIO_CalcFrame(wDevID
,
751 CDADev
[wDevID
].dwTimeFormat
, lpParms
->dwFrom
);
752 TRACE(cdaudio
,"MCI_FROM=%08lX -> %u \n",
753 lpParms
->dwFrom
, start
);
755 if (dwFlags
& MCI_TO
) {
756 end
= CDAUDIO_CalcFrame(wDevID
,
757 CDADev
[wDevID
].dwTimeFormat
, lpParms
->dwTo
);
758 TRACE(cdaudio
, "MCI_TO=%08lX -> %u \n",
761 start
+= CDADev
[wDevID
].dwFirstOffset
;
762 end
+= CDADev
[wDevID
].dwFirstOffset
;
764 msf
.cdmsf_min0
= start
/ CDFRAMES_PERMIN
;
765 msf
.cdmsf_sec0
= (start
% CDFRAMES_PERMIN
) / CDFRAMES_PERSEC
;
766 msf
.cdmsf_frame0
= start
% CDFRAMES_PERSEC
;
767 msf
.cdmsf_min1
= end
/ CDFRAMES_PERMIN
;
768 msf
.cdmsf_sec1
= (end
% CDFRAMES_PERMIN
) / CDFRAMES_PERSEC
;
769 msf
.cdmsf_frame1
= end
% CDFRAMES_PERSEC
;
770 #elif defined(__FreeBSD__)
771 msf
.start_m
= start
/ CDFRAMES_PERMIN
;
772 msf
.start_s
= (start
% CDFRAMES_PERMIN
) / CDFRAMES_PERSEC
;
773 msf
.start_f
= start
% CDFRAMES_PERSEC
;
774 msf
.end_m
= end
/ CDFRAMES_PERMIN
;
775 msf
.end_s
= (end
% CDFRAMES_PERMIN
) / CDFRAMES_PERSEC
;
776 msf
.end_f
= end
% CDFRAMES_PERSEC
;
778 if (ioctl(CDADev
[wDevID
].unixdev
,
781 #elif defined(__FreeBSD__)
785 WARN(cdaudio
, "motor doesn't start !\n");
786 return MCIERR_HARDWARE
;
788 if (ioctl(CDADev
[wDevID
].unixdev
,
791 #elif defined(__FreeBSD__)
795 WARN(cdaudio
, "device doesn't play !\n");
796 return MCIERR_HARDWARE
;
799 TRACE(cdaudio
,"msf = %d:%d:%d %d:%d:%d\n",
800 msf
.cdmsf_min0
, msf
.cdmsf_sec0
, msf
.cdmsf_frame0
,
801 msf
.cdmsf_min1
, msf
.cdmsf_sec1
, msf
.cdmsf_frame1
);
802 #elif defined(__FreeBSD__)
803 TRACE(cdaudio
,"msf = %d:%d:%d %d:%d:%d\n",
804 msf
.start_m
, msf
.start_s
, msf
.start_f
,
805 msf
.end_m
, msf
.end_s
, msf
.end_f
);
807 CDADev
[wDevID
].mode
= MCI_MODE_PLAY
;
808 if (dwFlags
& MCI_NOTIFY
) {
809 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
810 lpParms
->dwCallback
);
812 mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
813 CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
818 return MCIERR_HARDWARE
;
822 /**************************************************************************
823 * CDAUDIO_mciStop [internal]
825 static DWORD
CDAUDIO_mciStop(UINT16 wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
827 #if defined(linux) || defined(__FreeBSD__)
828 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
829 wDevID
, dwFlags
, lpParms
);
830 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
831 if (ioctl(CDADev
[wDevID
].unixdev
,
834 #elif defined(__FreeBSD__)
837 )) return MCIERR_HARDWARE
;
838 CDADev
[wDevID
].mode
= MCI_MODE_STOP
;
839 if (dwFlags
& MCI_NOTIFY
) {
840 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
841 lpParms
->dwCallback
);
842 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
843 CDADev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
847 return MCIERR_HARDWARE
;
851 /**************************************************************************
852 * CDAUDIO_mciPause [internal]
854 static DWORD
CDAUDIO_mciPause(UINT16 wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
856 #if defined(linux) || defined(__FreeBSD__)
857 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
858 wDevID
, dwFlags
, lpParms
);
859 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
860 if (ioctl(CDADev
[wDevID
].unixdev
,
863 #elif defined(__FreeBSD__)
866 )) return MCIERR_HARDWARE
;
867 CDADev
[wDevID
].mode
= MCI_MODE_PAUSE
;
868 if (dwFlags
& MCI_NOTIFY
) {
869 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
870 lpParms
->dwCallback
);
871 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
872 CDADev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
876 return MCIERR_HARDWARE
;
880 /**************************************************************************
881 * CDAUDIO_mciResume [internal]
883 static DWORD
CDAUDIO_mciResume(UINT16 wDevID
, DWORD dwFlags
, LPMCI_GENERIC_PARMS lpParms
)
885 #if defined(linux) || defined(__FreeBSD__)
886 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
887 wDevID
, dwFlags
, lpParms
);
888 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
889 if (ioctl(CDADev
[wDevID
].unixdev
,
892 #elif defined(__FreeBSD__)
895 )) return MCIERR_HARDWARE
;
896 CDADev
[wDevID
].mode
= MCI_MODE_STOP
;
897 if (dwFlags
& MCI_NOTIFY
) {
898 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
899 lpParms
->dwCallback
);
900 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
901 CDADev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
905 return MCIERR_HARDWARE
;
909 /**************************************************************************
910 * CDAUDIO_mciSeek [internal]
912 static DWORD
CDAUDIO_mciSeek(UINT16 wDevID
, DWORD dwFlags
, LPMCI_SEEK_PARMS lpParms
)
914 #if defined(linux) || defined(__FreeBSD__)
916 MCI_PLAY_PARMS PlayParms
;
917 TRACE(cdaudio
,"(%04X, %08lX, %p);\n",
918 wDevID
, dwFlags
, lpParms
);
919 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
920 if (ioctl(CDADev
[wDevID
].unixdev
,
923 #elif defined(__FreeBSD__)
927 perror("ioctl CDROMRESUME");
928 return MCIERR_HARDWARE
;
930 CDADev
[wDevID
].mode
= MCI_MODE_SEEK
;
932 case MCI_SEEK_TO_START
:
933 PlayParms
.dwFrom
= 0;
935 case MCI_SEEK_TO_END
:
936 PlayParms
.dwFrom
= CDADev
[wDevID
].dwTotalLen
;
939 PlayParms
.dwFrom
= lpParms
->dwTo
;
942 dwRet
= CDAUDIO_mciPlay(wDevID
, MCI_WAIT
| MCI_FROM
, &PlayParms
);
943 if (dwRet
!= 0) return dwRet
;
944 dwRet
= CDAUDIO_mciStop(wDevID
, MCI_WAIT
, (LPMCI_GENERIC_PARMS
)&PlayParms
);
945 if (dwFlags
& MCI_NOTIFY
) {
946 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
947 lpParms
->dwCallback
);
948 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
949 CDADev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
953 return MCIERR_HARDWARE
;
958 /**************************************************************************
959 * CDAUDIO_mciSet [internal]
961 static DWORD
CDAUDIO_mciSet(UINT16 wDevID
, DWORD dwFlags
, LPMCI_SET_PARMS lpParms
)
963 #if defined(linux) || defined(__FreeBSD__)
964 TRACE(cdaudio
,"(%04X, %08lX, %p);\n", wDevID
, dwFlags
, lpParms
);
965 if (lpParms
== NULL
) return MCIERR_INTERNAL
;
967 TRACE(cdaudio,"dwTimeFormat=%08lX\n", lpParms->dwTimeFormat);
968 TRACE(cdaudio,"dwAudio=%08lX\n", lpParms->dwAudio);
970 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
971 switch (lpParms
->dwTimeFormat
) {
972 case MCI_FORMAT_MILLISECONDS
:
973 TRACE(cdaudio
, "MCI_FORMAT_MILLISECONDS !\n");
976 TRACE(cdaudio
,"MCI_FORMAT_MSF !\n");
978 case MCI_FORMAT_TMSF
:
979 TRACE(cdaudio
,"MCI_FORMAT_TMSF !\n");
982 WARN(cdaudio
, "bad time format !\n");
983 return MCIERR_BAD_TIME_FORMAT
;
985 CDADev
[wDevID
].dwTimeFormat
= lpParms
->dwTimeFormat
;
987 if (dwFlags
& MCI_SET_DOOR_OPEN
) {
988 TRACE(cdaudio
, "MCI_SET_DOOR_OPEN !\n");
990 if (ioctl(CDADev
[wDevID
].unixdev
, CDIOCALLOW
)) return MCIERR_HARDWARE
;
991 if (ioctl(CDADev
[wDevID
].unixdev
, CDIOCEJECT
)) return MCIERR_HARDWARE
;
992 if (ioctl(CDADev
[wDevID
].unixdev
, CDIOCPREVENT
)) return MCIERR_HARDWARE
;
994 if (ioctl(CDADev
[wDevID
].unixdev
, CDROMEJECT
)) return MCIERR_HARDWARE
;
996 CDADev
[wDevID
].nTracks
= 0;
998 if (dwFlags
& MCI_SET_DOOR_CLOSED
) {
999 TRACE(cdaudio
, "MCI_SET_DOOR_CLOSED !\n");
1001 if (ioctl(CDADev
[wDevID
].unixdev
, CDIOCALLOW
)) return MCIERR_HARDWARE
;
1002 if (ioctl(CDADev
[wDevID
].unixdev
, CDIOCCLOSE
)) return MCIERR_HARDWARE
;
1003 if (ioctl(CDADev
[wDevID
].unixdev
, CDIOCPREVENT
)) return MCIERR_HARDWARE
;
1005 if (ioctl(CDADev
[wDevID
].unixdev
, CDROMEJECT
)) return MCIERR_HARDWARE
;
1006 /* XXX should it be ",1" ??? */
1008 CDADev
[wDevID
].nTracks
= 0;
1010 if (dwFlags
& MCI_SET_VIDEO
) return MCIERR_UNSUPPORTED_FUNCTION
;
1011 if (dwFlags
& MCI_SET_ON
) return MCIERR_UNSUPPORTED_FUNCTION
;
1012 if (dwFlags
& MCI_SET_OFF
) return MCIERR_UNSUPPORTED_FUNCTION
;
1013 if (dwFlags
& MCI_NOTIFY
) {
1014 TRACE(cdaudio
, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
1015 lpParms
->dwCallback
);
1016 mciDriverNotify((HWND16
)LOWORD(lpParms
->dwCallback
),
1017 CDADev
[wDevID
].wNotifyDeviceID
, MCI_NOTIFY_SUCCESSFUL
);
1021 return MCIERR_HARDWARE
;
1026 /**************************************************************************
1027 * CDAUDIO_DriverProc16 [sample driver]
1029 LONG
CDAUDIO_DriverProc16(DWORD dwDevID
, HDRVR16 hDriv
, WORD wMsg
,
1030 DWORD dwParam1
, DWORD dwParam2
)
1032 #if defined(linux) || defined(__FreeBSD__)
1034 case DRV_LOAD
: return 1;
1035 case DRV_FREE
: return 1;
1037 case MCI_OPEN_DRIVER
:
1038 case MCI_OPEN
: return CDAUDIO_mciOpen(dwDevID
, dwParam1
, (LPMCI_OPEN_PARMS16
)PTR_SEG_TO_LIN(dwParam2
), FALSE
);
1040 case MCI_CLOSE_DRIVER
:
1041 case MCI_CLOSE
: return CDAUDIO_mciClose(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1042 case DRV_ENABLE
: return 1;
1043 case DRV_DISABLE
: return 1;
1044 case DRV_QUERYCONFIGURE
: return 1;
1045 case DRV_CONFIGURE
: MessageBox16(0, "Sample MultiMedia Linux Driver !", "MMLinux Driver", MB_OK
); return 1;
1046 case DRV_INSTALL
: return DRVCNF_RESTART
;
1047 case DRV_REMOVE
: return DRVCNF_RESTART
;
1048 case MCI_GETDEVCAPS
: return CDAUDIO_mciGetDevCaps(dwDevID
, dwParam1
, (LPMCI_GETDEVCAPS_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1049 case MCI_INFO
: return CDAUDIO_mciInfo(dwDevID
, dwParam1
, (LPMCI_INFO_PARMS16
)PTR_SEG_TO_LIN(dwParam2
));
1050 case MCI_STATUS
: return CDAUDIO_mciStatus(dwDevID
, dwParam1
, (LPMCI_STATUS_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1051 case MCI_SET
: return CDAUDIO_mciSet(dwDevID
, dwParam1
, (LPMCI_SET_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1052 case MCI_PLAY
: return CDAUDIO_mciPlay(dwDevID
, dwParam1
, (LPMCI_PLAY_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1053 case MCI_STOP
: return CDAUDIO_mciStop(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1054 case MCI_PAUSE
: return CDAUDIO_mciPause(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1055 case MCI_RESUME
: return CDAUDIO_mciResume(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1056 case MCI_SEEK
: return CDAUDIO_mciSeek(dwDevID
, dwParam1
, (LPMCI_SEEK_PARMS
)PTR_SEG_TO_LIN(dwParam2
));
1057 case MCI_SET_DOOR_OPEN
: TRACE(cdaudio
, "MCI_SET_DOOR_OPEN !\n");
1059 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCALLOW
)) return MCIERR_HARDWARE
;
1060 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCEJECT
)) return MCIERR_HARDWARE
;
1061 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCPREVENT
)) return MCIERR_HARDWARE
;
1063 if (ioctl(CDADev
[dwDevID
].unixdev
, CDROMEJECT
)) return MCIERR_HARDWARE
;
1065 CDADev
[dwDevID
].nTracks
= 0;
1067 case MCI_SET_DOOR_CLOSED
: TRACE(cdaudio
,"MCI_SET_DOOR_CLOSED !\n");
1069 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCALLOW
)) return MCIERR_HARDWARE
;
1070 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCCLOSE
)) return MCIERR_HARDWARE
;
1071 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCPREVENT
)) return MCIERR_HARDWARE
;
1073 if (ioctl(CDADev
[dwDevID
].unixdev
, CDROMEJECT
, 1)) return MCIERR_HARDWARE
;
1075 CDADev
[dwDevID
].nTracks
= 0;
1078 return DefDriverProc16(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
1081 return MCIERR_HARDWARE
;
1084 /**************************************************************************
1085 * CDAUDIO_DriverProc32 [sample driver]
1087 LONG
CDAUDIO_DriverProc32(DWORD dwDevID
, HDRVR16 hDriv
, DWORD wMsg
,
1088 DWORD dwParam1
, DWORD dwParam2
)
1090 #if defined(linux) || defined(__FreeBSD__)
1092 case DRV_LOAD
: return 1;
1093 case DRV_FREE
: return 1;
1095 case MCI_OPEN_DRIVER
:
1096 case MCI_OPEN
: return CDAUDIO_mciOpen(dwDevID
, dwParam1
, (LPMCI_OPEN_PARMS32A
)dwParam2
, TRUE
);
1098 case MCI_CLOSE_DRIVER
:
1099 case MCI_CLOSE
: return CDAUDIO_mciClose(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)dwParam2
);
1100 case DRV_ENABLE
: return 1;
1101 case DRV_DISABLE
: return 1;
1102 case DRV_QUERYCONFIGURE
: return 1;
1103 case DRV_CONFIGURE
: MessageBox16(0, "Sample MultiMedia Linux Driver !", "MMLinux Driver", MB_OK
); return 1;
1104 case DRV_INSTALL
: return DRVCNF_RESTART
;
1105 case DRV_REMOVE
: return DRVCNF_RESTART
;
1106 case MCI_GETDEVCAPS
: return CDAUDIO_mciGetDevCaps(dwDevID
, dwParam1
, (LPMCI_GETDEVCAPS_PARMS
)dwParam2
);
1107 case MCI_INFO
: return CDAUDIO_mciInfo(dwDevID
, dwParam1
, (LPMCI_INFO_PARMS16
)dwParam2
);
1108 case MCI_STATUS
: return CDAUDIO_mciStatus(dwDevID
, dwParam1
, (LPMCI_STATUS_PARMS
)dwParam2
);
1109 case MCI_SET
: return CDAUDIO_mciSet(dwDevID
, dwParam1
, (LPMCI_SET_PARMS
)dwParam2
);
1110 case MCI_PLAY
: return CDAUDIO_mciPlay(dwDevID
, dwParam1
, (LPMCI_PLAY_PARMS
)dwParam2
);
1111 case MCI_STOP
: return CDAUDIO_mciStop(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)dwParam2
);
1112 case MCI_PAUSE
: return CDAUDIO_mciPause(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)dwParam2
);
1113 case MCI_RESUME
: return CDAUDIO_mciResume(dwDevID
, dwParam1
, (LPMCI_GENERIC_PARMS
)dwParam2
);
1114 case MCI_SEEK
: return CDAUDIO_mciSeek(dwDevID
, dwParam1
, (LPMCI_SEEK_PARMS
)dwParam2
);
1115 case MCI_SET_DOOR_OPEN
: TRACE(cdaudio
, "MCI_SET_DOOR_OPEN !\n");
1117 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCALLOW
)) return MCIERR_HARDWARE
;
1118 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCEJECT
)) return MCIERR_HARDWARE
;
1119 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCPREVENT
)) return MCIERR_HARDWARE
;
1121 if (ioctl(CDADev
[dwDevID
].unixdev
, CDROMEJECT
)) return MCIERR_HARDWARE
;
1123 CDADev
[dwDevID
].nTracks
= 0;
1125 case MCI_SET_DOOR_CLOSED
: TRACE(cdaudio
,"MCI_SET_DOOR_CLOSED !\n");
1127 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCALLOW
)) return MCIERR_HARDWARE
;
1128 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCCLOSE
)) return MCIERR_HARDWARE
;
1129 if (ioctl(CDADev
[dwDevID
].unixdev
, CDIOCPREVENT
)) return MCIERR_HARDWARE
;
1131 if (ioctl(CDADev
[dwDevID
].unixdev
, CDROMEJECT
, 1)) return MCIERR_HARDWARE
;
1133 CDADev
[dwDevID
].nTracks
= 0;
1136 return DefDriverProc32(dwDevID
, hDriv
, wMsg
, dwParam1
, dwParam2
);
1139 return MCIERR_HARDWARE
;
1144 /*-----------------------------------------------------------------------*/