Mercurial > sdl-ios-xcode
comparison src/cdrom/openbsd/SDL_syscdrom.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
44 /* A list of available CD-ROM drives */ | 44 /* A list of available CD-ROM drives */ |
45 static char *SDL_cdlist[MAX_DRIVES]; | 45 static char *SDL_cdlist[MAX_DRIVES]; |
46 static dev_t SDL_cdmode[MAX_DRIVES]; | 46 static dev_t SDL_cdmode[MAX_DRIVES]; |
47 | 47 |
48 /* The system-dependent CD control functions */ | 48 /* The system-dependent CD control functions */ |
49 static const char *SDL_SYS_CDName (int drive); | 49 static const char *SDL_SYS_CDName(int drive); |
50 static int SDL_SYS_CDOpen (int drive); | 50 static int SDL_SYS_CDOpen(int drive); |
51 static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); | 51 static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); |
52 static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); | 52 static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); |
53 static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); | 53 static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); |
54 static int SDL_SYS_CDPause (SDL_CD * cdrom); | 54 static int SDL_SYS_CDPause(SDL_CD * cdrom); |
55 static int SDL_SYS_CDResume (SDL_CD * cdrom); | 55 static int SDL_SYS_CDResume(SDL_CD * cdrom); |
56 static int SDL_SYS_CDStop (SDL_CD * cdrom); | 56 static int SDL_SYS_CDStop(SDL_CD * cdrom); |
57 static int SDL_SYS_CDEject (SDL_CD * cdrom); | 57 static int SDL_SYS_CDEject(SDL_CD * cdrom); |
58 static void SDL_SYS_CDClose (SDL_CD * cdrom); | 58 static void SDL_SYS_CDClose(SDL_CD * cdrom); |
59 | 59 |
60 /* Some ioctl() errno values which occur when the tray is empty */ | 60 /* Some ioctl() errno values which occur when the tray is empty */ |
61 #define ERRNO_TRAYEMPTY(errno) \ | 61 #define ERRNO_TRAYEMPTY(errno) \ |
62 ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL) || \ | 62 ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL) || \ |
63 (errno == ENODEV)) | 63 (errno == ENODEV)) |
64 | 64 |
65 /* Check a drive to see if it is a CD-ROM */ | 65 /* Check a drive to see if it is a CD-ROM */ |
66 static int | 66 static int |
67 CheckDrive (char *drive, struct stat *stbuf) | 67 CheckDrive(char *drive, struct stat *stbuf) |
68 { | 68 { |
69 int is_cd, cdfd; | 69 int is_cd, cdfd; |
70 struct ioc_read_subchannel info; | 70 struct ioc_read_subchannel info; |
71 | 71 |
72 /* If it doesn't exist, return -1 */ | 72 /* If it doesn't exist, return -1 */ |
73 if (stat (drive, stbuf) < 0) { | 73 if (stat(drive, stbuf) < 0) { |
74 return (-1); | 74 return (-1); |
75 } | 75 } |
76 | 76 |
77 /* If it does exist, verify that it's an available CD-ROM */ | 77 /* If it does exist, verify that it's an available CD-ROM */ |
78 is_cd = 0; | 78 is_cd = 0; |
79 if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { | 79 if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { |
80 cdfd = open (drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); | 80 cdfd = open(drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); |
81 if (cdfd >= 0) { | 81 if (cdfd >= 0) { |
82 info.address_format = CD_MSF_FORMAT; | 82 info.address_format = CD_MSF_FORMAT; |
83 info.data_format = CD_CURRENT_POSITION; | 83 info.data_format = CD_CURRENT_POSITION; |
84 info.data_len = 0; | 84 info.data_len = 0; |
85 info.data = NULL; | 85 info.data = NULL; |
86 /* Under Linux, EIO occurs when a disk is not present. | 86 /* Under Linux, EIO occurs when a disk is not present. |
87 This isn't 100% reliable, so we use the USE_MNTENT | 87 This isn't 100% reliable, so we use the USE_MNTENT |
88 code above instead. | 88 code above instead. |
89 */ | 89 */ |
90 if ((ioctl (cdfd, CDIOCREADSUBCHANNEL, &info) == 0) || | 90 if ((ioctl(cdfd, CDIOCREADSUBCHANNEL, &info) == 0) || |
91 ERRNO_TRAYEMPTY (errno)) { | 91 ERRNO_TRAYEMPTY(errno)) { |
92 is_cd = 1; | 92 is_cd = 1; |
93 } | 93 } |
94 close (cdfd); | 94 close(cdfd); |
95 } else if (ERRNO_TRAYEMPTY (errno)) | 95 } else if (ERRNO_TRAYEMPTY(errno)) |
96 is_cd = 1; | 96 is_cd = 1; |
97 } | 97 } |
98 return (is_cd); | 98 return (is_cd); |
99 } | 99 } |
100 | 100 |
101 /* Add a CD-ROM drive to our list of valid drives */ | 101 /* Add a CD-ROM drive to our list of valid drives */ |
102 static void | 102 static void |
103 AddDrive (char *drive, struct stat *stbuf) | 103 AddDrive(char *drive, struct stat *stbuf) |
104 { | 104 { |
105 int i; | 105 int i; |
106 | 106 |
107 if (SDL_numcds < MAX_DRIVES) { | 107 if (SDL_numcds < MAX_DRIVES) { |
108 /* Check to make sure it's not already in our list. | 108 /* Check to make sure it's not already in our list. |
109 This can happen when we see a drive via symbolic link. | 109 This can happen when we see a drive via symbolic link. |
110 */ | 110 */ |
111 for (i = 0; i < SDL_numcds; ++i) { | 111 for (i = 0; i < SDL_numcds; ++i) { |
112 if (stbuf->st_rdev == SDL_cdmode[i]) { | 112 if (stbuf->st_rdev == SDL_cdmode[i]) { |
113 #ifdef DEBUG_CDROM | 113 #ifdef DEBUG_CDROM |
114 fprintf (stderr, "Duplicate drive detected: %s == %s\n", | 114 fprintf(stderr, "Duplicate drive detected: %s == %s\n", |
115 drive, SDL_cdlist[i]); | 115 drive, SDL_cdlist[i]); |
116 #endif | 116 #endif |
117 return; | 117 return; |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 /* Add this drive to our list */ | 121 /* Add this drive to our list */ |
122 i = SDL_numcds; | 122 i = SDL_numcds; |
123 SDL_cdlist[i] = SDL_strdup (drive); | 123 SDL_cdlist[i] = SDL_strdup(drive); |
124 if (SDL_cdlist[i] == NULL) { | 124 if (SDL_cdlist[i] == NULL) { |
125 SDL_OutOfMemory (); | 125 SDL_OutOfMemory(); |
126 return; | 126 return; |
127 } | 127 } |
128 SDL_cdmode[i] = stbuf->st_rdev; | 128 SDL_cdmode[i] = stbuf->st_rdev; |
129 ++SDL_numcds; | 129 ++SDL_numcds; |
130 #ifdef DEBUG_CDROM | 130 #ifdef DEBUG_CDROM |
131 fprintf (stderr, "Added CD-ROM drive: %s\n", drive); | 131 fprintf(stderr, "Added CD-ROM drive: %s\n", drive); |
132 #endif | 132 #endif |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 int | 136 int |
137 SDL_SYS_CDInit (void) | 137 SDL_SYS_CDInit(void) |
138 { | 138 { |
139 static char *checklist[] = { | 139 static char *checklist[] = { |
140 #if defined(__OPENBSD__) | 140 #if defined(__OPENBSD__) |
141 "?0 cd?c", "cdrom", NULL | 141 "?0 cd?c", "cdrom", NULL |
142 #elif defined(__NETBSD__) | 142 #elif defined(__NETBSD__) |
161 SDL_CDcaps.Stop = SDL_SYS_CDStop; | 161 SDL_CDcaps.Stop = SDL_SYS_CDStop; |
162 SDL_CDcaps.Eject = SDL_SYS_CDEject; | 162 SDL_CDcaps.Eject = SDL_SYS_CDEject; |
163 SDL_CDcaps.Close = SDL_SYS_CDClose; | 163 SDL_CDcaps.Close = SDL_SYS_CDClose; |
164 | 164 |
165 /* Look in the environment for our CD-ROM drive list */ | 165 /* Look in the environment for our CD-ROM drive list */ |
166 SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ | 166 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ |
167 if (SDLcdrom != NULL) { | 167 if (SDLcdrom != NULL) { |
168 char *cdpath, *delim; | 168 char *cdpath, *delim; |
169 size_t len = SDL_strlen (SDLcdrom) + 1; | 169 size_t len = SDL_strlen(SDLcdrom) + 1; |
170 cdpath = SDL_stack_alloc (char, len); | 170 cdpath = SDL_stack_alloc(char, len); |
171 if (cdpath != NULL) { | 171 if (cdpath != NULL) { |
172 SDL_strlcpy (cdpath, SDLcdrom, len); | 172 SDL_strlcpy(cdpath, SDLcdrom, len); |
173 SDLcdrom = cdpath; | 173 SDLcdrom = cdpath; |
174 do { | 174 do { |
175 delim = SDL_strchr (SDLcdrom, ':'); | 175 delim = SDL_strchr(SDLcdrom, ':'); |
176 if (delim) { | 176 if (delim) { |
177 *delim++ = '\0'; | 177 *delim++ = '\0'; |
178 } | 178 } |
179 if (CheckDrive (SDLcdrom, &stbuf) > 0) { | 179 if (CheckDrive(SDLcdrom, &stbuf) > 0) { |
180 AddDrive (SDLcdrom, &stbuf); | 180 AddDrive(SDLcdrom, &stbuf); |
181 } | 181 } |
182 if (delim) { | 182 if (delim) { |
183 SDLcdrom = delim; | 183 SDLcdrom = delim; |
184 } else { | 184 } else { |
185 SDLcdrom = NULL; | 185 SDLcdrom = NULL; |
186 } | 186 } |
187 } | 187 } |
188 while (SDLcdrom); | 188 while (SDLcdrom); |
189 SDL_stack_free (cdpath); | 189 SDL_stack_free(cdpath); |
190 } | 190 } |
191 | 191 |
192 /* If we found our drives, there's nothing left to do */ | 192 /* If we found our drives, there's nothing left to do */ |
193 if (SDL_numcds > 0) { | 193 if (SDL_numcds > 0) { |
194 return (0); | 194 return (0); |
199 for (i = 0; checklist[i]; ++i) { | 199 for (i = 0; checklist[i]; ++i) { |
200 if (checklist[i][0] == '?') { | 200 if (checklist[i][0] == '?') { |
201 char *insert; | 201 char *insert; |
202 exists = 1; | 202 exists = 1; |
203 for (j = checklist[i][1]; exists; ++j) { | 203 for (j = checklist[i][1]; exists; ++j) { |
204 SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", | 204 SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", |
205 &checklist[i][3]); | 205 &checklist[i][3]); |
206 insert = SDL_strchr (drive, '?'); | 206 insert = SDL_strchr(drive, '?'); |
207 if (insert != NULL) { | 207 if (insert != NULL) { |
208 *insert = j; | 208 *insert = j; |
209 } | 209 } |
210 switch (CheckDrive (drive, &stbuf)) { | 210 switch (CheckDrive(drive, &stbuf)) { |
211 /* Drive exists and is a CD-ROM */ | 211 /* Drive exists and is a CD-ROM */ |
212 case 1: | 212 case 1: |
213 AddDrive (drive, &stbuf); | 213 AddDrive(drive, &stbuf); |
214 break; | 214 break; |
215 /* Drive exists, but isn't a CD-ROM */ | 215 /* Drive exists, but isn't a CD-ROM */ |
216 case 0: | 216 case 0: |
217 break; | 217 break; |
218 /* Drive doesn't exist */ | 218 /* Drive doesn't exist */ |
220 exists = 0; | 220 exists = 0; |
221 break; | 221 break; |
222 } | 222 } |
223 } | 223 } |
224 } else { | 224 } else { |
225 SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", | 225 SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", |
226 checklist[i]); | 226 checklist[i]); |
227 if (CheckDrive (drive, &stbuf) > 0) { | 227 if (CheckDrive(drive, &stbuf) > 0) { |
228 AddDrive (drive, &stbuf); | 228 AddDrive(drive, &stbuf); |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 return (0); | 232 return (0); |
233 } | 233 } |
234 | 234 |
235 /* General ioctl() CD-ROM command function */ | 235 /* General ioctl() CD-ROM command function */ |
236 static int | 236 static int |
237 SDL_SYS_CDioctl (int id, int command, void *arg) | 237 SDL_SYS_CDioctl(int id, int command, void *arg) |
238 { | 238 { |
239 int retval; | 239 int retval; |
240 | 240 |
241 retval = ioctl (id, command, arg); | 241 retval = ioctl(id, command, arg); |
242 if (retval < 0) { | 242 if (retval < 0) { |
243 SDL_SetError ("ioctl() error: %s", strerror (errno)); | 243 SDL_SetError("ioctl() error: %s", strerror(errno)); |
244 } | 244 } |
245 return (retval); | 245 return (retval); |
246 } | 246 } |
247 | 247 |
248 static const char * | 248 static const char * |
249 SDL_SYS_CDName (int drive) | 249 SDL_SYS_CDName(int drive) |
250 { | 250 { |
251 return (SDL_cdlist[drive]); | 251 return (SDL_cdlist[drive]); |
252 } | 252 } |
253 | 253 |
254 static int | 254 static int |
255 SDL_SYS_CDOpen (int drive) | 255 SDL_SYS_CDOpen(int drive) |
256 { | 256 { |
257 return (open (SDL_cdlist[drive], (O_RDONLY | O_EXCL | O_NONBLOCK), 0)); | 257 return (open(SDL_cdlist[drive], (O_RDONLY | O_EXCL | O_NONBLOCK), 0)); |
258 } | 258 } |
259 | 259 |
260 static int | 260 static int |
261 SDL_SYS_CDGetTOC (SDL_CD * cdrom) | 261 SDL_SYS_CDGetTOC(SDL_CD * cdrom) |
262 { | 262 { |
263 struct ioc_toc_header toc; | 263 struct ioc_toc_header toc; |
264 int i, okay; | 264 int i, okay; |
265 struct ioc_read_toc_entry entry; | 265 struct ioc_read_toc_entry entry; |
266 struct cd_toc_entry data; | 266 struct cd_toc_entry data; |
267 | 267 |
268 okay = 0; | 268 okay = 0; |
269 if (SDL_SYS_CDioctl (cdrom->id, CDIOREADTOCHEADER, &toc) == 0) { | 269 if (SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0) { |
270 cdrom->numtracks = toc.ending_track - toc.starting_track + 1; | 270 cdrom->numtracks = toc.ending_track - toc.starting_track + 1; |
271 if (cdrom->numtracks > SDL_MAX_TRACKS) { | 271 if (cdrom->numtracks > SDL_MAX_TRACKS) { |
272 cdrom->numtracks = SDL_MAX_TRACKS; | 272 cdrom->numtracks = SDL_MAX_TRACKS; |
273 } | 273 } |
274 /* Read all the track TOC entries */ | 274 /* Read all the track TOC entries */ |
278 } else { | 278 } else { |
279 cdrom->track[i].id = toc.starting_track + i; | 279 cdrom->track[i].id = toc.starting_track + i; |
280 } | 280 } |
281 entry.starting_track = cdrom->track[i].id; | 281 entry.starting_track = cdrom->track[i].id; |
282 entry.address_format = CD_MSF_FORMAT; | 282 entry.address_format = CD_MSF_FORMAT; |
283 entry.data_len = sizeof (data); | 283 entry.data_len = sizeof(data); |
284 entry.data = &data; | 284 entry.data = &data; |
285 if (SDL_SYS_CDioctl (cdrom->id, CDIOREADTOCENTRYS, &entry) < 0) { | 285 if (SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCENTRYS, &entry) < 0) { |
286 break; | 286 break; |
287 } else { | 287 } else { |
288 cdrom->track[i].type = data.control; | 288 cdrom->track[i].type = data.control; |
289 cdrom->track[i].offset = | 289 cdrom->track[i].offset = |
290 MSF_TO_FRAMES (data.addr.msf.minute, | 290 MSF_TO_FRAMES(data.addr.msf.minute, |
291 data.addr.msf.second, data.addr.msf.frame); | 291 data.addr.msf.second, data.addr.msf.frame); |
292 cdrom->track[i].length = 0; | 292 cdrom->track[i].length = 0; |
293 if (i > 0) { | 293 if (i > 0) { |
294 cdrom->track[i - 1].length = | 294 cdrom->track[i - 1].length = |
295 cdrom->track[i].offset - cdrom->track[i - 1].offset; | 295 cdrom->track[i].offset - cdrom->track[i - 1].offset; |
296 } | 296 } |
303 return (okay ? 0 : -1); | 303 return (okay ? 0 : -1); |
304 } | 304 } |
305 | 305 |
306 /* Get CD-ROM status */ | 306 /* Get CD-ROM status */ |
307 static CDstatus | 307 static CDstatus |
308 SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) | 308 SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) |
309 { | 309 { |
310 CDstatus status; | 310 CDstatus status; |
311 struct ioc_toc_header toc; | 311 struct ioc_toc_header toc; |
312 struct ioc_read_subchannel info; | 312 struct ioc_read_subchannel info; |
313 struct cd_sub_channel_info data; | 313 struct cd_sub_channel_info data; |
314 | 314 |
315 info.address_format = CD_MSF_FORMAT; | 315 info.address_format = CD_MSF_FORMAT; |
316 info.data_format = CD_CURRENT_POSITION; | 316 info.data_format = CD_CURRENT_POSITION; |
317 info.track = 0; | 317 info.track = 0; |
318 info.data_len = sizeof (data); | 318 info.data_len = sizeof(data); |
319 info.data = &data; | 319 info.data = &data; |
320 if (ioctl (cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0) { | 320 if (ioctl(cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0) { |
321 if (ERRNO_TRAYEMPTY (errno)) { | 321 if (ERRNO_TRAYEMPTY(errno)) { |
322 status = CD_TRAYEMPTY; | 322 status = CD_TRAYEMPTY; |
323 } else { | 323 } else { |
324 status = CD_ERROR; | 324 status = CD_ERROR; |
325 } | 325 } |
326 } else { | 326 } else { |
327 switch (data.header.audio_status) { | 327 switch (data.header.audio_status) { |
328 case CD_AS_AUDIO_INVALID: | 328 case CD_AS_AUDIO_INVALID: |
329 case CD_AS_NO_STATUS: | 329 case CD_AS_NO_STATUS: |
330 /* Try to determine if there's a CD available */ | 330 /* Try to determine if there's a CD available */ |
331 if (ioctl (cdrom->id, CDIOREADTOCHEADER, &toc) == 0) | 331 if (ioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0) |
332 status = CD_STOPPED; | 332 status = CD_STOPPED; |
333 else | 333 else |
334 status = CD_TRAYEMPTY; | 334 status = CD_TRAYEMPTY; |
335 break; | 335 break; |
336 case CD_AS_PLAY_COMPLETED: | 336 case CD_AS_PLAY_COMPLETED: |
348 } | 348 } |
349 } | 349 } |
350 if (position) { | 350 if (position) { |
351 if (status == CD_PLAYING || (status == CD_PAUSED)) { | 351 if (status == CD_PLAYING || (status == CD_PAUSED)) { |
352 *position = | 352 *position = |
353 MSF_TO_FRAMES (data.what.position.absaddr.msf.minute, | 353 MSF_TO_FRAMES(data.what.position.absaddr.msf.minute, |
354 data.what.position.absaddr.msf.second, | 354 data.what.position.absaddr.msf.second, |
355 data.what.position.absaddr.msf.frame); | 355 data.what.position.absaddr.msf.frame); |
356 } else { | 356 } else { |
357 *position = 0; | 357 *position = 0; |
358 } | 358 } |
359 } | 359 } |
360 return (status); | 360 return (status); |
361 } | 361 } |
362 | 362 |
363 /* Start play */ | 363 /* Start play */ |
364 static int | 364 static int |
365 SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) | 365 SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) |
366 { | 366 { |
367 struct ioc_play_msf playtime; | 367 struct ioc_play_msf playtime; |
368 | 368 |
369 FRAMES_TO_MSF (start, | 369 FRAMES_TO_MSF(start, |
370 &playtime.start_m, &playtime.start_s, &playtime.start_f); | 370 &playtime.start_m, &playtime.start_s, &playtime.start_f); |
371 FRAMES_TO_MSF (start + length, | 371 FRAMES_TO_MSF(start + length, |
372 &playtime.end_m, &playtime.end_s, &playtime.end_f); | 372 &playtime.end_m, &playtime.end_s, &playtime.end_f); |
373 #ifdef DEBUG_CDROM | 373 #ifdef DEBUG_CDROM |
374 fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", | 374 fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", |
375 playtime.start_m, playtime.start_s, playtime.start_f, | 375 playtime.start_m, playtime.start_s, playtime.start_f, |
376 playtime.end_m, playtime.end_s, playtime.end_f); | 376 playtime.end_m, playtime.end_s, playtime.end_f); |
377 #endif | 377 #endif |
378 ioctl (cdrom->id, CDIOCSTART, 0); | 378 ioctl(cdrom->id, CDIOCSTART, 0); |
379 return (SDL_SYS_CDioctl (cdrom->id, CDIOCPLAYMSF, &playtime)); | 379 return (SDL_SYS_CDioctl(cdrom->id, CDIOCPLAYMSF, &playtime)); |
380 } | 380 } |
381 | 381 |
382 /* Pause play */ | 382 /* Pause play */ |
383 static int | 383 static int |
384 SDL_SYS_CDPause (SDL_CD * cdrom) | 384 SDL_SYS_CDPause(SDL_CD * cdrom) |
385 { | 385 { |
386 return (SDL_SYS_CDioctl (cdrom->id, CDIOCPAUSE, 0)); | 386 return (SDL_SYS_CDioctl(cdrom->id, CDIOCPAUSE, 0)); |
387 } | 387 } |
388 | 388 |
389 /* Resume play */ | 389 /* Resume play */ |
390 static int | 390 static int |
391 SDL_SYS_CDResume (SDL_CD * cdrom) | 391 SDL_SYS_CDResume(SDL_CD * cdrom) |
392 { | 392 { |
393 return (SDL_SYS_CDioctl (cdrom->id, CDIOCRESUME, 0)); | 393 return (SDL_SYS_CDioctl(cdrom->id, CDIOCRESUME, 0)); |
394 } | 394 } |
395 | 395 |
396 /* Stop play */ | 396 /* Stop play */ |
397 static int | 397 static int |
398 SDL_SYS_CDStop (SDL_CD * cdrom) | 398 SDL_SYS_CDStop(SDL_CD * cdrom) |
399 { | 399 { |
400 return (SDL_SYS_CDioctl (cdrom->id, CDIOCSTOP, 0)); | 400 return (SDL_SYS_CDioctl(cdrom->id, CDIOCSTOP, 0)); |
401 } | 401 } |
402 | 402 |
403 /* Eject the CD-ROM */ | 403 /* Eject the CD-ROM */ |
404 static int | 404 static int |
405 SDL_SYS_CDEject (SDL_CD * cdrom) | 405 SDL_SYS_CDEject(SDL_CD * cdrom) |
406 { | 406 { |
407 return (SDL_SYS_CDioctl (cdrom->id, CDIOCEJECT, 0)); | 407 return (SDL_SYS_CDioctl(cdrom->id, CDIOCEJECT, 0)); |
408 } | 408 } |
409 | 409 |
410 /* Close the CD-ROM handle */ | 410 /* Close the CD-ROM handle */ |
411 static void | 411 static void |
412 SDL_SYS_CDClose (SDL_CD * cdrom) | 412 SDL_SYS_CDClose(SDL_CD * cdrom) |
413 { | 413 { |
414 close (cdrom->id); | 414 close(cdrom->id); |
415 } | 415 } |
416 | 416 |
417 void | 417 void |
418 SDL_SYS_CDQuit (void) | 418 SDL_SYS_CDQuit(void) |
419 { | 419 { |
420 int i; | 420 int i; |
421 | 421 |
422 if (SDL_numcds > 0) { | 422 if (SDL_numcds > 0) { |
423 for (i = 0; i < SDL_numcds; ++i) { | 423 for (i = 0; i < SDL_numcds; ++i) { |
424 SDL_free (SDL_cdlist[i]); | 424 SDL_free(SDL_cdlist[i]); |
425 } | 425 } |
426 SDL_numcds = 0; | 426 SDL_numcds = 0; |
427 } | 427 } |
428 } | 428 } |
429 | 429 |