Mercurial > sdl-ios-xcode
annotate src/cdrom/macosx/SDL_syscdrom.c @ 1312:c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
I batch edited these files, so please let me know if I've accidentally removed anybody's
credit here.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 01 Feb 2006 06:32:25 +0000 |
parents | d581fe3f36db |
children | 604d73db6802 |
rev | line source |
---|---|
616 | 1 /* |
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 | 4 |
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 | 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 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
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 | 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 | 18 |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 #include "SDL_syscdrom_c.h" | |
24 | |
25 #pragma mark -- Globals -- | |
26 | |
27 static FSRef** tracks; | |
28 static FSVolumeRefNum* volumes; | |
29 static CDstatus status; | |
30 static int nextTrackFrame; | |
31 static int nextTrackFramesRemaining; | |
32 static int fakeCD; | |
33 static int currentTrack; | |
34 static int didReadTOC; | |
35 static int cacheTOCNumTracks; | |
36 static int currentDrive; /* Only allow 1 drive in use at a time */ | |
37 | |
38 #pragma mark -- Prototypes -- | |
39 | |
40 static const char *SDL_SYS_CDName (int drive); | |
41 static int SDL_SYS_CDOpen (int drive); | |
42 static int SDL_SYS_CDGetTOC (SDL_CD *cdrom); | |
43 static CDstatus SDL_SYS_CDStatus (SDL_CD *cdrom, int *position); | |
44 static int SDL_SYS_CDPlay (SDL_CD *cdrom, int start, int length); | |
45 static int SDL_SYS_CDPause (SDL_CD *cdrom); | |
46 static int SDL_SYS_CDResume (SDL_CD *cdrom); | |
47 static int SDL_SYS_CDStop (SDL_CD *cdrom); | |
48 static int SDL_SYS_CDEject (SDL_CD *cdrom); | |
49 static void SDL_SYS_CDClose (SDL_CD *cdrom); | |
50 | |
51 #pragma mark -- Helper Functions -- | |
52 | |
53 /* Read a list of tracks from the volume */ | |
54 static int LoadTracks (SDL_CD *cdrom) | |
55 { | |
56 /* Check if tracks are already loaded */ | |
57 if ( tracks[cdrom->id] != NULL ) | |
58 return 0; | |
59 | |
60 /* Allocate memory for tracks */ | |
61 tracks[cdrom->id] = (FSRef*) calloc (1, sizeof(**tracks) * cdrom->numtracks); | |
62 if (tracks[cdrom->id] == NULL) { | |
63 SDL_OutOfMemory (); | |
64 return -1; | |
65 } | |
66 | |
67 /* Load tracks */ | |
68 if (ListTrackFiles (volumes[cdrom->id], tracks[cdrom->id], cdrom->numtracks) < 0) | |
69 return -1; | |
70 | |
71 return 0; | |
72 } | |
73 | |
74 /* Find a file for a given start frame and length */ | |
75 static FSRef* GetFileForOffset (SDL_CD *cdrom, int start, int length, int *outStartFrame, int *outStopFrame) | |
76 { | |
77 int i; | |
78 | |
79 for (i = 0; i < cdrom->numtracks; i++) { | |
80 | |
81 if (cdrom->track[i].offset <= start && | |
82 start < (cdrom->track[i].offset + cdrom->track[i].length)) | |
83 break; | |
84 } | |
85 | |
86 if (i == cdrom->numtracks) | |
87 return NULL; | |
88 | |
89 currentTrack = i; | |
90 | |
91 *outStartFrame = start - cdrom->track[i].offset; | |
92 | |
93 if ((*outStartFrame + length) < cdrom->track[i].length) { | |
94 *outStopFrame = *outStartFrame + length; | |
95 length = 0; | |
96 nextTrackFrame = -1; | |
97 nextTrackFramesRemaining = -1; | |
98 } | |
99 else { | |
100 *outStopFrame = -1; | |
101 length -= cdrom->track[i].length - *outStartFrame; | |
102 nextTrackFrame = cdrom->track[i+1].offset; | |
103 nextTrackFramesRemaining = length; | |
104 } | |
105 | |
106 return &tracks[cdrom->id][i]; | |
107 } | |
108 | |
109 /* Setup another file for playback, or stop playback (called from another thread) */ | |
110 static void CompletionProc (SDL_CD *cdrom) | |
111 { | |
112 | |
113 Lock (); | |
114 | |
115 if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) { | |
116 | |
117 /* Load the next file to play */ | |
118 int startFrame, stopFrame; | |
119 FSRef *file; | |
120 | |
121 PauseFile (); | |
122 ReleaseFile (); | |
123 | |
124 file = GetFileForOffset (cdrom, nextTrackFrame, | |
125 nextTrackFramesRemaining, &startFrame, &stopFrame); | |
126 | |
127 if (file == NULL) { | |
128 status = CD_STOPPED; | |
129 Unlock (); | |
130 return; | |
131 } | |
132 | |
133 LoadFile (file, startFrame, stopFrame); | |
134 | |
135 SetCompletionProc (CompletionProc, cdrom); | |
136 | |
137 PlayFile (); | |
138 } | |
139 else { | |
140 | |
141 /* Release the current file */ | |
142 PauseFile (); | |
143 ReleaseFile (); | |
144 status = CD_STOPPED; | |
145 } | |
146 | |
147 Unlock (); | |
148 } | |
149 | |
150 | |
151 #pragma mark -- Driver Functions -- | |
152 | |
153 /* Initialize */ | |
154 int SDL_SYS_CDInit (void) | |
155 { | |
156 /* Initialize globals */ | |
157 volumes = NULL; | |
158 tracks = NULL; | |
159 status = CD_STOPPED; | |
160 nextTrackFrame = -1; | |
161 nextTrackFramesRemaining = -1; | |
162 fakeCD = SDL_FALSE; | |
163 currentTrack = -1; | |
164 didReadTOC = SDL_FALSE; | |
165 cacheTOCNumTracks = -1; | |
166 currentDrive = -1; | |
167 | |
168 /* Fill in function pointers */ | |
169 SDL_CDcaps.Name = SDL_SYS_CDName; | |
170 SDL_CDcaps.Open = SDL_SYS_CDOpen; | |
171 SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; | |
172 SDL_CDcaps.Status = SDL_SYS_CDStatus; | |
173 SDL_CDcaps.Play = SDL_SYS_CDPlay; | |
174 SDL_CDcaps.Pause = SDL_SYS_CDPause; | |
175 SDL_CDcaps.Resume = SDL_SYS_CDResume; | |
176 SDL_CDcaps.Stop = SDL_SYS_CDStop; | |
177 SDL_CDcaps.Eject = SDL_SYS_CDEject; | |
178 SDL_CDcaps.Close = SDL_SYS_CDClose; | |
179 | |
180 /* | |
181 Read the list of "drives" | |
182 | |
183 This is currently a hack that infers drives from | |
184 mounted audio CD volumes, rather than | |
185 actual CD-ROM devices - which means it may not | |
186 act as expected sometimes. | |
187 */ | |
188 | |
189 /* Find out how many cd volumes are mounted */ | |
190 SDL_numcds = DetectAudioCDVolumes (NULL, 0); | |
191 | |
192 /* | |
193 If there are no volumes, fake a cd device | |
194 so tray empty can be reported. | |
195 */ | |
196 if (SDL_numcds == 0) { | |
197 | |
198 fakeCD = SDL_TRUE; | |
199 SDL_numcds = 1; | |
200 status = CD_TRAYEMPTY; | |
201 | |
202 return 0; | |
203 } | |
204 | |
205 /* Allocate space for volumes */ | |
206 volumes = (FSVolumeRefNum*) calloc (1, sizeof(*volumes) * SDL_numcds); | |
207 if (volumes == NULL) { | |
208 SDL_OutOfMemory (); | |
209 return -1; | |
210 } | |
211 | |
212 /* Allocate space for tracks */ | |
213 tracks = (FSRef**) calloc (1, sizeof(*tracks) * (SDL_numcds + 1)); | |
214 if (tracks == NULL) { | |
215 SDL_OutOfMemory (); | |
216 return -1; | |
217 } | |
218 | |
219 /* Mark the end of the tracks array */ | |
220 tracks[ SDL_numcds ] = (FSRef*)-1; | |
221 | |
222 /* | |
223 Redetect, now save all volumes for later | |
224 Update SDL_numcds just in case it changed | |
225 */ | |
226 { | |
227 int numVolumes = SDL_numcds; | |
228 | |
229 SDL_numcds = DetectAudioCDVolumes (volumes, numVolumes); | |
230 | |
231 /* If more cds suddenly show up, ignore them */ | |
232 if (SDL_numcds > numVolumes) { | |
233 SDL_SetError ("Some CD's were added but they will be ignored"); | |
234 SDL_numcds = numVolumes; | |
235 } | |
236 } | |
237 | |
238 return 0; | |
239 } | |
240 | |
241 /* Shutdown and cleanup */ | |
242 void SDL_SYS_CDQuit(void) | |
243 { | |
244 ReleaseFile(); | |
245 | |
246 if (volumes != NULL) | |
247 free (volumes); | |
248 | |
249 if (tracks != NULL) { | |
250 | |
251 FSRef **ptr; | |
252 for (ptr = tracks; *ptr != (FSRef*)-1; ptr++) | |
253 if (*ptr != NULL) | |
254 free (*ptr); | |
255 | |
256 free (tracks); | |
257 } | |
258 } | |
259 | |
260 /* Get the Unix disk name of the volume */ | |
261 static const char *SDL_SYS_CDName (int drive) | |
262 { | |
263 OSStatus 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
|
264 HParamBlockRec pb; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
265 GetVolParmsInfoBuffer volParmsInfo; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
266 |
616 | 267 if (fakeCD) |
268 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
|
269 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
270 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
|
271 pb.ioParam.ioVRefNum = volumes[drive]; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
272 pb.ioParam.ioBuffer = (Ptr)&volParmsInfo; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
273 pb.ioParam.ioReqCount = (SInt32)sizeof(volParmsInfo); |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
274 err = PBHGetVolParmsSync(&pb); |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
275 |
616 | 276 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
|
277 SDL_SetError ("PBHGetVolParmsSync returned %d", err); |
616 | 278 return NULL; |
279 } | |
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
|
280 |
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 return volParmsInfo.vMDeviceID; |
616 | 282 } |
283 | |
284 /* Open the "device" */ | |
285 static int SDL_SYS_CDOpen (int drive) | |
286 { | |
287 /* Only allow 1 device to be open */ | |
288 if (currentDrive >= 0) { | |
289 SDL_SetError ("Only one cdrom is supported"); | |
290 return -1; | |
291 } | |
292 else | |
293 currentDrive = drive; | |
294 | |
295 return drive; | |
296 } | |
297 | |
298 /* Get the table of contents */ | |
299 static int SDL_SYS_CDGetTOC (SDL_CD *cdrom) | |
300 { | |
301 if (fakeCD) { | |
302 SDL_SetError (kErrorFakeDevice); | |
303 return -1; | |
304 } | |
305 | |
306 if (didReadTOC) { | |
307 cdrom->numtracks = cacheTOCNumTracks; | |
308 return 0; | |
309 } | |
310 | |
311 | |
312 ReadTOCData (volumes[cdrom->id], cdrom); | |
313 didReadTOC = SDL_TRUE; | |
314 cacheTOCNumTracks = cdrom->numtracks; | |
315 | |
316 return 0; | |
317 } | |
318 | |
319 /* Get CD-ROM status */ | |
320 static CDstatus SDL_SYS_CDStatus (SDL_CD *cdrom, int *position) | |
321 { | |
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
|
322 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
|
323 int 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
|
324 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
325 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
|
326 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
|
327 Unlock (); |
616 | 328 |
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
|
329 *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
|
330 } |
616 | 331 |
332 return status; | |
333 } | |
334 | |
335 /* Start playback */ | |
336 static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) | |
337 { | |
338 int startFrame, stopFrame; | |
339 FSRef *ref; | |
340 | |
341 if (fakeCD) { | |
342 SDL_SetError (kErrorFakeDevice); | |
343 return -1; | |
344 } | |
345 | |
346 Lock(); | |
347 | |
348 if (LoadTracks (cdrom) < 0) | |
349 return -2; | |
350 | |
351 if (PauseFile () < 0) | |
352 return -3; | |
353 | |
354 if (ReleaseFile () < 0) | |
355 return -4; | |
356 | |
357 ref = GetFileForOffset (cdrom, start, length, &startFrame, &stopFrame); | |
358 if (ref == NULL) { | |
359 SDL_SetError ("SDL_SYS_CDPlay: No file for start=%d, length=%d", start, length); | |
360 return -5; | |
361 } | |
362 | |
363 if (LoadFile (ref, startFrame, stopFrame) < 0) | |
364 return -6; | |
365 | |
366 SetCompletionProc (CompletionProc, cdrom); | |
367 | |
368 if (PlayFile () < 0) | |
369 return -7; | |
370 | |
371 status = CD_PLAYING; | |
372 | |
373 Unlock(); | |
374 | |
375 return 0; | |
376 } | |
377 | |
378 /* Pause playback */ | |
379 static int SDL_SYS_CDPause(SDL_CD *cdrom) | |
380 { | |
381 if (fakeCD) { | |
382 SDL_SetError (kErrorFakeDevice); | |
383 return -1; | |
384 } | |
385 | |
386 Lock (); | |
387 | |
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
|
388 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
|
389 Unlock (); |
616 | 390 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
|
391 } |
616 | 392 |
393 status = CD_PAUSED; | |
394 | |
395 Unlock (); | |
396 | |
397 return 0; | |
398 } | |
399 | |
400 /* Resume playback */ | |
401 static int SDL_SYS_CDResume(SDL_CD *cdrom) | |
402 { | |
403 if (fakeCD) { | |
404 SDL_SetError (kErrorFakeDevice); | |
405 return -1; | |
406 } | |
407 | |
408 Lock (); | |
409 | |
1126
d581fe3f36db
Fix for bug reported by Michael Benfield on the SDL mailing list:
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
410 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
|
411 Unlock (); |
616 | 412 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
|
413 } |
616 | 414 |
415 status = CD_PLAYING; | |
416 | |
417 Unlock (); | |
418 | |
419 return 0; | |
420 } | |
421 | |
422 /* Stop playback */ | |
423 static int SDL_SYS_CDStop(SDL_CD *cdrom) | |
424 { | |
425 if (fakeCD) { | |
426 SDL_SetError (kErrorFakeDevice); | |
427 return -1; | |
428 } | |
429 | |
430 Lock (); | |
431 | |
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
|
432 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
|
433 Unlock (); |
616 | 434 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
|
435 } |
616 | 436 |
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
|
437 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
|
438 Unlock (); |
616 | 439 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
|
440 } |
616 | 441 |
442 status = CD_STOPPED; | |
443 | |
444 Unlock (); | |
445 | |
446 return 0; | |
447 } | |
448 | |
449 /* Eject the CD-ROM (Unmount the volume) */ | |
450 static int SDL_SYS_CDEject(SDL_CD *cdrom) | |
451 { | |
452 OSStatus err; | |
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
|
453 HParamBlockRec pb; |
616 | 454 |
455 if (fakeCD) { | |
456 SDL_SetError (kErrorFakeDevice); | |
457 return -1; | |
458 } | |
459 | |
460 Lock (); | |
461 | |
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
|
462 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
|
463 Unlock (); |
616 | 464 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
|
465 } |
616 | 466 |
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
|
467 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
|
468 Unlock (); |
616 | 469 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
|
470 } |
616 | 471 |
472 status = CD_STOPPED; | |
473 | |
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
|
474 // Eject the volume |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
475 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
|
476 pb.ioParam.ioVRefNum = volumes[cdrom->id]; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
477 err = PBUnmountVol((ParamBlockRec *) &pb); |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
478 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
479 if (err != noErr) { |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
480 Unlock (); |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
616
diff
changeset
|
481 SDL_SetError ("PBUnmountVol returned %d", err); |
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 return -4; |
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 } |
616 | 484 |
485 status = CD_TRAYEMPTY; | |
486 | |
487 /* Invalidate volume and track info */ | |
488 volumes[cdrom->id] = 0; | |
489 free (tracks[cdrom->id]); | |
490 tracks[cdrom->id] = NULL; | |
491 | |
492 Unlock (); | |
493 | |
494 return 0; | |
495 } | |
496 | |
497 /* Close the CD-ROM */ | |
498 static void SDL_SYS_CDClose(SDL_CD *cdrom) | |
499 { | |
500 currentDrive = -1; | |
501 return; | |
502 } | |
503 |