misc/winutils/include/SDL_cdrom.h
changeset 10017 de822cd3df3a
parent 7809 7d4fb2f35f4f
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
    43  *  with the SDL_INIT_CDROM flag.  This causes SDL to scan the system
    43  *  with the SDL_INIT_CDROM flag.  This causes SDL to scan the system
    44  *  for CD-ROM drives, and load appropriate drivers.
    44  *  for CD-ROM drives, and load appropriate drivers.
    45  */
    45  */
    46 
    46 
    47 /** The maximum number of CD-ROM tracks on a disk */
    47 /** The maximum number of CD-ROM tracks on a disk */
    48 #define SDL_MAX_TRACKS	99
    48 #define SDL_MAX_TRACKS  99
    49 
    49 
    50 /** @name Track Types
    50 /** @name Track Types
    51  *  The types of CD-ROM track possible
    51  *  The types of CD-ROM track possible
    52  */
    52  */
    53 /*@{*/
    53 /*@{*/
    54 #define SDL_AUDIO_TRACK	0x00
    54 #define SDL_AUDIO_TRACK 0x00
    55 #define SDL_DATA_TRACK	0x04
    55 #define SDL_DATA_TRACK  0x04
    56 /*@}*/
    56 /*@}*/
    57 
    57 
    58 /** The possible states which a CD-ROM drive can be in. */
    58 /** The possible states which a CD-ROM drive can be in. */
    59 typedef enum {
    59 typedef enum {
    60 	CD_TRAYEMPTY,
    60     CD_TRAYEMPTY,
    61 	CD_STOPPED,
    61     CD_STOPPED,
    62 	CD_PLAYING,
    62     CD_PLAYING,
    63 	CD_PAUSED,
    63     CD_PAUSED,
    64 	CD_ERROR = -1
    64     CD_ERROR = -1
    65 } CDstatus;
    65 } CDstatus;
    66 
    66 
    67 /** Given a status, returns true if there's a disk in the drive */
    67 /** Given a status, returns true if there's a disk in the drive */
    68 #define CD_INDRIVE(status)	((int)(status) > 0)
    68 #define CD_INDRIVE(status)  ((int)(status) > 0)
    69 
    69 
    70 typedef struct SDL_CDtrack {
    70 typedef struct SDL_CDtrack {
    71 	Uint8 id;		/**< Track number */
    71     Uint8 id;       /**< Track number */
    72 	Uint8 type;		/**< Data or audio track */
    72     Uint8 type;     /**< Data or audio track */
    73 	Uint16 unused;
    73     Uint16 unused;
    74 	Uint32 length;		/**< Length, in frames, of this track */
    74     Uint32 length;      /**< Length, in frames, of this track */
    75 	Uint32 offset;		/**< Offset, in frames, from start of disk */
    75     Uint32 offset;      /**< Offset, in frames, from start of disk */
    76 } SDL_CDtrack;
    76 } SDL_CDtrack;
    77 
    77 
    78 /** This structure is only current as of the last call to SDL_CDStatus() */
    78 /** This structure is only current as of the last call to SDL_CDStatus() */
    79 typedef struct SDL_CD {
    79 typedef struct SDL_CD {
    80 	int id;			/**< Private drive identifier */
    80     int id;         /**< Private drive identifier */
    81 	CDstatus status;	/**< Current drive status */
    81     CDstatus status;    /**< Current drive status */
    82 
    82 
    83 	/** The rest of this structure is only valid if there's a CD in drive */
    83     /** The rest of this structure is only valid if there's a CD in drive */
    84         /*@{*/
    84         /*@{*/
    85 	int numtracks;		/**< Number of tracks on disk */
    85     int numtracks;      /**< Number of tracks on disk */
    86 	int cur_track;		/**< Current track position */
    86     int cur_track;      /**< Current track position */
    87 	int cur_frame;		/**< Current frame offset within current track */
    87     int cur_frame;      /**< Current frame offset within current track */
    88 	SDL_CDtrack track[SDL_MAX_TRACKS+1];
    88     SDL_CDtrack track[SDL_MAX_TRACKS+1];
    89         /*@}*/
    89         /*@}*/
    90 } SDL_CD;
    90 } SDL_CD;
    91 
    91 
    92 /** @name Frames / MSF Conversion Functions
    92 /** @name Frames / MSF Conversion Functions
    93  *  Conversion functions from frames to Minute/Second/Frames and vice versa
    93  *  Conversion functions from frames to Minute/Second/Frames and vice versa
    94  */
    94  */
    95 /*@{*/
    95 /*@{*/
    96 #define CD_FPS	75
    96 #define CD_FPS  75
    97 #define FRAMES_TO_MSF(f, M,S,F)	{					\
    97 #define FRAMES_TO_MSF(f, M,S,F) {                   \
    98 	int value = f;							\
    98     int value = f;                          \
    99 	*(F) = value%CD_FPS;						\
    99     *(F) = value%CD_FPS;                        \
   100 	value /= CD_FPS;						\
   100     value /= CD_FPS;                        \
   101 	*(S) = value%60;						\
   101     *(S) = value%60;                        \
   102 	value /= 60;							\
   102     value /= 60;                            \
   103 	*(M) = value;							\
   103     *(M) = value;                           \
   104 }
   104 }
   105 #define MSF_TO_FRAMES(M, S, F)	((M)*60*CD_FPS+(S)*CD_FPS+(F))
   105 #define MSF_TO_FRAMES(M, S, F)  ((M)*60*CD_FPS+(S)*CD_FPS+(F))
   106 /*@}*/
   106 /*@}*/
   107 
   107 
   108 /* CD-audio API functions: */
   108 /* CD-audio API functions: */
   109 
   109 
   110 /**
   110 /**
   138  */
   138  */
   139 extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
   139 extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
   140 
   140 
   141 /**
   141 /**
   142  *  Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
   142  *  Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
   143  *  tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play 
   143  *  tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play
   144  *  until the end of the CD.  This function will skip data tracks.
   144  *  until the end of the CD.  This function will skip data tracks.
   145  *  This function should only be called after calling SDL_CDStatus() to 
   145  *  This function should only be called after calling SDL_CDStatus() to
   146  *  get track information about the CD.
   146  *  get track information about the CD.
   147  *  For example:
   147  *  For example:
   148  *      @code
   148  *      @code
   149  *	// Play entire CD:
   149  *  // Play entire CD:
   150  *	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
   150  *  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
   151  *		SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
   151  *      SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
   152  *	// Play last track:
   152  *  // Play last track:
   153  *	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
   153  *  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
   154  *		SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
   154  *      SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
   155  *	}
   155  *  }
   156  *	// Play first and second track and 10 seconds of third track:
   156  *  // Play first and second track and 10 seconds of third track:
   157  *	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
   157  *  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
   158  *		SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
   158  *      SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
   159  *      @endcode
   159  *      @endcode
   160  *
   160  *
   161  *  @return This function returns 0, or -1 if there was an error.
   161  *  @return This function returns 0, or -1 if there was an error.
   162  */
   162  */
   163 extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom,
   163 extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom,
   164 		int start_track, int start_frame, int ntracks, int nframes);
   164         int start_track, int start_frame, int ntracks, int nframes);
   165 
   165 
   166 /**
   166 /**
   167  *  Play the given CD starting at 'start' frame for 'length' frames.
   167  *  Play the given CD starting at 'start' frame for 'length' frames.
   168  *  @return It returns 0, or -1 if there was an error.
   168  *  @return It returns 0, or -1 if there was an error.
   169  */
   169  */