Mercurial > sdl-ios-xcode
comparison src/cdrom/macosx/AudioFilePlayer.h @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | dc6b59e925a2 |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
34 | 34 |
35 #include <AudioUnit/AudioUnit.h> | 35 #include <AudioUnit/AudioUnit.h> |
36 | 36 |
37 #include "SDL_error.h" | 37 #include "SDL_error.h" |
38 | 38 |
39 const char* AudioFilePlayerErrorStr (OSStatus error); | 39 const char *AudioFilePlayerErrorStr (OSStatus error); |
40 | 40 |
41 /* | 41 /* |
42 void ThrowResult (OSStatus result, const char *str); | 42 void ThrowResult (OSStatus result, const char *str); |
43 | 43 |
44 #define THROW_RESULT(str) \ | 44 #define THROW_RESULT(str) \ |
45 if (result) { \ | 45 if (result) { \ |
46 ThrowResult (result, str); \ | 46 ThrowResult (result, str); \ |
47 } | 47 } |
48 */ | 48 */ |
49 | 49 |
50 typedef void (*AudioFilePlayNotifier)(void *inRefCon, | 50 typedef void (*AudioFilePlayNotifier) (void *inRefCon, OSStatus inStatus); |
51 OSStatus inStatus); | |
52 | 51 |
53 enum { | 52 enum |
53 { | |
54 kAudioFilePlayErr_FilePlayUnderrun = -10000, | 54 kAudioFilePlayErr_FilePlayUnderrun = -10000, |
55 kAudioFilePlay_FileIsFinished = -10001, | 55 kAudioFilePlay_FileIsFinished = -10001, |
56 kAudioFilePlay_PlayerIsUninitialized = -10002 | 56 kAudioFilePlay_PlayerIsUninitialized = -10002 |
57 }; | 57 }; |
58 | 58 |
61 | 61 |
62 #pragma mark __________ AudioFilePlayer | 62 #pragma mark __________ AudioFilePlayer |
63 typedef struct S_AudioFilePlayer | 63 typedef struct S_AudioFilePlayer |
64 { | 64 { |
65 /*public:*/ | 65 /*public:*/ |
66 int (*SetDestination)(struct S_AudioFilePlayer *afp, AudioUnit *inDestUnit); | 66 int (*SetDestination) (struct S_AudioFilePlayer * afp, |
67 void (*SetNotifier)(struct S_AudioFilePlayer *afp, AudioFilePlayNotifier inNotifier, void *inRefCon); | 67 AudioUnit * inDestUnit); |
68 void (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); /* seek in the file */ | 68 void (*SetNotifier) (struct S_AudioFilePlayer * afp, |
69 int (*GetCurrentFrame)(struct S_AudioFilePlayer *afp); /* get the current frame position */ | 69 AudioFilePlayNotifier inNotifier, void *inRefCon); |
70 void (*SetStopFrame)(struct S_AudioFilePlayer *afp, int frame); /* set limit in the file */ | 70 void (*SetStartFrame) (struct S_AudioFilePlayer * afp, int frame); /* seek in the file */ |
71 int (*Connect)(struct S_AudioFilePlayer *afp); | 71 int (*GetCurrentFrame) (struct S_AudioFilePlayer * afp); /* get the current frame position */ |
72 void (*Disconnect)(struct S_AudioFilePlayer *afp); | 72 void (*SetStopFrame) (struct S_AudioFilePlayer * afp, int frame); /* set limit in the file */ |
73 void (*DoNotification)(struct S_AudioFilePlayer *afp, OSStatus inError); | 73 int (*Connect) (struct S_AudioFilePlayer * afp); |
74 int (*IsConnected)(struct S_AudioFilePlayer *afp); | 74 void (*Disconnect) (struct S_AudioFilePlayer * afp); |
75 AudioUnit (*GetDestUnit)(struct S_AudioFilePlayer *afp); | 75 void (*DoNotification) (struct S_AudioFilePlayer * afp, OSStatus inError); |
76 void (*Print)(struct S_AudioFilePlayer *afp); | 76 int (*IsConnected) (struct S_AudioFilePlayer * afp); |
77 AudioUnit (*GetDestUnit) (struct S_AudioFilePlayer * afp); | |
78 void (*Print) (struct S_AudioFilePlayer * afp); | |
77 | 79 |
78 /*private:*/ | 80 /*private:*/ |
79 AudioUnit mPlayUnit; | 81 AudioUnit mPlayUnit; |
80 SInt16 mForkRefNum; | 82 SInt16 mForkRefNum; |
81 | |
82 AudioUnitInputCallback mInputCallback; | |
83 | 83 |
84 AudioStreamBasicDescription mFileDescription; | 84 AudioUnitInputCallback mInputCallback; |
85 | 85 |
86 int mConnected; | 86 AudioStreamBasicDescription mFileDescription; |
87 | 87 |
88 struct S_AudioFileManager* mAudioFileManager; | 88 int mConnected; |
89 | 89 |
90 AudioFilePlayNotifier mNotifier; | 90 struct S_AudioFileManager *mAudioFileManager; |
91 void* mRefCon; | 91 |
92 | 92 AudioFilePlayNotifier mNotifier; |
93 int mStartFrame; | 93 void *mRefCon; |
94 | 94 |
95 int mStartFrame; | |
96 | |
95 #pragma mark __________ Private_Methods | 97 #pragma mark __________ Private_Methods |
96 | 98 |
97 int (*OpenFile)(struct S_AudioFilePlayer *afp, const FSRef *inRef, SInt64 *outFileSize); | 99 int (*OpenFile) (struct S_AudioFilePlayer * afp, const FSRef * inRef, |
100 SInt64 * outFileSize); | |
98 } AudioFilePlayer; | 101 } AudioFilePlayer; |
99 | 102 |
100 | 103 |
101 AudioFilePlayer *new_AudioFilePlayer(const FSRef *inFileRef); | 104 AudioFilePlayer *new_AudioFilePlayer (const FSRef * inFileRef); |
102 void delete_AudioFilePlayer(AudioFilePlayer *afp); | 105 void delete_AudioFilePlayer (AudioFilePlayer * afp); |
103 | 106 |
104 | 107 |
105 | 108 |
106 #pragma mark __________ AudioFileManager | 109 #pragma mark __________ AudioFileManager |
107 typedef struct S_AudioFileManager | 110 typedef struct S_AudioFileManager |
108 { | 111 { |
109 /*public:*/ | 112 /*public:*/ |
110 /* this method should NOT be called by an object of this class | 113 /* this method should NOT be called by an object of this class |
111 as it is called by the parent's Disconnect() method */ | 114 as it is called by the parent's Disconnect() method */ |
112 void (*Disconnect)(struct S_AudioFileManager *afm); | 115 void (*Disconnect) (struct S_AudioFileManager * afm); |
113 int (*DoConnect)(struct S_AudioFileManager *afm); | 116 int (*DoConnect) (struct S_AudioFileManager * afm); |
114 OSStatus (*Read)(struct S_AudioFileManager *afm, char *buffer, UInt32 *len); | 117 OSStatus (*Read) (struct S_AudioFileManager * afm, char *buffer, |
115 const char* (*GetFileBuffer)(struct S_AudioFileManager *afm); | 118 UInt32 * len); |
116 const AudioFilePlayer *(*GetParent)(struct S_AudioFileManager *afm); | 119 const char *(*GetFileBuffer) (struct S_AudioFileManager * afm); |
117 void (*SetPosition)(struct S_AudioFileManager *afm, SInt64 pos); /* seek/rewind in the file */ | 120 const AudioFilePlayer *(*GetParent) (struct S_AudioFileManager * afm); |
118 int (*GetByteCounter)(struct S_AudioFileManager *afm); /* return actual bytes streamed to audio hardware */ | 121 void (*SetPosition) (struct S_AudioFileManager * afm, SInt64 pos); /* seek/rewind in the file */ |
119 void (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos); /* set the "EOF" (will behave just like it reached eof) */ | 122 int (*GetByteCounter) (struct S_AudioFileManager * afm); /* return actual bytes streamed to audio hardware */ |
120 | 123 void (*SetEndOfFile) (struct S_AudioFileManager * afm, SInt64 pos); /* set the "EOF" (will behave just like it reached eof) */ |
124 | |
121 /*protected:*/ | 125 /*protected:*/ |
122 AudioFilePlayer* mParent; | 126 AudioFilePlayer *mParent; |
123 SInt16 mForkRefNum; | 127 SInt16 mForkRefNum; |
124 SInt64 mAudioDataOffset; | 128 SInt64 mAudioDataOffset; |
125 | |
126 char* mFileBuffer; | |
127 | 129 |
128 int mByteCounter; | 130 char *mFileBuffer; |
129 | 131 |
130 int mReadFromFirstBuffer; | 132 int mByteCounter; |
131 int mLockUnsuccessful; | 133 |
132 int mIsEngaged; | 134 int mReadFromFirstBuffer; |
133 | 135 int mLockUnsuccessful; |
134 int mNumTimesAskedSinceFinished; | 136 int mIsEngaged; |
137 | |
138 int mNumTimesAskedSinceFinished; | |
135 | 139 |
136 | 140 |
137 void* mTmpBuffer; | 141 void *mTmpBuffer; |
138 UInt32 mBufferSize; | 142 UInt32 mBufferSize; |
139 UInt32 mBufferOffset; | 143 UInt32 mBufferOffset; |
140 /*public:*/ | 144 /*public:*/ |
141 UInt32 mChunkSize; | 145 UInt32 mChunkSize; |
142 SInt64 mFileLength; | 146 SInt64 mFileLength; |
143 SInt64 mReadFilePosition; | 147 SInt64 mReadFilePosition; |
144 int mWriteToFirstBuffer; | 148 int mWriteToFirstBuffer; |
145 int mFinishedReadingData; | 149 int mFinishedReadingData; |
146 | 150 |
147 /*protected:*/ | 151 /*protected:*/ |
148 OSStatus (*Render)(struct S_AudioFileManager *afm, AudioBuffer *ioData); | 152 OSStatus (*Render) (struct S_AudioFileManager * afm, |
149 OSStatus (*GetFileData)(struct S_AudioFileManager *afm, void** inOutData, UInt32 *inOutDataSize); | 153 AudioBuffer * ioData); |
150 void (*AfterRender)(struct S_AudioFileManager *afm); | 154 OSStatus (*GetFileData) (struct S_AudioFileManager * afm, |
155 void **inOutData, UInt32 * inOutDataSize); | |
156 void (*AfterRender) (struct S_AudioFileManager * afm); | |
151 | 157 |
152 /*public:*/ | 158 /*public:*/ |
153 /*static*/ | 159 /*static */ |
154 OSStatus (*FileInputProc)(void *inRefCon, | 160 OSStatus (*FileInputProc) (void *inRefCon, |
155 AudioUnitRenderActionFlags inActionFlags, | 161 AudioUnitRenderActionFlags inActionFlags, |
156 const AudioTimeStamp *inTimeStamp, | 162 const AudioTimeStamp * inTimeStamp, |
157 UInt32 inBusNumber, | 163 UInt32 inBusNumber, AudioBuffer * ioData); |
158 AudioBuffer *ioData); | |
159 } AudioFileManager; | 164 } AudioFileManager; |
160 | 165 |
161 | 166 |
162 AudioFileManager *new_AudioFileManager (AudioFilePlayer *inParent, | 167 AudioFileManager *new_AudioFileManager (AudioFilePlayer * inParent, |
163 SInt16 inForkRefNum, | 168 SInt16 inForkRefNum, |
164 SInt64 inFileLength, | 169 SInt64 inFileLength, |
165 UInt32 inChunkSize); | 170 UInt32 inChunkSize); |
166 | 171 |
167 void delete_AudioFileManager(AudioFileManager *afm); | 172 void delete_AudioFileManager (AudioFileManager * afm); |
168 | 173 |
169 #endif | 174 #endif |
170 | 175 /* vi: set ts=4 sw=4 expandtab: */ |