2026-02-26 19:58:37 +01:00
|
|
|
//! État partagé du renderer (backend ↔ pipeline)
|
2026-02-09 07:18:13 +01:00
|
|
|
|
|
|
|
|
use parking_lot::RwLock;
|
2026-04-05 15:02:44 +02:00
|
|
|
use std::collections::VecDeque;
|
2026-02-09 07:18:13 +01:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2026-04-05 15:02:44 +02:00
|
|
|
use crate::adapter::DeviceCommand;
|
2026-02-26 19:58:37 +01:00
|
|
|
use crate::messages::PlaybackState;
|
2026-02-09 07:18:13 +01:00
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct RendererState {
|
|
|
|
|
pub playback_state: PlaybackState,
|
|
|
|
|
pub current_uri: Option<String>,
|
|
|
|
|
pub current_metadata: Option<String>,
|
2026-02-21 10:16:49 +01:00
|
|
|
pub next_uri: Option<String>,
|
|
|
|
|
pub next_metadata: Option<String>,
|
2026-02-09 07:18:13 +01:00
|
|
|
pub position: Option<String>,
|
|
|
|
|
pub duration: Option<String>,
|
|
|
|
|
pub volume: u16,
|
|
|
|
|
pub mute: bool,
|
2026-04-05 15:02:44 +02:00
|
|
|
pub pending_commands: VecDeque<DeviceCommand>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RendererState {
|
|
|
|
|
pub fn push_command(&mut self, cmd: DeviceCommand) {
|
|
|
|
|
self.pending_commands.push_back(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn pop_command(&mut self) -> Option<DeviceCommand> {
|
|
|
|
|
self.pending_commands.pop_front()
|
|
|
|
|
}
|
2026-02-09 07:18:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for RendererState {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
playback_state: PlaybackState::Stopped,
|
|
|
|
|
current_uri: None,
|
|
|
|
|
current_metadata: None,
|
2026-02-21 10:16:49 +01:00
|
|
|
next_uri: None,
|
|
|
|
|
next_metadata: None,
|
2026-02-09 07:18:13 +01:00
|
|
|
position: None,
|
|
|
|
|
duration: None,
|
|
|
|
|
volume: 100,
|
|
|
|
|
mute: false,
|
2026-04-05 15:02:44 +02:00
|
|
|
pending_commands: VecDeque::new(),
|
2026-02-09 07:18:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub type SharedState = Arc<RwLock<RendererState>>;
|