26 #import <AudioToolbox/AudioToolbox.h>
27 #import <Foundation/Foundation.h>
33 #pragma mark - AudioBufferList Utilities
48 #define AEAllocateAndInitAudioBufferList AEAudioBufferListCreate // Legacy alias
64 #define AEAudioBufferListCreateOnStack(name, audioFormat) \
65 int name ## _numberBuffers = audioFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved \
66 ? audioFormat.mChannelsPerFrame : 1; \
67 char name ## _bytes[sizeof(AudioBufferList)+(sizeof(AudioBuffer)*(name ## _numberBuffers-1))]; \
68 memset(&name ## _bytes, 0, sizeof(name ## _bytes)); \
69 AudioBufferList * name = (AudioBufferList*)name ## _bytes; \
70 name->mNumberBuffers = name ## _numberBuffers;
87 #define AEAudioBufferListCopyOnStack(name, sourceBufferList, offsetBytes) \
88 char name ## _bytes[sizeof(AudioBufferList)+(sizeof(AudioBuffer)*(sourceBufferList->mNumberBuffers-1))]; \
89 memcpy(name ## _bytes, sourceBufferList, sizeof(name ## _bytes)); \
90 AudioBufferList * name = (AudioBufferList*)name ## _bytes; \
91 for ( int i=0; i<name->mNumberBuffers; i++ ) { \
92 name->mBuffers[i].mData = (char*)name->mBuffers[i].mData + offsetBytes; \
93 name->mBuffers[i].mDataByteSize -= offsetBytes; \
106 #define AECopyAudioBufferList AEAudioBufferListCopy // Legacy alias
115 #define AEFreeAudioBufferList AEAudioBufferListFree // Legacy alias
129 AudioStreamBasicDescription audioFormat,
130 int *oNumberOfChannels);
131 #define AEGetNumberOfFramesInAudioBufferList AEAudioBufferListGetLength // Legacy alias
144 AudioStreamBasicDescription audioFormat,
158 AudioStreamBasicDescription audioFormat,
170 AudioStreamBasicDescription audioFormat,
185 static inline size_t AEAudioBufferListGetStructSize(
const AudioBufferList *bufferList) {
186 return sizeof(AudioBufferList) + (bufferList->mNumberBuffers-1) *
sizeof(AudioBuffer);
190 #pragma mark - AudioStreamBasicDescription Utilities
229 int numberOfChannels,
241 #pragma mark - Time Utilities
277 #pragma mark - Other Utilities
305 #define AECheckOSStatus(result,operation) (_AECheckOSStatus((result),(operation),strrchr(__FILE__, '/')+1,__LINE__))
306 static inline BOOL _AECheckOSStatus(OSStatus result,
const char *operation,
const char* file,
int line) {
307 if ( result != noErr ) {
309 int fourCC = CFSwapInt32HostToBig(result);
310 if ( isascii(((
char*)&fourCC)[0]) && isascii(((
char*)&fourCC)[1]) && isascii(((
char*)&fourCC)[2]) ) {
311 NSLog(
@"%s:%d: %s: '%4.4s' (%d)", file, line, operation, (
char*)&fourCC, (
int)result);
313 NSLog(
@"%s:%d: %s: %d", file, line, operation, (
int)result);