← API Reference Class

asge::audio::AudioStream

A shared handle to one SDL_AudioStream bound to an AudioDevice, plus the slot it occupies in that device's stream pool.

#include <AudioStream.hpp>

Copies share the same underlying SDL_AudioStream (via shared_ptr) and the same Index() AudioDevice::CreateStream is the only place a fresh one is minted. Not meant to be constructed directly by callers other than AudioDevice; see its doc comment for how the pool owns these slots.

Private Attributes

#std::shared_ptr< SDL_AudioStream > m_Streamprivate
#std::size_t m_InDevIdxprivate

Public Member Functions

#AudioStream()
#AudioStream(std::shared_ptr< SDL_AudioStream > inStream, std::size_t inIdx)
#AudioStream(AudioStream const &)=default
#AudioStream(AudioStream &&)=default
#AudioStream & operator=(AudioStream const &)=default
#AudioStream & operator=(AudioStream &&)=default
#SDL_AudioStream * Get() const noexcept

The underlying SDL stream handle, or nullptr once Reset().

#bool IsValid() const noexcept

True if this still wraps a live SDL stream (i.e.

Get() isn't null).

#std::size_t Index() const noexcept

This stream's slot index in its owning AudioDevice's pool, or -1 once detached.

#void Index(std::size_t inIndex) noexcept
#void Reset() noexcept
#BoolResult ClearData() noexcept

Discards any PCM data currently queued on this stream.

#BoolResult PutData(media::AudioClip &inClip) noexcept

Queues inClip's whole PCM buffer onto this stream and flushes it for playback.

#bool IsDataAvailable() const noexcept

True if this stream still has queued PCM data the device hasn't consumed yet.

#BoolResult SetAudioGain(float inVolume) noexcept

Sets this stream's own playback gain (1.0 = unchanged, 0.0 = silent), independent of the device's master gain.