Mercurial > sdl-ios-xcode
annotate src/cdrom/macosx/CDPlayer.cpp @ 626:b98f732b4322
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 29 May 2003 04:23:03 +0000 |
parents | 9c6717a1c66f |
children | de1b2c3063b9 |
rev | line source |
---|---|
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #include "CDPlayer.h" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "AudioFilePlayer.h" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "CAGuard.h" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 // we're exporting these functions into C land for SDL_syscdrom.c |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 extern "C" { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 // Constants |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #define kAudioCDFilesystemID (UInt16)(('J' << 8) | 'H') // 'JH'; this avoids compiler warning |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 // XML PList keys |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #define kRawTOCDataString "Format 0x02 TOC Data" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #define kSessionsString "Sessions" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #define kSessionTypeString "Session Type" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 #define kTrackArrayString "Track Array" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 #define kFirstTrackInSessionString "First Track" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 #define kLastTrackInSessionString "Last Track" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 #define kLeadoutBlockString "Leadout Block" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 #define kDataKeyString "Data" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 #define kPointKeyString "Point" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 #define kSessionNumberKeyString "Session Number" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 #define kStartBlockKeyString "Start Block" |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 // Globals |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 #pragma mark -- Globals -- |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 static bool playBackWasInit = false; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 static AudioUnit theUnit; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 static AudioFilePlayer* thePlayer = NULL; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 static CDPlayerCompletionProc completionProc = NULL; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 static pthread_mutex_t apiMutex; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 static pthread_t callbackThread; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 static pthread_mutex_t callbackMutex; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 static volatile int runCallBackThread; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 static int initMutex = SDL_TRUE; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 static SDL_CD* theCDROM; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 // Prototypes |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 #pragma mark -- Prototypes -- |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 OSStatus CheckInit (); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 OSStatus MatchAUFormats (AudioUnit theUnit, UInt32 theInputBus); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 void FilePlayNotificationHandler (void* inRefCon, OSStatus inStatus); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 void* RunCallBackThread (void* inRefCon); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 #pragma mark -- Public Functions -- |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 void Lock () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 if (initMutex) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 pthread_mutexattr_t attr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 pthread_mutexattr_init (&attr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 pthread_mutex_init (&apiMutex, &attr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 pthread_mutexattr_destroy (&attr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 initMutex = SDL_FALSE; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 pthread_mutex_lock (&apiMutex); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 void Unlock () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 pthread_mutex_unlock (&apiMutex); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 // DetectAudioCDVolumes |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 int volumeIndex; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 int cdVolumeCount = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 OSStatus result = noErr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 for (volumeIndex = 1; result == noErr || result != nsvErr; volumeIndex++) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 FSVolumeRefNum actualVolume; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 HFSUniStr255 volumeName; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 FSVolumeInfo volumeInfo; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 FSRef rootDirectory; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 memset (&volumeInfo, 0, sizeof(volumeInfo)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 result = FSGetVolumeInfo (kFSInvalidVolumeRefNum, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 volumeIndex, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 &actualVolume, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 kFSVolInfoFSInfo, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 &volumeInfo, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 &volumeName, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 &rootDirectory); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 if (result == noErr) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 if (volumeInfo.filesystemID == kAudioCDFilesystemID) // It's an audio CD |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 if (volumes != NULL && cdVolumeCount < numVolumes) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 volumes[cdVolumeCount] = actualVolume; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 cdVolumeCount++; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 else |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 // I'm commenting this out because it seems to be harmless |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 //SDL_SetError ("DetectAudioCDVolumes: FSGetVolumeInfo returned %d", result); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 return cdVolumeCount; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 // ReadTOCData |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 HFSUniStr255 dataForkName; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 OSStatus theErr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 SInt16 forkRefNum; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 SInt64 forkSize; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 Ptr forkData = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 ByteCount actualRead; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 CFDataRef dataRef = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 CFPropertyListRef propertyListRef = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 FSRefParam fsRefPB; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 FSRef tocPlistFSRef; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 const char* error = "Unspecified Error"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 // get stuff from .TOC.plist |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 fsRefPB.ioCompletion = NULL; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 fsRefPB.ioNamePtr = "\p.TOC.plist"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 fsRefPB.ioVRefNum = theVolume; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 fsRefPB.ioDirID = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 fsRefPB.newRef = &tocPlistFSRef; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 theErr = PBMakeFSRefSync (&fsRefPB); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 if(theErr != noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 error = "PBMakeFSRefSync"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 // Load and parse the TOC XML data |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 theErr = FSGetDataForkName (&dataForkName); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 if (theErr != noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 error = "FSGetDataForkName"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 theErr = FSOpenFork (&tocPlistFSRef, dataForkName.length, dataForkName.unicode, fsRdPerm, &forkRefNum); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 if (theErr != noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 error = "FSOpenFork"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 theErr = FSGetForkSize (forkRefNum, &forkSize); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 if (theErr != noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 error = "FSGetForkSize"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 // Allocate some memory for the XML data |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 forkData = NewPtr (forkSize); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 if(forkData == NULL) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 error = "NewPtr"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 theErr = FSReadFork (forkRefNum, fsFromStart, 0 /* offset location */, forkSize, forkData, &actualRead); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 if(theErr != noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 error = "FSReadFork"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 dataRef = CFDataCreate (kCFAllocatorDefault, (UInt8 *)forkData, forkSize); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 if(dataRef == 0) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 error = "CFDataCreate"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 propertyListRef = CFPropertyListCreateFromXMLData (kCFAllocatorDefault, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 dataRef, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 kCFPropertyListImmutable, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 NULL); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 if (propertyListRef == NULL) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 error = "CFPropertyListCreateFromXMLData"; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 // Now we got the Property List in memory. Parse it. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 // First, make sure the root item is a CFDictionary. If not, release and bail. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 if(CFGetTypeID(propertyListRef)== CFDictionaryGetTypeID()) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 CFDictionaryRef dictRef = (CFDictionaryRef)propertyListRef; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 CFDataRef theRawTOCDataRef; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 CFArrayRef theSessionArrayRef; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 CFIndex numSessions; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 CFIndex index; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 // This is how we get the Raw TOC Data |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 theRawTOCDataRef = (CFDataRef)CFDictionaryGetValue (dictRef, CFSTR(kRawTOCDataString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 // Get the session array info. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 theSessionArrayRef = (CFArrayRef)CFDictionaryGetValue (dictRef, CFSTR(kSessionsString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 // Find out how many sessions there are. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 numSessions = CFArrayGetCount (theSessionArrayRef); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 // Initialize the total number of tracks to 0 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 theCD->numtracks = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 // Iterate over all sessions, collecting the track data |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 for(index = 0; index < numSessions; index++) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 CFDictionaryRef theSessionDict; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 CFNumberRef leadoutBlock; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 CFArrayRef trackArray; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 CFIndex numTracks; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 CFIndex trackIndex; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 UInt32 value = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 theSessionDict = (CFDictionaryRef) CFArrayGetValueAtIndex (theSessionArrayRef, index); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 leadoutBlock = (CFNumberRef) CFDictionaryGetValue (theSessionDict, CFSTR(kLeadoutBlockString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 trackArray = (CFArrayRef)CFDictionaryGetValue (theSessionDict, CFSTR(kTrackArrayString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 numTracks = CFArrayGetCount (trackArray); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 for(trackIndex = 0; trackIndex < numTracks; trackIndex++) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 CFDictionaryRef theTrackDict; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 CFNumberRef trackNumber; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 CFNumberRef sessionNumber; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 CFNumberRef startBlock; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 CFBooleanRef isDataTrack; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 UInt32 value; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 theTrackDict = (CFDictionaryRef) CFArrayGetValueAtIndex (trackArray, trackIndex); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 trackNumber = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kPointKeyString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 sessionNumber = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kSessionNumberKeyString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 startBlock = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kStartBlockKeyString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 isDataTrack = (CFBooleanRef) CFDictionaryGetValue (theTrackDict, CFSTR(kDataKeyString)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 // Fill in the SDL_CD struct |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 int idx = theCD->numtracks++; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 CFNumberGetValue (trackNumber, kCFNumberSInt32Type, &value); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 theCD->track[idx].id = value; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 CFNumberGetValue (startBlock, kCFNumberSInt32Type, &value); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 theCD->track[idx].offset = value; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 theCD->track[idx].type = (isDataTrack == kCFBooleanTrue) ? SDL_DATA_TRACK : SDL_AUDIO_TRACK; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 // Since the track lengths are not stored in .TOC.plist we compute them. |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 if (trackIndex > 0) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 theCD->track[idx-1].length = theCD->track[idx].offset - theCD->track[idx-1].offset; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 // Compute the length of the last track |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 CFNumberGetValue (leadoutBlock, kCFNumberSInt32Type, &value); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 theCD->track[theCD->numtracks-1].length = |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 value - theCD->track[theCD->numtracks-1].offset; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 // Set offset to leadout track |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 theCD->track[theCD->numtracks].offset = value; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 theErr = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 goto cleanup; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 bail: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 SDL_SetError ("ReadTOCData: %s returned %d", error, theErr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 theErr = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 cleanup: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 if (propertyListRef != NULL) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 CFRelease(propertyListRef); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 if (dataRef != NULL) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 CFRelease(dataRef); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 if (forkData != NULL) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 DisposePtr(forkData); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 FSCloseFork (forkRefNum); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 return theErr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 // ListTrackFiles |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 int ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 OSStatus result = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 FSIterator iterator; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 ItemCount actualObjects; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 FSRef rootDirectory; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 FSRef ref; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 HFSUniStr255 nameStr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 result = FSGetVolumeInfo (theVolume, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 0, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 NULL, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 kFSVolInfoFSInfo, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 NULL, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 NULL, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 &rootDirectory); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 if (result != noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 SDL_SetError ("ListTrackFiles: FSGetVolumeInfo returned %d", result); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 result = FSOpenIterator (&rootDirectory, kFSIterateFlat, &iterator); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 if (result == noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 do |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 result = FSGetCatalogInfoBulk (iterator, 1, &actualObjects, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 NULL, kFSCatInfoNone, NULL, &ref, NULL, &nameStr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 if (result == noErr) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 CFStringRef name; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 name = CFStringCreateWithCharacters (NULL, nameStr.unicode, nameStr.length); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 // Look for .aiff extension |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 if (CFStringHasSuffix (name, CFSTR(".aiff"))) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 // Extract the track id from the filename |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 int trackID = 0, i = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 while (nameStr.unicode[i] >= '0' && nameStr.unicode[i] <= '9') { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 trackID = 10 * trackID +(nameStr.unicode[i] - '0'); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 i++; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 #if DEBUG_CDROM |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 printf("Found AIFF for track %d: '%s'\n", trackID, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 CFStringGetCStringPtr (name, CFStringGetSystemEncoding())); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 // Track ID's start at 1, but we want to start at 0 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 trackID--; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 assert(0 <= trackID && trackID <= SDL_MAX_TRACKS); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 if (trackID < numTracks) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 memcpy (&trackFiles[trackID], &ref, sizeof(FSRef)); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 CFRelease (name); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 } while(noErr == result); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 FSCloseIterator (iterator); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 result = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 bail: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 return result; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 // LoadFile |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 int LoadFile (const FSRef *ref, int startFrame, int stopFrame) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 int error = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 if (CheckInit () < 0) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 // release any currently playing file |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 if (ReleaseFile () < 0) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 #if DEBUG_CDROM |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 printf ("LoadFile: %d %d\n", startFrame, stopFrame); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 try { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 // create a new player, and attach to the audio unit |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 thePlayer = new AudioFilePlayer(ref); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 if (thePlayer == NULL) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 SDL_SetError ("LoadFile: Could not create player"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 throw (-3); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 thePlayer->SetDestination(theUnit, 0); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 if (startFrame >= 0) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 thePlayer->SetStartFrame (startFrame); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 if (stopFrame >= 0 && stopFrame > startFrame) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 thePlayer->SetStopFrame (stopFrame); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 // we set the notifier later |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 //thePlayer->SetNotifier(FilePlayNotificationHandler, NULL); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 thePlayer->Connect(); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 #if DEBUG_CDROM |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 thePlayer->Print(); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 fflush (stdout); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 catch (...) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 error = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 bail: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 return error; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 // ReleaseFile |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 int ReleaseFile () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 int error = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 try { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 if (thePlayer != NULL) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 thePlayer->Disconnect(); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 delete thePlayer; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 thePlayer = NULL; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 catch (...) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 error = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 bail: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 return error; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 // PlayFile |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 int PlayFile () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 OSStatus result = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 if (CheckInit () < 0) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 try { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 // start processing of the audio unit |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 result = AudioOutputUnitStart (theUnit); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 THROW_RESULT("PlayFile: AudioOutputUnitStart") |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 catch (...) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 result = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 bail: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 return result; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 // PauseFile |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 int PauseFile () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 OSStatus result = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 if (CheckInit () < 0) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 try { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 // stop processing the audio unit |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 result = AudioOutputUnitStop (theUnit); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 THROW_RESULT("PauseFile: AudioOutputUnitStop") |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 catch (...) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 goto bail; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 result = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 bail: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 return result; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 // SetCompletionProc |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 //ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 void SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD *cdrom) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 assert(thePlayer != NULL); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 theCDROM = cdrom; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 completionProc = proc; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 thePlayer->SetNotifier (FilePlayNotificationHandler, cdrom); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 int GetCurrentFrame () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
566 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
567 int frame; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 if (thePlayer == NULL) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 frame = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 else |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 frame = thePlayer->GetCurrentFrame (); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 return frame; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 #pragma mark -- Private Functions -- |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 OSStatus CheckInit () |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 if (playBackWasInit) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 return 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 OSStatus result = noErr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 // Create the callback mutex |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 pthread_mutexattr_t attr; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 pthread_mutexattr_init (&attr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 pthread_mutex_init (&callbackMutex, &attr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 pthread_mutexattr_destroy (&attr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 pthread_mutex_lock (&callbackMutex); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 // Start callback thread |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 pthread_attr_t attr1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 pthread_attr_init (&attr1); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 pthread_create (&callbackThread, &attr1, RunCallBackThread, NULL); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 pthread_attr_destroy (&attr1); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 try { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 ComponentDescription desc; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 desc.componentType = kAudioUnitComponentType; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 desc.componentSubType = kAudioUnitSubType_Output; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 desc.componentManufacturer = kAudioUnitID_DefaultOutput; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 desc.componentFlags = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 desc.componentFlagsMask = 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 Component comp = FindNextComponent (NULL, &desc); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 if (comp == NULL) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 SDL_SetError ("CheckInit: FindNextComponent returned NULL"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 throw(internalComponentErr); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 result = OpenAComponent (comp, &theUnit); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 THROW_RESULT("CheckInit: OpenAComponent") |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 // you need to initialize the output unit before you set it as a destination |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 result = AudioUnitInitialize (theUnit); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 THROW_RESULT("CheckInit: AudioUnitInitialize") |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 // In this case we first want to get the output format of the OutputUnit |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 // Then we set that as the input format. Why? |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 // So that only a single conversion process is done |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 // when SetDestination is called it will get the input format of the |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 // unit its supplying data to. This defaults to 44.1K, stereo, so if |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 // the device is not that, then we lose a possibly rendering of data |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 result = MatchAUFormats (theUnit, 0); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 THROW_RESULT("CheckInit: MatchAUFormats") |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 playBackWasInit = true; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 catch (...) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 return -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 return 0; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 OSStatus MatchAUFormats (AudioUnit theUnit, UInt32 theInputBus) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 AudioStreamBasicDescription theDesc; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 UInt32 size = sizeof (theDesc); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 OSStatus result = AudioUnitGetProperty (theUnit, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 kAudioUnitProperty_StreamFormat, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 kAudioUnitScope_Output, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 0, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 &theDesc, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 &size); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 THROW_RESULT("MatchAUFormats: AudioUnitGetProperty") |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
657 result = AudioUnitSetProperty (theUnit, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 kAudioUnitProperty_StreamFormat, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 kAudioUnitScope_Input, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
660 theInputBus, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
661 &theDesc, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 size); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 return result; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 void FilePlayNotificationHandler(void * inRefCon, OSStatus inStatus) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 if (inStatus == kAudioFilePlay_FileIsFinished) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 // notify non-CA thread to perform the callback |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 pthread_mutex_unlock (&callbackMutex); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 } else if (inStatus == kAudioFilePlayErr_FilePlayUnderrun) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 SDL_SetError ("CDPlayer Notification: buffer underrun"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 } else if (inStatus == kAudioFilePlay_PlayerIsUninitialized) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
679 SDL_SetError ("CDPlayer Notification: player is uninitialized"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 } else { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 SDL_SetError ("CDPlayer Notification: unknown error %ld", inStatus); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 void* RunCallBackThread (void *param) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
687 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 runCallBackThread = 1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 while (runCallBackThread) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 pthread_mutex_lock (&callbackMutex); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
693 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
694 if (completionProc && theCDROM) { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 #if DEBUG_CDROM |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
696 printf ("callback!\n"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
697 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 (*completionProc)(theCDROM); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
699 } else { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
700 #if DEBUG_CDROM |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 printf ("callback?\n"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
702 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 runCallBackThread = -1; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 #if DEBUG_CDROM |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 printf ("thread dying now...\n"); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
712 return NULL; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
713 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 }; // extern "C" |