Skip to content

Engine → Audio → null_backend.h

null_backend

Syntax

class CONJURE_API null_backend final : public audio_backend

Inheritance Hierarchy

audio_backend → null_backend

Constructors

AccessSignatureDescription
publicnull_backend();

Destructors

AccessSignatureDescription
public~null_backend() override;

Variables

AccessNameTypeDefaultDescription
privatemCapturedstd::vector<f32>{}
privatemCaptureFramesu320
privatemDescbackend_desc{}
privatemFailingStartsu320
privatemFractionalFramesf640.0
privatemRenderBufferstd::vector<f32>{}
privatemStatestd::atomic<device_state>device_state::STOPPED
privatemStatsnull_backend_stats{}

Functions

Public

captured

[[nodiscard]] std::span<const f32> captured() const noexcept;

The captured frames, oldest first, interleaved stereo.

enumerate_devices

[[nodiscard]] core::result<std::vector<audio_device_info>> enumerate_devices() const override;

One device, "Null Output", 48000 Hz stereo, default.

fail_next_starts

void fail_next_starts(
    u32 count) noexcept;

Tests: the next count start() calls fail with DEVICE_START_FAILED and leave the backend STOPPED, like a device that cannot be reopened after a loss.

kind

[[nodiscard]] audio_backend_kind kind() const noexcept override;

output_format

[[nodiscard]] audio_format output_format() const noexcept override;

render_frames

void render_frames(
    u32 frameCount);

Renders exactly frameCount frames, ignoring the clock. Tests use it to step by block.

set_capture_frames

void set_capture_frames(
    u32 frames);

Tests: keep the last frames rendered stereo f32 frames for inspection (0 disables).

simulate_device_loss

void simulate_device_loss() noexcept;

Tests: publishes device_state::LOST, as the miniaudio notification callback does when the OS stops a device. Nothing renders until the next successful start(), which is how the engine's recovery path is exercised headlessly.

start

[[nodiscard]] core::result<void> start(
    const backend_desc &desc) override;

Resets the virtual clock. Fails with INVALID_SETTINGS only when desc.callback is null or desc.format.sampleRate is outside [MIN_SAMPLE_RATE, MAX_SAMPLE_RATE], and with DEVICE_START_FAILED while a fail_next_starts() budget remains.

state

[[nodiscard]] device_state state() const noexcept override;

stats

[[nodiscard]] const null_backend_stats &stats() const noexcept;

The snapshot written by the last update().

stop

void stop() noexcept override;

update

void update(
    f32 deltaSeconds) override;

Renders round(deltaSeconds * sampleRate) frames (fraction carried to the next call) through the callback in MIX_BLOCK_FRAMES blocks. Nothing happens while stopped or for a non-positive delta.

virtual_time

[[nodiscard]] f64 virtual_time() const noexcept;

Seconds of audio rendered since start().

Private

mutable_stats

[[nodiscard]] null_backend_stats &mutable_stats() noexcept;