|
libSDL2pp
C++ bindings/wrapper for SDL2
|
Audio device. More...
#include <SDL2pp/AudioDevice.hh>
Classes | |
| class | LockHandle |
| SDL2pp::AudioDevice lock. More... | |
Public Types | |
| typedef std::function< void(Uint8 *stream, int len)> | AudioCallback |
| Function type for audio callback. | |
Public Member Functions | |
| AudioDevice (const Optional< std::string > &device, bool iscapture, const AudioSpec &spec, AudioCallback &&callback=AudioCallback()) | |
| Open audio device with specified output format. | |
| AudioDevice (const Optional< std::string > &device, bool iscapture, AudioSpec &spec, int allowed_changes, AudioCallback &&callback=AudioCallback()) | |
| Open audio device with desired output format. | |
| virtual | ~AudioDevice () |
| Destructor. | |
| AudioDevice (AudioDevice &&other) noexcept | |
| Move constructor. | |
| AudioDevice & | operator= (AudioDevice &&other) noexcept |
| Move constructor. | |
| AudioDevice (const AudioDevice &)=delete | |
| Deleted copy constructor. | |
| AudioDevice & | operator= (const AudioDevice &)=delete |
| Deleted assignment operator. | |
| SDL_AudioDeviceID | Get () const |
| Get managed audio device ID. | |
| AudioDevice & | Pause (bool pause_on) |
| Pause or unpause audio playback. | |
| SDL_AudioStatus | GetStatus () const |
| Get playback status. | |
| AudioDevice & | ChangeCallback (AudioCallback &&callback) |
| Replace audio callback. | |
| LockHandle | Lock () |
| Lock audio device to prevent it from calling audio callback. | |
| AudioDevice & | QueueAudio (const void *data, Uint32 len) |
| Queue more audio for a non-callback device. | |
| AudioDevice & | ClearQueuedAudio () |
| Drop queued audio. | |
| Uint32 | GetQueuedAudioSize () const |
| Get number of bytes of still-queued audio. | |
Audio device.
This class provides access to basic SDL (not SDL_mixer!) audio functionality.
| SDL2pp::AudioDevice::AudioDevice | ( | const Optional< std::string > & | device, |
| bool | iscapture, | ||
| const AudioSpec & | spec, | ||
| AudioDevice::AudioCallback && | callback = AudioCallback() |
||
| ) |
Open audio device with specified output format.
| [in] | device | Name of the device to open |
| [in] | iscapture | Non-zero to open device for recording (SDL2 doesn't support this yet) |
| [in] | spec | Audio output format |
| [in] | callback | Callback which will feed audio to the device |
| SDL2pp::Exception |
| SDL2pp::AudioDevice::AudioDevice | ( | const Optional< std::string > & | device, |
| bool | iscapture, | ||
| AudioSpec & | spec, | ||
| int | allowed_changes, | ||
| AudioDevice::AudioCallback && | callback = AudioCallback() |
||
| ) |
Open audio device with desired output format.
| [in] | device | Name of the device to open |
| [in] | iscapture | Non-zero to open device for recording (SDL2 doesn't support this yet) |
| [in] | allowed_changes | Flag mask specifying which audio format properties may change |
| [in,out] | spec | Desired audio output format (may be changed) |
| [in] | callback | Callback which will feed audio to the device |
| SDL2pp::Exception |
|
noexcept |
Move constructor.
| [in] | other | SDL2pp::AudioDevice to move data from |
|
delete |
Deleted copy constructor.
This class is not copyable
| AudioDevice & SDL2pp::AudioDevice::ChangeCallback | ( | AudioDevice::AudioCallback && | callback | ) |
Replace audio callback.
| [in] | callback | New audio callback |
| AudioDevice & SDL2pp::AudioDevice::ClearQueuedAudio | ( | ) |
| SDL_AudioDeviceID SDL2pp::AudioDevice::Get | ( | ) | const |
Get managed audio device ID.
| Uint32 SDL2pp::AudioDevice::GetQueuedAudioSize | ( | ) | const |
Get number of bytes of still-queued audio.
| SDL_AudioStatus SDL2pp::AudioDevice::GetStatus | ( | ) | const |
Get playback status.
| AudioDevice::LockHandle SDL2pp::AudioDevice::Lock | ( | ) |
Lock audio device to prevent it from calling audio callback.
The device remains locked for the lifetime of returned LockHandle
Recursive locking is allowed
|
noexcept |
Move constructor.
| [in] | other | SDL2pp::AudioDevice to move data from |
|
delete |
Deleted assignment operator.
This class is not copyable
| AudioDevice & SDL2pp::AudioDevice::Pause | ( | bool | pause_on | ) |
Pause or unpause audio playback.
| [in] | pause_on | Whether audio should be paused |
| AudioDevice & SDL2pp::AudioDevice::QueueAudio | ( | const void * | data, |
| Uint32 | len | ||
| ) |
Queue more audio for a non-callback device.
| [in] | data | Data to queue for later playback |
| [in] | len | Data length in bytes (not samples!) |
| SDL2pp::Exception |