Mercurial > sdl-ios-xcode
annotate src/cdrom/macosx/AudioFilePlayer.h @ 769:b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2004 16:49:27 +0000 |
parents | de1b2c3063b9 |
children | f8d5ddc7aef1 |
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 |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
768
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
613
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 This file based on Apple sample code. We haven't changed the file name, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 so if you want to see the original search for it on apple.com/developer |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 */ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
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 // AudioFilePlayer.h |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 // |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #ifndef __AudioFilePlayer_H__ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #define __AudioFilePlayer_H__ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include <CoreServices/CoreServices.h> |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
34 #include <AudioToolbox/AudioConverter.h> |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include <AudioUnit/AudioUnit.h> |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
653
1bd056de5d1b
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
613
diff
changeset
|
37 #include "SDL_error.h" |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 const char* AudioFilePlayerErrorStr (OSStatus error); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 void ThrowResult (OSStatus result, const char *str); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 #define THROW_RESULT(str) \ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 if (result) { \ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 ThrowResult (result, str); \ |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 typedef void (*AudioFilePlayNotifier)(void *inRefCon, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 OSStatus inStatus); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 enum { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 kAudioFilePlayErr_FilePlayUnderrun = -10000, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 kAudioFilePlay_FileIsFinished = -10001, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 kAudioFilePlay_PlayerIsUninitialized = -10002 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 }; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 class AudioFileManager; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 #pragma mark __________ AudioFilePlayer |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 class AudioFilePlayer |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 public: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 AudioFilePlayer (const FSRef *inFileRef); |
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 ~AudioFilePlayer(); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 void SetDestination (AudioUnit &inDestUnit, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 int inBusNumber); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 void SetNotifier (AudioFilePlayNotifier inNotifier, void *inRefCon) |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 mNotifier = inNotifier; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 mRefCon = inRefCon; |
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 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 void SetStartFrame (int frame); // seek in the file |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 int GetCurrentFrame (); // get the current frame position |
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 void SetStopFrame (int frame); // set limit in the file |
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 Connect(); |
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 void Disconnect(); |
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 void DoNotification (OSStatus inError) const; |
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 bool IsConnected () const { return mConnected; } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 UInt32 GetBusNumber () const { return mBusNumber; } |
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 AudioUnit GetDestUnit () const { return mPlayUnit; } |
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 AudioConverterRef GetAudioConverter() const { return mConverter; } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 #if DEBUG |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 void Print() const |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 { |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 printf ("Destination Bus:%ld\n", GetBusNumber()); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 printf ("Is Connected:%s\n", (IsConnected() ? "true" : "false")); |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
102 printf ("- - - - - - - - - - - - - - \n"); |
613
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 #endif |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 const AudioStreamBasicDescription& GetFileFormat() const { return mFileDescription; } |
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 private: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 AudioUnit mPlayUnit; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 UInt32 mBusNumber; |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
111 SInt16 mForkRefNum; |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 AudioUnitInputCallback mInputCallback; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 AudioStreamBasicDescription mFileDescription; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 bool mConnected; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 AudioFileManager* mAudioFileManager; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 AudioConverterRef mConverter; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 AudioFilePlayNotifier mNotifier; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 void* mRefCon; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 int mStartFrame; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 #pragma mark __________ Private_Methods |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 void OpenFile (const FSRef *inRef, SInt64& outFileSize); |
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 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 #pragma mark __________ AudioFileManager |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 class AudioFileManager |
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 public: |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
136 AudioFileManager (AudioFilePlayer &inParent, |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
137 SInt16 inForkRefNum, |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
138 SInt64 inFileLength, |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
139 UInt32 inChunkSize); |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
141 ~AudioFileManager(); |
613
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 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 void Connect (AudioConverterRef inConverter) |
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 mParentConverter = inConverter; |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 DoConnect(); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 } |
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 // this method should NOT be called by an object of this class |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 // as it is called by the parent's Disconnect() method |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
152 void Disconnect (); |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
154 OSStatus Read(char *buffer, UInt32 *len); |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 const char* GetFileBuffer () { return mFileBuffer; } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 const AudioFilePlayer& GetParent () const { return mParent; } |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
160 void SetPosition (SInt64 pos); // seek/rewind in the file |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
162 int GetByteCounter () { return mByteCounter; } // return actual bytes streamed to audio hardware |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
164 void SetEndOfFile (SInt64 pos); // set the "EOF" (will behave just like it reached eof) |
613
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 protected: |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
167 AudioFilePlayer& mParent; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
168 AudioConverterRef mParentConverter; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
169 SInt16 mForkRefNum; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
170 SInt64 mAudioDataOffset; |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
172 char* mFileBuffer; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
173 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
174 int mByteCounter; |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
176 bool mReadFromFirstBuffer; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
177 bool mLockUnsuccessful; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
178 bool mIsEngaged; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
179 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
180 int mNumTimesAskedSinceFinished; |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
182 public: |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
183 const UInt32 mChunkSize; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
184 SInt64 mFileLength; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
185 SInt64 mReadFilePosition; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
186 bool mWriteToFirstBuffer; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
187 bool mFinishedReadingData; |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
188 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
189 protected: |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
190 OSStatus Render (AudioBuffer &ioData); |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
192 OSStatus GetFileData (void** inOutData, UInt32 *inOutDataSize); |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
193 |
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
194 void DoConnect (); |
613
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
768
de1b2c3063b9
Max has been reworking this code so it works on MacOS X 10.1
Sam Lantinga <slouken@libsdl.org>
parents:
653
diff
changeset
|
196 void AfterRender (); |
613
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 public: |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 static OSStatus FileInputProc (void *inRefCon, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 AudioUnitRenderActionFlags inActionFlags, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 const AudioTimeStamp *inTimeStamp, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 UInt32 inBusNumber, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 AudioBuffer *ioData); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 static OSStatus ACInputProc (AudioConverterRef inAudioConverter, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 UInt32* outDataSize, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 void** outData, |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 void* inUserData); |
9c6717a1c66f
Added MacOS X CD-ROM audio support (thanks Max and Darrell)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 }; |
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 #endif |