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 (AudioStreamRef 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= (LockBase other)
 Move assignment.
 
- Public Member Functions inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
RESOURCE release ()
 Returns reference and reset this.
 
- Public Member Functions inherited from SDL::ResourcePtrBase< RESOURCE >
constexpr operator bool () const
 Check if not null.
 
constexpr bool operator== (const ResourcePtrBase &other) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr reference operator* () const
 Gets reference.
 
constexpr const referenceoperator-> () const
 Gets addressable reference.
 
constexpr referenceoperator-> ()
 Gets addressable reference.
 
reference get () const
 Get reference.
 

Additional Inherited Members

- Public Types inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
using deleter = DELETER
 The deleter type.
 
- Public Types inherited from SDL::ResourcePtrBase< RESOURCE >
using reference = RESOURCE
 The reference resource type.
 
using value_type = typename reference::value_type
 The raw resource type.
 
- Protected Member Functions inherited from SDL::LockBase< AudioStreamRef >
constexpr LockBase (AudioStreamRef &&resource)
 Constructs initializing member.
 
- Protected Member Functions inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
constexpr ResourceOwnerBase (base::value_type value={}, DELETER deleter={})
 Constructs from raw type.
 
void free ()
 Frees resource.
 
- Protected Member Functions inherited from SDL::ResourcePtrBase< RESOURCE >
constexpr ResourcePtrBase (value_type value={})
 Constructs from raw type.
 
referenceget ()
 Get reference.
 

Constructor & Destructor Documentation

◆ AudioStreamLock()

SDL::AudioStreamLock::AudioStreamLock ( AudioStreamRef  stream)
inline

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 MutexRef.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 AudioStreamRef.Lock.

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

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