Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
authorSam Lantinga <slouken@libsdl.org>
Tue, 22 Jul 2003 14:01:21 +0000
changeset 654e92bcf2573cb
parent 653 1bd056de5d1b
child 655 9c42ee1b7d77
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
configure.in
include/SDL_types.h
src/audio/Makefile.am
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
src/audio/mme/.cvsignore
src/audio/mme/Makefile.am
src/audio/mme/SDL_mmeaudio.c
src/audio/mme/SDL_mmeaudio.h
src/audio/riscos/.cvsignore
src/cdrom/Makefile.am
src/cdrom/osf/.cvsignore
src/cdrom/osf/Makefile.am
src/cdrom/osf/SDL_syscdrom.c
     1.1 --- a/configure.in	Tue Jul 22 05:29:48 2003 +0000
     1.2 +++ b/configure.in	Tue Jul 22 14:01:21 2003 +0000
     1.3 @@ -2170,13 +2170,15 @@
     1.4          CheckAAlib
     1.5          CheckOpenGL
     1.6          CheckPTHREAD
     1.7 +        SDL_LIBS="$SDL_LIBS -lrt"
     1.8          # Set up files for the main() stub
     1.9          COPY_ARCH_SRC(src/main, linux, SDL_main.c)
    1.10          # Set up files for the audio library
    1.11          if test x$enable_audio = xyes; then
    1.12 -            CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
    1.13 -            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
    1.14 -            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
    1.15 +            CFLAGS="$CFLAGS -I/usr/include/mme -DMMEAUDIO_SUPPORT"
    1.16 +            SYSTEM_LIBS="$SYSTEM_LIBS -lmme"
    1.17 +            AUDIO_SUBDIRS="$AUDIO_SUBDIRS mme"
    1.18 +            AUDIO_DRIVERS="$AUDIO_DRIVERS mme/libaudio_mme.la"
    1.19          fi
    1.20          # Set up files for the joystick library
    1.21          # (No joystick support yet)
    1.22 @@ -2187,8 +2189,8 @@
    1.23          # Set up files for the cdrom library
    1.24          # (No cdrom support yet)
    1.25          if test x$enable_cdrom = xyes; then
    1.26 -            CDROM_SUBDIRS="$CDROM_SUBDIRS dummy"
    1.27 -            CDROM_DRIVERS="$CDROM_DRIVERS dummy/libcdrom_dummy.la"
    1.28 +            CDROM_SUBDIRS="$CDROM_SUBDIRS osf"
    1.29 +            CDROM_DRIVERS="$CDROM_DRIVERS osf/libcdrom_osf.la"
    1.30          fi
    1.31          # Set up files for the thread library
    1.32          if test x$enable_threads = xyes; then
    1.33 @@ -2626,6 +2628,7 @@
    1.34  src/audio/esd/Makefile
    1.35  src/audio/macrom/Makefile
    1.36  src/audio/mint/Makefile
    1.37 +src/audio/mme/Makefile
    1.38  src/audio/nas/Makefile
    1.39  src/audio/nto/Makefile
    1.40  src/audio/openbsd/Makefile
    1.41 @@ -2695,6 +2698,7 @@
    1.42  src/cdrom/macos/Makefile
    1.43  src/cdrom/macosx/Makefile
    1.44  src/cdrom/openbsd/Makefile
    1.45 +src/cdrom/osf/Makefile
    1.46  src/cdrom/qnx/Makefile
    1.47  src/cdrom/win32/Makefile
    1.48  src/thread/Makefile
     2.1 --- a/include/SDL_types.h	Tue Jul 22 05:29:48 2003 +0000
     2.2 +++ b/include/SDL_types.h	Tue Jul 22 14:01:21 2003 +0000
     2.3 @@ -47,7 +47,7 @@
     2.4  
     2.5  /* Figure out how to support 64-bit datatypes */
     2.6  #if !defined(__STRICT_ANSI__)
     2.7 -#if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C)
     2.8 +#if defined(__GNUC__) || defined(__MWERKS__) || defined(__DECC)
     2.9  #define SDL_HAS_64BIT_TYPE	long long
    2.10  #elif defined(_MSC_VER) /* VC++ */
    2.11  #define SDL_HAS_64BIT_TYPE	__int64
    2.12 @@ -61,7 +61,9 @@
    2.13  
    2.14  /* The 64-bit datatype isn't supported on all platforms */
    2.15  #ifdef SDL_HAS_64BIT_TYPE
    2.16 +#ifndef H_MMBASIC
    2.17  typedef unsigned SDL_HAS_64BIT_TYPE Uint64;
    2.18 +#endif
    2.19  typedef SDL_HAS_64BIT_TYPE Sint64;
    2.20  #else
    2.21  /* This is really just a hack to prevent the compiler from complaining */
     3.1 --- a/src/audio/Makefile.am	Tue Jul 22 05:29:48 2003 +0000
     3.2 +++ b/src/audio/Makefile.am	Tue Jul 22 14:01:21 2003 +0000
     3.3 @@ -5,8 +5,28 @@
     3.4  
     3.5  # Define which subdirectories need to be built
     3.6  SUBDIRS = @AUDIO_SUBDIRS@
     3.7 -DIST_SUBDIRS = alsa arts baudio dma dmedia dsp esd macrom nas nto openbsd \
     3.8 -	paudio riscos sun ums windib windx5 disk mint dc
     3.9 +DIST_SUBDIRS =	\
    3.10 +	alsa	\
    3.11 +	arts	\
    3.12 +	baudio	\
    3.13 +	dc	\
    3.14 +	disk	\
    3.15 +	dma	\
    3.16 +	dmedia	\
    3.17 +	dsp	\
    3.18 +	esd	\
    3.19 +	macrom	\
    3.20 +	mint	\
    3.21 +	mme	\
    3.22 +	nas	\
    3.23 +	nto	\
    3.24 +	openbsd	\
    3.25 +	paudio	\
    3.26 +	riscos	\
    3.27 +	sun	\
    3.28 +	ums	\
    3.29 +	windib	\
    3.30 +	windx5
    3.31  
    3.32  DRIVERS = @AUDIO_DRIVERS@
    3.33  
     4.1 --- a/src/audio/SDL_audio.c	Tue Jul 22 05:29:48 2003 +0000
     4.2 +++ b/src/audio/SDL_audio.c	Tue Jul 22 14:01:21 2003 +0000
     4.3 @@ -83,6 +83,9 @@
     4.4  #ifdef ENABLE_AHI
     4.5  	&AHI_bootstrap,
     4.6  #endif
     4.7 +#ifdef MMEAUDIO_SUPPORT
     4.8 +	&MMEAUDIO_bootstrap,
     4.9 +#endif
    4.10  #ifdef MINTAUDIO_SUPPORT
    4.11  	&MINTAUDIO_GSXB_bootstrap,
    4.12  	&MINTAUDIO_MCSN_bootstrap,
     5.1 --- a/src/audio/SDL_sysaudio.h	Tue Jul 22 05:29:48 2003 +0000
     5.2 +++ b/src/audio/SDL_sysaudio.h	Tue Jul 22 14:01:21 2003 +0000
     5.3 @@ -163,6 +163,9 @@
     5.4  #ifdef DRENDERER_SUPPORT
     5.5  extern AudioBootStrap DRENDERER_bootstrap;
     5.6  #endif
     5.7 +#ifdef MMEAUDIO_SUPPORT
     5.8 +extern AudioBootStrap MMEAUDIO_bootstrap;
     5.9 +#endif
    5.10  
    5.11  /* This is the current audio device */
    5.12  extern SDL_AudioDevice *current_audio;
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/audio/mme/.cvsignore	Tue Jul 22 14:01:21 2003 +0000
     6.3 @@ -0,0 +1,6 @@
     6.4 +Makefile.in
     6.5 +Makefile
     6.6 +.libs
     6.7 +*.o
     6.8 +*.lo
     6.9 +*.la
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/audio/mme/Makefile.am	Tue Jul 22 14:01:21 2003 +0000
     7.3 @@ -0,0 +1,9 @@
     7.4 +
     7.5 +## Makefile.am for SDL using the Tru64 MME sound driver
     7.6 +
     7.7 +noinst_LTLIBRARIES = libaudio_mme.la
     7.8 +libaudio_mme_la_SOURCES = $(SRCS)
     7.9 +
    7.10 +# The SDL audio driver sources
    7.11 +SRCS =	SDL_mmeaudio.c	\
    7.12 +	SDL_mmeaudio.h
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/audio/mme/SDL_mmeaudio.c	Tue Jul 22 14:01:21 2003 +0000
     8.3 @@ -0,0 +1,256 @@
     8.4 +/*
     8.5 +    SDL - Simple DirectMedia Layer
     8.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     8.7 +
     8.8 +    This library is free software; you can redistribute it and/or
     8.9 +    modify it under the terms of the GNU Library General Public
    8.10 +    License as published by the Free Software Foundation; either
    8.11 +    version 2 of the License, or (at your option) any later version.
    8.12 +
    8.13 +    This library is distributed in the hope that it will be useful,
    8.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 +    Library General Public License for more details.
    8.17 +
    8.18 +    You should have received a copy of the GNU Library General Public
    8.19 +    License along with this library; if not, write to the Free
    8.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.21 +
    8.22 +    Sam Lantinga
    8.23 +    slouken@libsdl.org
    8.24 +*/
    8.25 +
    8.26 +/* Tru64 UNIX MME support */
    8.27 +#include "SDL_mmeaudio.h"
    8.28 +
    8.29 +static BOOL inUse[NUM_BUFFERS];
    8.30 +
    8.31 +/* Audio driver functions */
    8.32 +static int MME_OpenAudio(_THIS, SDL_AudioSpec *spec);
    8.33 +static void MME_WaitAudio(_THIS);
    8.34 +static Uint8 *MME_GetAudioBuf(_THIS);
    8.35 +static void MME_PlayAudio(_THIS);
    8.36 +static void MME_WaitDone(_THIS);
    8.37 +static void MME_CloseAudio(_THIS);
    8.38 +
    8.39 +/* Audio driver bootstrap functions */
    8.40 +static int Audio_Available(void)
    8.41 +{
    8.42 +    return(1);
    8.43 +}
    8.44 +
    8.45 +static void Audio_DeleteDevice(SDL_AudioDevice *device)
    8.46 +{
    8.47 +    if ( device ) {
    8.48 +	if ( device->hidden ) {
    8.49 +	    free(device->hidden);
    8.50 +	    device->hidden = NULL;
    8.51 +	}
    8.52 +	free(device);
    8.53 +	device = NULL;
    8.54 +    }
    8.55 +}
    8.56 +
    8.57 +static SDL_AudioDevice *Audio_CreateDevice(int devindex)
    8.58 +{
    8.59 +    SDL_AudioDevice *this;
    8.60 +
    8.61 +/* Initialize all variables that we clean on shutdown */
    8.62 +    this = malloc(sizeof(SDL_AudioDevice));
    8.63 +    if ( this ) {
    8.64 +	memset(this, 0, (sizeof *this));
    8.65 +	this->hidden = malloc((sizeof *this->hidden));
    8.66 +    }
    8.67 +    if ( (this == NULL) || (this->hidden == NULL) ) {
    8.68 +	SDL_OutOfMemory();
    8.69 +	if ( this ) {
    8.70 +	    free(this);
    8.71 +	}
    8.72 +	return(0);
    8.73 +    }
    8.74 +    memset(this->hidden, 0, (sizeof *this->hidden));
    8.75 +    /* Set the function pointers */
    8.76 +    this->OpenAudio       =       MME_OpenAudio;
    8.77 +    this->WaitAudio       =       MME_WaitAudio;
    8.78 +    this->PlayAudio       =       MME_PlayAudio;
    8.79 +    this->GetAudioBuf     =     MME_GetAudioBuf;
    8.80 +    this->WaitDone        =        MME_WaitDone;
    8.81 +    this->CloseAudio      =      MME_CloseAudio;
    8.82 +    this->free            =  Audio_DeleteDevice;
    8.83 +
    8.84 +    return this;
    8.85 +}
    8.86 +
    8.87 +AudioBootStrap MMEAUDIO_bootstrap = {
    8.88 +    "waveout", "Tru64 MME WaveOut",
    8.89 +    Audio_Available, Audio_CreateDevice
    8.90 +};
    8.91 +
    8.92 +static void SetMMerror(char *function, MMRESULT code)
    8.93 +{
    8.94 +    int len;
    8.95 +    char errbuf[MAXERRORLENGTH];
    8.96 +
    8.97 +    sprintf(errbuf, "%s: ", function);
    8.98 +    len = strlen(errbuf);
    8.99 +    waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
   8.100 +    SDL_SetError("%s",errbuf);
   8.101 +}
   8.102 +
   8.103 +static void CALLBACK MME_CALLBACK(HWAVEOUT hwo,
   8.104 +				  UINT uMsg,
   8.105 +				  DWORD dwInstance,
   8.106 +				  LPARAM dwParam1,
   8.107 +				  LPARAM dwParam2)
   8.108 +{
   8.109 +    WAVEHDR *wp = (WAVEHDR *) dwParam1;
   8.110 +
   8.111 +    if ( uMsg == WOM_DONE )
   8.112 +	inUse[wp->dwUser] = FALSE;
   8.113 +}
   8.114 +
   8.115 +static int MME_OpenAudio(_THIS, SDL_AudioSpec *spec)
   8.116 +{
   8.117 +    MMRESULT result;
   8.118 +    int i;
   8.119 +
   8.120 +    mixbuf = NULL;
   8.121 +
   8.122 +    /* Set basic WAVE format parameters */
   8.123 +    shm = mmeAllocMem(sizeof(*shm));
   8.124 +    if ( shm == NULL ) {
   8.125 +	SDL_SetError("Out of memory: shm");
   8.126 +	return(-1);
   8.127 +    }
   8.128 +    shm->sound = 0;
   8.129 +    shm->wFmt.wf.wFormatTag = WAVE_FORMAT_PCM;
   8.130 +
   8.131 +    /* Determine the audio parameters from the AudioSpec */
   8.132 +    switch ( spec->format & 0xFF ) {
   8.133 +	case 8:
   8.134 +	    /* Unsigned 8 bit audio data */
   8.135 +	    spec->format = AUDIO_U8;
   8.136 +	    shm->wFmt.wBitsPerSample = 8;
   8.137 +	    break;
   8.138 +	case 16:
   8.139 +	    /* Signed 16 bit audio data */
   8.140 +	    spec->format = AUDIO_S16;
   8.141 +	    shm->wFmt.wBitsPerSample = 16;
   8.142 +	    break;
   8.143 +	    default:
   8.144 +	    SDL_SetError("Unsupported audio format");
   8.145 +	    return(-1);
   8.146 +    }
   8.147 +
   8.148 +    shm->wFmt.wf.nChannels = spec->channels;
   8.149 +    shm->wFmt.wf.nSamplesPerSec = spec->freq;
   8.150 +    shm->wFmt.wf.nBlockAlign =
   8.151 +	shm->wFmt.wf.nChannels * shm->wFmt.wBitsPerSample / 8;
   8.152 +    shm->wFmt.wf.nAvgBytesPerSec =
   8.153 +	shm->wFmt.wf.nSamplesPerSec * shm->wFmt.wf.nBlockAlign;
   8.154 +
   8.155 +    /* Check the buffer size -- minimum of 1/4 second (word aligned) */
   8.156 +    if ( spec->samples < (spec->freq/4) )
   8.157 +	spec->samples = ((spec->freq/4)+3)&~3;
   8.158 +
   8.159 +    /* Update the fragment size as size in bytes */
   8.160 +    SDL_CalculateAudioSpec(spec);
   8.161 +
   8.162 +    /* Open the audio device */
   8.163 +    result = waveOutOpen(&(shm->sound),
   8.164 +			 WAVE_MAPPER,
   8.165 +			 &(shm->wFmt.wf),
   8.166 +			 MME_CALLBACK,
   8.167 +			 NULL,
   8.168 +			 (CALLBACK_FUNCTION|WAVE_OPEN_SHAREABLE));
   8.169 +    if ( result != MMSYSERR_NOERROR ) {
   8.170 +	    SetMMerror("waveOutOpen()", result);
   8.171 +	    return(-1);
   8.172 +    }
   8.173 +
   8.174 +    /* Create the sound buffers */
   8.175 +    mixbuf = (Uint8 *)mmeAllocBuffer(NUM_BUFFERS * (spec->size));
   8.176 +    if ( mixbuf == NULL ) {
   8.177 +	SDL_SetError("Out of memory: mixbuf");
   8.178 +	return(-1);
   8.179 +    }
   8.180 +
   8.181 +    for (i = 0; i < NUM_BUFFERS; i++) {
   8.182 +	shm->wHdr[i].lpData         = &mixbuf[i * (spec->size)];
   8.183 +	shm->wHdr[i].dwBufferLength = spec->size;
   8.184 +	shm->wHdr[i].dwFlags        = 0;
   8.185 +	shm->wHdr[i].dwUser         = i;
   8.186 +	shm->wHdr[i].dwLoops        = 0;       /* loop control counter */
   8.187 +	shm->wHdr[i].lpNext         = NULL;    /* reserved for driver */
   8.188 +	shm->wHdr[i].reserved       = 0;
   8.189 +	inUse[i] = FALSE;
   8.190 +    }
   8.191 +    next_buffer = 0;
   8.192 +    return 0;
   8.193 +}
   8.194 +
   8.195 +static void MME_WaitAudio(_THIS)
   8.196 +{
   8.197 +    mmeWaitForCallbacks ();
   8.198 +    mmeProcessCallbacks ();
   8.199 +}
   8.200 +
   8.201 +static Uint8 *MME_GetAudioBuf(_THIS)
   8.202 +{
   8.203 +    Uint8 *retval;
   8.204 +
   8.205 +    while ( inUse[next_buffer] )
   8.206 +	;
   8.207 +
   8.208 +    inUse[next_buffer] = TRUE;
   8.209 +    retval = (Uint8 *)(shm->wHdr[next_buffer].lpData);
   8.210 +    return retval;
   8.211 +}
   8.212 +
   8.213 +static void MME_PlayAudio(_THIS)
   8.214 +{
   8.215 +    /* Queue it up */
   8.216 +    waveOutWrite(shm->sound, &(shm->wHdr[next_buffer]), sizeof(WAVEHDR));
   8.217 +    next_buffer = (next_buffer+1)%NUM_BUFFERS;
   8.218 +}
   8.219 +
   8.220 +static void MME_WaitDone(_THIS)
   8.221 +{
   8.222 +    MMRESULT result;
   8.223 +    int i;
   8.224 +
   8.225 +    if ( shm->sound ) {
   8.226 +	result = waveOutReset(shm->sound);
   8.227 +	if ( result != MMSYSERR_NOERROR )
   8.228 +	    SetMMerror("waveOutReset()", result);
   8.229 +	else {
   8.230 +	    mmeWaitForCallbacks ();
   8.231 +	    mmeProcessCallbacks ();
   8.232 +	}
   8.233 +    }
   8.234 +}
   8.235 +
   8.236 +static void MME_CloseAudio(_THIS)
   8.237 +{
   8.238 +    MMRESULT result;
   8.239 +
   8.240 +    if ( mixbuf ) {
   8.241 +	result = mmeFreeBuffer(mixbuf);
   8.242 +	if (result != MMSYSERR_NOERROR )
   8.243 +	    SetMMerror("mmeFreeBuffer", result);
   8.244 +	mixbuf = NULL;
   8.245 +    }
   8.246 +
   8.247 +    if ( shm ) {
   8.248 +	if ( shm->sound ) {
   8.249 +	    result = waveOutClose(shm->sound);
   8.250 +	    if (result != MMSYSERR_NOERROR )
   8.251 +		SetMMerror("waveOutClose()", result);
   8.252 +	}
   8.253 +	result = mmeFreeMem(shm);
   8.254 +	if (result != MMSYSERR_NOERROR )
   8.255 +	    SetMMerror("mmeFreeMem()", result);
   8.256 +	shm = NULL;
   8.257 +    }
   8.258 +}
   8.259 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/audio/mme/SDL_mmeaudio.h	Tue Jul 22 14:01:21 2003 +0000
     9.3 @@ -0,0 +1,59 @@
     9.4 +/*
     9.5 +    SDL - Simple DirectMedia Layer
     9.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     9.7 +
     9.8 +    This library is free software; you can redistribute it and/or
     9.9 +    modify it under the terms of the GNU Library General Public
    9.10 +    License as published by the Free Software Foundation; either
    9.11 +    version 2 of the License, or (at your option) any later version.
    9.12 +
    9.13 +    This library is distributed in the hope that it will be useful,
    9.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 +    Library General Public License for more details.
    9.17 +
    9.18 +    You should have received a copy of the GNU Library General Public
    9.19 +    License along with this library; if not, write to the Free
    9.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    9.21 +
    9.22 +    Sam Lantinga
    9.23 +    slouken@libsdl.org
    9.24 +*/
    9.25 +
    9.26 +/* Allow access to a raw mixing buffer */
    9.27 +
    9.28 +#include <stdio.h>
    9.29 +#include <stdlib.h>
    9.30 +#include <string.h>
    9.31 +#include <mme_api.h>
    9.32 +
    9.33 +#include "SDL_audio.h"
    9.34 +#include "SDL_mutex.h"
    9.35 +#include "SDL_timer.h"
    9.36 +#include "SDL_audio_c.h"
    9.37 +
    9.38 +#ifndef _SDL_lowaudio_h
    9.39 +#define _SDL_lowaudio_h
    9.40 +#include "SDL_sysaudio.h"
    9.41 +
    9.42 +/* Hidden "this" pointer for the video functions */
    9.43 +#define _THIS	SDL_AudioDevice *this
    9.44 +#define NUM_BUFFERS 2
    9.45 +
    9.46 +struct SharedMem {
    9.47 +    HWAVEOUT sound;
    9.48 +    WAVEHDR wHdr[NUM_BUFFERS];
    9.49 +    PCMWAVEFORMAT wFmt;
    9.50 +};
    9.51 +
    9.52 +struct SDL_PrivateAudioData {
    9.53 +    Uint8 *mixbuf;          /* The raw allocated mixing buffer */
    9.54 +    struct SharedMem *shm;
    9.55 +    int next_buffer;
    9.56 +};
    9.57 +
    9.58 +#define shm			(this->hidden->shm)
    9.59 +#define mixbuf			(this->hidden->mixbuf)
    9.60 +#define next_buffer		(this->hidden->next_buffer)
    9.61 +/* Old variable names */
    9.62 +#endif /* _SDL_lowaudio_h */
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/audio/riscos/.cvsignore	Tue Jul 22 14:01:21 2003 +0000
    10.3 @@ -0,0 +1,6 @@
    10.4 +Makefile.in
    10.5 +Makefile
    10.6 +.libs
    10.7 +*.o
    10.8 +*.lo
    10.9 +*.la
    11.1 --- a/src/cdrom/Makefile.am	Tue Jul 22 05:29:48 2003 +0000
    11.2 +++ b/src/cdrom/Makefile.am	Tue Jul 22 14:01:21 2003 +0000
    11.3 @@ -5,18 +5,19 @@
    11.4  
    11.5  # Define which subdirectories need to be built
    11.6  SUBDIRS = @CDROM_SUBDIRS@
    11.7 -DIST_SUBDIRS = \
    11.8 -	aix \
    11.9 -	beos \
   11.10 -	bsdi \
   11.11 -	dc \
   11.12 -	dummy \
   11.13 -	freebsd \
   11.14 -	linux \
   11.15 -	macos \
   11.16 -	macosx \
   11.17 -	openbsd \
   11.18 -	qnx \
   11.19 +DIST_SUBDIRS =	\
   11.20 +	aix	\
   11.21 +	beos	\
   11.22 +	bsdi	\
   11.23 +	dc	\
   11.24 +	dummy	\
   11.25 +	freebsd	\
   11.26 +	linux	\
   11.27 +	macos	\
   11.28 +	macosx	\
   11.29 +	openbsd	\
   11.30 +	osf	\
   11.31 +	qnx	\
   11.32  	win32
   11.33  
   11.34  DRIVERS = @CDROM_DRIVERS@
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/cdrom/osf/.cvsignore	Tue Jul 22 14:01:21 2003 +0000
    12.3 @@ -0,0 +1,6 @@
    12.4 +Makefile.in
    12.5 +Makefile
    12.6 +.libs
    12.7 +*.o
    12.8 +*.lo
    12.9 +*.la
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/cdrom/osf/Makefile.am	Tue Jul 22 14:01:21 2003 +0000
    13.3 @@ -0,0 +1,8 @@
    13.4 +
    13.5 +## Makefile.am for the osf cdrom driver for SDL
    13.6 +
    13.7 +noinst_LTLIBRARIES = libcdrom_osf.la
    13.8 +libcdrom_osf_la_SOURCES = $(SRCS)
    13.9 +
   13.10 +# The SDL cdrom driver sources
   13.11 +SRCS =  SDL_syscdrom.c
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/cdrom/osf/SDL_syscdrom.c	Tue Jul 22 14:01:21 2003 +0000
    14.3 @@ -0,0 +1,453 @@
    14.4 +/*
    14.5 +    Tru64 audio module for SDL (Simple DirectMedia Layer)
    14.6 +    Copyright (C) 2003
    14.7 +
    14.8 +    This library is free software; you can redistribute it and/or
    14.9 +    modify it under the terms of the GNU Library General Public
   14.10 +    License as published by the Free Software Foundation; either
   14.11 +    version 2 of the License, or (at your option) any later version.
   14.12 +
   14.13 +    This library is distributed in the hope that it will be useful,
   14.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.16 +    Library General Public License for more details.
   14.17 +
   14.18 +    You should have received a copy of the GNU Library General Public
   14.19 +    License along with this library; if not, write to the Free
   14.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   14.21 +
   14.22 +
   14.23 +*/
   14.24 +
   14.25 +
   14.26 +/* Functions for system-level CD-ROM audio control */
   14.27 +
   14.28 +//#define DEBUG_CDROM 1
   14.29 +
   14.30 +#include <sys/types.h>
   14.31 +#include <sys/stat.h>
   14.32 +#include <fcntl.h>
   14.33 +#include <io/cam/cdrom.h>
   14.34 +#include <io/cam/rzdisk.h>
   14.35 +#include <io/common/devgetinfo.h>
   14.36 +#include <alloca.h>
   14.37 +#include <stdlib.h>
   14.38 +#include <stdio.h>
   14.39 +#include <string.h>
   14.40 +#include <errno.h>
   14.41 +
   14.42 +#include "SDL_error.h"
   14.43 +#include "SDL_cdrom.h"
   14.44 +#include "SDL_syscdrom.h"
   14.45 +
   14.46 +/* The maximum number of CD-ROM drives we'll detect */
   14.47 +#define MAX_DRIVES 16
   14.48 +
   14.49 +/* A list of available CD-ROM drives */
   14.50 +static char *SDL_cdlist[MAX_DRIVES];
   14.51 +static dev_t SDL_cdmode[MAX_DRIVES];
   14.52 +
   14.53 +/* The system-dependent CD control functions */
   14.54 +static const char *SDL_SYS_CDName(int drive);
   14.55 +static int         SDL_SYS_CDOpen(int drive);
   14.56 +static int         SDL_SYS_CDGetTOC(SDL_CD *cdrom);
   14.57 +static CDstatus    SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
   14.58 +static int         SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
   14.59 +static int         SDL_SYS_CDPause(SDL_CD *cdrom);
   14.60 +static int         SDL_SYS_CDResume(SDL_CD *cdrom);
   14.61 +static int         SDL_SYS_CDStop(SDL_CD *cdrom);
   14.62 +static int         SDL_SYS_CDEject(SDL_CD *cdrom);
   14.63 +static void        SDL_SYS_CDClose(SDL_CD *cdrom);
   14.64 +
   14.65 +/* Some ioctl() errno values which occur when the tray is empty */
   14.66 +#define ERRNO_TRAYEMPTY(errno)	\
   14.67 +    ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL))
   14.68 +
   14.69 +/* Check a drive to see if it is a CD-ROM */
   14.70 +/* Caution!! Not tested. */ 
   14.71 +static int CheckDrive(char *drive, struct stat *stbuf)
   14.72 +{
   14.73 +    int is_cd, cdfd;
   14.74 +    struct cd_sub_channel info;
   14.75 +
   14.76 +    /* If it doesn't exist, return -1 */
   14.77 +    if ( stat(drive, stbuf) < 0 ) {
   14.78 +	return(-1);
   14.79 +    }
   14.80 +
   14.81 +    /* If it does exist, verify that it's an available CD-ROM */
   14.82 +    is_cd = 0;
   14.83 +    if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
   14.84 +	cdfd = open(drive, (O_RDWR|O_NDELAY), 0);
   14.85 +	if ( cdfd >= 0 ) {
   14.86 +	    info.sch_address_format = CDROM_MSF_FORMAT;
   14.87 +	    info.sch_data_format = CDROM_CURRENT_POSITION;
   14.88 +	    info.sch_alloc_length = 0;
   14.89 +	    info.sch_track_number = 0;
   14.90 +	    info.sch_buffer = NULL;
   14.91 +	    /*
   14.92 +	     *
   14.93 +	     * Under Linux, EIO occurs when a disk is not present.
   14.94 +	     * This isn't 100% reliable, so we use the USE_MNTENT
   14.95 +	     * code above instead.
   14.96 +	     *
   14.97 +	     */
   14.98 +	    if ( (ioctl(cdfd, CDROM_READ_SUBCHANNEL, &info) == 0) ||
   14.99 +		    ERRNO_TRAYEMPTY(errno) ) {
  14.100 +		is_cd = 1;
  14.101 +	    }
  14.102 +
  14.103 +	    close(cdfd);
  14.104 +	}
  14.105 +    }
  14.106 +
  14.107 +    return(is_cd);
  14.108 +}
  14.109 +
  14.110 +/* Add a CD-ROM drive to our list of valid drives */
  14.111 +static void AddDrive(char *drive, struct stat *stbuf)
  14.112 +{
  14.113 +    int i;
  14.114 +
  14.115 +    if ( SDL_numcds < MAX_DRIVES ) {
  14.116 +	/* Check to make sure it's not already in our list.
  14.117 +	 * This can happen when we see a drive via symbolic link.
  14.118 +	 *
  14.119 +	 * /
  14.120 +	for ( i=0; i<SDL_numcds; ++i ) {
  14.121 +	    if ( stbuf->st_rdev == SDL_cdmode[i] ) {
  14.122 +#ifdef DEBUG_CDROM
  14.123 +  fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
  14.124 +#endif
  14.125 +	    return;
  14.126 +	    }
  14.127 +	}
  14.128 +
  14.129 +	/* Add this drive to our list */
  14.130 +	i = SDL_numcds;
  14.131 +	SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
  14.132 +	if ( SDL_cdlist[i] == NULL ) {
  14.133 +	    SDL_OutOfMemory();
  14.134 +	    return;
  14.135 +	}
  14.136 +
  14.137 +	strcpy(SDL_cdlist[i], drive);
  14.138 +	SDL_cdmode[i] = stbuf->st_rdev;
  14.139 +	++SDL_numcds;
  14.140 +#ifdef DEBUG_CDROM
  14.141 +  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
  14.142 +#endif
  14.143 +    }
  14.144 +}
  14.145 +
  14.146 +int  SDL_SYS_CDInit(void)
  14.147 +{
  14.148 +    /* checklist: /dev/cdrom,/dev/cd?c /dev/acd?c
  14.149 +     * /dev/matcd?c /dev/mcd?c /dev/scd?c
  14.150 +     *
  14.151 +     */
  14.152 +    static char *checklist[] = {
  14.153 +	"?0 rdisk/cdrom?",NULL};
  14.154 +    char drive[32];
  14.155 +    char *SDLcdrom;
  14.156 +    int i, j, exists;
  14.157 +    struct stat stbuf;
  14.158 +
  14.159 +    /* Fill in our driver capabilities */
  14.160 +    SDL_CDcaps.Name   = SDL_SYS_CDName;
  14.161 +    SDL_CDcaps.Open   = SDL_SYS_CDOpen;
  14.162 +    SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
  14.163 +    SDL_CDcaps.Status = SDL_SYS_CDStatus;
  14.164 +    SDL_CDcaps.Play   = SDL_SYS_CDPlay;
  14.165 +    SDL_CDcaps.Pause  = SDL_SYS_CDPause;
  14.166 +    SDL_CDcaps.Resume = SDL_SYS_CDResume;
  14.167 +    SDL_CDcaps.Stop   = SDL_SYS_CDStop;
  14.168 +    SDL_CDcaps.Eject  = SDL_SYS_CDEject;
  14.169 +    SDL_CDcaps.Close  = SDL_SYS_CDClose;
  14.170 +
  14.171 +
  14.172 +    /* Look in the environment for our CD-ROM drive list */
  14.173 +    SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
  14.174 +    if ( SDLcdrom != NULL ) {
  14.175 +	char *cdpath, *delim;
  14.176 +	cdpath = malloc(strlen(SDLcdrom)+1);
  14.177 +	if ( cdpath != NULL ) {
  14.178 +	    strcpy(cdpath, SDLcdrom);
  14.179 +	    SDLcdrom = cdpath;
  14.180 +	    do {
  14.181 +		delim = strchr(SDLcdrom, ':');
  14.182 +		if ( delim ) {
  14.183 +		    *delim++ = '\0';
  14.184 +		}
  14.185 +		if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
  14.186 +		    AddDrive(SDLcdrom, &stbuf);
  14.187 +		}
  14.188 +		if ( delim ) {
  14.189 +		    SDLcdrom = delim;
  14.190 +		} else {
  14.191 +		    SDLcdrom = NULL;
  14.192 +		}
  14.193 +	    } while ( SDLcdrom );
  14.194 +	    free(cdpath);
  14.195 +	}
  14.196 +
  14.197 +	/* If we found our drives, there's nothing left to do */
  14.198 +	if ( SDL_numcds > 0 ) {
  14.199 +	    return(0);
  14.200 +	}
  14.201 +    }
  14.202 +    /* Scan the system for CD-ROM drives */
  14.203 +    for ( i=0; checklist[i]; ++i ) {
  14.204 +	if ( checklist[i][0] == '?' ) {
  14.205 +	    char *insert;
  14.206 +	    exists = 1;
  14.207 +	    for ( j=checklist[i][1]; exists; ++j ) {
  14.208 +		sprintf(drive, "/dev/%sc", &checklist[i][3]);
  14.209 +		insert = strchr(drive, '?');
  14.210 +		if ( insert != NULL ) {
  14.211 +		    *insert = j;
  14.212 +		}
  14.213 +		switch (CheckDrive(drive, &stbuf)) {
  14.214 +		    /* Drive exists and is a CD-ROM */
  14.215 +		    case 1:
  14.216 +			AddDrive(drive, &stbuf);
  14.217 +			break;
  14.218 +			/* Drive exists, but isn't a CD-ROM */
  14.219 +		    case 0:
  14.220 +			break;
  14.221 +			/* Drive doesn't exist */
  14.222 +		    case -1:
  14.223 +			exists = 0;
  14.224 +			break;
  14.225 +		}
  14.226 +	    }
  14.227 +	} else {
  14.228 +	    sprintf(drive, "/dev/%s", checklist[i]);
  14.229 +	    if ( CheckDrive(drive, &stbuf) > 0 ) {
  14.230 +		AddDrive(drive, &stbuf);
  14.231 +	    }
  14.232 +	}
  14.233 +    }
  14.234 +/*
  14.235 +    SDLcdrom=malloc(sizeof(char) * 32);
  14.236 +    strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
  14.237 +    SDL_cdlist[0] = SDLcdrom;
  14.238 +    stat(SDLcdrom, &stbuf);
  14.239 +    SDL_cdmode[0] = stbuf.st_rdev;
  14.240 +    SDL_numcds = 1;
  14.241 + */
  14.242 +    return (0);
  14.243 +}
  14.244 +
  14.245 +static const char *SDL_SYS_CDName(int drive)
  14.246 +{
  14.247 +    return(SDL_cdlist[drive]);
  14.248 +}
  14.249 +
  14.250 +static int SDL_SYS_CDOpen(int drive)
  14.251 +{
  14.252 +    /* O_RDWR: To use ioctl(fd, SCSI_STOP_UNIT) */
  14.253 +    return(open(SDL_cdlist[drive], (O_RDWR|O_NDELAY), 0));
  14.254 +}
  14.255 +
  14.256 +static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
  14.257 +{
  14.258 +    struct cd_toc                  toc;
  14.259 +    struct cd_toc_header           hdr;
  14.260 +    struct cd_toc_entry          *cdte;
  14.261 +    int i;
  14.262 +    int okay = 0;
  14.263 +    if ( ioctl(cdrom->id, CDROM_TOC_HEADER, &hdr) ) {
  14.264 +	fprintf(stderr,"ioctl error CDROM_TOC_HEADER\n");
  14.265 +	return -1;
  14.266 +    }
  14.267 +    cdrom->numtracks = hdr.th_ending_track - hdr.th_starting_track + 1;
  14.268 +    if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
  14.269 +	cdrom->numtracks = SDL_MAX_TRACKS;
  14.270 +    }
  14.271 +#ifdef DEBUG_CDROM
  14.272 +  fprintf(stderr,"hdr.th_data_len1 = %d\n", hdr.th_data_len1);
  14.273 +  fprintf(stderr,"hdr.th_data_len0 = %d\n", hdr.th_data_len0);
  14.274 +  fprintf(stderr,"hdr.th_starting_track = %d\n", hdr.th_starting_track);
  14.275 +  fprintf(stderr,"hdr.th_ending_track = %d\n", hdr.th_ending_track);
  14.276 +  fprintf(stderr,"cdrom->numtracks = %d\n", cdrom->numtracks);
  14.277 +#endif
  14.278 +    toc.toc_address_format = CDROM_LBA_FORMAT;
  14.279 +    toc.toc_starting_track = 0;
  14.280 +    toc.toc_alloc_length = (hdr.th_data_len1 << 8) +
  14.281 +			    hdr.th_data_len0 + sizeof(hdr);
  14.282 +    if ( (toc.toc_buffer = alloca(toc.toc_alloc_length)) == NULL) {
  14.283 +	fprintf(stderr,"cannot allocate toc.toc_buffer\n");
  14.284 +	return -1;
  14.285 +    }
  14.286 +
  14.287 +    bzero (toc.toc_buffer, toc.toc_alloc_length);
  14.288 +    if (ioctl(cdrom->id, CDROM_TOC_ENTRYS, &toc)) {
  14.289 +	fprintf(stderr,"ioctl error CDROM_TOC_ENTRYS\n");
  14.290 +	return -1;
  14.291 +    }
  14.292 +
  14.293 +    (char *)cdte = toc.toc_buffer + sizeof(hdr);
  14.294 +	for (i=0; i <= cdrom->numtracks; ++i) {
  14.295 +	    if (i == cdrom->numtracks ) {
  14.296 +		cdrom->track[i].id = 0xAA;;
  14.297 +	    } else {
  14.298 +		cdrom->track[i].id = hdr.th_starting_track + i;
  14.299 +	    }
  14.300 +
  14.301 +	    cdrom->track[i].type =
  14.302 +		cdte[i].te_control & CDROM_DATA_TRACK;
  14.303 +	    cdrom->track[i].offset =
  14.304 +		cdte[i].te_absaddr.lba.addr3 << 24 |
  14.305 +		cdte[i].te_absaddr.lba.addr2 << 16 |
  14.306 +		cdte[i].te_absaddr.lba.addr1 << 8  |
  14.307 +		cdte[i].te_absaddr.lba.addr0;
  14.308 +	    cdrom->track[i].length = 0;
  14.309 +	    if ( i > 0 ) {
  14.310 +		cdrom->track[i - 1].length =
  14.311 +		    cdrom->track[i].offset -
  14.312 +		    cdrom->track[i - 1].offset;
  14.313 +	    }
  14.314 +	}
  14.315 +#ifdef DEBUG_CDROM
  14.316 +  for (i = 0; i <= cdrom->numtracks; i++) {
  14.317 +    fprintf(stderr,"toc_entry[%d].te_track_number = %d\n",
  14.318 +	    i,cdte[i].te_track_number);
  14.319 +    fprintf(stderr,"cdrom->track[%d].id = %d\n", i,cdrom->track[i].id);
  14.320 +    fprintf(stderr,"cdrom->track[%d].type = %x\n", i,cdrom->track[i].type);
  14.321 +    fprintf(stderr,"cdrom->track[%d].offset = %d\n", i,cdrom->track[i].offset);
  14.322 +    fprintf(stderr,"cdrom->track[%d].length = %d\n", i,cdrom->track[i].length);
  14.323 +  }
  14.324 +#endif
  14.325 +    if ( i == (cdrom->numtracks+1) ) {
  14.326 +	okay = 1;
  14.327 +    }
  14.328 +
  14.329 +    return(okay ? 0 : -1);
  14.330 +}
  14.331 +
  14.332 +/* Get CD-ROM status */
  14.333 +static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
  14.334 +{
  14.335 +    CDstatus                     status;
  14.336 +    struct cd_sub_channel            sc;
  14.337 +    struct cd_subc_channel_data     scd;
  14.338 +
  14.339 +    sc.sch_address_format = CDROM_LBA_FORMAT;
  14.340 +    sc.sch_data_format    = CDROM_CURRENT_POSITION;
  14.341 +    sc.sch_track_number   = 0;
  14.342 +    sc.sch_alloc_length   = sizeof(scd);
  14.343 +    sc.sch_buffer         = (caddr_t)&scd;
  14.344 +    if ( ioctl(cdrom->id, CDROM_READ_SUBCHANNEL, &sc) ) {
  14.345 +	status = CD_ERROR;
  14.346 +	fprintf(stderr,"ioctl error CDROM_READ_SUBCHANNEL \n");
  14.347 +    } else {
  14.348 +	switch (scd.scd_header.sh_audio_status) {
  14.349 +	    case AS_AUDIO_INVALID:
  14.350 +		status = CD_STOPPED;
  14.351 +		break;
  14.352 +	    case AS_PLAY_IN_PROGRESS:
  14.353 +		status = CD_PLAYING;
  14.354 +		break;
  14.355 +	    case AS_PLAY_PAUSED:
  14.356 +		status = CD_PAUSED;
  14.357 +		break;
  14.358 +	    case AS_PLAY_COMPLETED:
  14.359 +		status = CD_STOPPED;
  14.360 +		break;
  14.361 +	    case AS_PLAY_ERROR:
  14.362 +		status = CD_ERROR;
  14.363 +		break;
  14.364 +	    case AS_NO_STATUS:
  14.365 +		status = CD_STOPPED;
  14.366 +		break;
  14.367 +	    default:
  14.368 +		status = CD_ERROR;
  14.369 +		break;
  14.370 +	}
  14.371 +#ifdef DEBUG_CDROM
  14.372 +  fprintf(stderr,"scd.scd_header.sh_audio_status = %x\n",
  14.373 +	scd.scd_header.sh_audio_status);
  14.374 +#endif
  14.375 +    }
  14.376 +    if (position) {
  14.377 +	if (status == CD_PLAYING || (status == CD_PAUSED) ) {
  14.378 +	    *position =
  14.379 +		scd.scd_position_data.scp_absaddr.lba.addr3 << 24 |
  14.380 +		scd.scd_position_data.scp_absaddr.lba.addr2 << 16 |
  14.381 +		scd.scd_position_data.scp_absaddr.lba.addr1 << 8  |
  14.382 +		scd.scd_position_data.scp_absaddr.lba.addr0;
  14.383 +	} else {
  14.384 +	    *position = 0;
  14.385 +	}
  14.386 +    }
  14.387 +
  14.388 +    return status;
  14.389 +}
  14.390 +
  14.391 +/* Start play */
  14.392 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
  14.393 +{
  14.394 +/* Play MSF
  14.395 + *
  14.396 + */
  14.397 +    struct cd_play_audio_msf msf;
  14.398 +    int end;
  14.399 +
  14.400 +    bzero(&msf, sizeof(msf));
  14.401 +    end = start +length;
  14.402 +    FRAMES_TO_MSF(start,
  14.403 +		  &msf.msf_starting_M_unit,
  14.404 +		  &msf.msf_starting_S_unit,
  14.405 +		  &msf.msf_starting_F_unit);
  14.406 +    FRAMES_TO_MSF(end,
  14.407 +		  &msf.msf_ending_M_unit,
  14.408 +		  &msf.msf_ending_S_unit,
  14.409 +		  &msf.msf_ending_F_unit);
  14.410 +
  14.411 +    return(ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf));
  14.412 +}
  14.413 +
  14.414 +/* Pause play */
  14.415 +static int SDL_SYS_CDPause(SDL_CD *cdrom)
  14.416 +{
  14.417 +    return(ioctl(cdrom->id, CDROM_PAUSE_PLAY));
  14.418 +}
  14.419 +
  14.420 +/* Resume play */
  14.421 +static int SDL_SYS_CDResume(SDL_CD *cdrom)
  14.422 +{
  14.423 +    return(ioctl(cdrom->id, CDROM_RESUME_PLAY));
  14.424 +}
  14.425 +
  14.426 +/* Stop play */
  14.427 +static int SDL_SYS_CDStop(SDL_CD *cdrom)
  14.428 +{
  14.429 +    return(ioctl(cdrom->id, SCSI_STOP_UNIT));
  14.430 +}
  14.431 +
  14.432 +/* Eject the CD-ROM */
  14.433 +static int SDL_SYS_CDEject(SDL_CD *cdrom)
  14.434 +{
  14.435 +    return(ioctl(cdrom->id, CDROM_EJECT_CADDY));
  14.436 +}
  14.437 +
  14.438 +/* Close the CD-ROM handle */
  14.439 +static void SDL_SYS_CDClose(SDL_CD *cdrom)
  14.440 +{
  14.441 +    close(cdrom->id);
  14.442 +}
  14.443 +
  14.444 +void SDL_SYS_CDQuit(void)
  14.445 +{
  14.446 +    int i;
  14.447 +
  14.448 +    if ( SDL_numcds > 0 ) {
  14.449 +	for ( i=0; i<SDL_numcds; ++i ) {
  14.450 +	    free(SDL_cdlist[i]);
  14.451 +	}
  14.452 +	SDL_numcds = 0;
  14.453 +    }
  14.454 +}
  14.455 +
  14.456 +