annotate src/cdrom/macosx/SDL_syscdrom.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 14717b52abc0
children 4da1ee79c9af
rev   line source
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
6 modify it under the terms of the GNU Lesser General Public
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
13 Lesser General Public License for more details.
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1126
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
22 #include "SDL_config.h"
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
24 #ifdef SDL_CDROM_MACOSX
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
25
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "SDL_syscdrom_c.h"
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #pragma mark -- Globals --
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
30 static FSRef **tracks;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
31 static FSVolumeRefNum *volumes;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
32 static CDstatus status;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
33 static int nextTrackFrame;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
34 static int nextTrackFramesRemaining;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
35 static int fakeCD;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
36 static int currentTrack;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
37 static int didReadTOC;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
38 static int cacheTOCNumTracks;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
39 static int currentDrive; /* Only allow 1 drive in use at a time */
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #pragma mark -- Prototypes --
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
43 static const char *SDL_SYS_CDName (int drive);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
44 static int SDL_SYS_CDOpen (int drive);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
45 static int SDL_SYS_CDGetTOC (SDL_CD * cdrom);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
46 static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
47 static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
48 static int SDL_SYS_CDPause (SDL_CD * cdrom);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
49 static int SDL_SYS_CDResume (SDL_CD * cdrom);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
50 static int SDL_SYS_CDStop (SDL_CD * cdrom);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
51 static int SDL_SYS_CDEject (SDL_CD * cdrom);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
52 static void SDL_SYS_CDClose (SDL_CD * cdrom);
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 #pragma mark -- Helper Functions --
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 /* Read a list of tracks from the volume */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
57 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
58 LoadTracks (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 /* Check if tracks are already loaded */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
61 if (tracks[cdrom->id] != NULL)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 return 0;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
63
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* Allocate memory for tracks */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
65 tracks[cdrom->id] =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
66 (FSRef *) SDL_calloc (1, sizeof (**tracks) * cdrom->numtracks);
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 if (tracks[cdrom->id] == NULL) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 SDL_OutOfMemory ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
71
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 /* Load tracks */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
73 if (ListTrackFiles
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
74 (volumes[cdrom->id], tracks[cdrom->id], cdrom->numtracks) < 0)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 /* Find a file for a given start frame and length */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
81 static FSRef *
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
82 GetFileForOffset (SDL_CD * cdrom, int start, int length, int *outStartFrame,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
83 int *outStopFrame)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 int i;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
86
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 for (i = 0; i < cdrom->numtracks; i++) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
88
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 if (cdrom->track[i].offset <= start &&
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 start < (cdrom->track[i].offset + cdrom->track[i].length))
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 break;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
93
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 if (i == cdrom->numtracks)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 return NULL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
96
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 currentTrack = i;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 *outStartFrame = start - cdrom->track[i].offset;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
100
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 if ((*outStartFrame + length) < cdrom->track[i].length) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 *outStopFrame = *outStartFrame + length;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 length = 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 nextTrackFrame = -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 nextTrackFramesRemaining = -1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
106 } else {
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 *outStopFrame = -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 length -= cdrom->track[i].length - *outStartFrame;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
109 nextTrackFrame = cdrom->track[i + 1].offset;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 nextTrackFramesRemaining = length;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
112
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 return &tracks[cdrom->id][i];
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 /* Setup another file for playback, or stop playback (called from another thread) */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
117 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
118 CompletionProc (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
120
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 Lock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
122
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
124
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 /* Load the next file to play */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 int startFrame, stopFrame;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 FSRef *file;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
128
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 PauseFile ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 ReleaseFile ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
131
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
132 file = GetFileForOffset (cdrom, nextTrackFrame,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
133 nextTrackFramesRemaining, &startFrame,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
134 &stopFrame);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
135
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 if (file == NULL) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 status = CD_STOPPED;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 Unlock ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 return;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
141
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 LoadFile (file, startFrame, stopFrame);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
143
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 SetCompletionProc (CompletionProc, cdrom);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
145
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 PlayFile ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
147 } else {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
148
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 /* Release the current file */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 PauseFile ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 ReleaseFile ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 status = CD_STOPPED;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
154
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 Unlock ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 #pragma mark -- Driver Functions --
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 /* Initialize */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
162 int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
163 SDL_SYS_CDInit (void)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 /* Initialize globals */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 volumes = NULL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
167 tracks = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
168 status = CD_STOPPED;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 nextTrackFrame = -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 nextTrackFramesRemaining = -1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
171 fakeCD = SDL_FALSE;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 currentTrack = -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 didReadTOC = SDL_FALSE;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 cacheTOCNumTracks = -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 currentDrive = -1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
176
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 /* Fill in function pointers */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
178 SDL_CDcaps.Name = SDL_SYS_CDName;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
179 SDL_CDcaps.Open = SDL_SYS_CDOpen;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 SDL_CDcaps.Status = SDL_SYS_CDStatus;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
182 SDL_CDcaps.Play = SDL_SYS_CDPlay;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
183 SDL_CDcaps.Pause = SDL_SYS_CDPause;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 SDL_CDcaps.Resume = SDL_SYS_CDResume;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
185 SDL_CDcaps.Stop = SDL_SYS_CDStop;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
186 SDL_CDcaps.Eject = SDL_SYS_CDEject;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
187 SDL_CDcaps.Close = SDL_SYS_CDClose;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 /*
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
190 Read the list of "drives"
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
191
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
192 This is currently a hack that infers drives from
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
193 mounted audio CD volumes, rather than
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
194 actual CD-ROM devices - which means it may not
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
195 act as expected sometimes.
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
196 */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
197
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 /* Find out how many cd volumes are mounted */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 SDL_numcds = DetectAudioCDVolumes (NULL, 0);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 /*
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
202 If there are no volumes, fake a cd device
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
203 so tray empty can be reported.
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
204 */
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 if (SDL_numcds == 0) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
206
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 fakeCD = SDL_TRUE;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 SDL_numcds = 1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 status = CD_TRAYEMPTY;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
210
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
213
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 /* Allocate space for volumes */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
215 volumes =
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
216 (FSVolumeRefNum *) SDL_calloc (1, sizeof (*volumes) * SDL_numcds);
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 if (volumes == NULL) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 SDL_OutOfMemory ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
221
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 /* Allocate space for tracks */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
223 tracks = (FSRef **) SDL_calloc (1, sizeof (*tracks) * (SDL_numcds + 1));
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if (tracks == NULL) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 SDL_OutOfMemory ();
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
228
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 /* Mark the end of the tracks array */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
230 tracks[SDL_numcds] = (FSRef *) - 1;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
231
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 /*
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
233 Redetect, now save all volumes for later
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
234 Update SDL_numcds just in case it changed
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
235 */
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 int numVolumes = SDL_numcds;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
238
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 SDL_numcds = DetectAudioCDVolumes (volumes, numVolumes);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
240
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 /* If more cds suddenly show up, ignore them */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 if (SDL_numcds > numVolumes) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 SDL_SetError ("Some CD's were added but they will be ignored");
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 SDL_numcds = numVolumes;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
247
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 /* Shutdown and cleanup */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
252 void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
253 SDL_SYS_CDQuit (void)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
255 ReleaseFile ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
256
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 if (volumes != NULL)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 free (volumes);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
259
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 if (tracks != NULL) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
261
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 FSRef **ptr;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
263 for (ptr = tracks; *ptr != (FSRef *) - 1; ptr++)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 if (*ptr != NULL)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 free (*ptr);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
266
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 free (tracks);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 /* Get the Unix disk name of the volume */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
272 static const char *
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
273 SDL_SYS_CDName (int drive)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
275 OSStatus err = noErr;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
276 HParamBlockRec pb;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
277 GetVolParmsInfoBuffer volParmsInfo;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
278
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 if (fakeCD)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 return "Fake CD-ROM Device";
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
281
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
282 pb.ioParam.ioNamePtr = NULL;
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
283 pb.ioParam.ioVRefNum = volumes[drive];
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
284 pb.ioParam.ioBuffer = (Ptr) & volParmsInfo;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
285 pb.ioParam.ioReqCount = (SInt32) sizeof (volParmsInfo);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
286 err = PBHGetVolParmsSync (&pb);
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
287
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 if (err != noErr) {
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
289 SDL_SetError ("PBHGetVolParmsSync returned %d", err);
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 return NULL;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 }
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
292
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
293 return volParmsInfo.vMDeviceID;
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 /* Open the "device" */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
297 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
298 SDL_SYS_CDOpen (int drive)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 /* Only allow 1 device to be open */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 if (currentDrive >= 0) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 SDL_SetError ("Only one cdrom is supported");
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 return -1;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
304 } else
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 currentDrive = drive;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 return drive;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 /* Get the table of contents */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
311 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
312 SDL_SYS_CDGetTOC (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 if (fakeCD) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 SDL_SetError (kErrorFakeDevice);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
318
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 if (didReadTOC) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 cdrom->numtracks = cacheTOCNumTracks;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
323
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
324
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 ReadTOCData (volumes[cdrom->id], cdrom);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 didReadTOC = SDL_TRUE;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 cacheTOCNumTracks = cdrom->numtracks;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
328
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 /* Get CD-ROM status */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
333 static CDstatus
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
334 SDL_SYS_CDStatus (SDL_CD * cdrom, int *position)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 {
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
336 if (position) {
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
337 int trackFrame;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
338
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
339 Lock ();
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
340 trackFrame = GetCurrentFrame ();
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
341 Unlock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
342
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
343 *position = cdrom->track[currentTrack].offset + trackFrame;
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
344 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
345
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 return status;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 /* Start playback */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
350 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
351 SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 int startFrame, stopFrame;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 FSRef *ref;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
355
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 if (fakeCD) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 SDL_SetError (kErrorFakeDevice);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
360
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
361 Lock ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
362
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 if (LoadTracks (cdrom) < 0)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 return -2;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
365
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 if (PauseFile () < 0)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 return -3;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
368
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 if (ReleaseFile () < 0)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 return -4;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
371
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 ref = GetFileForOffset (cdrom, start, length, &startFrame, &stopFrame);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 if (ref == NULL) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
374 SDL_SetError ("SDL_SYS_CDPlay: No file for start=%d, length=%d",
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
375 start, length);
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 return -5;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
378
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 if (LoadFile (ref, startFrame, stopFrame) < 0)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 return -6;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
381
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 SetCompletionProc (CompletionProc, cdrom);
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
383
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 if (PlayFile () < 0)
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 return -7;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
386
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 status = CD_PLAYING;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
388
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
389 Unlock ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
390
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 /* Pause playback */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
395 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
396 SDL_SYS_CDPause (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 if (fakeCD) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 SDL_SetError (kErrorFakeDevice);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
402
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 Lock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
404
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
405 if (PauseFile () < 0) {
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
406 Unlock ();
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 return -2;
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
408 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
409
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 status = CD_PAUSED;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
411
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 Unlock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
413
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 /* Resume playback */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
418 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
419 SDL_SYS_CDResume (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 if (fakeCD) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 SDL_SetError (kErrorFakeDevice);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
425
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 Lock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
427
1126
d581fe3f36db Fix for bug reported by Michael Benfield on the SDL mailing list:
Ryan C. Gordon <icculus@icculus.org>
parents: 769
diff changeset
428 if (PlayFile () < 0) {
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
429 Unlock ();
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 return -2;
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
431 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
432
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 status = CD_PLAYING;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
434
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 Unlock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
436
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 /* Stop playback */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
441 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
442 SDL_SYS_CDStop (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 if (fakeCD) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 SDL_SetError (kErrorFakeDevice);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
448
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 Lock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
450
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
451 if (PauseFile () < 0) {
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
452 Unlock ();
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 return -2;
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
454 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
455
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
456 if (ReleaseFile () < 0) {
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
457 Unlock ();
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 return -3;
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
459 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
460
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 status = CD_STOPPED;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
462
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 Unlock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
464
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 /* Eject the CD-ROM (Unmount the volume) */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
469 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
470 SDL_SYS_CDEject (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 OSStatus err;
1659
14717b52abc0 Merge trunk-1.3-3
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
473 pid_t dissenter;
14717b52abc0 Merge trunk-1.3-3
Sam Lantinga <slouken@libsdl.org>
parents: 1635
diff changeset
474
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 if (fakeCD) {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 SDL_SetError (kErrorFakeDevice);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 return -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
479
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 Lock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
481
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
482 if (PauseFile () < 0) {
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
483 Unlock ();
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 return -2;
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
485 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
486
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
487 if (ReleaseFile () < 0) {
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
488 Unlock ();
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 return -3;
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
490 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
491
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 status = CD_STOPPED;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
493
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
494 /* Eject the volume */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
495 err = FSEjectVolumeSync (volumes[cdrom->id], kNilOptions, &dissenter);
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
496
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
497 if (err != noErr) {
768
de1b2c3063b9 Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents: 616
diff changeset
498 Unlock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
499 SDL_SetError ("PBUnmountVol returned %d", err);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
500 return -4;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
501 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
502
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 status = CD_TRAYEMPTY;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 /* Invalidate volume and track info */
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 volumes[cdrom->id] = 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 free (tracks[cdrom->id]);
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508 tracks[cdrom->id] = NULL;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
509
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 Unlock ();
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
511
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 return 0;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 /* Close the CD-ROM */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
516 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
517 SDL_SYS_CDClose (SDL_CD * cdrom)
616
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 {
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 currentDrive = -1;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 return;
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 }
12c746afbc27 Oops...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522
1635
92947e3a18db Make sure code is only compiled if the appropriate subsystem is enabled
Sam Lantinga <slouken@libsdl.org>
parents: 1487
diff changeset
523 #endif /* SDL_CDROM_MACOSX */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1659
diff changeset
524 /* vi: set ts=4 sw=4 expandtab: */