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