wine/multimedia/mcicda.c
Alexandre Julliard a845b88ead Release 980601
Sun May 31 13:40:13 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [if1632/signal.c]
	Added display of exception name.

	* [loader/task.c]
	Yet another attempt at fixing SwitchStackTo/SwitchStackBack.

	* [memory/selector.c] [relay32/builtin32.c] [tools/build.c]
	  [win32/kernel32.c]
	Generate an assembly stub for Win32 register functions to make
	their names available at link time.

	* [programs/*/Makefile.in]
	Added hacks to support old resource compiler.

Fri May 29 16:27:14 1998  Marcus Meissner <marcus@jet.franken.de>

	* [tools/testrun]
	Merge of my testscripts at home into one single perl program
	(tested with perl5). Works only on Linux due to 'ps' and 'ipcs'
	magic.

	* [controls/menu.c]
	Added some DefaultMenuItem stubs.

	* [debugger/stabs.c]
	Fixed stabs loading, now supports (int,int) typeinfo format used
	by gcc-2.8 and egcs-1. If it still crashes, please mail me.

	* [if1632/][relay32/]
	Added msvideo.dll (stubs only)
	Replaced some ptr by str for stringcases
	Added some new stubs (VxDCall, FindCloseNotif....)

	* [misc/network.c]
	Some argument fixes.

	* [misc/registry.c][misc/cpu.c]
	Registry initialization partially rewritten and enhanced.

	* [scheduler/*.c]
	Some additions so we don't do kill(0,SIGUSR1) (kill processgroup
	instead of targeted thread)
	Added SetThreadContext.

Thu May 28 23:59:59 1998  Bertho Stultiens <bertho@akhphd.au.dk>

	* [tools/wrc/*]
	New resource compiler version 1.0.0 (28-May-1998)

	* [Make.rules.in] [Makefile.in]
	Changed and added rc rules to point to tools/wrc/wrc.

	* [configure.in] [include/config.h.in]
	Added check for function 'stricmp'.

	* [include/resource.h]
	Commented out the old resource structure to catch references.
	It also includes wrc_rsc.h.

	* [include/wrc_rsc.h]
	New file. Definitions for the resources generated with wrc.

	* [include/windows.h]
	Added #ifdef RC_INVOKED to exclude stdarg.h.
	Added SS_NOTIFY flag.

	* [include/winnls.h]
	Added SUBLANG_* definitions and corrected some defaults.

	* [loader/libres.c]
	Changed the sysres load functions to support wrc generated
	resources.

	* [resource/sysres_*.rc]
	Added #include <windows.h>

	* [resource/sysres.c]
	Changed declarations to match wrc's output

	* [resource/Makefile.in]
	Changed rules to work with wrc.

	* [tools/makedep.c]
	Changed generation of .rc file dependencies to .s target.

Thu May 28 22:28:39 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [files/file.c][include/windows.c][relay32/kernel32.spec]
	Implemented GetFileAttributesEx32A/W.

	* [misc/imagelist.h][include/commctrl.h][relay32/comctl32.spec]
	Added ImageList_Read and ImageList_Write stubs.
	Added ImageList_AddIcon function.
	Added ImageList_LoadImage. It is the same as ImageList_LoadImage32A.

	* [controls/header.c]
	Fixed bitmap drawing bug.
	Added full bitmap support.

	* [include/commctrl.h]
	Added missing header macros.

	* [controls/toolbar.c][include/toolbar.h][include/commctrl.h]
	  [controls/commctrl.c] [relay32/comctl32.spec]
	First implementation of toolbar control.
	Implemented CreateToolbar, CreateToolbarEx and CreateMappedBitmap.

	* [controls/progress.c][controls/status.c]
	Some code cleanup.

	* [controls/commctrl.c][include/commctrl.h][relay32/comctl32.spec]
	Removed CreateStatusWindow16 and DrawStatusText16.
	CreateStatusWindow is the same as CreateStatusWindow32A.
	DrawStatusText is the same as DrawStatusText32A.

Thu May 28 16:01:28 1998  Matthew J. Francis  <asbel@dial.pipex.com>

	* [objects/bitmap.c] [objects/bitmap.h] [objects/oembitmap.c]
	  [objects/dc.c] [graphics/x11drv/bitblt.c]
	Added partial implementation of CreateDIBSection, with great thanks
	to Ulrich Weigand <weigand@informatik.uni-erlangen.de> for
	contributing the bulk of the patch.

Wed May 27 19:04:31 1998  Ulrich Weigand <weigand@informatik.uni-erlangen.de>

	* [win32/kernel32.c] [if1632/thunk.c] [include/flatthunk.h]
	ThunkConnect16 and related functions moved to emulator.

	* [loader/ne/segment.c]
	Call DllEntryPoint with correct arguments.

	* [relay32/builtin32.c]
	Bugfix: Relay debugging did not work for multiple processes.

	* [controls/menu.c]
	Bugfix: dwItemData was not set for MF_OWNERDRAW menus.

	* [if1632/relay.c] [relay32/relay386.c]
	Relay messages converted to use DPRINTF.

	* [controls/desktop.c] [relay32/user32.spec]
	Implemented PaintDesktop.

	* [files/profile.c] [if1632/kernel.spec] [misc/network.c]
	  [misc/printdrv.c] [relay32/winspool.spec] 
	  [win32/ordinals.c] [relay32/kernel32.spec]
	Some stubs added.

	* [relay32/mpr.spec]
	All ordinals were off by one.

Tue May 26 13:32:57 1998  Bill Hawes <whawes@star.net>

	* [misc/lstr.c] [include/casemap.h] [tools/unimap.pl]
	Added Unicode case conversion routines towupper/towlower,
	with mapping tables casemap.h created by tools/unimap.pl.

	* [misc/ntdll.c] [include/winnls.h] [relay32/ntdll.spec]
	  [relay32/advapi.spec]
	Minimal implementation of IsTextUnicode, just enough to get
	NT4 notepad to open ascii/unicode files.

	* [Make.rules.in] [resources/sysres_En.rc]
	Added include file dlgs.h for building resource files, so that
	resources can refer to defined values (e.g. pshHelp).

	* [misc/crtdll.c] [relay32/crtdll.spec]
	Use towupper/towlower for 32W case conversions.

	* [memory/string.c]
	Use towupper for 32W case conversions.

	* [ole/ole2nls.c]
	Use towupper for 32W case conversions; fix mem leak; minor cleanup

	* [controls/edit.c]
	Added soft break flag to edit state. Print unknown action values
	for WM_VSCROLL (action 190 occurs when running NT4 notepad.)

Mon May 25 22:42:40 1998  Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>

	* [files/file.c]
	Care for a pathological case in SetFilePointer.

	* [graphics/x11drv/xfont.c]
	Handle longer Font names in LFD_ComposeLFD and try to catch errors.

	* [loader/pe_image.c]
	Unload Dummymodule when PE_LoadLibraryEx32A fails with
	PE_LoadImage (makes Encarta 98 installer proceed).

	* [misc/registry.c]
	Move a check for a special case in RegCreateKeyEx32W after the
	check for existence.

Tue May 25 20:18:26 1998  Matthew Becker <mbecker@glasscity.net>

	* [misc/ntdll.c]
	Added some stubs, just guessing at the size of their param lists.

	* [misc/registry.c]
	Added stubs for RegUnLoadKey, RegSetKeySecurity, RegSaveKey,
	RegRestoreKey, and RegReplaceKey

	* [programs/regtest/regtest.c]
	Updated registry testing program.

Sun May 24 18:11:40 1998  Alex Priem <alexp@sci.kun.nl>

	* [file/profile.c]
	Added flag 'return_values' to PROFILE_GetSection.

Sun May 24 13:41:10 1998  James Juran <jrj120@psu.edu>

	* [misc/shell.c] [files/directory.c]
	Documentation/debugging info additions.

	* [*/*.c] [include/*.h]
	Moved many extern function definitions to appropriate header files.
	Cleaned up a few compile warnings.
	If #include "debug.h" is present, removed #include <stdio.h>.
	debug.h includes stdio.h, so it is not necessary to include both.

	* [graphics/*.c] [if1632/signal.c] [ipc/*.c] [scheduler/*.c]
	  [win32/*.c] [windows/*.c]
	Final patch to convert fprintf statements to new debugging interface.
	Some fprintfs are still left, especially in the debugger/ directory.
	However, IMHO, it's not worth the effort to change the rest.

Fri May 22 21:58:35 1998  Morten Welinder  <terra@diku.dk>

	* [windows/keyboard.c]
	Correct handling of keys "`-=[]\;',./".

Fri May 22 12:06:00 1998  Per Lindström <pelinstr@algonet.se>

	* [include/windows.h] [relay32/kernel32.spec] [win32/console.c]
	Added stub for ReadConsoleOutputCharacter32A.

Thu May 21 16:45:48 1998  Pascal Cuoq <pcuoq@ens-lyon.fr>

	* [ole/ole2nls.c]
	Began better implementation of LCMapString32A.
	Not very well tested yet, and still need improvements.

	* [controls/scroll.c]
	Documented functions.

Wed May 20 21:37:56 1998  Peter Hunnisett <hunnise@nortel.ca>

	* [include/windows.h][misc/main.c]
	Change SystemParameterInfo to support SPI_GETHIGHCONTRAST. Also
	include some missing SPI_ definitions.

	* [include/dsound.h][multimedia/dsound.c][relay32/dplayx.spec]
	Added stubs for DirectPlayLobbyCreate[AW]. Not sure if these
	should go into a new files dplayx.c? Anyone care?

	* [include/winnls.h]
	Added two missing flags for the CompareString32 functions.
1998-06-01 10:44:35 +00:00

1092 lines
32 KiB
C

/*
* Sample MCI CDAUDIO Wine Driver for Linux
*
* Copyright 1994 Martin Ayotte
*/
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "windows.h"
#include "user.h"
#include "driver.h"
#include "mmsystem.h"
#include "debug.h"
#ifdef HAVE_LINUX_CDROM_H
# include <linux/cdrom.h>
#endif
#ifdef HAVE_MACHINE_SOUNDCARD_H
# include <machine/soundcard.h>
#endif
#ifdef HAVE_SYS_CDIO_H
# include <sys/cdio.h>
#endif
#ifdef __FreeBSD__
# define CDAUDIO_DEV "/dev/rcd0c"
#else
# define CDAUDIO_DEV "/dev/cdrom"
#endif
#ifdef SOUND_VERSION
# define IOCTL(a,b,c) ioctl(a,b,&c)
#else
# define IOCTL(a,b,c) (c = ioctl(a,b,c) )
#endif
#define MAX_CDAUDIODRV (1)
#define MAX_CDAUDIO_TRACKS 256
#define CDFRAMES_PERSEC 75
#define CDFRAMES_PERMIN 4500
#define SECONDS_PERMIN 60
#if defined(linux) || defined(__FreeBSD__)
typedef struct {
int nUseCount; /* Incremented for each shared open */
BOOL16 fShareable; /* TRUE if first open was shareable */
WORD wNotifyDeviceID; /* MCI device ID with a pending notification */
HANDLE16 hCallback; /* Callback handle for pending notification */
MCI_OPEN_PARMS16 openParms;
DWORD dwTimeFormat;
int unixdev;
#ifdef linux
struct cdrom_subchnl sc;
#elif __FreeBSD__
struct cd_sub_channel_info sc;
#endif
int mode;
UINT16 nCurTrack;
DWORD dwCurFrame;
UINT16 nTracks;
DWORD dwTotalLen;
LPDWORD lpdwTrackLen;
LPDWORD lpdwTrackPos;
DWORD dwFirstOffset;
} LINUX_CDAUDIO;
static LINUX_CDAUDIO CDADev[MAX_CDAUDIODRV];
#endif
/*-----------------------------------------------------------------------*/
/**************************************************************************
* CDAUDIO_GetNumberOfTracks [internal]
*/
static UINT16 CDAUDIO_GetNumberOfTracks(UINT16 wDevID)
{
#if defined(linux) || defined(__FreeBSD__)
#ifdef linux
struct cdrom_tochdr hdr;
#elif __FreeBSD__
struct ioc_toc_header hdr;
#endif
if (CDADev[wDevID].nTracks == 0) {
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMREADTOCHDR
#elif __FreeBSD__
CDIOREADTOCHEADER
#endif
, &hdr)) {
WARN(cdaudio, "(%04X) -- Error occured !\n",
wDevID);
return (WORD)-1;
}
#ifdef linux
CDADev[wDevID].nTracks = hdr.cdth_trk1;
#elif __FreeBSD__
CDADev[wDevID].nTracks = hdr.ending_track - hdr.starting_track + 1;
#endif
}
return CDADev[wDevID].nTracks;
#else
return (WORD)-1;
#endif
}
/**************************************************************************
* CDAUDIO_GetTracksInfo [internal]
*/
static BOOL32 CDAUDIO_GetTracksInfo(UINT16 wDevID)
{
#if defined(linux) || defined(__FreeBSD__)
int i, length;
int start, last_start = 0;
int total_length = 0;
#ifdef linux
struct cdrom_tocentry entry;
#elif __FreeBSD__
struct ioc_read_toc_entry entry;
struct cd_toc_entry toc_buffer;
#endif
if (CDADev[wDevID].nTracks == 0) {
if (CDAUDIO_GetNumberOfTracks(wDevID) == (WORD)-1) return FALSE;
}
TRACE(cdaudio,"nTracks=%u\n",
CDADev[wDevID].nTracks);
if (CDADev[wDevID].lpdwTrackLen != NULL)
free(CDADev[wDevID].lpdwTrackLen);
CDADev[wDevID].lpdwTrackLen = (LPDWORD)malloc(
(CDADev[wDevID].nTracks + 1) * sizeof(DWORD));
if (CDADev[wDevID].lpdwTrackPos != NULL)
free(CDADev[wDevID].lpdwTrackPos);
CDADev[wDevID].lpdwTrackPos = (LPDWORD)malloc(
(CDADev[wDevID].nTracks + 1) * sizeof(DWORD));
if (CDADev[wDevID].lpdwTrackLen == NULL ||
CDADev[wDevID].lpdwTrackPos == NULL) {
WARN(cdaudio, "error allocating track table !\n");
return FALSE;
}
memset(CDADev[wDevID].lpdwTrackLen, 0,
(CDADev[wDevID].nTracks + 1) * sizeof(DWORD));
memset(CDADev[wDevID].lpdwTrackPos, 0,
(CDADev[wDevID].nTracks + 1) * sizeof(DWORD));
for (i = 0; i <= CDADev[wDevID].nTracks; i++) {
if (i == CDADev[wDevID].nTracks)
#ifdef linux
entry.cdte_track = CDROM_LEADOUT;
#elif __FreeBSD__
#define LEADOUT 0xaa
entry.starting_track = LEADOUT; /* XXX */
#endif
else
#ifdef linux
entry.cdte_track = i + 1;
#elif __FreeBSD__
entry.starting_track = i + 1;
#endif
#ifdef linux
entry.cdte_format = CDROM_MSF;
#elif __FreeBSD__
bzero((char *)&toc_buffer, sizeof(toc_buffer));
entry.address_format = CD_MSF_FORMAT;
entry.data_len = sizeof(toc_buffer);
entry.data = &toc_buffer;
#endif
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMREADTOCENTRY
#elif __FreeBSD__
CDIOREADTOCENTRYS
#endif
, &entry)) {
WARN(cdaudio, "error read entry\n");
return FALSE;
}
#ifdef linux
start = CDFRAMES_PERSEC * (SECONDS_PERMIN *
entry.cdte_addr.msf.minute + entry.cdte_addr.msf.second) +
entry.cdte_addr.msf.frame;
#elif __FreeBSD__
start = CDFRAMES_PERSEC * (SECONDS_PERMIN *
toc_buffer.addr.msf.minute + toc_buffer.addr.msf.second) +
toc_buffer.addr.msf.frame;
#endif
if (i == 0) {
last_start = start;
CDADev[wDevID].dwFirstOffset = start;
TRACE(cdaudio, "dwFirstOffset=%u\n",
start);
}
else {
length = start - last_start;
last_start = start;
start = last_start - length;
total_length += length;
CDADev[wDevID].lpdwTrackLen[i - 1] = length;
CDADev[wDevID].lpdwTrackPos[i - 1] = start;
TRACE(cdaudio, "track #%u start=%u len=%u\n",
i, start, length);
}
}
CDADev[wDevID].dwTotalLen = total_length;
TRACE(cdaudio,"total_len=%u\n",
total_length);
return TRUE;
#else
return FALSE;
#endif
}
/**************************************************************************
* CDAUDIO_mciOpen [internal]
*/
static DWORD CDAUDIO_mciOpen(UINT16 wDevID, DWORD dwFlags, LPMCI_OPEN_PARMS16 lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (CDADev[wDevID].nUseCount > 0) {
/* The driver already open on this channel */
/* If the driver was opened shareable before and this open specifies */
/* shareable then increment the use count */
if (CDADev[wDevID].fShareable && (dwFlags & MCI_OPEN_SHAREABLE))
++CDADev[wDevID].nUseCount;
else
return MCIERR_MUST_USE_SHAREABLE;
}
else {
CDADev[wDevID].nUseCount = 1;
CDADev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE;
}
if (dwFlags & MCI_OPEN_ELEMENT) {
TRACE(cdaudio,"MCI_OPEN_ELEMENT !\n");
/* return MCIERR_NO_ELEMENT_ALLOWED; */
}
memcpy(&CDADev[wDevID].openParms, lpParms, sizeof(MCI_OPEN_PARMS16));
CDADev[wDevID].wNotifyDeviceID = lpParms->wDeviceID;
CDADev[wDevID].unixdev = open (CDAUDIO_DEV, O_RDONLY, 0);
if (CDADev[wDevID].unixdev == -1) {
WARN(cdaudio,"can't open '%s' !\n", CDAUDIO_DEV);
return MCIERR_HARDWARE;
}
CDADev[wDevID].mode = 0;
CDADev[wDevID].dwTimeFormat = MCI_FORMAT_TMSF;
CDADev[wDevID].nCurTrack = 0;
CDADev[wDevID].nTracks = 0;
CDADev[wDevID].dwTotalLen = 0;
CDADev[wDevID].dwFirstOffset = 0;
CDADev[wDevID].lpdwTrackLen = NULL;
CDADev[wDevID].lpdwTrackPos = NULL;
if (!CDAUDIO_GetTracksInfo(wDevID)) {
WARN(cdaudio,"error reading TracksInfo !\n");
/* return MCIERR_INTERNAL; */
}
/*
Moved to mmsystem.c mciOpen routine
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
*/
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_mciClose [internal]
*/
static DWORD CDAUDIO_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwParam, lpParms);
if (CDADev[wDevID].lpdwTrackLen != NULL) free(CDADev[wDevID].lpdwTrackLen);
if (CDADev[wDevID].lpdwTrackPos != NULL) free(CDADev[wDevID].lpdwTrackPos);
close(CDADev[wDevID].unixdev);
#endif
return 0;
}
/**************************************************************************
* CDAUDIO_mciGetDevCaps [internal]
*/
static DWORD CDAUDIO_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags,
LPMCI_GETDEVCAPS_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (dwFlags & MCI_GETDEVCAPS_ITEM) {
TRACE(cdaudio, "MCI_GETDEVCAPS_ITEM dwItem=%08lX;\n",
lpParms->dwItem);
switch(lpParms->dwItem) {
case MCI_GETDEVCAPS_CAN_RECORD:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_HAS_AUDIO:
lpParms->dwReturn = TRUE;
break;
case MCI_GETDEVCAPS_HAS_VIDEO:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_DEVICE_TYPE:
lpParms->dwReturn = MCI_DEVTYPE_CD_AUDIO;
break;
case MCI_GETDEVCAPS_USES_FILES:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_COMPOUND_DEVICE:
lpParms->dwReturn = FALSE;
break;
case MCI_GETDEVCAPS_CAN_EJECT:
lpParms->dwReturn = TRUE;
break;
case MCI_GETDEVCAPS_CAN_PLAY:
lpParms->dwReturn = TRUE;
break;
case MCI_GETDEVCAPS_CAN_SAVE:
lpParms->dwReturn = FALSE;
break;
default:
return MCIERR_UNRECOGNIZED_COMMAND;
}
}
TRACE(cdaudio, "lpParms->dwReturn=%08lX;\n",
lpParms->dwReturn);
return 0;
#else
return MCIERR_INTERNAL;
#endif
}
/**************************************************************************
* CDAUDIO_mciInfo [internal]
*/
static DWORD CDAUDIO_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
lpParms->lpstrReturn = NULL;
switch(dwFlags) {
case MCI_INFO_PRODUCT:
lpParms->lpstrReturn = "Linux CDROM 0.5";
break;
default:
return MCIERR_UNRECOGNIZED_COMMAND;
}
if (lpParms->lpstrReturn != NULL)
lpParms->dwRetSize = strlen(lpParms->lpstrReturn);
else
lpParms->dwRetSize = 0;
return 0;
#else
return MCIERR_INTERNAL;
#endif
}
/**************************************************************************
* CDAUDIO_CalcFrame [internal]
*/
static DWORD CDAUDIO_CalcFrame(UINT16 wDevID, DWORD dwFormatType, DWORD dwTime)
{
DWORD dwFrame = 0;
#if defined(linux) || defined(__FreeBSD__)
UINT16 wTrack;
TRACE(cdaudio,"(%04X, %08lX, %lu);\n",
wDevID, dwFormatType, dwTime);
switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS:
dwFrame = dwTime * CDFRAMES_PERSEC / 1000;
TRACE(cdaudio, "MILLISECONDS %lu\n",
dwFrame);
break;
case MCI_FORMAT_MSF:
TRACE(cdaudio, "MSF %02u:%02u:%02u\n",
MCI_MSF_MINUTE(dwTime), MCI_MSF_SECOND(dwTime),
MCI_MSF_FRAME(dwTime));
dwFrame += CDFRAMES_PERMIN * MCI_MSF_MINUTE(dwTime);
dwFrame += CDFRAMES_PERSEC * MCI_MSF_SECOND(dwTime);
dwFrame += MCI_MSF_FRAME(dwTime);
break;
default:
/* unknown format ! force TMSF ! ... */
dwFormatType = MCI_FORMAT_TMSF;
case MCI_FORMAT_TMSF:
wTrack = MCI_TMSF_TRACK(dwTime);
TRACE(cdaudio, "MSF %02u-%02u:%02u:%02u\n",
MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime),
MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
TRACE(cdaudio, "TMSF trackpos[%u]=%lu\n",
wTrack, CDADev[wDevID].lpdwTrackPos[wTrack - 1]);
dwFrame = CDADev[wDevID].lpdwTrackPos[wTrack - 1];
dwFrame += CDFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime);
dwFrame += CDFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime);
dwFrame += MCI_TMSF_FRAME(dwTime);
break;
}
#endif
return dwFrame;
}
/**************************************************************************
* CDAUDIO_GetCDStatus [internal]
*/
static BOOL32 CDAUDIO_GetCDStatus(UINT16 wDevID)
{
#if defined(linux) || defined(__FreeBSD__)
int oldmode = CDADev[wDevID].mode;
#ifdef __FreeBSD__
struct ioc_read_subchannel read_sc;
read_sc.address_format = CD_MSF_FORMAT;
read_sc.data_format = CD_CURRENT_POSITION;
read_sc.track = 0;
read_sc.data_len = sizeof(CDADev[wDevID].sc);
read_sc.data = (struct cd_sub_channel_info *)&CDADev[wDevID].sc;
#elif linux
CDADev[wDevID].sc.cdsc_format = CDROM_MSF;
#endif
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMSUBCHNL, &CDADev[wDevID].sc
#elif __FreeBSD__
CDIOCREADSUBCHANNEL, &read_sc
#endif
)) {
TRACE(cdaudio,"opened or no_media !\n");
CDADev[wDevID].mode = MCI_MODE_NOT_READY;
return TRUE;
}
switch (
#ifdef linux
CDADev[wDevID].sc.cdsc_audiostatus
#elif __FreeBSD__
CDADev[wDevID].sc.header.audio_status
#endif
) {
#ifdef linux
case CDROM_AUDIO_INVALID:
#elif __FreeBSD__
case CD_AS_AUDIO_INVALID:
#endif
WARN(cdaudio, "device doesn't support status, returning NOT_READY.\n");
#ifdef linux
CDADev[wDevID].mode = MCI_MODE_NOT_READY;
#elif __FreeBSD__
CDADev[wDevID].mode = MCI_MODE_STOP;
#endif
break;
#ifdef linux
case CDROM_AUDIO_NO_STATUS:
#elif __FreeBSD__
case CD_AS_NO_STATUS:
#endif
CDADev[wDevID].mode = MCI_MODE_STOP;
TRACE(cdaudio,"MCI_MODE_STOP !\n");
break;
#ifdef linux
case CDROM_AUDIO_PLAY:
#elif __FreeBSD__
case CD_AS_PLAY_IN_PROGRESS:
#endif
CDADev[wDevID].mode = MCI_MODE_PLAY;
TRACE(cdaudio,"MCI_MODE_PLAY !\n");
break;
#ifdef linux
case CDROM_AUDIO_PAUSED:
#elif __FreeBSD__
case CD_AS_PLAY_PAUSED:
#endif
CDADev[wDevID].mode = MCI_MODE_PAUSE;
TRACE(cdaudio,"MCI_MODE_PAUSE !\n");
break;
default:
#ifdef linux
TRACE(cdaudio,"status=%02X !\n",
CDADev[wDevID].sc.cdsc_audiostatus);
#elif __FreeBSD__
TRACE(cdaudio,"status=%02X !\n",
CDADev[wDevID].sc.header.audio_status);
#endif
}
#ifdef linux
CDADev[wDevID].nCurTrack = CDADev[wDevID].sc.cdsc_trk;
CDADev[wDevID].dwCurFrame =
CDFRAMES_PERMIN * CDADev[wDevID].sc.cdsc_absaddr.msf.minute +
CDFRAMES_PERSEC * CDADev[wDevID].sc.cdsc_absaddr.msf.second +
CDADev[wDevID].sc.cdsc_absaddr.msf.frame;
#elif __FreeBSD__
CDADev[wDevID].nCurTrack = CDADev[wDevID].sc.what.position.track_number;
CDADev[wDevID].dwCurFrame =
CDFRAMES_PERMIN * CDADev[wDevID].sc.what.position.absaddr.msf.minute +
CDFRAMES_PERSEC * CDADev[wDevID].sc.what.position.absaddr.msf.second +
CDADev[wDevID].sc.what.position.absaddr.msf.frame;
#endif
#ifdef linux
TRACE(cdaudio,"%02u-%02u:%02u:%02u \n",
CDADev[wDevID].sc.cdsc_trk,
CDADev[wDevID].sc.cdsc_absaddr.msf.minute,
CDADev[wDevID].sc.cdsc_absaddr.msf.second,
CDADev[wDevID].sc.cdsc_absaddr.msf.frame);
#elif __FreeBSD__
TRACE(cdaudio,"%02u-%02u:%02u:%02u \n",
CDADev[wDevID].sc.what.position.track_number,
CDADev[wDevID].sc.what.position.absaddr.msf.minute,
CDADev[wDevID].sc.what.position.absaddr.msf.second,
CDADev[wDevID].sc.what.position.absaddr.msf.frame);
#endif
if (oldmode != CDADev[wDevID].mode && oldmode == MCI_MODE_OPEN) {
if (!CDAUDIO_GetTracksInfo(wDevID)) {
WARN(cdaudio, "error updating TracksInfo !\n");
return MCIERR_INTERNAL;
}
}
return TRUE;
#else
return FALSE;
#endif
}
/**************************************************************************
* CDAUDIO_CalcTime [internal]
*/
static DWORD CDAUDIO_CalcTime(UINT16 wDevID, DWORD dwFormatType, DWORD dwFrame)
{
DWORD dwTime = 0;
#if defined(linux) || defined(__FreeBSD__)
UINT16 wTrack;
UINT16 wMinutes;
UINT16 wSeconds;
UINT16 wFrames;
TRACE(cdaudio,"(%04X, %08lX, %lu);\n",
wDevID, dwFormatType, dwFrame);
switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS:
dwTime = dwFrame / CDFRAMES_PERSEC * 1000;
TRACE(cdaudio, "MILLISECONDS %lu\n",
dwTime);
break;
case MCI_FORMAT_MSF:
wMinutes = dwFrame / CDFRAMES_PERMIN;
wSeconds = (dwFrame - CDFRAMES_PERMIN * wMinutes) / CDFRAMES_PERSEC;
wFrames = dwFrame - CDFRAMES_PERMIN * wMinutes -
CDFRAMES_PERSEC * wSeconds;
dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames);
TRACE(cdaudio,"MSF %02u:%02u:%02u -> dwTime=%lu\n",
wMinutes, wSeconds, wFrames, dwTime);
break;
default:
/* unknown format ! force TMSF ! ... */
dwFormatType = MCI_FORMAT_TMSF;
case MCI_FORMAT_TMSF:
for (wTrack = 0; wTrack < CDADev[wDevID].nTracks; wTrack++) {
/* dwTime += CDADev[wDevID].lpdwTrackLen[wTrack - 1];
TRACE(cdaudio, "Adding trk#%u curpos=%u \n", dwTime);
if (dwTime >= dwFrame) break; */
if (CDADev[wDevID].lpdwTrackPos[wTrack - 1] >= dwFrame) break;
}
wMinutes = dwFrame / CDFRAMES_PERMIN;
wSeconds = (dwFrame - CDFRAMES_PERMIN * wMinutes) / CDFRAMES_PERSEC;
wFrames = dwFrame - CDFRAMES_PERMIN * wMinutes -
CDFRAMES_PERSEC * wSeconds;
dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames);
TRACE(cdaudio, "%02u-%02u:%02u:%02u\n",
wTrack, wMinutes, wSeconds, wFrames);
break;
}
#endif
return dwTime;
}
/**************************************************************************
* CDAUDIO_mciStatus [internal]
*/
static DWORD CDAUDIO_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (CDADev[wDevID].unixdev == 0) return MMSYSERR_NOTENABLED;
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
if (dwFlags & MCI_STATUS_ITEM) {
switch(lpParms->dwItem) {
case MCI_STATUS_CURRENT_TRACK:
if (!CDAUDIO_GetCDStatus(wDevID)) return MCIERR_INTERNAL;
lpParms->dwReturn = CDADev[wDevID].nCurTrack;
TRACE(cdaudio,"CURRENT_TRACK=%lu!\n", lpParms->dwReturn);
return 0;
case MCI_STATUS_LENGTH:
if (CDADev[wDevID].nTracks == 0) {
if (!CDAUDIO_GetTracksInfo(wDevID)) {
WARN(cdaudio, "error reading TracksInfo !\n");
return MCIERR_INTERNAL;
}
}
if (dwFlags & MCI_TRACK) {
TRACE(cdaudio,"MCI_TRACK #%lu LENGTH=??? !\n",
lpParms->dwTrack);
if (lpParms->dwTrack > CDADev[wDevID].nTracks)
return MCIERR_OUTOFRANGE;
lpParms->dwReturn = CDADev[wDevID].lpdwTrackLen[lpParms->dwTrack];
}
else
lpParms->dwReturn = CDADev[wDevID].dwTotalLen;
lpParms->dwReturn = CDAUDIO_CalcTime(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwReturn);
TRACE(cdaudio,"LENGTH=%lu !\n", lpParms->dwReturn);
return 0;
case MCI_STATUS_MODE:
if (!CDAUDIO_GetCDStatus(wDevID)) return MCIERR_INTERNAL;
lpParms->dwReturn = CDADev[wDevID].mode;
TRACE(cdaudio,"MCI_STATUS_MODE=%08lX !\n",
lpParms->dwReturn);
return 0;
case MCI_STATUS_MEDIA_PRESENT:
lpParms->dwReturn = (CDADev[wDevID].nTracks > 0) ? TRUE : FALSE;
if (lpParms->dwReturn == FALSE)
TRACE(cdaudio,"MEDIA_NOT_PRESENT !\n");
else
TRACE(cdaudio,"MCI_STATUS_MEDIA_PRESENT !\n");
return 0;
case MCI_STATUS_NUMBER_OF_TRACKS:
lpParms->dwReturn = CDAUDIO_GetNumberOfTracks(wDevID);
TRACE(cdaudio,"MCI_STATUS_NUMBER_OF_TRACKS = %lu !\n",
lpParms->dwReturn);
if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL;
return 0;
case MCI_STATUS_POSITION:
if (!CDAUDIO_GetCDStatus(wDevID)) return MCIERR_INTERNAL;
lpParms->dwReturn = CDADev[wDevID].dwCurFrame;
if (dwFlags & MCI_STATUS_START) {
lpParms->dwReturn = CDADev[wDevID].dwFirstOffset;
TRACE(cdaudio,"get MCI_STATUS_START !\n");
}
if (dwFlags & MCI_TRACK) {
if (lpParms->dwTrack > CDADev[wDevID].nTracks)
return MCIERR_OUTOFRANGE;
lpParms->dwReturn = CDADev[wDevID].lpdwTrackPos[lpParms->dwTrack - 1];
TRACE(cdaudio,"get MCI_TRACK #%lu !\n", lpParms->dwTrack);
}
lpParms->dwReturn = CDAUDIO_CalcTime(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwReturn);
TRACE(cdaudio,"MCI_STATUS_POSITION=%08lX !\n",
lpParms->dwReturn);
return 0;
case MCI_STATUS_READY:
TRACE(cdaudio,"MCI_STATUS_READY !\n");
lpParms->dwReturn = TRUE;
return 0;
case MCI_STATUS_TIME_FORMAT:
TRACE(cdaudio,"MCI_STATUS_TIME_FORMAT !\n");
lpParms->dwReturn = CDADev[wDevID].dwTimeFormat;
return 0;
default:
WARN(cdaudio, "unknown command %08lX !\n", lpParms->dwItem);
return MCIERR_UNRECOGNIZED_COMMAND;
}
}
WARN(cdaudio, "not MCI_STATUS_ITEM !\n");
return 0;
#else
return MMSYSERR_NOTENABLED;
#endif
}
/**************************************************************************
* CDAUDIO_mciPlay [internal]
*/
static DWORD CDAUDIO_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
int start, end;
#ifdef linux
struct cdrom_msf msf;
#elif __FreeBSD__
struct ioc_play_msf msf;
#endif
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (CDADev[wDevID].unixdev == 0) return MMSYSERR_NOTENABLED;
start = 0; end = CDADev[wDevID].dwTotalLen;
CDADev[wDevID].nCurTrack = 1;
if (dwFlags & MCI_FROM) {
start = CDAUDIO_CalcFrame(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwFrom);
TRACE(cdaudio,"MCI_FROM=%08lX -> %u \n",
lpParms->dwFrom, start);
}
if (dwFlags & MCI_TO) {
end = CDAUDIO_CalcFrame(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwTo);
TRACE(cdaudio, "MCI_TO=%08lX -> %u \n",
lpParms->dwTo, end);
}
start += CDADev[wDevID].dwFirstOffset;
end += CDADev[wDevID].dwFirstOffset;
#ifdef linux
msf.cdmsf_min0 = start / CDFRAMES_PERMIN;
msf.cdmsf_sec0 = (start % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
msf.cdmsf_frame0 = start % CDFRAMES_PERSEC;
msf.cdmsf_min1 = end / CDFRAMES_PERMIN;
msf.cdmsf_sec1 = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
msf.cdmsf_frame1 = end % CDFRAMES_PERSEC;
#elif __FreeBSD__
msf.start_m = start / CDFRAMES_PERMIN;
msf.start_s = (start % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
msf.start_f = start % CDFRAMES_PERSEC;
msf.end_m = end / CDFRAMES_PERMIN;
msf.end_s = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
msf.end_f = end % CDFRAMES_PERSEC;
#endif
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMSTART
#elif __FreeBSD__
CDIOCSTART
#endif
)) {
WARN(cdaudio, "motor doesn't start !\n");
return MCIERR_HARDWARE;
}
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMPLAYMSF
#elif __FreeBSD__
CDIOCPLAYMSF
#endif
, &msf)) {
WARN(cdaudio, "device doesn't play !\n");
return MCIERR_HARDWARE;
}
#ifdef linux
TRACE(cdaudio,"msf = %d:%d:%d %d:%d:%d\n",
msf.cdmsf_min0, msf.cdmsf_sec0, msf.cdmsf_frame0,
msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1);
#elif __FreeBSD__
TRACE(cdaudio,"msf = %d:%d:%d %d:%d:%d\n",
msf.start_m, msf.start_s, msf.start_f,
msf.end_m, msf.end_s, msf.end_f);
#endif
CDADev[wDevID].mode = MCI_MODE_PLAY;
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
/*
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
*/
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_mciStop [internal]
*/
static DWORD CDAUDIO_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMSTOP
#elif __FreeBSD__
CDIOCSTOP
#endif
)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_mciPause [internal]
*/
static DWORD CDAUDIO_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMPAUSE
#elif __FreeBSD__
CDIOCPAUSE
#endif
)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_PAUSE;
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_mciResume [internal]
*/
static DWORD CDAUDIO_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMRESUME
#elif __FreeBSD__
CDIOCRESUME
#endif
)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_mciSeek [internal]
*/
static DWORD CDAUDIO_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
DWORD dwRet;
MCI_PLAY_PARMS PlayParms;
TRACE(cdaudio,"(%04X, %08lX, %p);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev,
#ifdef linux
CDROMRESUME
#elif __FreeBSD__
CDIOCRESUME
#endif
)) {
perror("ioctl CDROMRESUME");
return MCIERR_HARDWARE;
}
CDADev[wDevID].mode = MCI_MODE_SEEK;
switch(dwFlags) {
case MCI_SEEK_TO_START:
PlayParms.dwFrom = 0;
break;
case MCI_SEEK_TO_END:
PlayParms.dwFrom = CDADev[wDevID].dwTotalLen;
break;
case MCI_TO:
PlayParms.dwFrom = lpParms->dwTo;
break;
}
dwRet = CDAUDIO_mciPlay(wDevID, MCI_WAIT | MCI_FROM, &PlayParms);
if (dwRet != 0) return dwRet;
dwRet = CDAUDIO_mciStop(wDevID, MCI_WAIT, (LPMCI_GENERIC_PARMS)&PlayParms);
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return dwRet;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_mciSet [internal]
*/
static DWORD CDAUDIO_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
{
#if defined(linux) || defined(__FreeBSD__)
TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
/*
TRACE(cdaudio,"dwTimeFormat=%08lX\n", lpParms->dwTimeFormat);
TRACE(cdaudio,"dwAudio=%08lX\n", lpParms->dwAudio);
*/
if (dwFlags & MCI_SET_TIME_FORMAT) {
switch (lpParms->dwTimeFormat) {
case MCI_FORMAT_MILLISECONDS:
TRACE(cdaudio, "MCI_FORMAT_MILLISECONDS !\n");
break;
case MCI_FORMAT_MSF:
TRACE(cdaudio,"MCI_FORMAT_MSF !\n");
break;
case MCI_FORMAT_TMSF:
TRACE(cdaudio,"MCI_FORMAT_TMSF !\n");
break;
default:
WARN(cdaudio, "bad time format !\n");
return MCIERR_BAD_TIME_FORMAT;
}
CDADev[wDevID].dwTimeFormat = lpParms->dwTimeFormat;
}
if (dwFlags & MCI_SET_DOOR_OPEN) {
TRACE(cdaudio, "MCI_SET_DOOR_OPEN !\n");
#ifdef __FreeBSD__
if (ioctl(CDADev[wDevID].unixdev, CDIOCALLOW)) return MCIERR_HARDWARE;
if (ioctl(CDADev[wDevID].unixdev, CDIOCEJECT)) return MCIERR_HARDWARE;
if (ioctl(CDADev[wDevID].unixdev, CDIOCPREVENT)) return MCIERR_HARDWARE;
#elif linux
if (ioctl(CDADev[wDevID].unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
#endif
CDADev[wDevID].nTracks = 0;
}
if (dwFlags & MCI_SET_DOOR_CLOSED) {
TRACE(cdaudio, "MCI_SET_DOOR_CLOSED !\n");
#ifdef __FreeBSD__
if (ioctl(CDADev[wDevID].unixdev, CDIOCALLOW)) return MCIERR_HARDWARE;
if (ioctl(CDADev[wDevID].unixdev, CDIOCCLOSE)) return MCIERR_HARDWARE;
if (ioctl(CDADev[wDevID].unixdev, CDIOCPREVENT)) return MCIERR_HARDWARE;
#elif linux
if (ioctl(CDADev[wDevID].unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
/* XXX should it be ",1" ??? */
#endif
CDADev[wDevID].nTracks = 0;
}
if (dwFlags & MCI_SET_VIDEO) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_SET_OFF) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_NOTIFY) {
TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n",
lpParms->dwCallback);
mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
return 0;
#else
return MCIERR_HARDWARE;
#endif
}
/**************************************************************************
* CDAUDIO_DriverProc [sample driver]
*/
LONG CDAUDIO_DriverProc(DWORD dwDevID, HDRVR16 hDriv, WORD wMsg,
DWORD dwParam1, DWORD dwParam2)
{
#if defined(linux) || defined(__FreeBSD__)
switch(wMsg) {
case DRV_LOAD:
return 1;
case DRV_FREE:
return 1;
case DRV_OPEN:
case MCI_OPEN_DRIVER:
case MCI_OPEN:
return CDAUDIO_mciOpen(dwDevID, dwParam1, (LPMCI_OPEN_PARMS16)PTR_SEG_TO_LIN(dwParam2));
case DRV_CLOSE:
case MCI_CLOSE_DRIVER:
case MCI_CLOSE:
return CDAUDIO_mciClose(dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case DRV_ENABLE:
return 1;
case DRV_DISABLE:
return 1;
case DRV_QUERYCONFIGURE:
return 1;
case DRV_CONFIGURE:
MessageBox16(0, "Sample MultiMedia Linux Driver !",
"MMLinux Driver", MB_OK);
return 1;
case DRV_INSTALL:
return DRVCNF_RESTART;
case DRV_REMOVE:
return DRVCNF_RESTART;
case MCI_GETDEVCAPS:
return CDAUDIO_mciGetDevCaps(dwDevID, dwParam1,
(LPMCI_GETDEVCAPS_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_INFO:
return CDAUDIO_mciInfo(dwDevID, dwParam1,
(LPMCI_INFO_PARMS16)PTR_SEG_TO_LIN(dwParam2));
case MCI_STATUS:
return CDAUDIO_mciStatus(dwDevID, dwParam1,
(LPMCI_STATUS_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SET:
return CDAUDIO_mciSet(dwDevID, dwParam1,
(LPMCI_SET_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_PLAY:
return CDAUDIO_mciPlay(dwDevID, dwParam1,
(LPMCI_PLAY_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_STOP:
return CDAUDIO_mciStop(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_PAUSE:
return CDAUDIO_mciPause(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_RESUME:
return CDAUDIO_mciResume(dwDevID, dwParam1,
(LPMCI_GENERIC_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SEEK:
return CDAUDIO_mciSeek(dwDevID, dwParam1,
(LPMCI_SEEK_PARMS)PTR_SEG_TO_LIN(dwParam2));
case MCI_SET_DOOR_OPEN:
TRACE(cdaudio, "MCI_SET_DOOR_OPEN !\n");
#ifdef __FreeBSD__
if (ioctl(CDADev[dwDevID].unixdev, CDIOCALLOW)) return MCIERR_HARDWARE;
if (ioctl(CDADev[dwDevID].unixdev, CDIOCEJECT)) return MCIERR_HARDWARE;
if (ioctl(CDADev[dwDevID].unixdev, CDIOCPREVENT)) return MCIERR_HARDWARE;
#elif linux
if (ioctl(CDADev[dwDevID].unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
#endif
CDADev[dwDevID].nTracks = 0;
return 0;
case MCI_SET_DOOR_CLOSED:
TRACE(cdaudio,"MCI_SET_DOOR_CLOSED !\n");
#ifdef __FreeBSD__
if (ioctl(CDADev[dwDevID].unixdev, CDIOCALLOW)) return MCIERR_HARDWARE;
if (ioctl(CDADev[dwDevID].unixdev, CDIOCCLOSE)) return MCIERR_HARDWARE;
if (ioctl(CDADev[dwDevID].unixdev, CDIOCPREVENT)) return MCIERR_HARDWARE;
#elif linux
if (ioctl(CDADev[dwDevID].unixdev, CDROMEJECT, 1)) return MCIERR_HARDWARE;
#endif
CDADev[dwDevID].nTracks = 0;
return 0;
default:
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
}
#else
return MCIERR_HARDWARE;
#endif
}
/*-----------------------------------------------------------------------*/