libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::CoreAudioAudioPlayer Class Reference

AudioPlayer implementation backed by Apple's Core Audio framework. More...

#include <CoreAudioAudioPlayer.h>

Inheritance diagram for Ship::CoreAudioAudioPlayer:
[legend]
Collaboration diagram for Ship::CoreAudioAudioPlayer:
[legend]

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.
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ CoreAudioAudioPlayer()

Ship::CoreAudioAudioPlayer::CoreAudioAudioPlayer ( AudioSettings  settings)

Constructs a CoreAudioAudioPlayer with the given audio settings.

Parameters
settingsSample rate, buffer size, desired buffered frames, and channel mode.

◆ ~CoreAudioAudioPlayer()

Ship::CoreAudioAudioPlayer::~CoreAudioAudioPlayer ( )

Member Function Documentation

◆ Buffered()

int Ship::CoreAudioAudioPlayer::Buffered ( )
overridevirtual

Returns the number of audio frames currently queued in the ring buffer.

Implements Ship::AudioPlayer.

◆ DoClose()

void Ship::CoreAudioAudioPlayer::DoClose ( )
overrideprotectedvirtual

Stops and disposes of the Core Audio output unit and frees the ring buffer.

Implements Ship::AudioPlayer.

◆ DoInit()

bool Ship::CoreAudioAudioPlayer::DoInit ( )
overrideprotectedvirtual

Opens and configures the Core Audio output unit.

Returns
true if the audio unit was created and started successfully.

Implements Ship::AudioPlayer.

◆ DoPlay()

void Ship::CoreAudioAudioPlayer::DoPlay ( const uint8_t *  buf,
size_t  len 
)
overrideprotectedvirtual

Copies interleaved PCM samples into the ring buffer for playback.

Parameters
bufInterleaved sample data.
lenLength of buf in bytes.

Implements Ship::AudioPlayer.


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