AECircularBuffer.h
Go to the documentation of this file.
1 //
2 // AECircularBuffer.h
3 // TheAmazingAudioEngine
4 //
5 // Created by Michael Tyson on 29/04/2016.
6 // Copyright © 2016 A Tasty Pixel. All rights reserved.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source distribution.
25 //
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #import "TPCircularBuffer.h"
32 #import <AudioToolbox/AudioToolbox.h>
33 
34 #define AECircularBufferCopyAll UINT32_MAX
35 
48 typedef struct {
50  AudioStreamBasicDescription audioDescription;
52 
65 BOOL AECircularBufferInit(AECircularBuffer * buffer, UInt32 capacityInFrames, int channelCount, double sampleRate);
66 
73 
82 
97 void AECircularBufferSetAtomic(AECircularBuffer *buffer, BOOL atomic);
98 
114  int channelCount,
115  double sampleRate);
116 
117 #pragma mark - Producing
118 
130 
141  const AudioBufferList *bufferList,
142  const AudioTimeStamp *timestamp,
143  UInt32 frames);
144 
154  UInt32 frameCount,
155  const AudioTimeStamp *timestamp);
156 
167 
168 #pragma mark - Consuming
169 
179 UInt32 AECircularBufferPeek(AECircularBuffer *buffer, AudioTimeStamp *outTimestamp);
180 
190  UInt32 *ioLengthInFrames,
191  const AudioBufferList *outputBufferList,
192  AudioTimeStamp *outTimestamp);
193 
202 AudioBufferList * AECircularBufferNextBufferList(AECircularBuffer *buffer,
203  AudioTimeStamp *outTimestamp,
204  const AudioBufferList * lastBufferList);
205 
212 
223 
224 #ifdef __cplusplus
225 }
226 #endif