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