Here’s the proposed CD-ROM API.
I’ve looked at how Linux, Solaris, Win32, and BeOS do CD audio control,
and I think this can mostly be supported on all platforms:
/* Note: Track positions are in terms of frames (75 frames-per-second) */
typedef enum {
CD_STOPPED,
CD_PLAYING,
CD_PAUSED,
CD_ERROR = -1,
CD_TRAYEMPTY = -2
CD_INVALIDTRACK = -3, /* Used for error reporting /
CD_INVALIDFRAME = -4 / Used for error reporting */
} CDstatus;
/* Returns the number of CD-ROM drives on the system */
int SDL_CDNumDrives();
/* Opens a CD-ROM drive – a CD may or may not be in the drive */
SDL_CD *SDL_CDOpen(int drive);
/* Returns number of CD-ROMs available on this drive (multi-changer support) */
int SDL_CDNumCDs(SDL_CD *cdrom);
/* Selects which CD is to be played (multi-changer support) */
void SDL_CDSelectCD(SDL_CD *cdrom, int which);
/* Returns the serial number of the current CD-ROM */
CDstatus SDL_CDGetID(SDL_CD *cdrom, Uint8 id[8]);
/* Returns the number of tracks on the current CD-ROM */
CDstatus SDL_CDNumTracks(SDL_CD *cdrom);
/* Returns the length, in frames, of the given track */
CDstatus SDL_CDTrackLength(SDL_CD *cdrom, int track, int *length);
/* Returns whether the given track is audio or data */
CDstatus SDL_CDTrackType(SDL_CD *cdrom, int track);
/* Returns the current status and position of the CD-ROM */
CDstatus SDL_CDStatus(SDL_CD *cdrom, int *track, int *frame);
/* Reads a data track, if supported */
CDstatus SDL_CDRead(SDL_CD *cdrom, int start_track, int start_frame, int end_track, int end_frame);
/* Plays an audio track from start_track.start_frame to end_track.end_frame.
Values of 0 are “use current value” flags.
*/
CDstatus SDL_CDPlay(SDL_CD *cdrom, int start_track, int start_frame, int end_track, int end_frame);
/* Pause play – returns status before pause */
CDstatus SDL_CDPause(SDL_CD *cdrom);
/* Stop play – returns status before stop */
int SDL_CDStop(SDL_CD *cdrom);
/* Eject CD-ROM – returns status before eject */
int SDL_CDEject(SDL_CD *cdrom);
/* Set the current CD audio output volume – returns previous volume.
If ‘volume’ is -1, the current volume is unchanged.
*/
int SDL_CDVolume(SDL_CD *cdrom, int volume);
/* Close a previously opened CD-ROM drive */
void SDL_CDClose(SDL_CD *cdrom);----
This seems fairly complete. Did I miss anything?
Play stop notification will have to be done by polling.
Programming play sequences will have to be done by the application.
The functions (hopefully) will be thread-safe.
See ya!
-Sam Lantinga (slouken at devolution.com)