annotate src/cdrom/osf/SDL_syscdrom.c @ 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
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 Tru64 audio module for SDL (Simple DirectMedia Layer)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 2003
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /* Functions for system-level CD-ROM audio control */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
25 /* #define DEBUG_CDROM 1 */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 #include <sys/types.h>
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
28 #include <dirent.h>
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include <sys/stat.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <fcntl.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <io/cam/cdrom.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <io/cam/rzdisk.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include <io/common/devgetinfo.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "SDL_cdrom.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_syscdrom.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 /* The maximum number of CD-ROM drives we'll detect */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #define MAX_DRIVES 16
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 /* A list of available CD-ROM drives */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 static char *SDL_cdlist[MAX_DRIVES];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 static dev_t SDL_cdmode[MAX_DRIVES];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 /* The system-dependent CD control functions */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 static const char *SDL_SYS_CDName(int drive);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 static int SDL_SYS_CDOpen(int drive);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 static int SDL_SYS_CDPause(SDL_CD *cdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 static int SDL_SYS_CDResume(SDL_CD *cdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 static int SDL_SYS_CDStop(SDL_CD *cdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 static int SDL_SYS_CDEject(SDL_CD *cdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 static void SDL_SYS_CDClose(SDL_CD *cdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 /* Check a drive to see if it is a CD-ROM */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 /* Caution!! Not tested. */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 static int CheckDrive(char *drive, struct stat *stbuf)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
61 int cdfd, is_cd = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
62 struct mode_sel_sns_params msp;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
63 struct inquiry_info inq;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
64
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
65 #ifdef DEBUG_CDROM
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
66 char *devtype[] = {"Disk", "Tape", "Printer", "Processor", "WORM",
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
67 "CD-ROM", "Scanner", "Optical", "Changer", "Comm", "Unknown"};
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
68 #endif
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
69
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
70 bzero(&msp, sizeof(msp));
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
71 bzero(&inq, sizeof(inq));
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 /* If it doesn't exist, return -1 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 if ( stat(drive, stbuf) < 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 return(-1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
78 if ( (cdfd = open(drive, (O_RDWR|O_NDELAY), 0)) >= 0 ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
79 msp.msp_addr = (caddr_t) &inq;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
80 msp.msp_pgcode = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
81 msp.msp_pgctrl = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
82 msp.msp_length = sizeof(inq);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
83 msp.msp_setps = 0;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
85 if ( ioctl(cdfd, SCSI_GET_INQUIRY_DATA, &msp) )
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
86 return (0);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
87
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
88 #ifdef DEBUG_CDROM
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
89 fprintf(stderr, "Device Type: %s\n", devtype[inq.perfdt]);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
90 fprintf(stderr, "Vendor: %.8s\n", inq.vndrid);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
91 fprintf(stderr, "Product: %.8s\n", inq.prodid);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
92 fprintf(stderr, "Revision: %.8s\n", inq.revlvl);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
93 #endif
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
94 if ( inq.perfdt == DTYPE_RODIRECT )
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
95 is_cd = 1;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 return(is_cd);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 /* Add a CD-ROM drive to our list of valid drives */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 static void AddDrive(char *drive, struct stat *stbuf)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 if ( SDL_numcds < MAX_DRIVES ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 /* Check to make sure it's not already in our list.
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 * This can happen when we see a drive via symbolic link.
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 *
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
110 */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 for ( i=0; i<SDL_numcds; ++i ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 if ( stbuf->st_rdev == SDL_cdmode[i] ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 return;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 /* Add this drive to our list */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 i = SDL_numcds;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
122 SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 if ( SDL_cdlist[i] == NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 SDL_OutOfMemory();
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 return;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
128 SDL_strcpy(SDL_cdlist[i], drive);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 SDL_cdmode[i] = stbuf->st_rdev;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 ++SDL_numcds;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 int SDL_SYS_CDInit(void)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 {
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
139 /* checklist:
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
140 *
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
141 * Tru64 5.X (/dev/rdisk/cdrom?c)
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
142 * dir: /dev/rdisk, name: cdrom
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
143 *
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
144 * Digital UNIX 4.0X (/dev/rrz?c)
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
145 * dir: /dev, name: rrz
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 *
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 */
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
148 struct {
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
149 char *dir;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
150 char *name;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
151 } checklist[] = {
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
152 {"/dev/rdisk", "cdrom"},
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
153 {"/dev", "rrz"},
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
154 {NULL, NULL}};
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 char drive[32];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 char *SDLcdrom;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 int i, j, exists;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 struct stat stbuf;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 /* Fill in our driver capabilities */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_CDcaps.Name = SDL_SYS_CDName;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 SDL_CDcaps.Open = SDL_SYS_CDOpen;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 SDL_CDcaps.Status = SDL_SYS_CDStatus;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 SDL_CDcaps.Play = SDL_SYS_CDPlay;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 SDL_CDcaps.Pause = SDL_SYS_CDPause;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 SDL_CDcaps.Resume = SDL_SYS_CDResume;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 SDL_CDcaps.Stop = SDL_SYS_CDStop;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 SDL_CDcaps.Eject = SDL_SYS_CDEject;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_CDcaps.Close = SDL_SYS_CDClose;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 /* 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: 1019
diff changeset
174 SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 if ( SDLcdrom != NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 char *cdpath, *delim;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
177 cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 if ( cdpath != NULL ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
179 SDL_strcpy(cdpath, SDLcdrom);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 SDLcdrom = cdpath;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 do {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
182 delim = SDL_strchr(SDLcdrom, ':');
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 if ( delim ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 *delim++ = '\0';
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 AddDrive(SDLcdrom, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 if ( delim ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 SDLcdrom = delim;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 SDLcdrom = NULL;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 } while ( SDLcdrom );
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
195 SDL_free(cdpath);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 /* If we found our drives, there's nothing left to do */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 if ( SDL_numcds > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 return(0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 /* Scan the system for CD-ROM drives */
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
204 for ( i = 0; checklist[i].dir; ++i) {
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
205 DIR *devdir;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
206 struct dirent *devent;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
207 int name_len;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
208
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
209 devdir = opendir(checklist[i].dir);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
210 if (devdir) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
211 name_len = SDL_strlen(checklist[i].name);
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
212 while (devent = readdir(devdir))
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
213 if (SDL_memcmp(checklist[i].name, devent->d_name, name_len) == 0)
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
214 if (devent->d_name[devent->d_namlen-1] == 'c') {
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
215 SDL_snprintf(drive, SDL_arraysize(drive), "%s/%s", checklist[i].dir, devent->d_name);
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
216 #ifdef DEBUG_CDROM
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
217 fprintf(stderr, "Try to add drive: %s\n", drive);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
218 #endif
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
219 if ( CheckDrive(drive, &stbuf) > 0 )
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
220 AddDrive(drive, &stbuf);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
221 }
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
222 closedir(devdir);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 } else {
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
224 #ifdef DEBUG_CDROM
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
225 fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
226 #endif
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 }
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
229
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 /*
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
231 SDLcdrom=SDL_malloc(sizeof(char) * 32);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
232 SDL_strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 SDL_cdlist[0] = SDLcdrom;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 stat(SDLcdrom, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 SDL_cdmode[0] = stbuf.st_rdev;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 SDL_numcds = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 return (0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 static const char *SDL_SYS_CDName(int drive)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 return(SDL_cdlist[drive]);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 static int SDL_SYS_CDOpen(int drive)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 /* O_RDWR: To use ioctl(fd, SCSI_STOP_UNIT) */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 return(open(SDL_cdlist[drive], (O_RDWR|O_NDELAY), 0));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 struct cd_toc toc;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 struct cd_toc_header hdr;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 struct cd_toc_entry *cdte;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 int okay = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 if ( ioctl(cdrom->id, CDROM_TOC_HEADER, &hdr) ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 fprintf(stderr,"ioctl error CDROM_TOC_HEADER\n");
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 cdrom->numtracks = hdr.th_ending_track - hdr.th_starting_track + 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 cdrom->numtracks = SDL_MAX_TRACKS;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 fprintf(stderr,"hdr.th_data_len1 = %d\n", hdr.th_data_len1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 fprintf(stderr,"hdr.th_data_len0 = %d\n", hdr.th_data_len0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 fprintf(stderr,"hdr.th_starting_track = %d\n", hdr.th_starting_track);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 fprintf(stderr,"hdr.th_ending_track = %d\n", hdr.th_ending_track);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 fprintf(stderr,"cdrom->numtracks = %d\n", cdrom->numtracks);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 toc.toc_address_format = CDROM_LBA_FORMAT;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 toc.toc_starting_track = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 toc.toc_alloc_length = (hdr.th_data_len1 << 8) +
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 hdr.th_data_len0 + sizeof(hdr);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 if ( (toc.toc_buffer = alloca(toc.toc_alloc_length)) == NULL) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 fprintf(stderr,"cannot allocate toc.toc_buffer\n");
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 bzero (toc.toc_buffer, toc.toc_alloc_length);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 if (ioctl(cdrom->id, CDROM_TOC_ENTRYS, &toc)) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 fprintf(stderr,"ioctl error CDROM_TOC_ENTRYS\n");
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
289 cdte =(struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof(hdr));
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
290 for (i=0; i <= cdrom->numtracks; ++i) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
291 if (i == cdrom->numtracks ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
292 cdrom->track[i].id = 0xAA;;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
293 } else {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
294 cdrom->track[i].id = hdr.th_starting_track + i;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
295 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
297 cdrom->track[i].type =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
298 cdte[i].te_control & CDROM_DATA_TRACK;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
299 cdrom->track[i].offset =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
300 cdte[i].te_absaddr.lba.addr3 << 24 |
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
301 cdte[i].te_absaddr.lba.addr2 << 16 |
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
302 cdte[i].te_absaddr.lba.addr1 << 8 |
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
303 cdte[i].te_absaddr.lba.addr0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
304 cdrom->track[i].length = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
305 if ( i > 0 ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
306 cdrom->track[i - 1].length =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
307 cdrom->track[i].offset -
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
308 cdrom->track[i - 1].offset;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 }
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
310 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 for (i = 0; i <= cdrom->numtracks; i++) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 fprintf(stderr,"toc_entry[%d].te_track_number = %d\n",
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 i,cdte[i].te_track_number);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 fprintf(stderr,"cdrom->track[%d].id = %d\n", i,cdrom->track[i].id);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 fprintf(stderr,"cdrom->track[%d].type = %x\n", i,cdrom->track[i].type);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 fprintf(stderr,"cdrom->track[%d].offset = %d\n", i,cdrom->track[i].offset);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 fprintf(stderr,"cdrom->track[%d].length = %d\n", i,cdrom->track[i].length);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 if ( i == (cdrom->numtracks+1) ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 okay = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 return(okay ? 0 : -1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 /* Get CD-ROM status */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 CDstatus status;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 struct cd_sub_channel sc;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 struct cd_subc_channel_data scd;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 sc.sch_address_format = CDROM_LBA_FORMAT;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 sc.sch_data_format = CDROM_CURRENT_POSITION;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 sc.sch_track_number = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 sc.sch_alloc_length = sizeof(scd);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 sc.sch_buffer = (caddr_t)&scd;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 if ( ioctl(cdrom->id, CDROM_READ_SUBCHANNEL, &sc) ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 fprintf(stderr,"ioctl error CDROM_READ_SUBCHANNEL \n");
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 switch (scd.scd_header.sh_audio_status) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 case AS_AUDIO_INVALID:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 case AS_PLAY_IN_PROGRESS:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 status = CD_PLAYING;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 case AS_PLAY_PAUSED:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 status = CD_PAUSED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 case AS_PLAY_COMPLETED:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 case AS_PLAY_ERROR:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 case AS_NO_STATUS:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 default:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 fprintf(stderr,"scd.scd_header.sh_audio_status = %x\n",
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 scd.scd_header.sh_audio_status);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 if (position) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 if (status == CD_PLAYING || (status == CD_PAUSED) ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 *position =
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 scd.scd_position_data.scp_absaddr.lba.addr3 << 24 |
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 scd.scd_position_data.scp_absaddr.lba.addr2 << 16 |
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 scd.scd_position_data.scp_absaddr.lba.addr1 << 8 |
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 scd.scd_position_data.scp_absaddr.lba.addr0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 *position = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 return status;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 /* Start play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
390 /*
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
391 * Play MSF
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 struct cd_play_audio_msf msf;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 int end;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 bzero(&msf, sizeof(msf));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 end = start +length;
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
398 FRAMES_TO_MSF(start + 150, /* LBA = 4500*M + 75*S + F - 150 */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 &msf.msf_starting_M_unit,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 &msf.msf_starting_S_unit,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 &msf.msf_starting_F_unit);
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
402 FRAMES_TO_MSF(end + 150, /* LBA = 4500*M + 75*S + F - 150 */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 &msf.msf_ending_M_unit,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 &msf.msf_ending_S_unit,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 &msf.msf_ending_F_unit);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 return(ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 /* Pause play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 static int SDL_SYS_CDPause(SDL_CD *cdrom)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 return(ioctl(cdrom->id, CDROM_PAUSE_PLAY));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 /* Resume play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 static int SDL_SYS_CDResume(SDL_CD *cdrom)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 return(ioctl(cdrom->id, CDROM_RESUME_PLAY));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 /* Stop play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 static int SDL_SYS_CDStop(SDL_CD *cdrom)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 return(ioctl(cdrom->id, SCSI_STOP_UNIT));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 /* Eject the CD-ROM */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 static int SDL_SYS_CDEject(SDL_CD *cdrom)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 return(ioctl(cdrom->id, CDROM_EJECT_CADDY));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 /* Close the CD-ROM handle */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 static void SDL_SYS_CDClose(SDL_CD *cdrom)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 close(cdrom->id);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 void SDL_SYS_CDQuit(void)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 if ( SDL_numcds > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 for ( i=0; i<SDL_numcds; ++i ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
446 SDL_free(SDL_cdlist[i]);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 SDL_numcds = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
452