annotate src/cdrom/osf/SDL_syscdrom.c @ 935:f8d5ddc7aef1

Audio improvements from Max Horn, including a new CoreAudio driver for MacOSX
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Aug 2004 02:06:30 +0000
parents 9719e7f51a3a
children e3b3130f3af8
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 //#define DEBUG_CDROM 1
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>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include <sys/stat.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include <fcntl.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #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
31 #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
32 #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
33 #include <alloca.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include <stdlib.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include <stdio.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include <string.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include <errno.h>
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL_error.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "SDL_cdrom.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #include "SDL_syscdrom.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 /* 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
44 #define MAX_DRIVES 16
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 /* 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
47 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
48 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
49
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 /* 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 /* 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
63 /* Caution!! Not tested. */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 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
65 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
66 int cdfd, is_cd = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
67 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
68 struct inquiry_info inq;
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 #ifdef DEBUG_CDROM
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
71 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
72 "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
73 #endif
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
74
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
75 bzero(&msp, sizeof(msp));
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
76 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
77
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 /* 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
79 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
80 return(-1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
83 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
84 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
85 msp.msp_pgcode = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
86 msp.msp_pgctrl = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
87 msp.msp_length = sizeof(inq);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
88 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
89
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
90 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
91 return (0);
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
92
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
93 #ifdef DEBUG_CDROM
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
94 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
95 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
96 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
97 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
98 #endif
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
99 if ( inq.perfdt == DTYPE_RODIRECT )
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
100 is_cd = 1;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 }
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 return(is_cd);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 }
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 /* 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
107 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
108 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 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
112 /* 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
113 * 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
114 *
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
115 */
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 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
117 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
118 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 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
120 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 return;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 }
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 /* 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
126 i = SDL_numcds;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 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
129 SDL_OutOfMemory();
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 return;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 }
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 strcpy(SDL_cdlist[i], drive);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 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
135 ++SDL_numcds;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 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
138 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 }
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 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
143 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
144 /* checklist: /dev/rdisk/cdrom?c
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 *
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 static char *checklist[] = {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 "?0 rdisk/cdrom?",NULL};
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 char drive[32];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 char *SDLcdrom;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 int i, j, exists;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 struct stat stbuf;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 /* 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 /* Look in the environment for our CD-ROM drive list */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 SDLcdrom = getenv("SDL_CDROM"); /* ':' separated list of devices */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 if ( SDLcdrom != NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 char *cdpath, *delim;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 cdpath = malloc(strlen(SDLcdrom)+1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 if ( cdpath != NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 strcpy(cdpath, SDLcdrom);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 SDLcdrom = cdpath;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 do {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 delim = strchr(SDLcdrom, ':');
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 if ( delim ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 *delim++ = '\0';
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 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
181 AddDrive(SDLcdrom, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 }
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 SDLcdrom = delim;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 SDLcdrom = NULL;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 } while ( SDLcdrom );
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 free(cdpath);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
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 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
193 if ( SDL_numcds > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 return(0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 }
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 /* Scan the system for CD-ROM drives */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 for ( i=0; checklist[i]; ++i ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 if ( checklist[i][0] == '?' ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 char *insert;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 exists = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 for ( j=checklist[i][1]; exists; ++j ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 sprintf(drive, "/dev/%sc", &checklist[i][3]);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 insert = strchr(drive, '?');
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 if ( insert != NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 *insert = j;
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 switch (CheckDrive(drive, &stbuf)) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 /* Drive exists and is a CD-ROM */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 case 1:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 AddDrive(drive, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 /* Drive exists, but isn't a CD-ROM */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 case 0:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 /* Drive doesn't exist */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 case -1:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 exists = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 sprintf(drive, "/dev/%s", checklist[i]);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if ( CheckDrive(drive, &stbuf) > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 AddDrive(drive, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 }
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 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 /*
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 SDLcdrom=malloc(sizeof(char) * 32);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 SDL_cdlist[0] = SDLcdrom;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 stat(SDLcdrom, &stbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 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
235 SDL_numcds = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 return (0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 }
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 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
241 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 return(SDL_cdlist[drive]);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 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
246 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 /* 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
248 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
249 }
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 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
252 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 struct cd_toc toc;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 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
255 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
256 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 int okay = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 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
259 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
260 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 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
263 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
264 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 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 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
268 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
269 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
270 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
271 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
272 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 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
274 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
275 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
276 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
277 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
278 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
279 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 }
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 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
283 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
284 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
285 return -1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
288 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
289 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
290 if (i == cdrom->numtracks ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
291 cdrom->track[i].id = 0xAA;;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
292 } else {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
293 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
294 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
296 cdrom->track[i].type =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
297 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
298 cdrom->track[i].offset =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
299 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
300 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
301 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
302 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
303 cdrom->track[i].length = 0;
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
304 if ( i > 0 ) {
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
305 cdrom->track[i - 1].length =
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
306 cdrom->track[i].offset -
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
307 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
308 }
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
309 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 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
312 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
313 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
314 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
315 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
316 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
317 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
318 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 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
321 okay = 1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 }
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 return(okay ? 0 : -1);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 /* Get CD-ROM status */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 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
329 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 CDstatus status;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 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
332 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
333
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 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
335 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
336 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
337 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
338 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
339 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
340 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 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
342 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 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
344 case AS_AUDIO_INVALID:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 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
348 status = CD_PLAYING;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 case AS_PLAY_PAUSED:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 status = CD_PAUSED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 case AS_PLAY_COMPLETED:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 case AS_PLAY_ERROR:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 case AS_NO_STATUS:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 status = CD_STOPPED;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 default:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 status = CD_ERROR;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 #ifdef DEBUG_CDROM
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 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
368 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
369 #endif
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 if (position) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 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
373 *position =
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 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
375 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
376 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
377 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
378 } else {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 *position = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 }
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 return status;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 }
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 /* Start play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 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
388 {
873
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
389 /*
89666943c598 Date: Sun, 07 Mar 2004 22:54:11 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
390 * Play MSF
654
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 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
393 int end;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 bzero(&msf, sizeof(msf));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 end = start +length;
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
397 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
398 &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
399 &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
400 &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
401 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
402 &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
403 &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
404 &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
405
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 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
407 }
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 /* Pause play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 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
411 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 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
413 }
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 /* Resume play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 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
417 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 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
419 }
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 /* Stop play */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 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
423 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 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
425 }
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 /* Eject the CD-ROM */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 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
429 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 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
431 }
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 /* 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
434 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
435 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 close(cdrom->id);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 }
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 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
440 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 int i;
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 if ( SDL_numcds > 0 ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 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
445 free(SDL_cdlist[i]);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 SDL_numcds = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 }
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
874
9719e7f51a3a Date: Thu, 11 Mar 2004 18:45:17 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 873
diff changeset
451