Skip to content

Engine → Audio → decoder.h

streaming_decoder

Syntax

class CONJURE_API streaming_decoder

Constructors

AccessSignatureDescription
publicstreaming_decoder();
publicstreaming_decoder( streaming_decoder &&) noexcept;

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~streaming_decoder();

Variables

AccessNameTypeDefaultDescription
privatemInfoclip_info{}
privatemPositionu640
privatemStatestd::unique_ptr<state>{}

Functions

Public

close

void close() noexcept;

Releases the decoder. Safe to call twice.

info

[[nodiscard]] const clip_info &info() const noexcept;

Format, length and encoding of the open stream (storage STREAMED).

is_open

[[nodiscard]] bool is_open() const noexcept;

True between a successful open() and close().

open

[[nodiscard]] core::result<void> open(
    std::span<const byte> encoded);

Opens a decoder over caller-owned bytes, which must outlive the decoder (or close()). An open decoder is closed first. A container that does not report its length (Ogg Vorbis) is decoded once to count it, which costs a full decode on the calling thread; use the overload below when the length is already known. Same errors as probe().

[[nodiscard]] core::result<void> open(
    std::span<const byte> encoded,
    u64 knownFrameCount);

open() with a length the caller already knows (a probed clip's info.frameCount): the container's own length wins when it reports one, otherwise knownFrameCount is used and nothing is decoded before the first read(). 0 counts as unknown.

position

[[nodiscard]] u64 position() const noexcept;

Frame index the next read() starts at.

read

[[nodiscard]] usize read(
    std::span<f32> out) noexcept;

Decodes up to out.size() / channels frames into interleaved f32; returns the number of frames written (0 at the end of the stream or when closed).

seek

[[nodiscard]] core::result<void> seek(
    u64 frame) noexcept;

Positions the next read at frame. INVALID_STATE when closed, DECODE_FAILED when the decoder refuses the position.

Operator Overloads

Public

operator=

streaming_decoder &operator=(
    streaming_decoder &&) noexcept;