libSDL2pp
C++ bindings/wrapper for SDL2
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
SDL2pp::AudioDevice::LockHandle Class Reference

SDL2pp::AudioDevice lock. More...

#include <SDL2pp/AudioDevice.hh>

Public Member Functions

 LockHandle ()
 Create no-op lock.
 
 ~LockHandle ()
 Destructor.
 
 LockHandle (LockHandle &&other) noexcept
 Move constructor.
 
LockHandleoperator= (LockHandle &&other) noexcept
 Move assignment operator.
 
 LockHandle (const LockHandle &other)
 Copy constructor.
 
LockHandleoperator= (const LockHandle &other)
 Assignment operator.
 

Friends

class AudioDevice
 

Detailed Description

SDL2pp::AudioDevice lock.

Audio devices may be locked, which means that audio callback will not be called in a locked state, allowing to change data it accesses in a thread-safe way.

This class represents the lock and controls its lifetime as the lock is released as soon as LockHandle is destroyed.

Usage example:

{
// Some audio data is loaded
SDL2pp::Wav audiodata;
// Audio device is created, its callback accesses our audio data
SDL2pp::AudioDevice dev(..., [&audiodata](){...});
dev.Pause(false); // playback starts, the callback is called periodically
{
// Now audiodata may be safely modified, no callback will be called to access it
}
// At this point lock is released, playback continues
}
SDL2pp::AudioDevice lock.
Definition: AudioDevice.hh:86
Audio device.
Definition: AudioDevice.hh:50
AudioDevice & Pause(bool pause_on)
Pause or unpause audio playback.
Definition: AudioDevice.cc:91
Chunk of audio data read from a .WAV file
Definition: Wav.hh:52

Constructor & Destructor Documentation

◆ LockHandle() [1/3]

SDL2pp::AudioDevice::LockHandle::LockHandle ( )

Create no-op lock.

This may be initialized with real lock later via move assignment

◆ ~LockHandle()

SDL2pp::AudioDevice::LockHandle::~LockHandle ( )

Destructor.

Releases the lock

See also
http://wiki.libsdl.org/SDL_UnlockAudioDevice

◆ LockHandle() [2/3]

SDL2pp::AudioDevice::LockHandle::LockHandle ( AudioDevice::LockHandle &&  other)
noexcept

Move constructor.

Parameters
[in]otherSDL2pp::AudioDevice::LockHandle to move data from

◆ LockHandle() [3/3]

SDL2pp::AudioDevice::LockHandle::LockHandle ( const LockHandle other)

Copy constructor.

Parameters
[in]otherSDL2pp::AudioDevice::LockHandle to copy data from

Member Function Documentation

◆ operator=() [1/2]

AudioDevice::LockHandle & SDL2pp::AudioDevice::LockHandle::operator= ( const LockHandle other)

Assignment operator.

Parameters
[in]otherSDL2pp::AudioDevice::LockHandle to copy data from
Returns
Reference to self

◆ operator=() [2/2]

AudioDevice::LockHandle & SDL2pp::AudioDevice::LockHandle::operator= ( AudioDevice::LockHandle &&  other)
noexcept

Move assignment operator.

Parameters
[in]otherSDL2pp::AudioDevice::LockHandle to move data from
Returns
Reference to self

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