|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
AudioPlayer implementation backed by SDL2's audio subsystem. More...
#include <SDLAudioPlayer.h>
Public Member Functions | |
| SDLAudioPlayer (AudioSettings settings) | |
| Constructs an SDLAudioPlayer with the given audio settings. | |
| ~SDLAudioPlayer () | |
| int | Buffered () override |
| Returns the number of audio frames currently queued in the SDL audio device. | |
Public Member Functions inherited from Ship::AudioPlayer | |
| AudioPlayer (AudioSettings settings) | |
| Constructs an AudioPlayer with the given configuration. | |
| ~AudioPlayer () | |
| bool | Init () |
| Calls DoInit() and sets the initialised flag on success. | |
| void | Play (const uint8_t *buf, size_t len) |
| Submits a frame of PCM audio to the output device. | |
| bool | IsInitialized () |
| Returns true if Init() has been called and succeeded. | |
| int32_t | GetSampleRate () const |
| Returns the configured output sample rate in Hz. | |
| int32_t | GetSampleLength () const |
| Returns the configured number of samples per audio frame. | |
| int32_t | GetDesiredBuffered () const |
| Returns the target number of frames to keep buffered. | |
| AudioChannelsSetting | GetAudioChannels () const |
| Returns the current channel-output mode. | |
| void | SetSampleRate (int32_t rate) |
| Sets the output sample rate. | |
| void | SetSampleLength (int32_t length) |
| Sets the number of samples per audio frame. | |
| void | SetDesiredBuffered (int32_t size) |
| Sets the target number of buffered frames. | |
| bool | SetAudioChannels (AudioChannelsSetting channels) |
| Changes the channel mode and reinitialises the audio device. | |
| int32_t | GetNumOutputChannels () const |
| Returns the number of output channels implied by the current channel setting. | |
Protected Member Functions | |
| bool | DoInit () override |
| Opens the SDL audio device with the configured settings. | |
| void | DoClose () override |
| Closes the SDL audio device and releases its resources. | |
| void | DoPlay (const uint8_t *buf, size_t len) override |
| Queues interleaved PCM samples to the SDL audio device. | |
AudioPlayer implementation backed by SDL2's audio subsystem.
SDLAudioPlayer uses SDL_OpenAudioDevice to open a platform audio output, then pushes interleaved PCM samples in DoPlay(). It supports both stereo and 6-channel (5.1) output depending on the AudioChannelsSetting configured in AudioPlayer.
This backend is available on all platforms that Ship supports.
|
inline |
Constructs an SDLAudioPlayer with the given audio settings.
| settings | Sample rate, buffer size, desired buffered frames, and channel mode. |
| Ship::SDLAudioPlayer::~SDLAudioPlayer | ( | ) |
|
overridevirtual |
Returns the number of audio frames currently queued in the SDL audio device.
Used by the audio subsystem to decide how many frames to produce per game tick.
Implements Ship::AudioPlayer.
|
overrideprotectedvirtual |
Closes the SDL audio device and releases its resources.
Implements Ship::AudioPlayer.
|
overrideprotectedvirtual |
Opens the SDL audio device with the configured settings.
Implements Ship::AudioPlayer.
|
overrideprotectedvirtual |
Queues interleaved PCM samples to the SDL audio device.
| buf | Interleaved sample data (stereo: L,R,… or surround: FL,FR,C,LFE,SL,SR,…). |
| len | Length of buf in bytes. |
Implements Ship::AudioPlayer.