blip  0.1
AudioEngine Class Reference

An audio playback engine. More...

#include <AudioEngine.hpp>

Public Member Functions

 AudioEngine ()
 Construct a new AudioEngine. More...
 
 ~AudioEngine ()
 Destructor. More...
 
void initialize ()
 Initialize the audio engine. More...
 
void shutdown ()
 Deallocate any allocated AudioPlayer instances and shut down the audio engine. More...
 
void allocatePlayer (const AudioFormat &format)
 Allocate an AudioPlayer instance within the engine that will play back audio with the given format. More...
 
AudioPlayerreservePlayer (const AudioFormat &format)
 Reserve an AudioPlayer instance that can play back the given audio format. More...
 
void releasePlayer (AudioPlayer *player)
 Release a previously reserved AudioPlayer instance. More...
 
LEDArraygetLEDArray ()
 Get the LEDArray object representing the device's LED arrays. More...
 
VibratorgetVibrator ()
 Get the Vibrator object representing the device's vibrator (haptic feedback) device. More...
 

Detailed Description

An audio playback engine.

This class is a wrapper around the OpenSL API. The engine manages zero or more AudioPlayer instances, each of which can be used to play back an independent audio stream; the audio from all of these instances is automatically mixed by the engine.

In addition to audio playback, it also provides access to LED array and vibrator (haptic feedback) devices, if the OpenSL implementation has such support.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ AudioEngine()

Construct a new AudioEngine.

The engine must be initialized with initialize() before it can be used.

◆ ~AudioEngine()

Destructor.

The engine should be shut down with shutdown() before it is destroyed.

Member Function Documentation

◆ allocatePlayer()

void allocatePlayer ( const AudioFormat format)

Allocate an AudioPlayer instance within the engine that will play back audio with the given format.

The number of AudioPlayer instances that can be allocated by an application is implementation defined.

Parameters
formatThe format of the audio that the player will play back.
Exceptions
AudioExceptionIf an error occurs.

◆ getLEDArray()

LEDArray * getLEDArray ( )

Get the LEDArray object representing the device's LED arrays.

Returns
The LEDArray object, or NULL if either the device doesn't have one or if the OpenSL implementation does not provide support for LED arrays.
Exceptions
AudioExceptionIf an error occurs.

◆ getVibrator()

Vibrator * getVibrator ( )

Get the Vibrator object representing the device's vibrator (haptic feedback) device.

Returns
The Vibrator object, or NULL if either the device doesn't have one or if the OpenSL implementation does not provide support for vibrators.
Exceptions
AudioExceptionIf an error occurs.

◆ initialize()

void initialize ( )

Initialize the audio engine.

This method is idempotent.

Exceptions
AudioExceptionIf an error occurs.

◆ releasePlayer()

void releasePlayer ( AudioPlayer player)

Release a previously reserved AudioPlayer instance.

If necessary, stops playback and releases all enqueued buffers.

Parameters
playerThe instance to release.

◆ reservePlayer()

AudioPlayer * reservePlayer ( const AudioFormat format)

Reserve an AudioPlayer instance that can play back the given audio format.

Parameters
formatThe audio format.
Returns
A compatible, available AudioPlayer instance, or NULL if none is available.

◆ shutdown()

void shutdown ( )

Deallocate any allocated AudioPlayer instances and shut down the audio engine.

This method is idempotent.


The documentation for this class was generated from the following files: