annotate src/cdrom/qnx/SDL_syscdrom.c @ 1350:adc8ff3c9597

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