asge::audio::AudioDevice
Owns SDL's audio subsystem, one physical playback device, and a fixed pool of up to 32 AudioStreams bound to it.
#include <AudioDevice.hpp>Initialize() brings up SDL_INIT_AUDIO and opens the default playback device; CreateStream() then hands out a shared_ptr<AudioStream> per AudioSource wanting to play a clip, backed by a slot in the fixed m_Streams array. Callers keep that shared_ptr for as long as they're playing (see AudioSystem) — it stays valid regardless of which slot backs it, even across a DetachStream() call elsewhere that swap-removes and relocates a slot still in use. Shutdown() (also run from the destructor) tears both the streams and the device back down.
Static Private Attributes
Private Attributes
Public Member Functions
~AudioDevice()BoolResult Initialize()Initializes SDL's audio subsystem and opens the default playback device, resumed and ready.
void Shutdown()std::size_t Size() const noexceptCount of stream slots currently handed out (grows on CreateStream, shrinks on DetachStream).
SDL_AudioDeviceID Id() const noexceptResult< std::shared_ptr< AudioStream > > CreateStream(media::AudioClip &inAudioClip) noexceptCreates a new AudioStream matching inAudioClip's format, binds it to this device, and returns a shared handle into this device's stream pool that stays valid until DetachStream() releases it.
BoolResult DetachStream(AudioStream &inStream) noexceptUnbinds and releases a stream previously returned by CreateStream(), swap-removing its slot (relocating the trailing stream into it, if it wasn't already the trailing one) so the pool stays compact.
BoolResult SetGain(float inVolume) noexceptSets the master playback gain for every stream on this device (1.0 = unchanged, 0.0 = silent).