Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
507 lines (440 loc) · 13.5 KB

SDL_syscdrom.c

File metadata and controls

507 lines (440 loc) · 13.5 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
/*
SDL - Simple DirectMedia Layer
Feb 1, 2006
Feb 1, 2006
3
Copyright (C) 1997-2006 Sam Lantinga
Apr 26, 2001
Apr 26, 2001
4
5
This library is free software; you can redistribute it and/or
Feb 1, 2006
Feb 1, 2006
6
modify it under the terms of the GNU Lesser General Public
Apr 26, 2001
Apr 26, 2001
7
License as published by the Free Software Foundation; either
Feb 1, 2006
Feb 1, 2006
8
version 2.1 of the License, or (at your option) any later version.
Apr 26, 2001
Apr 26, 2001
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Feb 1, 2006
Feb 1, 2006
13
Lesser General Public License for more details.
Apr 26, 2001
Apr 26, 2001
14
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Apr 26, 2001
Apr 26, 2001
18
19
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Apr 26, 2001
Apr 26, 2001
21
*/
Feb 21, 2006
Feb 21, 2006
22
#include "SDL_config.h"
Apr 26, 2001
Apr 26, 2001
23
Apr 14, 2006
Apr 14, 2006
24
25
#ifdef SDL_CDROM_QNX
Apr 26, 2001
Apr 26, 2001
26
27
28
29
30
31
32
33
34
35
36
/* Functions for system-level CD-ROM audio control */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/cdrom.h>
#include <sys/dcmd_cam.h>
Jan 20, 2003
Jan 20, 2003
37
#include "SDL_timer.h"
Feb 10, 2006
Feb 10, 2006
38
#include "SDL_cdrom.h"
Feb 16, 2006
Feb 16, 2006
39
#include "../SDL_syscdrom.h"
Apr 26, 2001
Apr 26, 2001
40
41
/* The maximum number of CD-ROM drives we'll detect */
Jan 20, 2003
Jan 20, 2003
42
43
44
#define MAX_DRIVES 16
#define QNX_CD_OPENMODE O_RDONLY | O_EXCL
Apr 26, 2001
Apr 26, 2001
45
46
47
48
/* A list of available CD-ROM drives */
static char *SDL_cdlist[MAX_DRIVES];
static dev_t SDL_cdmode[MAX_DRIVES];
Jul 10, 2006
Jul 10, 2006
49
static int SDL_cdopen[MAX_DRIVES];
Apr 26, 2001
Apr 26, 2001
50
51
52
53
/* The system-dependent CD control functions */
static const char *SDL_SYS_CDName(int drive);
static int SDL_SYS_CDOpen(int drive);
Jul 10, 2006
Jul 10, 2006
54
55
56
57
58
59
60
61
static int SDL_SYS_CDGetTOC(SDL_CD * cdrom);
static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position);
static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length);
static int SDL_SYS_CDPause(SDL_CD * cdrom);
static int SDL_SYS_CDResume(SDL_CD * cdrom);
static int SDL_SYS_CDStop(SDL_CD * cdrom);
static int SDL_SYS_CDEject(SDL_CD * cdrom);
static void SDL_SYS_CDClose(SDL_CD * cdrom);
Apr 26, 2001
Apr 26, 2001
62
63
/* Check a drive to see if it is a CD-ROM */
Jul 10, 2006
Jul 10, 2006
64
65
static int
CheckDrive(char *drive, struct stat *stbuf)
Apr 26, 2001
Apr 26, 2001
66
{
Jan 20, 2003
Jan 20, 2003
67
68
int is_cd, cdfd;
cam_devinfo_t dinfo;
Jul 10, 2006
Jul 10, 2006
69
int devctlret = 0;
Jan 20, 2003
Jan 20, 2003
70
71
72
73
74
75
int atapi;
int removable;
int cdb10;
/* If it doesn't exist, return -1 */
Jul 10, 2006
Jul 10, 2006
76
77
if (stat(drive, stbuf) < 0) {
return (-1);
Jan 20, 2003
Jan 20, 2003
78
79
80
81
82
}
/* If it does exist, verify that it's an available CD-ROM */
is_cd = 0;
Jul 10, 2006
Jul 10, 2006
83
if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) {
Jan 20, 2003
Jan 20, 2003
84
cdfd = open(drive, QNX_CD_OPENMODE);
Jul 10, 2006
Jul 10, 2006
85
86
87
88
89
90
91
92
93
94
95
96
97
98
if (cdfd >= 0) {
devctlret =
devctl(cdfd, DCMD_CAM_DEVINFO, &dinfo,
sizeof(cam_devinfo_t), NULL);
if (devctlret == EOK) {
atapi = dinfo.flags & DEV_ATAPI;
removable = dinfo.flags & DEV_REMOVABLE;
cdb10 = dinfo.flags & DEV_CDB_10; /* I'm not sure about that flag */
/* in the near future need to add more checks for splitting cdroms from other devices */
if ((atapi) && (removable)) {
is_cd = 1;
}
Jan 20, 2003
Jan 20, 2003
99
100
101
102
103
}
close(cdfd);
}
}
Jul 10, 2006
Jul 10, 2006
104
return (is_cd);
Apr 26, 2001
Apr 26, 2001
105
106
107
}
/* Add a CD-ROM drive to our list of valid drives */
Jul 10, 2006
Jul 10, 2006
108
109
static void
AddDrive(char *drive, struct stat *stbuf)
Apr 26, 2001
Apr 26, 2001
110
{
Jan 20, 2003
Jan 20, 2003
111
112
int i;
Jul 10, 2006
Jul 10, 2006
113
if (SDL_numcds < MAX_DRIVES) {
Jan 20, 2003
Jan 20, 2003
114
/* Check to make sure it's not already in our list.
Jul 10, 2006
Jul 10, 2006
115
This can happen when we see a drive via symbolic link. */
Jan 20, 2003
Jan 20, 2003
116
Jul 10, 2006
Jul 10, 2006
117
118
for (i = 0; i < SDL_numcds; ++i) {
if (stbuf->st_rdev == SDL_cdmode[i]) {
Jan 20, 2003
Jan 20, 2003
119
120
121
122
123
124
125
return;
}
}
/* Add this drive to our list */
i = SDL_numcds;
Feb 19, 2006
Feb 19, 2006
126
SDL_cdlist[i] = SDL_strdup(drive);
Jul 10, 2006
Jul 10, 2006
127
if (SDL_cdlist[i] == NULL) {
Jan 20, 2003
Jan 20, 2003
128
129
130
131
132
133
SDL_OutOfMemory();
return;
}
SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds;
}
Apr 26, 2001
Apr 26, 2001
134
135
}
Jul 10, 2006
Jul 10, 2006
136
137
int
SDL_SYS_CDInit(void)
Apr 26, 2001
Apr 26, 2001
138
{
Jan 20, 2003
Jan 20, 2003
139
/* checklist: /dev/cdrom, /dev/cd?, /dev/scd? */
Jul 10, 2006
Jul 10, 2006
140
141
static char *checklist[] =
{ "cdrom", "?0 cd?", "?1 cd?", "?0 scd?", NULL };
Jan 20, 2003
Jan 20, 2003
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
char *SDLcdrom;
int i, j, exists;
char drive[32];
struct stat stbuf;
/* Fill in our driver capabilities */
SDL_CDcaps.Name = SDL_SYS_CDName;
SDL_CDcaps.Open = SDL_SYS_CDOpen;
SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
SDL_CDcaps.Status = SDL_SYS_CDStatus;
SDL_CDcaps.Play = SDL_SYS_CDPlay;
SDL_CDcaps.Pause = SDL_SYS_CDPause;
SDL_CDcaps.Resume = SDL_SYS_CDResume;
SDL_CDcaps.Stop = SDL_SYS_CDStop;
SDL_CDcaps.Eject = SDL_SYS_CDEject;
SDL_CDcaps.Close = SDL_SYS_CDClose;
/* clearing device open status */
Jul 10, 2006
Jul 10, 2006
161
162
for (i = 0; i < MAX_DRIVES; i++) {
SDL_cdopen[i] = 0;
Jan 20, 2003
Jan 20, 2003
163
164
165
}
/* Look in the environment for our CD-ROM drive list */
Jul 10, 2006
Jul 10, 2006
166
167
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if (SDLcdrom != NULL) {
Jan 20, 2003
Jan 20, 2003
168
char *cdpath, *delim;
Jul 10, 2006
Jul 10, 2006
169
size_t len = SDL_strlen(SDLcdrom) + 1;
Mar 8, 2006
Mar 8, 2006
170
cdpath = SDL_stack_alloc(char, len);
Jul 10, 2006
Jul 10, 2006
171
if (cdpath != NULL) {
Feb 19, 2006
Feb 19, 2006
172
SDL_strlcpy(cdpath, SDLcdrom, len);
Jan 20, 2003
Jan 20, 2003
173
174
SDLcdrom = cdpath;
do {
Feb 7, 2006
Feb 7, 2006
175
delim = SDL_strchr(SDLcdrom, ':');
Jul 10, 2006
Jul 10, 2006
176
if (delim) {
Jan 20, 2003
Jan 20, 2003
177
178
*delim++ = '\0';
}
Jul 10, 2006
Jul 10, 2006
179
if (CheckDrive(SDLcdrom, &stbuf) > 0) {
Jan 20, 2003
Jan 20, 2003
180
181
AddDrive(SDLcdrom, &stbuf);
}
Jul 10, 2006
Jul 10, 2006
182
if (delim) {
Jan 20, 2003
Jan 20, 2003
183
SDLcdrom = delim;
Jul 10, 2006
Jul 10, 2006
184
} else {
Jan 20, 2003
Jan 20, 2003
185
186
SDLcdrom = NULL;
}
Aug 27, 2008
Aug 27, 2008
187
} while (SDLcdrom);
Feb 19, 2006
Feb 19, 2006
188
SDL_stack_free(cdpath);
Jan 20, 2003
Jan 20, 2003
189
190
191
}
/* If we found our drives, there's nothing left to do */
Jul 10, 2006
Jul 10, 2006
192
193
if (SDL_numcds > 0) {
return (0);
Jan 20, 2003
Jan 20, 2003
194
195
196
197
}
}
/* Scan the system for CD-ROM drives */
Jul 10, 2006
Jul 10, 2006
198
199
200
for (i = 0; checklist[i]; ++i) {
if (checklist[i][0] == '?') {
char *insert;
Jan 20, 2003
Jan 20, 2003
201
202
exists = 1;
Jul 10, 2006
Jul 10, 2006
203
204
205
for (j = checklist[i][1]; exists; ++j) {
SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
&checklist[i][3]);
Feb 7, 2006
Feb 7, 2006
206
insert = SDL_strchr(drive, '?');
Jul 10, 2006
Jul 10, 2006
207
if (insert != NULL) {
Jan 20, 2003
Jan 20, 2003
208
209
*insert = j;
}
Jul 10, 2006
Jul 10, 2006
210
switch (CheckDrive(drive, &stbuf)) {
Jan 20, 2003
Jan 20, 2003
211
/* Drive exists and is a CD-ROM */
Jul 10, 2006
Jul 10, 2006
212
213
214
case 1:
AddDrive(drive, &stbuf);
break;
Jan 20, 2003
Jan 20, 2003
215
/* Drive exists, but isn't a CD-ROM */
Jul 10, 2006
Jul 10, 2006
216
217
case 0:
break;
Jan 20, 2003
Jan 20, 2003
218
/* Drive doesn't exist */
Jul 10, 2006
Jul 10, 2006
219
220
221
case -1:
exists = 0;
break;
Jan 20, 2003
Jan 20, 2003
222
223
}
}
Jul 10, 2006
Jul 10, 2006
224
225
226
227
} else {
SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
checklist[i]);
if (CheckDrive(drive, &stbuf) > 0) {
Jan 20, 2003
Jan 20, 2003
228
229
230
231
AddDrive(drive, &stbuf);
}
}
}
Jul 10, 2006
Jul 10, 2006
232
return (0);
Apr 26, 2001
Apr 26, 2001
233
234
}
Jul 10, 2006
Jul 10, 2006
235
236
static const char *
SDL_SYS_CDName(int drive)
Apr 26, 2001
Apr 26, 2001
237
{
Jul 10, 2006
Jul 10, 2006
238
return (SDL_cdlist[drive]);
Apr 26, 2001
Apr 26, 2001
239
240
}
Jul 10, 2006
Jul 10, 2006
241
242
static int
SDL_SYS_CDOpen(int drive)
Apr 26, 2001
Apr 26, 2001
243
{
Jan 20, 2003
Jan 20, 2003
244
245
int handle;
Jul 10, 2006
Jul 10, 2006
246
handle = open(SDL_cdlist[drive], QNX_CD_OPENMODE);
Jan 20, 2003
Jan 20, 2003
247
Jul 10, 2006
Jul 10, 2006
248
249
if (handle > 0) {
SDL_cdopen[drive] = handle;
Jan 20, 2003
Jan 20, 2003
250
251
252
}
return (handle);
Apr 26, 2001
Apr 26, 2001
253
254
}
Jul 10, 2006
Jul 10, 2006
255
256
static int
SDL_SYS_CDGetTOC(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
257
{
Jan 20, 2003
Jan 20, 2003
258
259
260
261
cdrom_read_toc_t toc;
int i, okay;
okay = 0;
Jul 10, 2006
Jul 10, 2006
262
263
if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) ==
0) {
Jan 20, 2003
Jan 20, 2003
264
cdrom->numtracks = toc.last_track - toc.first_track + 1;
Jul 10, 2006
Jul 10, 2006
265
if (cdrom->numtracks > SDL_MAX_TRACKS) {
Jan 20, 2003
Jan 20, 2003
266
267
268
cdrom->numtracks = SDL_MAX_TRACKS;
}
/* Read all the track TOC entries */
Jul 10, 2006
Jul 10, 2006
269
270
for (i = 0; i <= cdrom->numtracks; ++i) {
if (i == cdrom->numtracks) {
Jan 20, 2003
Jan 20, 2003
271
cdrom->track[i].id = CDROM_LEADOUT;
Jul 10, 2006
Jul 10, 2006
272
273
} else {
cdrom->track[i].id = toc.first_track + i;
Jan 20, 2003
Jan 20, 2003
274
275
276
277
278
279
}
cdrom->track[i].type = toc.toc_entry[i].control_adr & 0x0F;
cdrom->track[i].offset = toc.toc_entry[i].addr.lba;
cdrom->track[i].length = 0;
Jul 10, 2006
Jul 10, 2006
280
281
282
if (i > 0) {
cdrom->track[i - 1].length =
cdrom->track[i].offset - cdrom->track[i - 1].offset;
Jan 20, 2003
Jan 20, 2003
283
284
}
}
Jul 10, 2006
Jul 10, 2006
285
if (i == (cdrom->numtracks + 1)) {
Jan 20, 2003
Jan 20, 2003
286
287
288
289
okay = 1;
}
}
return (okay ? 0 : -1);
Apr 26, 2001
Apr 26, 2001
290
291
292
}
/* Get CD-ROM status */
Jul 10, 2006
Jul 10, 2006
293
294
static CDstatus
SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
Apr 26, 2001
Apr 26, 2001
295
{
Jan 20, 2003
Jan 20, 2003
296
297
298
299
300
301
CDstatus status;
cdrom_read_toc_t toc;
cdrom_subch_data_t info;
cam_devinfo_t dinfo;
Jul 10, 2006
Jul 10, 2006
302
303
int devctlret = 0;
int drive = -1;
Jan 20, 2003
Jan 20, 2003
304
int i;
Jul 10, 2006
Jul 10, 2006
305
int eagaincnt = 0;
Jan 20, 2003
Jan 20, 2003
306
307
308
/* check media presence before read subchannel call, some cdroms can lockups */
/* if no media, while calling read subchannel functions. */
Jul 10, 2006
Jul 10, 2006
309
310
311
devctlret =
devctl(cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof(cam_devinfo_t),
NULL);
Jan 20, 2003
Jan 20, 2003
312
Jul 10, 2006
Jul 10, 2006
313
314
if (devctlret == EOK) {
if ((dinfo.flags & DEV_NO_MEDIA) != 0) {
Jan 20, 2003
Jan 20, 2003
315
status = CD_TRAYEMPTY;
Jul 10, 2006
Jul 10, 2006
316
if (position) {
Jan 20, 2003
Jan 20, 2003
317
318
319
320
321
322
323
324
*position = 0;
}
return (status);
}
}
/* if media exists, then do other stuff */
Feb 7, 2006
Feb 7, 2006
325
SDL_memset(&info, 0x00, sizeof(info));
Jan 20, 2003
Jan 20, 2003
326
327
328
info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION;
do {
Jul 10, 2006
Jul 10, 2006
329
330
331
332
devctlret =
devctl(cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof(info),
NULL);
if (devctlret == EIO) {
Jan 20, 2003
Jan 20, 2003
333
334
335
/* big workaround for media change, handle is unusable after that,
that bug was found in QNX 6.2, 6.2.1 is not released yet. */
Jul 10, 2006
Jul 10, 2006
336
337
338
for (i = 0; i < MAX_DRIVES; i++) {
if (SDL_cdopen[i] == cdrom->id) {
drive = i;
Jan 20, 2003
Jan 20, 2003
339
340
341
break;
}
}
Jul 10, 2006
Jul 10, 2006
342
343
344
if (drive == -1) {
/* that cannot happen, but ... */
break;
Jan 20, 2003
Jan 20, 2003
345
346
}
close(cdrom->id);
Jul 10, 2006
Jul 10, 2006
347
348
cdrom->id = open(SDL_cdlist[drive], QNX_CD_OPENMODE);
devctlret = EAGAIN;
Jan 20, 2003
Jan 20, 2003
349
}
Jul 10, 2006
Jul 10, 2006
350
if (devctlret == EAGAIN) {
Jan 20, 2003
Jan 20, 2003
351
352
eagaincnt++;
}
Jul 10, 2006
Jul 10, 2006
353
if (eagaincnt == 2) {
Jan 20, 2003
Jan 20, 2003
354
355
/* workaround for broken cdroms, which can return always EAGAIN when its not ready, */
/* that mean errornous media or just no media avail */
Jul 10, 2006
Jul 10, 2006
356
devctlret = ENXIO;
Jan 20, 2003
Jan 20, 2003
357
358
break;
}
Aug 27, 2008
Aug 27, 2008
359
} while ((devctlret == EAGAIN) || (devctlret == ESTALE));
Jan 20, 2003
Jan 20, 2003
360
Jul 10, 2006
Jul 10, 2006
361
362
if (devctlret != 0) {
if (devctlret == ENXIO) {
Jan 20, 2003
Jan 20, 2003
363
status = CD_TRAYEMPTY;
Jul 10, 2006
Jul 10, 2006
364
} else {
Jan 20, 2003
Jan 20, 2003
365
366
status = CD_ERROR;
}
Jul 10, 2006
Jul 10, 2006
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
} else {
switch (info.current_position.header.audio_status) {
case CDROM_AUDIO_INVALID:
case CDROM_AUDIO_NO_STATUS:
/* Try to determine if there's a CD available */
if (devctl
(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc),
NULL) == 0)
status = CD_STOPPED;
else
status = CD_TRAYEMPTY;
break;
case CDROM_AUDIO_COMPLETED:
status = CD_STOPPED;
break;
case CDROM_AUDIO_PLAY:
status = CD_PLAYING;
break;
case CDROM_AUDIO_PAUSED:
/* Workaround buggy CD-ROM drive */
if (info.current_position.data_format == CDROM_LEADOUT) {
status = CD_STOPPED;
} else {
status = CD_PAUSED;
}
break;
default:
status = CD_ERROR;
break;
Jan 20, 2003
Jan 20, 2003
396
397
398
}
}
Jul 10, 2006
Jul 10, 2006
399
400
401
402
403
404
405
406
407
if (position) {
if (status == CD_PLAYING || (status == CD_PAUSED)) {
*position =
MSF_TO_FRAMES(info.current_position.addr.msf.minute,
info.current_position.addr.msf.second,
info.current_position.addr.msf.frame);
} else {
*position = 0;
}
Jan 20, 2003
Jan 20, 2003
408
409
410
}
return (status);
Apr 26, 2001
Apr 26, 2001
411
412
413
}
/* Start play */
Jul 10, 2006
Jul 10, 2006
414
415
static int
SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
Apr 26, 2001
Apr 26, 2001
416
{
Jan 20, 2003
Jan 20, 2003
417
418
cdrom_playmsf_t playtime;
Jul 10, 2006
Jul 10, 2006
419
420
421
422
423
424
425
426
427
428
429
FRAMES_TO_MSF(start, &playtime.start_minute, &playtime.start_second,
&playtime.start_frame);
FRAMES_TO_MSF(start + length, &playtime.end_minute, &playtime.end_second,
&playtime.end_frame);
if (devctl
(cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof(playtime),
NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
430
}
Apr 26, 2001
Apr 26, 2001
431
432
433
}
/* Pause play */
Jul 10, 2006
Jul 10, 2006
434
435
static int
SDL_SYS_CDPause(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
436
{
Jul 10, 2006
Jul 10, 2006
437
438
439
440
if (devctl(cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
441
}
Apr 26, 2001
Apr 26, 2001
442
443
444
}
/* Resume play */
Jul 10, 2006
Jul 10, 2006
445
446
static int
SDL_SYS_CDResume(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
447
{
Jul 10, 2006
Jul 10, 2006
448
449
450
451
if (devctl(cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
452
}
Apr 26, 2001
Apr 26, 2001
453
454
455
}
/* Stop play */
Jul 10, 2006
Jul 10, 2006
456
457
static int
SDL_SYS_CDStop(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
458
{
Jul 10, 2006
Jul 10, 2006
459
460
461
462
if (devctl(cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
463
}
Apr 26, 2001
Apr 26, 2001
464
465
466
}
/* Eject the CD-ROM */
Jul 10, 2006
Jul 10, 2006
467
468
static int
SDL_SYS_CDEject(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
469
{
Jul 10, 2006
Jul 10, 2006
470
471
472
473
if (devctl(cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
474
}
Apr 26, 2001
Apr 26, 2001
475
476
477
}
/* Close the CD-ROM handle */
Jul 10, 2006
Jul 10, 2006
478
479
static void
SDL_SYS_CDClose(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
480
{
Jan 20, 2003
Jan 20, 2003
481
482
int i;
Jul 10, 2006
Jul 10, 2006
483
484
485
486
487
for (i = 0; i < MAX_DRIVES; i++) {
if (SDL_cdopen[i] == cdrom->id) {
SDL_cdopen[i] = 0;
break;
}
Jan 20, 2003
Jan 20, 2003
488
489
490
}
close(cdrom->id);
Apr 26, 2001
Apr 26, 2001
491
492
}
Jul 10, 2006
Jul 10, 2006
493
494
void
SDL_SYS_CDQuit(void)
Apr 26, 2001
Apr 26, 2001
495
{
Jan 20, 2003
Jan 20, 2003
496
497
int i;
Jul 10, 2006
Jul 10, 2006
498
499
if (SDL_numcds > 0) {
for (i = 0; i < SDL_numcds; ++i) {
Feb 7, 2006
Feb 7, 2006
500
SDL_free(SDL_cdlist[i]);
Jan 20, 2003
Jan 20, 2003
501
502
503
}
SDL_numcds = 0;
}
Apr 26, 2001
Apr 26, 2001
504
}
Apr 14, 2006
Apr 14, 2006
505
506
#endif /* SDL_CDROM_QNX */
Jul 10, 2006
Jul 10, 2006
507
/* vi: set ts=4 sw=4 expandtab: */