Detects a host that calls the audio callback faster than real time. More...
#include <pull_rate_detector.hpp>
Public Types | |
| using | Clock = std::chrono::steady_clock |
Public Member Functions | |
| bool | observe (std::size_t frames, double sample_rate, Clock::time_point now) noexcept |
| Records one callback of frames at sample_rate that started at now and returns whether the host is currently pulling faster than real time. | |
| bool | fast () const noexcept |
| double | speed () const noexcept |
| Audio seconds delivered per wall-clock second over the last full window; 0 until kWindow calls were observed. | |
| void | reset () noexcept |
| Forget every observation (a new stream: prepare, transport restart). | |
Static Public Attributes | |
| static constexpr std::size_t | kWindow = 8 |
| static constexpr double | kEnter = 2.0 |
| static constexpr double | kLeave = 1.25 |
Detects a host that calls the audio callback faster than real time.
A plug-in that renders on a worker thread (an emulator, offloaded DSP) never waits for the worker on a live callback; it plays whatever the worker has finished. A host that bounces or freezes faster than real time without declaring an offline render therefore gets silence, because the calls arrive back to back and the worker cannot keep up. Feed every callback to observe(); while it returns true the callback may wait for the worker as it would for a declared offline render.
The decision covers the last kWindow calls, so a host that splits one device cycle into several back-to-back calls still averages to real time across cycles. Hysteresis keeps a bounce from flapping: the detector enters above kEnter times real time and leaves below kLeave times.
Realtime safe: arithmetic on a fixed ring, no allocation, no lock. One thread (the audio thread) calls observe().
| using pulp::audio::PullRateDetector::Clock = std::chrono::steady_clock |
|
inlinenoexcept |
|
inlinenoexcept |
Records one callback of frames at sample_rate that started at now and returns whether the host is currently pulling faster than real time.
|
inlinenoexcept |
Forget every observation (a new stream: prepare, transport restart).
|
inlinenoexcept |
Audio seconds delivered per wall-clock second over the last full window; 0 until kWindow calls were observed.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |