AudioDeviceBase class
#include <nCine/Audio/AudioDeviceBase.h>
Backend-independent part of an audio device.
Owns the pool of free sources, the list of active players and the stream decoding thread - everything an IAudioDevice has to do that does not depend on the sound hardware. A backend derives from this, hands over the source ids it created with setSourcePool() and only implements the buffer and source operations of IAudioDevice.
Base classes
- class IAudioDevice
- Interface for an audio device backend.
Derived classes
- class ALAudioDevice
- OpenAL implementation of IAudioDevice.
- class AicaAudioDevice
- Dreamcast implementation of IAudioDevice on top of the AICA.
- class AsndAudioDevice
- Wii/GameCube implementation of IAudioDevice on top of libogc's ASND.
Constructors, destructors, conversion operators
- ~AudioDeviceBase() override
- AudioDeviceBase(const AudioDeviceBase&) deleted
- AudioDeviceBase() protected
Public functions
- auto operator=(const AudioDeviceBase&) -> AudioDeviceBase& deleted
- auto gain() const -> float override
- Returns the listener gain (master volume).
-
auto maxNumPlayers() const -> std::
uint32_t override - Returns the maximum number of players that can be active at once.
-
auto numPlayers() const -> std::
uint32_t override - Returns the number of currently active players.
-
auto player(std::
uint32_t index) const -> const IAudioPlayer* override - Returns the active player at the specified index.
-
auto player(std::
uint32_t index) -> IAudioPlayer* override - void stopPlayers() override
- Stops every player currently playing.
- void pausePlayers() override
- Pauses every player currently playing.
- void stopPlayers(PlayerType playerType) override
- Stops every player of the specified type.
- void pausePlayers(PlayerType playerType) override
- Pauses every player of the specified type.
- void freezePlayers() override
- Pauses every player currently playing while keeping it registered.
- void unfreezePlayers() override
- Resumes every player previously paused by freezePlayers().
-
auto registerPlayer(IAudioPlayer* player) -> std::
uint32_t override - Registers a player so it receives state and buffer queue updates, returning its source id.
- void unregisterPlayer(IAudioPlayer* player) override
- Unregisters a previously registered player.
- void updatePlayers() override
- Updates the state of every registered player, including the buffer queue of stream players.
-
auto submitStreamDecode(const std::
shared_ptr<StreamDecodeRequest>& request) -> bool override - Submits a decode request to be executed asynchronously on the decoding thread.
-
void drainStreamDecode(const std::
shared_ptr<StreamDecodeRequest>& request) override - Ensures the specified request is neither queued nor being executed when this method returns.
- auto getListenerPosition() const -> const Vector3f& override
- Returns the 3D position of the listener.
Protected functions
-
void setSourcePool(ArrayView<const std::
uint32_t> sourceIds) - Hands the source ids created by the backend over to the pool.
- void shutdownDecodeThread()
- Stops the decoding thread and releases every request still queued.
Protected static variables
-
static std::
size_t TypicalNumSources constexpr - Typical number of sources a backend creates, only the inline capacity of the pools.
Protected variables
- float _gain
- Listener gain (master volume).
- Vector3f _listenerPos
- Listener position.
-
SmallVector<std::
uint32_t, TypicalNumSources> _sourcePool - Pool of currently inactive source ids.
- SmallVector<IAudioPlayer*, TypicalNumSources> _players
- Currently active audio players.
Function documentation
IAudioPlayer* nCine:: AudioDeviceBase:: player(std:: uint32_t index) override
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool nCine:: AudioDeviceBase:: submitStreamDecode(const std:: shared_ptr<StreamDecodeRequest>& request) override
Submits a decode request to be executed asynchronously on the decoding thread.
| Returns | false when no decoding thread is available and the caller has to decode synchronously |
|---|
The request state must be StreamDecodeRequest::
void nCine:: AudioDeviceBase:: drainStreamDecode(const std:: shared_ptr<StreamDecodeRequest>& request) override
Ensures the specified request is neither queued nor being executed when this method returns.
Required before the caller touches the request's reader (rewinding, changing looping or replacing it). A request removed from the queue before execution is reset to StreamDecodeRequest::
void nCine:: AudioDeviceBase:: shutdownDecodeThread() protected
Stops the decoding thread and releases every request still queued.
Has to be called by the backend destructor before it tears down anything the readers could still touch, the base destructor is too late for that.