#import <SndAudioBufferQueue.h>
Public Member Functions | |
(id) | - initQueueWithLength: |
Initializes queue for operation with a total of pending+processed buffers. | |
(SndAudioBuffer *) | - popNextPendingBuffer |
Blocks the calling thread until a buffer is present for popping. | |
(SndAudioBuffer *) | - popNextProcessedBuffer |
Returns the next. | |
(id) | - addPendingBuffer: |
Adds buffer to the pending queue. | |
(id) | - addProcessedBuffer: |
Adds a buffer to the processed queue. | |
(void) | - cancelProcessedBuffers |
Moves all processed buffers onto the pending queue. | |
(int) | - pendingBuffersCount |
(int) | - processedBuffersCount |
(id) | - freeBuffers |
Frees the SndAudioBuffers within the queues. | |
(id) | - prepareQueueAsType:withBufferPrototype: |
Primes the SndAudioBufferQueue for streaming. | |
(int) | - bufferCount |
Returns the total number of buffers being shuffled about betwixt pending and processed queues. | |
Static Public Member Functions | |
(id) | + audioBufferQueueWithLength: |
Factory method. | |
Protected Attributes | |
NSMutableArray * | pendingBuffers |
NSMutableArray * | processedBuffers |
NSConditionLock * | pendingBuffersLock |
NSConditionLock * | processedBuffersLock |
int | numBuffers |
+ (id) audioBufferQueueWithLength: | (int) | n |
Factory method.
n | Buffer queue length |
- (id) initQueueWithLength: | (int) | n |
Initializes queue for operation with a total of pending+processed buffers.
Since we add and pop buffers in separate methods, if we try to add before popping, we will need to use one less than the full number of buffers initialized with, such that we never exceed the maximum. For example, if we initialize with 4 buffers, at best we can hold only 3 processed buffers so we can add a pending buffer, before then popping a processed buffer.
n | Number of buffers. |
- (SndAudioBuffer*) popNextPendingBuffer |
Blocks the calling thread until a buffer is present for popping.
- (SndAudioBuffer*) popNextProcessedBuffer |
Returns the next.
Blocks the calling thread until a buffer is present for popping.
- (id) addPendingBuffer: | (SndAudioBuffer *) | audioBuffer |
Adds buffer to the pending queue.
audioBuffer | Buffer to be added |
- (id) addProcessedBuffer: | (SndAudioBuffer *) | audioBuffer |
Adds a buffer to the processed queue.
audioBuffer | Buffer to be added |
- (int) pendingBuffersCount |
- (int) processedBuffersCount |
- (id) freeBuffers |
Frees the SndAudioBuffers within the queues.
- (id) prepareQueueAsType: | (SndAudioBufferQueueType) | type | ||
withBufferPrototype: | (SndAudioBuffer *) | buff | ||
Primes the SndAudioBufferQueue for streaming.
type | Either audioBufferQueue_typeInput or audioBufferQueue_typeOutput | |
buff | The format of the SndAudioBuffer buff will be used as a template for the internal queued buffers. |
- (int) bufferCount |
Returns the total number of buffers being shuffled about betwixt pending and processed queues.
- (NSMutableArray*) pendingBuffers [protected] |
Array of buffers pending processing (to be consumed)
- (NSMutableArray*) processedBuffers [protected] |
Array of processed buffers (post consumption)
- (NSConditionLock*) pendingBuffersLock [protected] |
Lock for thread safety around pending buffers array
- (NSConditionLock*) processedBuffersLock [protected] |
Lock for thread safety around processed buffers array
- (int) numBuffers [protected] |
Total number of buffers in the queue, both pending and processed