MusicKit
0.0.0
|
Abstraction of the producer / consumer buffer queue operation found inside the SndStreamClients, which have both an input and output SndAudioBufferQueue. Provides thread safe buffer exchange and blocking operations. More...
#import <SndAudioBufferQueue.h>
Public Member Functions | |
(id) | - initQueueWithLength: |
Initializes queue for operation with a total of pending+processed buffers. | |
(SndAudioBuffer *) | - popNextPendingBuffer |
Returns the next buffer that is yet to be processed. | |
(SndAudioBuffer *) | - popNextProcessedBuffer |
Returns the next buffer that has already been processed. | |
(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. | |
(BOOL) | - prepareQueueAsType:withBufferPrototype: |
Primes the SndAudioBufferQueue for streaming. | |
(int) | - bufferCount |
Returns the total number of buffers being shuffled about betwixt pending and processed queues. | |
(id) | - initQueueWithLength: |
Initializes queue for operation with a total of pending+processed buffers. | |
(SndAudioBuffer *) | - popNextPendingBuffer |
Returns the next buffer that is yet to be processed. | |
(SndAudioBuffer *) | - popNextProcessedBuffer |
Returns the next buffer that has already been processed. | |
(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. | |
(BOOL) | - 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. | |
(id) | + audioBufferQueueWithLength: |
Factory method. | |
Protected Attributes | |
NSMutableArray * | pendingBuffers |
NSMutableArray * | processedBuffers |
NSConditionLock * | pendingBuffersLock |
NSConditionLock * | processedBuffersLock |
unsigned int | numBuffers |
unsigned int | maximumPendingBuffers |
unsigned int | maximumProcessedBuffers |
Abstraction of the producer / consumer buffer queue operation found inside the SndStreamClients, which have both an input and output SndAudioBufferQueue. Provides thread safe buffer exchange and blocking operations.
- (id) addPendingBuffer: | (SndAudioBuffer *) | audioBuffer |
Adds buffer to the pending queue.
audioBuffer | Buffer to be added |
- (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 |
- (id) addProcessedBuffer: | (SndAudioBuffer *) | audioBuffer |
Adds a buffer to the processed queue.
audioBuffer | Buffer to be added |
+ (id) audioBufferQueueWithLength: | (int) | numberOfBuffers |
Factory method.
numberOfBuffers | Buffer queue length. |
Creates a fresh new SndAudioBufferQueue, sets the eventual number of buffers to numberOfBuffers.
+ (id) audioBufferQueueWithLength: | (int) | numberOfBuffers |
Factory method.
numberOfBuffers | Buffer queue length. |
Creates a fresh new SndAudioBufferQueue, sets the eventual number of buffers to numberOfBuffers.
- (int) bufferCount |
Returns the total number of buffers being shuffled about betwixt pending and processed queues.
- (int) bufferCount |
Returns the total number of buffers being shuffled about betwixt pending and processed queues.
- (id) freeBuffers |
Frees the SndAudioBuffers within the queues.
- (id) freeBuffers |
Frees the SndAudioBuffers within the queues.
- (id) initQueueWithLength: | (int) | numberOfBuffers |
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.
numberOfBuffers | Number of buffers. |
- (id) initQueueWithLength: | (int) | numberOfBuffers |
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.
numberOfBuffers | Number of buffers. |
- (int) pendingBuffersCount |
- (int) pendingBuffersCount |
Returns the next buffer that is yet to be processed.
In contexts where the queue is used for input and output processing, the returned buffer can be interpreted as:
Blocks the calling thread until a buffer is present for popping.
Returns the next buffer that is yet to be processed.
In contexts where the queue is used for input and output processing, the returned buffer can be interpreted as:
Blocks the calling thread until a buffer is present for popping.
Returns the next buffer that has already been processed.
In contexts where the queue is used for input and output processing, the returned buffer can be interpreted as:
Blocks the calling thread until a buffer is present for popping.
Returns the next buffer that has already been processed.
In contexts where the queue is used for input and output processing, the returned buffer can be interpreted as:
Blocks the calling thread until a buffer is present for popping.
- (BOOL) 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. |
If prepared as an input queue, the buffers are initially placed in the processed queue; otherwise the fresh buffers are placed in the pending queue. The former ensures that any input buffer consumers do not get empty buffers, and the latter allows buffer producers (eg synthesizers) to process several buffers ahead, giving them some processing head room in a multi-threaded environment.
- (BOOL) 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. |
If prepared as an input queue, the buffers are initially placed in the processed queue; otherwise the fresh buffers are placed in the pending queue. The former ensures that any input buffer consumers do not get empty buffers, and the latter allows buffer producers (eg synthesizers) to process several buffers ahead, giving them some processing head room in a multi-threaded environment.
- (int) processedBuffersCount |
- (int) processedBuffersCount |
- (unsigned int) maximumPendingBuffers [protected] |
Maximum number of buffers ever stored in pending queue
- (unsigned int) maximumProcessedBuffers [protected] |
Maximum number of buffers ever stored in process queue
- (unsigned int) numBuffers [protected] |
Total number of buffers in the queue, both pending and processed
- (NSMutableArray *) pendingBuffers [protected] |
Array of buffers pending processing (to be consumed)
- (NSConditionLock *) pendingBuffersLock [protected] |
Lock for thread safety around pending buffers array
- (NSMutableArray *) processedBuffers [protected] |
Array of processed buffers (post consumption)
- (NSConditionLock *) processedBuffersLock [protected] |
Lock for thread safety around processed buffers array