31 #import <Foundation/Foundation.h>
32 #import <AudioToolbox/AudioToolbox.h>
71 #define AEAudioBufferListCreateOnStack(name) \
72 AEAudioBufferListCreateOnStackWithFormat(name, AEAudioDescription)
88 #define AEAudioBufferListCreateOnStackWithFormat(name, audioFormat) \
89 int name ## _numberBuffers = audioFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved \
90 ? audioFormat.mChannelsPerFrame : 1; \
91 char name ## _bytes[sizeof(AudioBufferList)+(sizeof(AudioBuffer)*(name ## _numberBuffers-1))]; \
92 memset(&name ## _bytes, 0, sizeof(name ## _bytes)); \
93 AudioBufferList * name = (AudioBufferList*)name ## _bytes; \
94 name->mNumberBuffers = name ## _numberBuffers; \
95 for ( int i=0; i<name->mNumberBuffers; i++ ) { \
96 name->mBuffers[i].mNumberChannels \
97 = audioFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved ? 1 : audioFormat.mChannelsPerFrame; \
115 #define AEAudioBufferListCopyOnStack(name, sourceBufferList, offsetFrames) \
116 AEAudioBufferListCopyOnStackWithByteOffset(name, sourceBufferList, offsetFrames * AEAudioDescription.mBytesPerFrame)
133 #define AEAudioBufferListCopyOnStackWithByteOffset(name, sourceBufferList, offsetBytes) \
134 char name ## _bytes[sizeof(AudioBufferList)+(sizeof(AudioBuffer)*(sourceBufferList->mNumberBuffers-1))]; \
135 memcpy(name ## _bytes, sourceBufferList, sizeof(name ## _bytes)); \
136 AudioBufferList * name = (AudioBufferList*)name ## _bytes; \
137 for ( int i=0; i<name->mNumberBuffers; i++ ) { \
138 name->mBuffers[i].mData = (char*)name->mBuffers[i].mData + offsetBytes; \
139 name->mBuffers[i].mDataByteSize -= offsetBytes; \
149 #define AEAudioBufferListCopyOnStackWithChannelSubset(name, sourceBufferList, channelSet) \
150 int name ## _bufferCount = MIN(sourceBufferList->mNumberBuffers-1, channelSet.lastChannel) - \
151 MIN(sourceBufferList->mNumberBuffers-1, channelSet.firstChannel) + 1; \
152 char name ## _bytes[sizeof(AudioBufferList)+(sizeof(AudioBuffer)*(name ## _bufferCount-1))]; \
153 AudioBufferList * name = (AudioBufferList*)name ## _bytes; \
154 name->mNumberBuffers = name ## _bufferCount; \
155 memcpy(name->mBuffers, &sourceBufferList->mBuffers[MIN(sourceBufferList->mNumberBuffers-1, channelSet.firstChannel)], \
156 sizeof(AudioBuffer) * name ## _bufferCount);
201 AudioStreamBasicDescription audioFormat,
202 int *oNumberOfChannels);
226 AudioStreamBasicDescription audioFormat,
251 AudioStreamBasicDescription audioFormat,
265 void AEAudioBufferListAssign(AudioBufferList * target,
const AudioBufferList * source, UInt32 offset, UInt32 length);
280 AudioStreamBasicDescription audioFormat, UInt32 offset, UInt32 length);
300 AudioStreamBasicDescription audioFormat,
314 const AudioBufferList * source,
330 const AudioBufferList * source,
331 AudioStreamBasicDescription audioFormat,
347 static inline size_t AEAudioBufferListGetStructSize(
const AudioBufferList *
bufferList) {
348 return sizeof(AudioBufferList) + (bufferList->mNumberBuffers-1) *
sizeof(AudioBuffer);