18 |
18 |
19 Sam Lantinga |
19 Sam Lantinga |
20 slouken@libsdl.org |
20 slouken@libsdl.org |
21 */ |
21 */ |
22 |
22 |
23 /* This is the CD-audio control API for Simple DirectMedia Layer */ |
23 /** |
|
24 * \file SDL_cdrom.h |
|
25 * |
|
26 * This is the CD-audio control API for Simple DirectMedia Layer |
|
27 */ |
24 |
28 |
25 #ifndef _SDL_cdrom_h |
29 #ifndef _SDL_cdrom_h |
26 #define _SDL_cdrom_h |
30 #define _SDL_cdrom_h |
27 |
31 |
28 #include "SDL_stdinc.h" |
32 #include "SDL_stdinc.h" |
29 #include "SDL_error.h" |
33 #include "SDL_error.h" |
30 |
34 |
31 #include "begin_code.h" |
35 #include "begin_code.h" |
32 /* Set up for C function definitions, even when using C++ */ |
36 /* Set up for C function definitions, even when using C++ */ |
33 #ifdef __cplusplus |
37 #ifdef __cplusplus |
|
38 /* *INDENT-OFF* */ |
34 extern "C" { |
39 extern "C" { |
|
40 /* *INDENT-ON* */ |
35 #endif |
41 #endif |
36 |
42 |
37 /* In order to use these functions, SDL_Init() must have been called |
43 /* In order to use these functions, SDL_Init() must have been called |
38 with the SDL_INIT_CDROM flag. This causes SDL to scan the system |
44 with the SDL_INIT_CDROM flag. This causes SDL to scan the system |
39 for CD-ROM drives, and load appropriate drivers. |
45 for CD-ROM drives, and load appropriate drivers. |
45 /* The types of CD-ROM track possible */ |
51 /* The types of CD-ROM track possible */ |
46 #define SDL_AUDIO_TRACK 0x00 |
52 #define SDL_AUDIO_TRACK 0x00 |
47 #define SDL_DATA_TRACK 0x04 |
53 #define SDL_DATA_TRACK 0x04 |
48 |
54 |
49 /* The possible states which a CD-ROM drive can be in. */ |
55 /* The possible states which a CD-ROM drive can be in. */ |
50 typedef enum { |
56 typedef enum |
51 CD_TRAYEMPTY, |
57 { |
52 CD_STOPPED, |
58 CD_TRAYEMPTY, |
53 CD_PLAYING, |
59 CD_STOPPED, |
54 CD_PAUSED, |
60 CD_PLAYING, |
55 CD_ERROR = -1 |
61 CD_PAUSED, |
|
62 CD_ERROR = -1 |
56 } CDstatus; |
63 } CDstatus; |
57 |
64 |
58 /* Given a status, returns true if there's a disk in the drive */ |
65 /* Given a status, returns true if there's a disk in the drive */ |
59 #define CD_INDRIVE(status) ((int)(status) > 0) |
66 #define CD_INDRIVE(status) ((int)(status) > 0) |
60 |
67 |
61 typedef struct SDL_CDtrack { |
68 typedef struct SDL_CDtrack |
62 Uint8 id; /* Track number */ |
69 { |
63 Uint8 type; /* Data or audio track */ |
70 Uint8 id; /* Track number */ |
64 Uint16 unused; |
71 Uint8 type; /* Data or audio track */ |
65 Uint32 length; /* Length, in frames, of this track */ |
72 Uint16 unused; |
66 Uint32 offset; /* Offset, in frames, from start of disk */ |
73 Uint32 length; /* Length, in frames, of this track */ |
|
74 Uint32 offset; /* Offset, in frames, from start of disk */ |
67 } SDL_CDtrack; |
75 } SDL_CDtrack; |
68 |
76 |
69 /* This structure is only current as of the last call to SDL_CDStatus() */ |
77 /* This structure is only current as of the last call to SDL_CDStatus() */ |
70 typedef struct SDL_CD { |
78 typedef struct SDL_CD |
71 int id; /* Private drive identifier */ |
79 { |
72 CDstatus status; /* Current drive status */ |
80 int id; /* Private drive identifier */ |
|
81 CDstatus status; /* Current drive status */ |
73 |
82 |
74 /* 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 */ |
75 int numtracks; /* Number of tracks on disk */ |
84 int numtracks; /* Number of tracks on disk */ |
76 int cur_track; /* Current track position */ |
85 int cur_track; /* Current track position */ |
77 int cur_frame; /* Current frame offset within current track */ |
86 int cur_frame; /* Current frame offset within current track */ |
78 SDL_CDtrack track[SDL_MAX_TRACKS+1]; |
87 SDL_CDtrack track[SDL_MAX_TRACKS + 1]; |
79 } SDL_CD; |
88 } SDL_CD; |
80 |
89 |
81 /* Conversion functions from frames to Minute/Second/Frames and vice versa */ |
90 /* Conversion functions from frames to Minute/Second/Frames and vice versa */ |
82 #define CD_FPS 75 |
91 #define CD_FPS 75 |
83 #define FRAMES_TO_MSF(f, M,S,F) { \ |
92 #define FRAMES_TO_MSF(f, M,S,F) { \ |
101 Example: |
110 Example: |
102 "/dev/cdrom" |
111 "/dev/cdrom" |
103 "E:" |
112 "E:" |
104 "/dev/disk/ide/1/master" |
113 "/dev/disk/ide/1/master" |
105 */ |
114 */ |
106 extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); |
115 extern DECLSPEC const char *SDLCALL SDL_CDName(int drive); |
107 |
116 |
108 /* Opens a CD-ROM drive for access. It returns a drive handle on success, |
117 /* Opens a CD-ROM drive for access. It returns a drive handle on success, |
109 or NULL if the drive was invalid or busy. This newly opened CD-ROM |
118 or NULL if the drive was invalid or busy. This newly opened CD-ROM |
110 becomes the default CD used when other CD functions are passed a NULL |
119 becomes the default CD used when other CD functions are passed a NULL |
111 CD-ROM handle. |
120 CD-ROM handle. |
112 Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. |
121 Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. |
113 */ |
122 */ |
114 extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); |
123 extern DECLSPEC SDL_CD *SDLCALL SDL_CDOpen(int drive); |
115 |
124 |
116 /* This function returns the current status of the given drive. |
125 /* This function returns the current status of the given drive. |
117 If the drive has a CD in it, the table of contents of the CD and current |
126 If the drive has a CD in it, the table of contents of the CD and current |
118 play position of the CD will be stored in the SDL_CD structure. |
127 play position of the CD will be stored in the SDL_CD structure. |
119 */ |
128 */ |
120 extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); |
129 extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD * cdrom); |
121 |
130 |
122 /* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' |
131 /* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' |
123 tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play |
132 tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play |
124 until the end of the CD. This function will skip data tracks. |
133 until the end of the CD. This function will skip data tracks. |
125 This function should only be called after calling SDL_CDStatus() to |
134 This function should only be called after calling SDL_CDStatus() to |
136 if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) |
145 if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) |
137 SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); |
146 SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); |
138 |
147 |
139 This function returns 0, or -1 if there was an error. |
148 This function returns 0, or -1 if there was an error. |
140 */ |
149 */ |
141 extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, |
150 extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD * cdrom, |
142 int start_track, int start_frame, int ntracks, int nframes); |
151 int start_track, |
|
152 int start_frame, int ntracks, |
|
153 int nframes); |
143 |
154 |
144 /* Play the given CD starting at 'start' frame for 'length' frames. |
155 /* Play the given CD starting at 'start' frame for 'length' frames. |
145 It returns 0, or -1 if there was an error. |
156 It returns 0, or -1 if there was an error. |
146 */ |
157 */ |
147 extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); |
158 extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD * cdrom, int start, int length); |
148 |
159 |
149 /* Pause play -- returns 0, or -1 on error */ |
160 /* Pause play -- returns 0, or -1 on error */ |
150 extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); |
161 extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD * cdrom); |
151 |
162 |
152 /* Resume play -- returns 0, or -1 on error */ |
163 /* Resume play -- returns 0, or -1 on error */ |
153 extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); |
164 extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD * cdrom); |
154 |
165 |
155 /* Stop play -- returns 0, or -1 on error */ |
166 /* Stop play -- returns 0, or -1 on error */ |
156 extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); |
167 extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD * cdrom); |
157 |
168 |
158 /* Eject CD-ROM -- returns 0, or -1 on error */ |
169 /* Eject CD-ROM -- returns 0, or -1 on error */ |
159 extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); |
170 extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD * cdrom); |
160 |
171 |
161 /* Closes the handle for the CD-ROM drive */ |
172 /* Closes the handle for the CD-ROM drive */ |
162 extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); |
173 extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD * cdrom); |
163 |
174 |
164 |
175 |
165 /* Ends C function definitions when using C++ */ |
176 /* Ends C function definitions when using C++ */ |
166 #ifdef __cplusplus |
177 #ifdef __cplusplus |
|
178 /* *INDENT-OFF* */ |
167 } |
179 } |
|
180 /* *INDENT-ON* */ |
168 #endif |
181 #endif |
169 #include "close_code.h" |
182 #include "close_code.h" |
170 |
183 |
171 #endif /* _SDL_video_h */ |
184 #endif /* _SDL_video_h */ |
|
185 |
|
186 /* vi: set ts=4 sw=4 expandtab: */ |