|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
AudioPlayer implementation backed by Apple's Core Audio framework. More...
#include <CoreAudioAudioPlayer.h>
Public Member Functions | |
| CoreAudioAudioPlayer (AudioSettings settings) | |
| Constructs a CoreAudioAudioPlayer with the given audio settings. | |
| ~CoreAudioAudioPlayer () | |
| int | Buffered () override |
| Returns the number of audio frames currently queued in the ring buffer. | |
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 and configures the Core Audio output unit. | |
| void | DoClose () override |
| Stops and disposes of the Core Audio output unit and frees the ring buffer. | |
| void | DoPlay (const uint8_t *buf, size_t len) override |
| Copies interleaved PCM samples into the ring buffer for playback. | |
AudioPlayer implementation backed by Apple's Core Audio framework.
CoreAudioAudioPlayer uses an AudioUnit (kAudioUnitSubType_DefaultOutput) with a render callback to pull interleaved PCM samples from an internal ring buffer. DoPlay() pushes data into the ring buffer, and the Core Audio render callback reads from it on the audio thread.
This backend is only available on Apple platforms (macOS / iOS).
| Ship::CoreAudioAudioPlayer::CoreAudioAudioPlayer | ( | AudioSettings | settings | ) |
Constructs a CoreAudioAudioPlayer with the given audio settings.
| settings | Sample rate, buffer size, desired buffered frames, and channel mode. |
| Ship::CoreAudioAudioPlayer::~CoreAudioAudioPlayer | ( | ) |
|
overridevirtual |
Returns the number of audio frames currently queued in the ring buffer.
Implements Ship::AudioPlayer.
|
overrideprotectedvirtual |
Stops and disposes of the Core Audio output unit and frees the ring buffer.
Implements Ship::AudioPlayer.
|
overrideprotectedvirtual |
Opens and configures the Core Audio output unit.
Implements Ship::AudioPlayer.
|
overrideprotectedvirtual |
Copies interleaved PCM samples into the ring buffer for playback.
| buf | Interleaved sample data. |
| len | Length of buf in bytes. |
Implements Ship::AudioPlayer.