annotate src/cdrom/beos/SDL_syscdrom.cc @ 1358:c71e05b4dc2e

More header massaging... works great on Windows. ;-)
author Sam Lantinga <slouken@libsdl.org>
date Fri, 10 Feb 2006 06:48:43 +0000
parents 604d73db6802
children 19418e4422cb
rev   line source
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
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
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
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
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
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.
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
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.
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
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
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 153
diff changeset
20 slouken@libsdl.org
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /* Functions for system-level CD-ROM audio control on BeOS
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 (not completely implemented yet)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include <sys/types.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include <sys/stat.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include <unistd.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <scsi.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <Directory.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include <Entry.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include <Path.h>
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_cdrom.h"
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 extern "C" {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include "SDL_syscdrom.h"
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 /* Constants to help us get at the SCSI table-of-contents info */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #define CD_NUMTRACKS(toc) toc.toc_data[3]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #define CD_TRACK(toc, track) (&toc.toc_data[6+(track)*8])
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #define CD_TRACK_N(toc, track) CD_TRACK(toc, track)[0]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #define CD_TRACK_M(toc, track) CD_TRACK(toc, track)[3]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #define CD_TRACK_S(toc, track) CD_TRACK(toc, track)[4]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 #define CD_TRACK_F(toc, track) CD_TRACK(toc, track)[5]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 /* Constants to help us get at the SCSI position info */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 #define POS_TRACK(pos) pos.position[6]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 #define POS_ABS_M(pos) pos.position[9]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 #define POS_ABS_S(pos) pos.position[10]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 #define POS_ABS_F(pos) pos.position[11]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 #define POS_REL_M(pos) pos.position[13]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 #define POS_REL_S(pos) pos.position[14]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 #define POS_REL_F(pos) pos.position[15]
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 /* The maximum number of CD-ROM drives we'll detect */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 #define MAX_DRIVES 16
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 /* A list of available CD-ROM drives */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 static char *SDL_cdlist[MAX_DRIVES];
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* The system-dependent CD control functions */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static const char *SDL_SYS_CDName(int drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 static int SDL_SYS_CDOpen(int drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 static int SDL_SYS_CDPause(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 static int SDL_SYS_CDResume(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static int SDL_SYS_CDStop(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 static int SDL_SYS_CDEject(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static void SDL_SYS_CDClose(SDL_CD *cdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 int try_dir(const char *directory);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 /* Check a drive to see if it is a CD-ROM */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 static int CheckDrive(char *drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 struct stat stbuf;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 int is_cd, cdfd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 device_geometry info;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 /* If it doesn't exist, return -1 */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 if ( stat(drive, &stbuf) < 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 return(-1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 /* If it does exist, verify that it's an available CD-ROM */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 is_cd = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 cdfd = open(drive, 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 if ( cdfd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 if ( ioctl(cdfd, B_GET_GEOMETRY, &info) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 if ( info.device_type == B_CD ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 is_cd = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 close(cdfd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 /* This can happen when the drive is open .. (?) */;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 is_cd = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 return(is_cd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 /* Add a CD-ROM drive to our list of valid drives */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 static void AddDrive(char *drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 int i;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 if ( SDL_numcds < MAX_DRIVES ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 /* Add this drive to our list */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 i = SDL_numcds;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
115 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 if ( SDL_cdlist[i] == NULL ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 SDL_OutOfMemory();
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 return;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
120 SDL_strcpy(SDL_cdlist[i], drive);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 ++SDL_numcds;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 #ifdef CDROM_DEBUG
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 #endif
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 /* IDE bus scanning magic */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 enum {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 IDE_GET_DEVICES_INFO = B_DEVICE_OP_CODES_END + 50,
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 };
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 struct ide_ctrl_info {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 bool ide_0_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 bool ide_0_master_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 bool ide_0_slave_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 int ide_0_master_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 int ide_0_slave_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 bool ide_1_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 bool ide_1_master_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 bool ide_1_slave_present;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 int ide_1_master_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 int ide_1_slave_type;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 };
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 int SDL_SYS_CDInit(void)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 char *SDLcdrom;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 int raw_fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 struct ide_ctrl_info info;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 /* Fill in our driver capabilities */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 SDL_CDcaps.Name = SDL_SYS_CDName;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 SDL_CDcaps.Open = SDL_SYS_CDOpen;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 SDL_CDcaps.Status = SDL_SYS_CDStatus;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 SDL_CDcaps.Play = SDL_SYS_CDPlay;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 SDL_CDcaps.Pause = SDL_SYS_CDPause;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 SDL_CDcaps.Resume = SDL_SYS_CDResume;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 SDL_CDcaps.Stop = SDL_SYS_CDStop;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 SDL_CDcaps.Eject = SDL_SYS_CDEject;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_CDcaps.Close = SDL_SYS_CDClose;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 /* 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
164 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 if ( SDLcdrom != NULL ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 char *cdpath, *delim;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
167 cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 if ( cdpath != NULL ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
169 SDL_strcpy(cdpath, SDLcdrom);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDLcdrom = cdpath;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 do {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
172 delim = SDL_strchr(SDLcdrom, ':');
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 if ( delim ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 *delim++ = '\0';
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 if ( CheckDrive(SDLcdrom) > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 AddDrive(SDLcdrom);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 if ( delim ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 SDLcdrom = delim;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 SDLcdrom = NULL;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 } while ( SDLcdrom );
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
185 SDL_free(cdpath);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 /* If we found our drives, there's nothing left to do */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 if ( SDL_numcds > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 return(0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 /* Scan the system for CD-ROM drives */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 try_dir("/dev/disk");
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 return 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 int try_dir(const char *directory)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 BDirectory dir;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 dir.SetTo(directory);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 if(dir.InitCheck() != B_NO_ERROR) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 return false;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 dir.Rewind();
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 BEntry entry;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 while(dir.GetNextEntry(&entry) >= 0) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 BPath path;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 const char *name;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 entry_ref e;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 if(entry.GetPath(&path) != B_NO_ERROR)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 continue;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 name = path.Path();
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 if(entry.GetRef(&e) != B_NO_ERROR)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 continue;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 if(entry.IsDirectory()) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
222 if(SDL_strcmp(e.name, "floppy") == 0)
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 continue; /* ignore floppy (it is not silent) */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 int devfd = try_dir(name);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 if(devfd >= 0)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 return devfd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 int devfd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 device_geometry g;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
232 if(SDL_strcmp(e.name, "raw") != 0)
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 continue; /* ignore partitions */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 devfd = open(name, O_RDONLY);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 if(devfd < 0)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 continue;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 if(g.device_type == B_CD)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 AddDrive(strdup(name));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 close(devfd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 return B_ERROR;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 /* General ioctl() CD-ROM command function */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 static int SDL_SYS_CDioctl(int index, int command, void *arg)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 int okay;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 int fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 okay = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 fd = open(SDL_cdlist[index], 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 if ( fd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 if ( ioctl(fd, command, arg) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 okay = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 close(fd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 return(okay ? 0 : -1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 static const char *SDL_SYS_CDName(int drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 return(SDL_cdlist[drive]);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 static int SDL_SYS_CDOpen(int drive)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 return(drive);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 int i;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 scsi_toc toc;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 if ( SDL_SYS_CDioctl(cdrom->id, B_SCSI_GET_TOC, &toc) == 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 cdrom->numtracks = CD_NUMTRACKS(toc);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 cdrom->numtracks = SDL_MAX_TRACKS;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 for ( i=0; i<=cdrom->numtracks; ++i ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 cdrom->track[i].id = CD_TRACK_N(toc, i);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 /* FIXME: How do we tell on BeOS? */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 cdrom->track[i].type = SDL_AUDIO_TRACK;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 cdrom->track[i].offset = MSF_TO_FRAMES(
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 CD_TRACK_M(toc, i),
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 CD_TRACK_S(toc, i),
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 CD_TRACK_F(toc, i));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 cdrom->track[i].length = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 if ( i > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 cdrom->track[i-1].length =
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 cdrom->track[i].offset-
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 cdrom->track[i-1].offset;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 return(0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 return(-1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 /* Get CD-ROM status */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 CDstatus status;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 int fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 int cur_frame;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 scsi_position pos;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 fd = open(SDL_cdlist[cdrom->id], 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 cur_frame = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 if ( fd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 if ( ioctl(fd, B_SCSI_GET_POSITION, &pos) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 cur_frame = MSF_TO_FRAMES(
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 POS_ABS_M(pos), POS_ABS_S(pos), POS_ABS_F(pos));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 if ( ! pos.position[1] || (pos.position[1] >= 0x13) ||
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 ((pos.position[1] == 0x12) && (!pos.position[6])) ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 status = CD_STOPPED;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 } else
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 if ( pos.position[1] == 0x11 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 status = CD_PLAYING;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 status = CD_PAUSED;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 close(fd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 } else {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 status = CD_TRAYEMPTY;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 if ( position ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 *position = cur_frame;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 return(status);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 /* Start play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 int okay;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 int fd;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 scsi_play_position pos;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 okay = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 fd = open(SDL_cdlist[cdrom->id], 0);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 if ( fd >= 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 FRAMES_TO_MSF(start, &pos.start_m, &pos.start_s, &pos.start_f);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 FRAMES_TO_MSF(start+length, &pos.end_m, &pos.end_s, &pos.end_f);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 if ( ioctl(fd, B_SCSI_PLAY_POSITION, &pos) == B_NO_ERROR ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 okay = 1;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 close(fd);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 return(okay ? 0 : -1);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 /* Pause play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 static int SDL_SYS_CDPause(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_PAUSE_AUDIO, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 /* Resume play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 static int SDL_SYS_CDResume(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_RESUME_AUDIO, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 /* Stop play */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 static int SDL_SYS_CDStop(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_STOP_AUDIO, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 /* Eject the CD-ROM */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 static int SDL_SYS_CDEject(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_EJECT, 0));
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 /* Close the CD-ROM handle */
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 static void SDL_SYS_CDClose(SDL_CD *cdrom)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 close(cdrom->id);
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 void SDL_SYS_CDQuit(void)
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 int i;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 if ( SDL_numcds > 0 ) {
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 for ( i=0; i<SDL_numcds; ++i ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
400 SDL_free(SDL_cdlist[i]);
153
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 SDL_numcds = 0;
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 }
2839f45bdba0 Fixed IDE and SCSI CD-ROM detection on BeOS (thanks Caz!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405