SPTCoreAudioController Class Reference
| Inherits from | NSObject |
| Declared in | SPTCoreAudioController.h |
Tasks
Control
Customizing the audio pipeline
Properties
-
volumeproperty -
audioOutputEnabledproperty -
delegateproperty -
availableOutputDevicesproperty -
currentOutputDeviceproperty -
backgroundPlaybackTaskproperty
Properties
audioOutputEnabled
Whether audio output is enabled.
@property (readwrite, nonatomic) BOOL audioOutputEnabledDeclared In
SPTCoreAudioController.havailableOutputDevices
Returns the available audio output devices. Mac only.
@property (readonly, nonatomic, copy) NSArray *availableOutputDevicesDeclared In
SPTCoreAudioController.hbackgroundPlaybackTask
Current background playback task reference.
@property (readwrite, nonatomic) UIBackgroundTaskIdentifier backgroundPlaybackTaskDeclared In
SPTCoreAudioController.hcurrentOutputDevice
Returns the current output device. Set to nil to use the system default. Mac only.
@property (readwrite, nonatomic, strong) SPTCoreAudioDevice *currentOutputDeviceDeclared In
SPTCoreAudioController.hInstance 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)audioDescriptionParameters
- 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.hbytesInAudioBuffer
Returns the number of bytes in the audio buffer.
- (uint32_t)bytesInAudioBufferDeclared In
SPTCoreAudioController.hclearAudioBuffers
Completely empties all audio that’s buffered for playback.
- (void)clearAudioBuffersDiscussion
This should be called when you need cancel all pending audio in order to, for example, play a new track.
Declared In
SPTCoreAudioController.hconnectOutputBus: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 **)errorParameters
- sourceOutputBusNumber
The bus on which the source node will be providing audio data.
- sourceNode
The
AUNodewhich will provide audio data for the graph.
- destinationInputBusNumber
The bus on which the destination node expects to receive audio data.
- destinationNode
The
AUNodewhich will carry the audio data to the system’s audio output.
- graph
The
AUGraphcontaining the given nodes.
- error
A pointer to an NSError instance to be filled with an
NSErrorshould 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.hdisposeOfCustomNodesInGraph:
Called when custom nodes in the pipeline should be disposed.
- (void)disposeOfCustomNodesInGraph:(AUGraph)graphParameters
- graph
The
AUGraphthat 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