|
|
1.1 root 1: /*
2: SDL - Simple DirectMedia Layer
1.1.1.2 ! root 3: Copyright (C) 1997-2006 Sam Lantinga
1.1 root 4:
5: This library is free software; you can redistribute it and/or
1.1.1.2 ! root 6: modify it under the terms of the GNU Lesser General Public
1.1 root 7: License as published by the Free Software Foundation; either
1.1.1.2 ! root 8: version 2.1 of the License, or (at your option) any later version.
1.1 root 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
1.1.1.2 ! root 13: Lesser General Public License for more details.
1.1 root 14:
1.1.1.2 ! root 15: You should have received a copy of the GNU Lesser General Public
! 16: License along with this library; if not, write to the Free Software
! 17: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1.1 root 18:
19: Sam Lantinga
20: [email protected]
21: */
22:
23: /* This is the CD-audio control API for Simple DirectMedia Layer */
24:
25: #ifndef _SDL_cdrom_h
26: #define _SDL_cdrom_h
27:
1.1.1.2 ! root 28: #include "SDL_stdinc.h"
! 29: #include "SDL_error.h"
1.1 root 30:
31: #include "begin_code.h"
32: /* Set up for C function definitions, even when using C++ */
33: #ifdef __cplusplus
34: extern "C" {
35: #endif
36:
37: /* 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
39: for CD-ROM drives, and load appropriate drivers.
40: */
41:
42: /* The maximum number of CD-ROM tracks on a disk */
43: #define SDL_MAX_TRACKS 99
44:
45: /* The types of CD-ROM track possible */
46: #define SDL_AUDIO_TRACK 0x00
47: #define SDL_DATA_TRACK 0x04
48:
49: /* The possible states which a CD-ROM drive can be in. */
50: typedef enum {
51: CD_TRAYEMPTY,
52: CD_STOPPED,
53: CD_PLAYING,
54: CD_PAUSED,
55: CD_ERROR = -1
56: } CDstatus;
57:
58: /* Given a status, returns true if there's a disk in the drive */
59: #define CD_INDRIVE(status) ((int)(status) > 0)
60:
61: typedef struct SDL_CDtrack {
62: Uint8 id; /* Track number */
63: Uint8 type; /* Data or audio track */
64: Uint16 unused;
65: Uint32 length; /* Length, in frames, of this track */
66: Uint32 offset; /* Offset, in frames, from start of disk */
67: } SDL_CDtrack;
68:
69: /* This structure is only current as of the last call to SDL_CDStatus() */
70: typedef struct SDL_CD {
71: int id; /* Private drive identifier */
72: CDstatus status; /* Current drive status */
73:
74: /* The rest of this structure is only valid if there's a CD in drive */
75: int numtracks; /* Number of tracks on disk */
76: int cur_track; /* Current track position */
77: int cur_frame; /* Current frame offset within current track */
78: SDL_CDtrack track[SDL_MAX_TRACKS+1];
79: } SDL_CD;
80:
81: /* Conversion functions from frames to Minute/Second/Frames and vice versa */
82: #define CD_FPS 75
83: #define FRAMES_TO_MSF(f, M,S,F) { \
84: int value = f; \
85: *(F) = value%CD_FPS; \
86: value /= CD_FPS; \
87: *(S) = value%60; \
88: value /= 60; \
89: *(M) = value; \
90: }
91: #define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
92:
93: /* CD-audio API functions: */
94:
95: /* Returns the number of CD-ROM drives on the system, or -1 if
96: SDL_Init() has not been called with the SDL_INIT_CDROM flag.
97: */
98: extern DECLSPEC int SDLCALL SDL_CDNumDrives(void);
99:
100: /* Returns a human-readable, system-dependent identifier for the CD-ROM.
101: Example:
102: "/dev/cdrom"
103: "E:"
104: "/dev/disk/ide/1/master"
105: */
106: extern DECLSPEC const char * SDLCALL SDL_CDName(int drive);
107:
108: /* 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
110: becomes the default CD used when other CD functions are passed a NULL
111: CD-ROM handle.
112: Drives are numbered starting with 0. Drive 0 is the system default CD-ROM.
113: */
114: extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive);
115:
116: /* 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
118: play position of the CD will be stored in the SDL_CD structure.
119: */
120: extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
121:
122: /* 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
124: until the end of the CD. This function will skip data tracks.
125: This function should only be called after calling SDL_CDStatus() to
126: get track information about the CD.
127: For example:
128: // Play entire CD:
129: if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
130: SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
131: // Play last track:
132: if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
133: SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
134: }
135: // Play first and second track and 10 seconds of third track:
136: if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
137: SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
138:
139: This function returns 0, or -1 if there was an error.
140: */
141: extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom,
142: int start_track, int start_frame, int ntracks, int nframes);
143:
144: /* Play the given CD starting at 'start' frame for 'length' frames.
145: It returns 0, or -1 if there was an error.
146: */
147: extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length);
148:
149: /* Pause play -- returns 0, or -1 on error */
150: extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom);
151:
152: /* Resume play -- returns 0, or -1 on error */
153: extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom);
154:
155: /* Stop play -- returns 0, or -1 on error */
156: extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom);
157:
158: /* Eject CD-ROM -- returns 0, or -1 on error */
159: extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom);
160:
161: /* Closes the handle for the CD-ROM drive */
162: extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
163:
164:
165: /* Ends C function definitions when using C++ */
166: #ifdef __cplusplus
167: }
168: #endif
169: #include "close_code.h"
170:
171: #endif /* _SDL_video_h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.