Subversion Repositories Kolibri OS

Rev

Rev 8209 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.     SDL - Simple DirectMedia Layer
  3.     Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public
  16.     License along with this library; if not, write to the Free
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19.     Sam Lantinga
  20.     slouken@devolution.com
  21. */
  22.  
  23. #ifdef SAVE_RCSID
  24. static char rcsid =
  25.  "@(#) $Id: SDL_cdrom.h,v 1.2 2001/04/26 16:50:17 hercules Exp $";
  26. #endif
  27.  
  28. /* This is the CD-audio control API for Simple DirectMedia Layer */
  29.  
  30. #ifndef _SDL_cdrom_h
  31. #define _SDL_cdrom_h
  32.  
  33. #include <stddef.h>
  34.  
  35. #include "SDL_types.h"
  36.  
  37. #include "begin_code.h"
  38. /* Set up for C function definitions, even when using C++ */
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. /* In order to use these functions, SDL_Init() must have been called
  44.    with the SDL_INIT_CDROM flag.  This causes SDL to scan the system
  45.    for CD-ROM drives, and load appropriate drivers.
  46. */
  47.  
  48. #warning "CD-ROM support in SDL is not implemented for KolibriOS. All functions are stubs!"
  49.  
  50. /* The maximum number of CD-ROM tracks on a disk */
  51. #define SDL_MAX_TRACKS  99
  52.  
  53. /* The types of CD-ROM track possible */
  54. #define SDL_AUDIO_TRACK 0x00
  55. #define SDL_DATA_TRACK  0x04
  56.  
  57. /* The possible states which a CD-ROM drive can be in. */
  58. typedef enum {
  59.         CD_TRAYEMPTY,
  60.         CD_STOPPED,
  61.         CD_PLAYING,
  62.         CD_PAUSED,
  63.         CD_ERROR = -1
  64. } CDstatus;
  65.  
  66. /* Given a status, returns true if there's a disk in the drive */
  67. #define CD_INDRIVE(status)      ((int)status > 0)
  68.  
  69. typedef struct {
  70.         Uint8 id;               /* Track number */
  71.         Uint8 type;             /* Data or audio track */
  72.         Uint16 unused;
  73.         Uint32 length;          /* Length, in frames, of this track */
  74.         Uint32 offset;          /* Offset, in frames, from start of disk */
  75. } SDL_CDtrack;
  76.  
  77. /* This structure is only current as of the last call to SDL_CDStatus() */
  78. typedef struct SDL_CD {
  79.         int id;                 /* Private drive identifier */
  80.         CDstatus status;        /* Current drive status */
  81.  
  82.         /* The rest of this structure is only valid if there's a CD in drive */
  83.         int numtracks;          /* Number of tracks on disk */
  84.         int cur_track;          /* Current track position */
  85.         int cur_frame;          /* Current frame offset within current track */
  86.         SDL_CDtrack track[SDL_MAX_TRACKS+1];
  87. } SDL_CD;
  88.  
  89. /* Conversion functions from frames to Minute/Second/Frames and vice versa */
  90. #define CD_FPS  75
  91. #define FRAMES_TO_MSF(f, M,S,F) {                                       \
  92.         int value = f;                                                  \
  93.         *(F) = value%CD_FPS;                                            \
  94.         value /= CD_FPS;                                                \
  95.         *(S) = value%60;                                                \
  96.         value /= 60;                                                    \
  97.         *(M) = value;                                                   \
  98. }
  99. #define MSF_TO_FRAMES(M, S, F)  ((M)*60*CD_FPS+(S)*CD_FPS+(F))
  100.  
  101. /* CD-audio API functions: */
  102.  
  103. /* Returns the number of CD-ROM drives on the system, or -1 if
  104.    SDL_Init() has not been called with the SDL_INIT_CDROM flag.
  105.  */
  106. static inline DECLSPEC int SDL_CDNumDrives(void)
  107. {
  108.         return -1;
  109. }
  110.  
  111. /* Returns a human-readable, system-dependent identifier for the CD-ROM.
  112.    Example:
  113.         "/dev/cdrom"
  114.         "E:"
  115.         "/dev/disk/ide/1/master"
  116. */
  117. static inline DECLSPEC const char * SDL_CDName(int drive)
  118. {
  119.         return NULL;
  120. }
  121.  
  122. /* Opens a CD-ROM drive for access.  It returns a drive handle on success,
  123.    or NULL if the drive was invalid or busy.  This newly opened CD-ROM
  124.    becomes the default CD used when other CD functions are passed a NULL
  125.    CD-ROM handle.
  126.    Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
  127. */
  128. static inline DECLSPEC SDL_CD * SDL_CDOpen(int drive)
  129. {
  130.         return NULL;
  131. }
  132.  
  133. /* This function returns the current status of the given drive.
  134.    If the drive has a CD in it, the table of contents of the CD and current
  135.    play position of the CD will be stored in the SDL_CD structure.
  136. */
  137. static inline DECLSPEC CDstatus SDL_CDStatus(SDL_CD *cdrom)
  138. {
  139.         return CD_ERROR;
  140. }
  141.  
  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
  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
  146.    get track information about the CD.
  147.    For example:
  148.         // Play entire CD:
  149.         if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
  150.                 SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
  151.         // Play last track:
  152.         if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
  153.                 SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
  154.         }
  155.         // Play first and second track and 10 seconds of third track:
  156.         if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
  157.                 SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
  158.  
  159.    This function returns 0, or -1 if there was an error.
  160. */
  161. static inline DECLSPEC int SDL_CDPlayTracks(SDL_CD *cdrom,
  162.                 int start_track, int start_frame, int ntracks, int nframes)
  163. {
  164.         return CD_ERROR;
  165. }
  166.  
  167. /* Play the given CD starting at 'start' frame for 'length' frames.
  168.    It returns 0, or -1 if there was an error.
  169. */
  170. static inline DECLSPEC int SDL_CDPlay(SDL_CD *cdrom, int start, int length)
  171. {
  172.         return CD_ERROR;
  173. }
  174.  
  175. /* Pause play -- returns 0, or -1 on error */
  176. static inline DECLSPEC int SDL_CDPause(SDL_CD *cdrom)
  177. {
  178.         return CD_ERROR;       
  179. }
  180.  
  181. /* Resume play -- returns 0, or -1 on error */
  182. static inline DECLSPEC int SDL_CDResume(SDL_CD *cdrom)
  183. {
  184.         return CD_ERROR;
  185. }
  186.  
  187. /* Stop play -- returns 0, or -1 on error */
  188. static inline DECLSPEC int SDL_CDStop(SDL_CD *cdrom)
  189. {
  190.         return CD_ERROR;
  191. }
  192.  
  193. /* Eject CD-ROM -- returns 0, or -1 on error */
  194. static inline DECLSPEC int SDL_CDEject(SDL_CD *cdrom)
  195. {
  196.         return CD_ERROR;
  197. }
  198.  
  199. /* Closes the handle for the CD-ROM drive */
  200. static inline DECLSPEC void SDL_CDClose(SDL_CD *cdrom)
  201. {
  202.         /* STUB! */
  203. }
  204.  
  205. /* Ends C function definitions when using C++ */
  206. #ifdef __cplusplus
  207. }
  208. #endif
  209. #include "close_code.h"
  210.  
  211. #endif /* _SDL_video_h */
  212.