SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::AudioStreamLock Class Reference

Lock an audio stream for serialized access. More...

Public Member Functions

 AudioStreamLock (AudioStreamRef resource)
 Lock an audio stream for serialized access. More...
 
 AudioStreamLock (const AudioStreamLock &other)=delete
 Copy constructor.
 
constexpr AudioStreamLock (AudioStreamLock &&other) noexcept
 Move constructor.
 
 ~AudioStreamLock ()
 Unlock an audio stream for serialized access. More...
 
AudioStreamLockoperator= (const AudioStreamLock &other)=delete
 
AudioStreamLockoperator= (AudioStreamLock &&other) noexcept
 Assignment operator.
 
constexpr operator bool () const
 True if not locked.
 
void reset ()
 Unlock an audio stream for serialized access. More...
 
AudioStreamRef get ()
 Get the reference to locked resource.
 
void release ()
 Releases the lock without unlocking.
 

Detailed Description

Each AudioStream has an internal mutex it uses to protect its data structures from threading conflicts. This function allows an app to lock that mutex, which could be useful if registering callbacks on this stream.

One does not need to lock a stream to use in it most cases, as the stream manages this lock internally. However, this lock is held during callbacks, which may run from arbitrary threads at any time, so if an app needs to protect shared data during those callbacks, locking the stream guarantees that the callback is not running while the lock is held.

As this is just a wrapper over Mutex.Lock for an internal lock; it has all the same attributes (recursive locks are allowed, etc).

See also
AudioStream.Lock

Constructor & Destructor Documentation

◆ ~AudioStreamLock()

SDL::AudioStreamLock::~AudioStreamLock ( )
inline

This unlocks an audio stream after a call to AudioStream.Lock.

Returns
true on success or false on failure; call GetError() for more information.
Thread safety:
You should only call this from the same thread that previously called AudioStream.Lock.
Since
This function is available since SDL 3.2.0.
See also
AudioStream.Lock

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