Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::audio::StreamingSampleSource Class Reference

#include <streaming_sample_source.hpp>

Classes

struct  Stats

Public Member Functions

 StreamingSampleSource ()=default
 ~StreamingSampleSource ()
 StreamingSampleSource (const StreamingSampleSource &)=delete
StreamingSampleSource & operator= (const StreamingSampleSource &)=delete
bool prepare (const StreamingSampleSourceConfig &config, FrameReader reader)
 Allocate buffers, synchronously fill the preload window via reader, and (optionally) start the background reader thread.
bool prepare (const StreamingSampleSourceConfig &config, FrameReaderBinding reader)
void release () noexcept
 Stop the reader thread and free all storage. Control thread only.
bool reset () noexcept
 Rewind to the start of the source (or loop_start) and refill the tail.
std::uint64_t pull (BufferView< float > dest, std::uint64_t frames) noexcept
 Emit frames sequential frames into dest, advancing the play cursor.
bool finished () const noexcept
 True once a non-looping source has played to its end and the tail is drained.
std::uint64_t position () const noexcept
 Current play position in source frames. RT-safe.
bool fully_resident () const noexcept
 True when the whole source fits in the preload window (no streaming).
bool prepared () const noexcept
std::uint32_t channels () const noexcept
std::uint64_t total_frames () const noexcept
std::uint64_t pump_background () noexcept
 Top the streamed-tail ring up toward full using the FrameReader.
Stats stats () const noexcept

Constructor & Destructor Documentation

◆ StreamingSampleSource() [1/2]

pulp::audio::StreamingSampleSource::StreamingSampleSource ( )
default

◆ ~StreamingSampleSource()

pulp::audio::StreamingSampleSource::~StreamingSampleSource ( )

◆ StreamingSampleSource() [2/2]

pulp::audio::StreamingSampleSource::StreamingSampleSource ( const StreamingSampleSource & )
delete

Member Function Documentation

◆ channels()

std::uint32_t pulp::audio::StreamingSampleSource::channels ( ) const
inlinenoexcept

◆ finished()

bool pulp::audio::StreamingSampleSource::finished ( ) const
noexcept

True once a non-looping source has played to its end and the tail is drained.

Always false for a resident loop. RT-safe.

◆ fully_resident()

bool pulp::audio::StreamingSampleSource::fully_resident ( ) const
inlinenoexcept

True when the whole source fits in the preload window (no streaming).

◆ operator=()

StreamingSampleSource & pulp::audio::StreamingSampleSource::operator= ( const StreamingSampleSource & )
delete

◆ position()

std::uint64_t pulp::audio::StreamingSampleSource::position ( ) const
inlinenoexcept

Current play position in source frames. RT-safe.

◆ prepare() [1/2]

bool pulp::audio::StreamingSampleSource::prepare ( const StreamingSampleSourceConfig & config,
FrameReader reader )

Allocate buffers, synchronously fill the preload window via reader, and (optionally) start the background reader thread.

Control thread only. Returns false on invalid config or a failed preload read.

◆ prepare() [2/2]

bool pulp::audio::StreamingSampleSource::prepare ( const StreamingSampleSourceConfig & config,
FrameReaderBinding reader )

◆ prepared()

bool pulp::audio::StreamingSampleSource::prepared ( ) const
inlinenoexcept

◆ pull()

std::uint64_t pulp::audio::StreamingSampleSource::pull ( BufferView< float > dest,
std::uint64_t frames )
noexcept

Emit frames sequential frames into dest, advancing the play cursor.

Returns the number of non-silent frames produced; the remainder of dest is zero-filled (end-of-source, or a streaming underrun, which is counted in stats()). Allocation-free, lock-free, wait-free.

◆ pump_background()

std::uint64_t pulp::audio::StreamingSampleSource::pump_background ( )
noexcept

Top the streamed-tail ring up toward full using the FrameReader.

Called automatically by the owned thread; call it directly when the thread is disabled (tests). Reads at most one read_chunk per invocation that there is room and remaining source for. No-op for resident sources. Returns the number of frames pushed into the ring this call.

◆ release()

void pulp::audio::StreamingSampleSource::release ( )
noexcept

Stop the reader thread and free all storage. Control thread only.

◆ reset()

bool pulp::audio::StreamingSampleSource::reset ( )
noexcept

Rewind to the start of the source (or loop_start) and refill the tail.

Control thread / quiescent only — not RT-safe (it may re-read and resets the background cursor). Returns false if not prepared.

◆ stats()

Stats pulp::audio::StreamingSampleSource::stats ( ) const
noexcept

◆ total_frames()

std::uint64_t pulp::audio::StreamingSampleSource::total_frames ( ) const
inlinenoexcept

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