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

Locks a AudioStream.

Inheritance diagram for SDL::AudioStreamLock:
Inheritance graph
[legend]

Public Member Functions

constexpr AudioStreamLock ()=default
 Creates an empty lock.
 
constexpr AudioStreamLock (AudioStreamLock &&other)
 Move ctor.
 
 AudioStreamLock (AudioStreamBase &stream)
 Lock an audio stream for serialized access.
 
 ~AudioStreamLock ()
 Destructor.
 
void Unlock ()
 Unlock an audio stream for serialized access.
 
void reset ()
 Same as Unlock(), just for uniformity.
 
- Public Member Functions inherited from SDL::LockBase< AudioStreamRef >
constexpr LockBase ()=default
 Default ctor.
 
 LockBase (const LockBase &other)=delete
 
 LockBase (LockBase &&other)
 Move ctor.
 
constexpr ~LockBase ()
 Dtor.
 
LockBaseoperator= (const LockBase &other)=delete
 
LockBaseoperator= (LockBase &&other)
 Move assignment.
 
AudioStreamRef release ()
 Release locked resource without unlocking it.
 

Additional Inherited Members

- Protected Member Functions inherited from SDL::LockBase< AudioStreamRef >
constexpr LockBase (AudioStreamRef &&resource)
 Constructs initializing member.
 

Constructor & Destructor Documentation

◆ AudioStreamLock()

SDL::AudioStreamLock::AudioStreamLock ( AudioStreamBase stream)
inline

Each AudioStreamBase 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 MutexBase.Lock for an internal lock; it has all the same attributes (recursive locks are allowed, etc).

Parameters
streamthe audio stream to lock.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
AudioStreamLock.Unlock

Member Function Documentation

◆ Unlock()

void SDL::AudioStreamLock::Unlock ( )
inline

This unlocks an audio stream after a call to AudioStreamLock.AudioStreamLock.

Exceptions
Erroron failure.
Thread safety:
You should only call this from the same thread that previously called AudioStreamLock.AudioStreamLock.
Since
This function is available since SDL 3.2.0.
See also
AudioStreamLock.AudioStreamLock

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