SPTCoreAudioController Class Reference
Inherits from | NSObject |
Declared in | SPTCoreAudioController.h |
Tasks
Control
Customizing the audio pipeline
Properties
-
volume
property -
audioOutputEnabled
property -
delegate
property -
availableOutputDevices
property -
currentOutputDevice
property -
backgroundPlaybackTask
property
Properties
audioOutputEnabled
Whether audio output is enabled.
@property (readwrite, nonatomic) BOOL audioOutputEnabled
Declared In
SPTCoreAudioController.h
availableOutputDevices
Returns the available audio output devices. Mac only.
@property (readonly, nonatomic, copy) NSArray *availableOutputDevices
Declared In
SPTCoreAudioController.h
backgroundPlaybackTask
Current background playback task reference.
@property (readwrite, nonatomic) UIBackgroundTaskIdentifier backgroundPlaybackTask
Declared In
SPTCoreAudioController.h
currentOutputDevice
Returns the current output device. Set to nil
to use the system default. Mac only.
@property (readwrite, nonatomic, strong) SPTCoreAudioDevice *currentOutputDevice
Declared In
SPTCoreAudioController.h
Instance Methods
attemptToDeliverAudioFrames:ofCount:streamDescription:
Attempts to deliver the passed audio frames passed to the audio output pipeline.
- (NSInteger)attemptToDeliverAudioFrames:(const void *)audioFrames ofCount:(NSInteger)frameCount streamDescription:(AudioStreamBasicDescription)audioDescription
Parameters
- audioFrames
A buffer containing the audio frames.
- frameCount
The number of frames included in the buffer.
- audioDescription
A description of the audio contained in
audioFrames
.
Return Value
Returns the number of frames actually delievered to the audio pipeline. If this is less than frameCount
,
you need to retry delivery again later as the internal buffers are full.
Declared In
SPTCoreAudioController.h
bytesInAudioBuffer
Returns the number of bytes in the audio buffer.
- (uint32_t)bytesInAudioBuffer
Declared In
SPTCoreAudioController.h
clearAudioBuffers
Completely empties all audio that’s buffered for playback.
- (void)clearAudioBuffers
Discussion
This should be called when you need cancel all pending audio in order to, for example, play a new track.
Declared In
SPTCoreAudioController.h
connectOutputBus:ofNode:toInputBus:ofNode:inGraph:error:
Connects the given AUNode
instances together to complete the audio pipeline for playback.
- (BOOL)connectOutputBus:(UInt32)sourceOutputBusNumber ofNode:(AUNode)sourceNode toInputBus:(UInt32)destinationInputBusNumber ofNode:(AUNode)destinationNode inGraph:(AUGraph)graph error:(NSError **)error
Parameters
- sourceOutputBusNumber
The bus on which the source node will be providing audio data.
- sourceNode
The
AUNode
which will provide audio data for the graph.
- destinationInputBusNumber
The bus on which the destination node expects to receive audio data.
- destinationNode
The
AUNode
which will carry the audio data to the system’s audio output.
- graph
The
AUGraph
containing the given nodes.
- error
A pointer to an NSError instance to be filled with an
NSError
should a problem occur.
Return Value
YES
if the connection was made successfully, otherwise NO
.
Discussion
If you wish to customise the audio pipeline, you can do so by overriding this method and inserting your
own AUNode
instances between sourceNode
and destinationNode
.
This method will be called whenever the audio pipeline needs to be (re)built.
Warning: If you override this method and connect the nodes yourself, do not call the super
implementation. You can, however, conditionally decide whether to customise the queue and call super
if you want the default behaviour.
Declared In
SPTCoreAudioController.h
disposeOfCustomNodesInGraph:
Called when custom nodes in the pipeline should be disposed.
- (void)disposeOfCustomNodesInGraph:(AUGraph)graph
Parameters
- graph
The
AUGraph
that is being disposed.
Discussion
If you inserted your own AUNode
instances into the audio pipeline, override this method to
perform any cleanup needed.
This method will be called whenever the audio pipeline is being torn down.
Declared In
SPTCoreAudioController.h