Skip to main content

proteus_lib/playback/engine/
state.rs

1//! Shared playback state and metrics structures.
2
3/// Buffering configuration for the playback engine.
4#[derive(Debug, Clone, Copy)]
5pub struct PlaybackBufferSettings {
6    pub start_buffer_ms: f32,
7    pub track_eos_ms: f32,
8    pub start_sink_chunks: usize,
9    pub max_sink_chunks: usize,
10    pub startup_silence_ms: f32,
11    pub startup_fade_ms: f32,
12    pub seek_fade_out_ms: f32,
13    pub seek_fade_in_ms: f32,
14    pub inline_effects_transition_ms: f32,
15    pub append_jitter_log_ms: f32,
16    pub effect_boundary_log: bool,
17}
18
19impl PlaybackBufferSettings {
20    /// Create new buffer settings with a given start buffer size (ms).
21    pub fn new(start_buffer_ms: f32) -> Self {
22        Self {
23            start_buffer_ms: start_buffer_ms.max(0.0),
24            track_eos_ms: 1000.0,
25            start_sink_chunks: 0,
26            max_sink_chunks: 0,
27            startup_silence_ms: 0.0,
28            startup_fade_ms: 150.0,
29            seek_fade_out_ms: 30.0,
30            seek_fade_in_ms: 80.0,
31            inline_effects_transition_ms: 25.0,
32            append_jitter_log_ms: 0.0,
33            effect_boundary_log: false,
34        }
35    }
36}
37
38/// Aggregated DSP chain performance metrics used by debug UI.
39#[derive(Debug, Clone, Copy, Default)]
40pub struct DspChainMetrics {
41    pub overrun: bool,
42    pub overrun_ms: f64,
43    pub avg_overrun_ms: f64,
44    pub max_overrun_ms: f64,
45    pub track_key_count: usize,
46    pub finished_track_count: usize,
47    pub prot_key_count: usize,
48    pub chain_ksps: f64,
49    pub avg_chain_ksps: f64,
50    pub min_chain_ksps: f64,
51    pub max_chain_ksps: f64,
52    pub underrun_count: u64,
53    pub underrun_active: bool,
54    pub pop_count: u64,
55    pub clip_count: u64,
56    pub nan_count: u64,
57    pub late_append_count: u64,
58    pub late_append_active: bool,
59}