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

Latest commit

 

History

History
509 lines (442 loc) · 13.5 KB

SDL_syscdrom.c

File metadata and controls

509 lines (442 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;
}
Jul 10, 2006
Jul 10, 2006
187
188
}
while (SDLcdrom);
Feb 19, 2006
Feb 19, 2006
189
SDL_stack_free(cdpath);
Jan 20, 2003
Jan 20, 2003
190
191
192
}
/* If we found our drives, there's nothing left to do */
Jul 10, 2006
Jul 10, 2006
193
194
if (SDL_numcds > 0) {
return (0);
Jan 20, 2003
Jan 20, 2003
195
196
197
198
}
}
/* Scan the system for CD-ROM drives */
Jul 10, 2006
Jul 10, 2006
199
200
201
for (i = 0; checklist[i]; ++i) {
if (checklist[i][0] == '?') {
char *insert;
Jan 20, 2003
Jan 20, 2003
202
203
exists = 1;
Jul 10, 2006
Jul 10, 2006
204
205
206
for (j = checklist[i][1]; exists; ++j) {
SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
&checklist[i][3]);
Feb 7, 2006
Feb 7, 2006
207
insert = SDL_strchr(drive, '?');
Jul 10, 2006
Jul 10, 2006
208
if (insert != NULL) {
Jan 20, 2003
Jan 20, 2003
209
210
*insert = j;
}
Jul 10, 2006
Jul 10, 2006
211
switch (CheckDrive(drive, &stbuf)) {
Jan 20, 2003
Jan 20, 2003
212
/* Drive exists and is a CD-ROM */
Jul 10, 2006
Jul 10, 2006
213
214
215
case 1:
AddDrive(drive, &stbuf);
break;
Jan 20, 2003
Jan 20, 2003
216
/* Drive exists, but isn't a CD-ROM */
Jul 10, 2006
Jul 10, 2006
217
218
case 0:
break;
Jan 20, 2003
Jan 20, 2003
219
/* Drive doesn't exist */
Jul 10, 2006
Jul 10, 2006
220
221
222
case -1:
exists = 0;
break;
Jan 20, 2003
Jan 20, 2003
223
224
}
}
Jul 10, 2006
Jul 10, 2006
225
226
227
228
} else {
SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s",
checklist[i]);
if (CheckDrive(drive, &stbuf) > 0) {
Jan 20, 2003
Jan 20, 2003
229
230
231
232
AddDrive(drive, &stbuf);
}
}
}
Jul 10, 2006
Jul 10, 2006
233
return (0);
Apr 26, 2001
Apr 26, 2001
234
235
}
Jul 10, 2006
Jul 10, 2006
236
237
static const char *
SDL_SYS_CDName(int drive)
Apr 26, 2001
Apr 26, 2001
238
{
Jul 10, 2006
Jul 10, 2006
239
return (SDL_cdlist[drive]);
Apr 26, 2001
Apr 26, 2001
240
241
}
Jul 10, 2006
Jul 10, 2006
242
243
static int
SDL_SYS_CDOpen(int drive)
Apr 26, 2001
Apr 26, 2001
244
{
Jan 20, 2003
Jan 20, 2003
245
246
int handle;
Jul 10, 2006
Jul 10, 2006
247
handle = open(SDL_cdlist[drive], QNX_CD_OPENMODE);
Jan 20, 2003
Jan 20, 2003
248
Jul 10, 2006
Jul 10, 2006
249
250
if (handle > 0) {
SDL_cdopen[drive] = handle;
Jan 20, 2003
Jan 20, 2003
251
252
253
}
return (handle);
Apr 26, 2001
Apr 26, 2001
254
255
}
Jul 10, 2006
Jul 10, 2006
256
257
static int
SDL_SYS_CDGetTOC(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
258
{
Jan 20, 2003
Jan 20, 2003
259
260
261
262
cdrom_read_toc_t toc;
int i, okay;
okay = 0;
Jul 10, 2006
Jul 10, 2006
263
264
if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) ==
0) {
Jan 20, 2003
Jan 20, 2003
265
cdrom->numtracks = toc.last_track - toc.first_track + 1;
Jul 10, 2006
Jul 10, 2006
266
if (cdrom->numtracks > SDL_MAX_TRACKS) {
Jan 20, 2003
Jan 20, 2003
267
268
269
cdrom->numtracks = SDL_MAX_TRACKS;
}
/* Read all the track TOC entries */
Jul 10, 2006
Jul 10, 2006
270
271
for (i = 0; i <= cdrom->numtracks; ++i) {
if (i == cdrom->numtracks) {
Jan 20, 2003
Jan 20, 2003
272
cdrom->track[i].id = CDROM_LEADOUT;
Jul 10, 2006
Jul 10, 2006
273
274
} else {
cdrom->track[i].id = toc.first_track + i;
Jan 20, 2003
Jan 20, 2003
275
276
277
278
279
280
}
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
281
282
283
if (i > 0) {
cdrom->track[i - 1].length =
cdrom->track[i].offset - cdrom->track[i - 1].offset;
Jan 20, 2003
Jan 20, 2003
284
285
}
}
Jul 10, 2006
Jul 10, 2006
286
if (i == (cdrom->numtracks + 1)) {
Jan 20, 2003
Jan 20, 2003
287
288
289
290
okay = 1;
}
}
return (okay ? 0 : -1);
Apr 26, 2001
Apr 26, 2001
291
292
293
}
/* Get CD-ROM status */
Jul 10, 2006
Jul 10, 2006
294
295
static CDstatus
SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
Apr 26, 2001
Apr 26, 2001
296
{
Jan 20, 2003
Jan 20, 2003
297
298
299
300
301
302
CDstatus status;
cdrom_read_toc_t toc;
cdrom_subch_data_t info;
cam_devinfo_t dinfo;
Jul 10, 2006
Jul 10, 2006
303
304
int devctlret = 0;
int drive = -1;
Jan 20, 2003
Jan 20, 2003
305
int i;
Jul 10, 2006
Jul 10, 2006
306
int eagaincnt = 0;
Jan 20, 2003
Jan 20, 2003
307
308
309
/* 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
310
311
312
devctlret =
devctl(cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof(cam_devinfo_t),
NULL);
Jan 20, 2003
Jan 20, 2003
313
Jul 10, 2006
Jul 10, 2006
314
315
if (devctlret == EOK) {
if ((dinfo.flags & DEV_NO_MEDIA) != 0) {
Jan 20, 2003
Jan 20, 2003
316
status = CD_TRAYEMPTY;
Jul 10, 2006
Jul 10, 2006
317
if (position) {
Jan 20, 2003
Jan 20, 2003
318
319
320
321
322
323
324
325
*position = 0;
}
return (status);
}
}
/* if media exists, then do other stuff */
Feb 7, 2006
Feb 7, 2006
326
SDL_memset(&info, 0x00, sizeof(info));
Jan 20, 2003
Jan 20, 2003
327
328
329
info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION;
do {
Jul 10, 2006
Jul 10, 2006
330
331
332
333
devctlret =
devctl(cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof(info),
NULL);
if (devctlret == EIO) {
Jan 20, 2003
Jan 20, 2003
334
335
336
/* 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
337
338
339
for (i = 0; i < MAX_DRIVES; i++) {
if (SDL_cdopen[i] == cdrom->id) {
drive = i;
Jan 20, 2003
Jan 20, 2003
340
341
342
break;
}
}
Jul 10, 2006
Jul 10, 2006
343
344
345
if (drive == -1) {
/* that cannot happen, but ... */
break;
Jan 20, 2003
Jan 20, 2003
346
347
}
close(cdrom->id);
Jul 10, 2006
Jul 10, 2006
348
349
cdrom->id = open(SDL_cdlist[drive], QNX_CD_OPENMODE);
devctlret = EAGAIN;
Jan 20, 2003
Jan 20, 2003
350
}
Jul 10, 2006
Jul 10, 2006
351
if (devctlret == EAGAIN) {
Jan 20, 2003
Jan 20, 2003
352
353
eagaincnt++;
}
Jul 10, 2006
Jul 10, 2006
354
if (eagaincnt == 2) {
Jan 20, 2003
Jan 20, 2003
355
356
/* 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
357
devctlret = ENXIO;
Jan 20, 2003
Jan 20, 2003
358
359
break;
}
Jul 10, 2006
Jul 10, 2006
360
361
}
while ((devctlret == EAGAIN) || (devctlret == ESTALE));
Jan 20, 2003
Jan 20, 2003
362
Jul 10, 2006
Jul 10, 2006
363
364
if (devctlret != 0) {
if (devctlret == ENXIO) {
Jan 20, 2003
Jan 20, 2003
365
status = CD_TRAYEMPTY;
Jul 10, 2006
Jul 10, 2006
366
} else {
Jan 20, 2003
Jan 20, 2003
367
368
status = CD_ERROR;
}
Jul 10, 2006
Jul 10, 2006
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
396
397
} 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
398
399
400
}
}
Jul 10, 2006
Jul 10, 2006
401
402
403
404
405
406
407
408
409
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
410
411
412
}
return (status);
Apr 26, 2001
Apr 26, 2001
413
414
415
}
/* Start play */
Jul 10, 2006
Jul 10, 2006
416
417
static int
SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
Apr 26, 2001
Apr 26, 2001
418
{
Jan 20, 2003
Jan 20, 2003
419
420
cdrom_playmsf_t playtime;
Jul 10, 2006
Jul 10, 2006
421
422
423
424
425
426
427
428
429
430
431
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
432
}
Apr 26, 2001
Apr 26, 2001
433
434
435
}
/* Pause play */
Jul 10, 2006
Jul 10, 2006
436
437
static int
SDL_SYS_CDPause(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
438
{
Jul 10, 2006
Jul 10, 2006
439
440
441
442
if (devctl(cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
443
}
Apr 26, 2001
Apr 26, 2001
444
445
446
}
/* Resume play */
Jul 10, 2006
Jul 10, 2006
447
448
static int
SDL_SYS_CDResume(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
449
{
Jul 10, 2006
Jul 10, 2006
450
451
452
453
if (devctl(cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
454
}
Apr 26, 2001
Apr 26, 2001
455
456
457
}
/* Stop play */
Jul 10, 2006
Jul 10, 2006
458
459
static int
SDL_SYS_CDStop(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
460
{
Jul 10, 2006
Jul 10, 2006
461
462
463
464
if (devctl(cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
465
}
Apr 26, 2001
Apr 26, 2001
466
467
468
}
/* Eject the CD-ROM */
Jul 10, 2006
Jul 10, 2006
469
470
static int
SDL_SYS_CDEject(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
471
{
Jul 10, 2006
Jul 10, 2006
472
473
474
475
if (devctl(cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) {
return -1;
} else {
return 0;
Jan 20, 2003
Jan 20, 2003
476
}
Apr 26, 2001
Apr 26, 2001
477
478
479
}
/* Close the CD-ROM handle */
Jul 10, 2006
Jul 10, 2006
480
481
static void
SDL_SYS_CDClose(SDL_CD * cdrom)
Apr 26, 2001
Apr 26, 2001
482
{
Jan 20, 2003
Jan 20, 2003
483
484
int i;
Jul 10, 2006
Jul 10, 2006
485
486
487
488
489
for (i = 0; i < MAX_DRIVES; i++) {
if (SDL_cdopen[i] == cdrom->id) {
SDL_cdopen[i] = 0;
break;
}
Jan 20, 2003
Jan 20, 2003
490
491
492
}
close(cdrom->id);
Apr 26, 2001
Apr 26, 2001
493
494
}
Jul 10, 2006
Jul 10, 2006
495
496
void
SDL_SYS_CDQuit(void)
Apr 26, 2001
Apr 26, 2001
497
{
Jan 20, 2003
Jan 20, 2003
498
499
int i;
Jul 10, 2006
Jul 10, 2006
500
501
if (SDL_numcds > 0) {
for (i = 0; i < SDL_numcds; ++i) {
Feb 7, 2006
Feb 7, 2006
502
SDL_free(SDL_cdlist[i]);
Jan 20, 2003
Jan 20, 2003
503
504
505
}
SDL_numcds = 0;
}
Apr 26, 2001
Apr 26, 2001
506
}
Apr 14, 2006
Apr 14, 2006
507
508
#endif /* SDL_CDROM_QNX */
Jul 10, 2006
Jul 10, 2006
509
/* vi: set ts=4 sw=4 expandtab: */