|
Player12
An open source football management simulator
|
#include <audio_device.h>
Public Member Functions | |
| AudioDevice (Mixer &mixer) | |
| ~AudioDevice () | |
| AudioDevice (const AudioDevice &)=delete | |
| AudioDevice & | operator= (const AudioDevice &)=delete |
| bool | isOpen () |
Private Member Functions | |
| void | open () |
Static Private Member Functions | |
| static void SDLCALL | feed (void *userdata, SDL_AudioStream *stream, int additionalAmount, int totalAmount) |
Private Attributes | |
| Mixer & | mixer |
| std::atomic< SDL_AudioStream * > | stream {nullptr} |
| bool | subsystemStarted = false |
| std::jthread | opener |
| std::array< float, 2 *CHUNK_FRAMES > | chunk {} |
Static Private Attributes | |
| static constexpr int | CHUNK_FRAMES = 512 |
Plays a Mixer on the default output through an SDL audio stream (48 kHz stereo float). SDL pulls audio from its own thread through the stream callback, which renders straight from the mixer. Without an audio device (or with SDL_AUDIODRIVER=dummy) everything still works; nothing is heard. The mixer must outlive the device.
The audio subsystem starts on the constructing (main) thread, as SDL asks; the stream itself opens on a short-lived helper thread because connecting to the sound server can take tens of milliseconds.
|
explicit |
| Audio::AudioDevice::~AudioDevice | ( | ) |
|
delete |
|
staticprivate |
| bool Audio::AudioDevice::isOpen | ( | ) |
Waits for the device to finish opening; true when it plays.
|
private |
|
delete |
|
private |
Callback scratch (audio thread only).
|
staticconstexprprivate |
|
private |
|
private |
|
private |
|
private |