#import <SndStreamManager.h>
Inherits SndDelegateMessagePassing-p.
Public Member Functions | |
(NSString *) | - description |
Returns an NSString with description of SndStreamManager. | |
(void) | - startStreaming |
Starts streaming. | |
(void) | - stopStreaming |
Stops streaming. | |
(void) | - streamStartStopThread |
a very lightweight thread used for starting and stopping the audio streams | |
(void) | - delegateMessageThread: |
A very lightweight thread used for sending delegate messages from the background threads to the main thread. | |
(BOOL) | - addClient: |
Adds an SndStreamClient to the manager's mixer. | |
(BOOL) | - removeClient: |
Removes the SndStreamClient from the manager's mixer. | |
(void) | - processStreamAtTime:input:output: |
Passes new input and output buffers from the underlying API to the mixer. | |
(id) | - setFormat: |
Sets the format to be used during streaming. | |
(SndFormat) | - format |
Returns the format to be used during streaming. | |
(double) | - nowTime |
Return the current time as understood by the SndStreamManager. | |
(SndStreamMixer *) | - mixer |
Mixer member accessor method. | |
(BOOL) | - isActive |
indicates whether streaming is happening (active) | |
(double) | - samplingRate |
(void) | - resetTime: |
Resets the global stream time to originTimeInSeconds. | |
(void) | - sendMessageInMainThreadToTarget:sel:arg1:arg2: |
Sends messages from any thread to any object in the main thread. | |
Static Public Member Functions | |
(SndStreamManager *) | + defaultStreamManager |
Accessor to the default stream manager created upon class initialization. | |
(NSArray *) | + getDriverNames |
Returns an NSArray of NSStrings listing the sound drivers available. |
Each SndStreamManager has a SndStreamMixer which has a SndAudioProcessorChain which has a SndAudioFader. Adding clients to a manager adds them to the underlying mixer.
+ (SndStreamManager *) defaultStreamManager |
Accessor to the default stream manager created upon class initialization.
SndStreamClients will usually connect to the default stream manager, unless the user wishes to explicitly create their own manager.
+ (NSArray *) getDriverNames |
Returns an NSArray of NSStrings listing the sound drivers available.
The format of the names is dependent on the underlying operating system.
- (NSString *) description |
Returns an NSString with description of SndStreamManager.
- (void) startStreaming |
Starts streaming.
You should never need to call this. Streaming is started automatically when the first client connects to the manager.
- (void) stopStreaming |
Stops streaming.
You should never need to call this. Streaming is stopped automatically when the last client disconnects from the manager.
- (void) streamStartStopThread |
a very lightweight thread used for starting and stopping the audio streams
You should never need to call this. The manager can instruct the starting and stopping of streams by setting bg_sem to BG_startNow or BG_stopNow, and setting the bg_threadLock condition. The thread is created on this method when a stream is to begin, if it does not exist already.
- (void) delegateMessageThread: | (NSArray *) | ports |
A very lightweight thread used for sending delegate messages from the background threads to the main thread.
ports | A pair of NSPorts in an NSArray, used for setting up the distributed object between this thread and the main thread. |
- (BOOL) addClient: | (SndStreamClient *) | client |
Adds an SndStreamClient to the manager's mixer.
If the SndStreamClient is already a client of the mixer, it is NOT added again. If the client is the first connected to the manager, the manager will automatically start streaming.
client | The SndStreamClient instance to begin managing and mixing. |
- (BOOL) removeClient: | (SndStreamClient *) | client |
Removes the SndStreamClient from the manager's mixer.
If the removed client was the last client connected to the manager, streaming will be automatically shut down.
client | The client to be disconnected from the manager. |
- (void) processStreamAtTime: | (double) | sampleCount | ||
input: | (SndAudioBuffer *) | inB | ||
output: | (SndAudioBuffer *) | outB | ||
Passes new input and output buffers from the underlying API to the mixer.
Do not call this method - it is part of the audio callback handler.
sampleCount | Time in samples | |
inB | inputBuffer | |
outB |
- (id) setFormat: | (SndFormat) | newFormat |
Sets the format to be used during streaming.
Do not call this method - it is called as part of the start-streaming process. The stream format used is the native format coming up from the devices below.
newFormat | A SndFormat structure. |
- (SndFormat) format |
- (double) nowTime |
- (SndStreamMixer *) mixer |
- (BOOL) isActive |
indicates whether streaming is happening (active)
- (double) samplingRate |
- (void) resetTime: | (double) | originTimeInSeconds |
Resets the global stream time to originTimeInSeconds.
originTimeInSeconds | New origin time, in seconds. |
- (void) sendMessageInMainThreadToTarget: | (id) | target | ||
sel: | (SEL) | sel | ||
arg1: | (id) | arg1 | ||
arg2: | (id) | arg2 | ||
Sends messages from any thread to any object in the main thread.
This method was introduced to allow easy delegate messaging from the underlying audio threads, but can be used by any object. The method creates an NSInvocation out of the parameters given, and adds it to an array of waiting messages. Then a background thread with an NSConnection to the main thread is notified, and the messages are passed up the connection one by one, and dispatched in the main thread. Note that the final dispatch is only done as part of the application's NSRunLoop, which means that if the main thread is busy doing anything, it can tke a little while for the delegate message to appear. Even if this is the case, this method should not block for long.
target | id target object | |
sel | SEL the selector to be sent, eg @selector(description:withObject:) | |
arg1 | the first argument in the selector | |
arg2 | the second argument in the selector |