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

#include <buffered_content_source.hpp>

Classes

struct  Stats

Public Member Functions

 BufferedContentSource ()=default
 ~BufferedContentSource ()
 BufferedContentSource (const BufferedContentSource &)=delete
BufferedContentSource & operator= (const BufferedContentSource &)=delete
bool prepare (const timeline::ProductionDeclaration &declaration, const BufferedContentSourceConfig &config, BufferedContentProducer producer)
 Control thread.
void release () noexcept
 Control thread. Stops the producer and frees all storage.
bool seek (std::uint64_t frame, BufferedContentEpoch epoch)
 Control thread; no pull() may be in flight.
bool loop_wrap (BufferedContentEpoch epoch)
 Control thread.
void cancel_production () noexcept
 Control thread.
std::uint64_t pull (audio::BufferView< float > destination, std::uint64_t frames) noexcept
 Audio thread.
std::uint64_t pump_background () noexcept
 Background or host thread.
bool prepared () const noexcept
const timeline::ProductionDeclaration & declaration () const noexcept
std::uint64_t declared_frames () const noexcept
BufferedContentEpoch current_epoch () const noexcept
 The epoch production currently belongs to. RT-safe.
std::uint64_t loop_start_frame () const noexcept
 Declared loop region; both zero when no loop is declared.
std::uint64_t loop_end_frame () const noexcept
std::uint64_t position () const noexcept
 Audio-thread position in content frames of the current epoch.
bool exhausted () const noexcept
 True once every declared frame has been accounted for, produced or not.
Stats stats () const noexcept

Static Public Member Functions

static std::uint64_t lookahead_frames (const timeline::ProductionDeclaration &declaration, std::uint32_t sample_rate) noexcept
 Frames the declaration's wall-clock lookahead covers at sample_rate.

Constructor & Destructor Documentation

◆ BufferedContentSource() [1/2]

pulp::playback::BufferedContentSource::BufferedContentSource ( )
default

◆ ~BufferedContentSource()

pulp::playback::BufferedContentSource::~BufferedContentSource ( )
inline

◆ BufferedContentSource() [2/2]

pulp::playback::BufferedContentSource::BufferedContentSource ( const BufferedContentSource & )
delete

Member Function Documentation

◆ cancel_production()

void pulp::playback::BufferedContentSource::cancel_production ( )
inlinenoexcept

Control thread.

Asks the in-flight producer call to stop through its token and waits for it — bounded by one chunk: a cooperative producer returns early, one that never checks its token finishes the chunk. The interrupted chunk publishes nothing, so produced and starved counters stay coherent with the play cursor, and the next pump retries the same position. Cancellation does not latch: production resumes on the next pump. Use seek() or release() to end production.

◆ current_epoch()

BufferedContentEpoch pulp::playback::BufferedContentSource::current_epoch ( ) const
inlinenoexcept

The epoch production currently belongs to. RT-safe.

◆ declaration()

const timeline::ProductionDeclaration & pulp::playback::BufferedContentSource::declaration ( ) const
inlinenoexcept

◆ declared_frames()

std::uint64_t pulp::playback::BufferedContentSource::declared_frames ( ) const
inlinenoexcept

◆ exhausted()

bool pulp::playback::BufferedContentSource::exhausted ( ) const
inlinenoexcept

True once every declared frame has been accounted for, produced or not.

◆ lookahead_frames()

std::uint64_t pulp::playback::BufferedContentSource::lookahead_frames ( const timeline::ProductionDeclaration & declaration,
std::uint32_t sample_rate )
inlinestaticnoexcept

Frames the declaration's wall-clock lookahead covers at sample_rate.

◆ loop_end_frame()

std::uint64_t pulp::playback::BufferedContentSource::loop_end_frame ( ) const
inlinenoexcept

◆ loop_start_frame()

std::uint64_t pulp::playback::BufferedContentSource::loop_start_frame ( ) const
inlinenoexcept

Declared loop region; both zero when no loop is declared.

◆ loop_wrap()

bool pulp::playback::BufferedContentSource::loop_wrap ( BufferedContentEpoch epoch)
inline

Control thread.

Restarts production at the declared loop head under a strictly newer epoch — the wrap half of a loop the transport owns. Returns false when no loop is declared or the epoch is not strictly newer.

◆ operator=()

BufferedContentSource & pulp::playback::BufferedContentSource::operator= ( const BufferedContentSource & )
delete

◆ position()

std::uint64_t pulp::playback::BufferedContentSource::position ( ) const
inlinenoexcept

Audio-thread position in content frames of the current epoch.

◆ prepare()

bool pulp::playback::BufferedContentSource::prepare ( const timeline::ProductionDeclaration & declaration,
const BufferedContentSourceConfig & config,
BufferedContentProducer producer )
inline

Control thread.

Rejects a declaration that is not coherent, or that does not declare Buffered — synchronous content has no ring to prepare.

◆ prepared()

bool pulp::playback::BufferedContentSource::prepared ( ) const
inlinenoexcept

◆ pull()

std::uint64_t pulp::playback::BufferedContentSource::pull ( audio::BufferView< float > destination,
std::uint64_t frames )
inlinenoexcept

Audio thread.

Emits up to frames frames into destination and zero-fills whatever the producer did not supply, counting the shortfall. Returns the number of produced (non-zero-filled) frames.

◆ pump_background()

std::uint64_t pulp::playback::BufferedContentSource::pump_background ( )
inlinenoexcept

Background or host thread.

Runs the producer once toward topping the ring up, and returns the number of frames it pushed. Drive this directly when the owned thread is disabled.

◆ release()

void pulp::playback::BufferedContentSource::release ( )
inlinenoexcept

Control thread. Stops the producer and frees all storage.

◆ seek()

bool pulp::playback::BufferedContentSource::seek ( std::uint64_t frame,
BufferedContentEpoch epoch )
inline

Control thread; no pull() may be in flight.

Repositions production to content frame frame under epoch: the in-flight producer call is asked to stop and whatever it produced for the superseded epoch is discarded with the old ring, a fresh ring is primed at the new position, and the declared preroll is filled before the call returns. epoch must be nonzero and strictly newer than current_epoch(). Returns false on an invalid epoch, an out-of-range frame, or a preroll that cannot fit the remaining content — all without disturbing the current position — and false leaving the source released when the producer could not fill the declared preroll.

◆ stats()

Stats pulp::playback::BufferedContentSource::stats ( ) const
inlinenoexcept

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