SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::AudioStreamBase Struct Reference

Base class to AudioStream. More...

Inheritance diagram for SDL::AudioStreamBase:
[legend]

Public Member Functions

void Destroy ()
 Free an audio stream.
PropertiesRef GetProperties () const
 Get the properties associated with an audio stream.
AudioSpec GetInputFormat () const
 Query the current input format of an audio stream.
AudioSpec GetOutputFormat () const
 Query the current output format of an audio stream.
void GetFormat (AudioSpec *src_spec, AudioSpec *dst_spec) const
 Query the current format of an audio stream.
void SetInputFormat (const AudioSpec &spec)
 Change the input format of an audio stream.
void SetOutputFormat (const AudioSpec &spec)
 Change the output format of an audio stream.
void SetFormat (OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
 Change the input and output formats of an audio stream.
float GetFrequencyRatio () const
 Get the frequency ratio of an audio stream.
void SetFrequencyRatio (float ratio)
 Change the frequency ratio of an audio stream.
float GetGain () const
 Get the gain of an audio stream.
void SetGain (float gain)
 Change the gain of an audio stream.
OwnArray< int > GetInputChannelMap () const
 Get the current input channel map of an audio stream.
OwnArray< int > GetOutputChannelMap () const
 Get the current output channel map of an audio stream.
void SetInputChannelMap (std::span< int > chmap)
 Set the current input channel map of an audio stream.
void SetOutputChannelMap (std::span< int > chmap)
 Set the current output channel map of an audio stream.
void PutData (SourceBytes buf)
 Add data to the stream.
void PutDataNoCopy (SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
 Add external data to an audio stream without copying it.
void PutDataNoCopy (SourceBytes buf, AudioStreamDataCompleteCB callback)
 Add external data to an audio stream without copying it.
int GetData (TargetBytes buf)
 Get converted/resampled data from the stream.
int GetAvailable () const
 Get the number of converted/resampled bytes available.
int GetQueued () const
 Get the number of bytes currently queued.
void Flush ()
 Tell the stream that you're done sending data, and anything being buffered should be converted/resampled and made available immediately.
void Clear ()
 Clear any pending data in the stream.
void PauseDevice ()
 Use this function to pause audio playback on the audio device associated with an audio stream.
void ResumeDevice ()
 Use this function to unpause audio playback on the audio device associated with an audio stream.
bool DevicePaused () const
 Use this function to query if an audio device associated with a stream is paused.
AudioStreamLock Lock ()
 Lock an audio stream for serialized access.
void Unlock (AudioStreamLock &&lock)
 Unlock an audio stream for serialized access.
void SetGetCallback (AudioStreamCallback callback, void *userdata)
 Set a callback that runs when data is requested from an audio stream.
void SetGetCallback (AudioStreamCB callback)
 Set a callback that runs when data is requested from an audio stream.
void SetPutCallback (AudioStreamCallback callback, void *userdata)
 Set a callback that runs when data is added to an audio stream.
void SetPutCallback (AudioStreamCB callback)
 Set a callback that runs when data is added to an audio stream.
void Unbind ()
 Unbind a single audio stream from its audio device.
AudioDeviceRef GetDevice () const
 Query an audio stream for its currently-bound device.
void PutPlanarData (const void *const *channel_buffers, int num_channels, int num_samples)
 Add data to the stream with each channel in a separate array.
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr ResourceBaseT (RawPointer resource)
 Constructs from resource pointer.
constexpr ResourceBaseT (std::nullptr_t)
 Constructs null/invalid.
constexpr ResourceBaseT (const ResourceBaseT &)=default
 Copy constructor.
constexpr ResourceBaseT (ResourceBaseT &&) noexcept=default
 Move constructor.
Public Member Functions inherited from SDL::ResourceBaseT< AudioStreamRaw >
constexpr ResourceBaseT ()=default
 Default constructor, creates null/invalid resource.
constexpr operator bool () const
 Converts to bool.
constexpr auto operator<=> (const ResourceBaseT &other) const=default
 Comparison.
constexpr RawConstPointer operator-> () const noexcept
 member access to underlying resource pointer.
constexpr RawPointer get () const noexcept
 Retrieves underlying resource pointer.
constexpr RawPointer release () noexcept
 Retrieves underlying resource pointer and clear this.

Additional Inherited Members

Public Types inherited from SDL::ResourceBaseT< AudioStreamRaw >
using RawPointer
 The underlying raw pointer type.
using RawConstPointer
 The underlying const raw pointer type.
Protected Member Functions inherited from SDL::ResourceBaseT< AudioStreamRaw >
constexpr ~ResourceBaseT ()=default
 Destructor.
constexpr ResourceBaseToperator= (const ResourceBaseT &)=default
 Assignment operator.

Detailed Description

Base class to AudioStream.

See also
AudioStream

Member Function Documentation

◆ GetInputFormat()

AudioSpec SDL::AudioStreamBase::GetInputFormat ( ) const
inline

Query the current input format of an audio stream.

Returns
the input audio format.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since
This function is available since SDL 3.2.0.
See also
AudioStream.SetFormat

◆ GetOutputFormat()

AudioSpec SDL::AudioStreamBase::GetOutputFormat ( ) const
inline

Query the current output format of an audio stream.

Returns
the output audio format.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since
This function is available since SDL 3.2.0.
See also
AudioStream.SetFormat

◆ SetInputFormat()

void SDL::AudioStreamBase::SetInputFormat ( const AudioSpec & spec)
inline

Change the input format of an audio stream.

Future calls to and AudioStreamRef.GetAvailable and AudioStreamRef.GetData will reflect the new format, and future calls to AudioStreamRef.PutData must provide data in the new input formats.

Data that was previously queued in the stream will still be operated on in the format that was current when it was added, which is to say you can put the end of a sound file in one format to a stream, change formats for the next sound file, and start putting that new data while the previous sound file is still queued, and everything will still play back correctly.

If a stream is bound to a device, then the format of the side of the stream bound to a device cannot be changed (src_spec for recording devices, dst_spec for playback devices). Attempts to make a change to this side will be ignored, but this will not report an error. The other side's format can be changed.

Parameters
specthe new format of the audio input.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since
This function is available since SDL 3.2.0.
See also
AudioStream.GetFormat
AudioStream.SetFrequencyRatio

◆ SetOutputFormat()

void SDL::AudioStreamBase::SetOutputFormat ( const AudioSpec & spec)
inline

Change the output format of an audio stream.

Future calls to and AudioStreamRef.GetAvailable and AudioStreamRef.GetData will reflect the new format, and future calls to AudioStreamRef.PutData must provide data in the new input formats.

Data that was previously queued in the stream will still be operated on in the format that was current when it was added, which is to say you can put the end of a sound file in one format to a stream, change formats for the next sound file, and start putting that new data while the previous sound file is still queued, and everything will still play back correctly.

If a stream is bound to a device, then the format of the side of the stream bound to a device cannot be changed (src_spec for recording devices, dst_spec for playback devices). Attempts to make a change to this side will be ignored, but this will not report an error. The other side's format can be changed.

Parameters
specthe new format of the audio output.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread, as it holds a stream-specific mutex while running.
Since
This function is available since SDL 3.2.0.
See also
AudioStream.GetFormat
AudioStream.SetFrequencyRatio

The documentation for this struct was generated from the following file: