annotate src/cdrom/osf/SDL_syscdrom.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents e3b3130f3af8
children 604d73db6802
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 #include <alloca.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include <stdlib.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include <stdio.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include <string.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include <errno.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "SDL_error.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #include "SDL_cdrom.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #include "SDL_syscdrom.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 /* 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
45 #define MAX_DRIVES 16
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 /* 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
48 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
49 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
50
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 /* 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 /* 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
64 /* Caution!! Not tested. */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 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
66 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
67 int cdfd, is_cd = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
68 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
69 struct inquiry_info inq;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
70
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
71 #ifdef DEBUG_CDROM
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
72 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
73 "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
74 #endif
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
75
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
76 bzero(&msp, sizeof(msp));
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
77 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
78
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 /* 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
80 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
81 return(-1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
84 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
85 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
86 msp.msp_pgcode = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
87 msp.msp_pgctrl = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
88 msp.msp_length = sizeof(inq);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
89 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
90
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
91 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
92 return (0);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
93
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
94 #ifdef DEBUG_CDROM
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
95 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
96 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
97 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
98 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
99 #endif
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
100 if ( inq.perfdt == DTYPE_RODIRECT )
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
101 is_cd = 1;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 }
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 return(is_cd);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 /* 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
108 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
109 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 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
113 /* 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
114 * 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
115 *
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
116 */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 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
118 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
119 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 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
121 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 return;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 /* 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
127 i = SDL_numcds;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
128 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
129 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
130 SDL_OutOfMemory();
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 return;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
134 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
135 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
136 ++SDL_numcds;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 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
139 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 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
144 {
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
145 /* checklist:
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
146 *
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
147 * 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
148 * dir: /dev/rdisk, name: cdrom
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
149 *
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
150 * 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
151 * 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
152 *
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 */
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
154 struct {
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
155 char *dir;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
156 char *name;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
157 } checklist[] = {
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
158 {"/dev/rdisk", "cdrom"},
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
159 {"/dev", "rrz"},
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
160 {NULL, NULL}};
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 char drive[32];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 char *SDLcdrom;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 int i, j, exists;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 struct stat stbuf;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 /* 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 /* 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
180 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
181 if ( SDLcdrom != NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 char *cdpath, *delim;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
183 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
184 if ( cdpath != NULL ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
185 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
186 SDLcdrom = cdpath;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 do {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
188 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
189 if ( delim ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 *delim++ = '\0';
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 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
193 AddDrive(SDLcdrom, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 if ( delim ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 SDLcdrom = delim;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SDLcdrom = NULL;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 } while ( SDLcdrom );
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
201 SDL_free(cdpath);
654
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 /* 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
205 if ( SDL_numcds > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 return(0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 /* 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
210 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
211 DIR *devdir;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
212 struct dirent *devent;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
213 int name_len;
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
214
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
215 devdir = opendir(checklist[i].dir);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
216 if (devdir) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
217 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
218 while (devent = readdir(devdir))
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
219 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
220 if (devent->d_name[devent->d_namlen-1] == 'c') {
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
221 sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
222 #ifdef DEBUG_CDROM
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
223 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
224 #endif
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
225 if ( CheckDrive(drive, &stbuf) > 0 )
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
226 AddDrive(drive, &stbuf);
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
227 }
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
228 closedir(devdir);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 } else {
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
230 #ifdef DEBUG_CDROM
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
231 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
232 #endif
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 }
1019
e3b3130f3af8 Date: Fri, 31 Dec 2004 04:14:09 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 874
diff changeset
235
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 /*
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
237 SDLcdrom=SDL_malloc(sizeof(char) * 32);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1019
diff changeset
238 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
239 SDL_cdlist[0] = SDLcdrom;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 stat(SDLcdrom, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 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
242 SDL_numcds = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 return (0);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 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
248 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 return(SDL_cdlist[drive]);
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_CDOpen(int drive)
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 /* 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
255 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
256 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 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
259 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 struct cd_toc toc;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 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
262 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
263 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 int okay = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 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
266 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
267 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 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
270 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
271 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
272 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 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
275 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
276 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
277 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
278 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
279 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 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
281 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
282 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
283 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
284 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
285 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
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 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
290 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
291 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
292 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
295 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
296 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
297 if (i == cdrom->numtracks ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
298 cdrom->track[i].id = 0xAA;;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
299 } else {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
300 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
301 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
303 cdrom->track[i].type =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
304 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
305 cdrom->track[i].offset =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
306 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
307 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
308 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
309 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
310 cdrom->track[i].length = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
311 if ( i > 0 ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
312 cdrom->track[i - 1].length =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
313 cdrom->track[i].offset -
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
314 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
315 }
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
316 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 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
328 okay = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 }
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 return(okay ? 0 : -1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 /* Get CD-ROM status */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 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
336 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 CDstatus status;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 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
339 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
340
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 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
342 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
343 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
344 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
345 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
346 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
347 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 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
349 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 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
351 case AS_AUDIO_INVALID:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 status = CD_STOPPED;
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_IN_PROGRESS:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 status = CD_PLAYING;
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_PAUSED:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 status = CD_PAUSED;
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_PLAY_COMPLETED:
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 case AS_PLAY_ERROR:
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 case AS_NO_STATUS:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 default:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 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
375 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
376 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 if (position) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 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
380 *position =
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 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
382 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
383 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
384 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
385 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 *position = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 return status;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 }
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 /* Start play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 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
395 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
396 /*
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
397 * Play MSF
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 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
400 int end;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 bzero(&msf, sizeof(msf));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 end = start +length;
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
404 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
405 &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
406 &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
407 &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
408 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
409 &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
410 &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
411 &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
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_PLAY_AUDIO_MSF, &msf));
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 /* Pause 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_CDPause(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_PAUSE_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 /* Resume 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_CDResume(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, CDROM_RESUME_PLAY));
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 /* Stop play */
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_CDStop(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, SCSI_STOP_UNIT));
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 /* Eject the CD-ROM */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 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
436 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 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
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 /* 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
441 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
442 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 close(cdrom->id);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 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
447 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 int i;
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 if ( SDL_numcds > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 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
452 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
453 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 SDL_numcds = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
458