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

A no-op AudioPlayer used when no audio device is available or audio is disabled. More...

#include <NullAudioPlayer.h>

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

Public Member Functions

 NullAudioPlayer (AudioSettings settings)
 Constructs a NullAudioPlayer with the given audio settings.
 
 ~NullAudioPlayer ()
 
int Buffered () override
 Returns the desired buffered frame count so the game always produces audio.
 
- 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
 Always returns true — no actual device needs to be opened.
 
void DoClose () override
 No-op — nothing to close.
 
void DoPlay (const uint8_t *buf, size_t len) override
 Silently discards all audio data.
 

Detailed Description

A no-op AudioPlayer used when no audio device is available or audio is disabled.

NullAudioPlayer silently discards all audio data. DoInit() succeeds immediately, Buffered() always returns the desired buffered frame count so the game continues to produce audio at the expected rate, and DoPlay() is a no-op.

This backend is always compiled in and is selected as a fallback when every other backend fails to initialise.

Constructor & Destructor Documentation

◆ NullAudioPlayer()

Ship::NullAudioPlayer::NullAudioPlayer ( AudioSettings  settings)
inline

Constructs a NullAudioPlayer with the given audio settings.

Parameters
settingsAudio configuration (rates are accepted but otherwise unused).

◆ ~NullAudioPlayer()

Ship::NullAudioPlayer::~NullAudioPlayer ( )

Member Function Documentation

◆ Buffered()

int Ship::NullAudioPlayer::Buffered ( )
overridevirtual

Returns the desired buffered frame count so the game always produces audio.

Implements Ship::AudioPlayer.

◆ DoClose()

void Ship::NullAudioPlayer::DoClose ( )
overrideprotectedvirtual

No-op — nothing to close.

Implements Ship::AudioPlayer.

◆ DoInit()

bool Ship::NullAudioPlayer::DoInit ( )
overrideprotectedvirtual

Always returns true — no actual device needs to be opened.

Implements Ship::AudioPlayer.

◆ DoPlay()

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

Silently discards all audio data.

Implements Ship::AudioPlayer.


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