v0.1.10
build / test (push) Waiting to run

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-16 22:48:34 +01:00
1 parent 052a27bc48
commit 528017b0e6
36 files changed
+3394 -216

No files matched your search

+33 -1
View File
@@ -67,6 +67,8 @@ pub struct AppState {
pub acl_refresh: Notify,
/// A stream detection (probe) of channels without known streams is running.
pub probing: AtomicBool,
/// Antenna meter: muxes kept tuned until the given time (mux id → deadline).
pub signal_hold: Mutex<HashMap<i64, std::time::Instant>>,
}
impl AppState {
@@ -112,6 +114,9 @@ impl AppState {
.epg_enabled
.store(settings.epg_ota_enabled, Ordering::Relaxed);
*tuners.linger.lock().unwrap() = Duration::from_secs(settings.tuner_linger_seconds as u64);
tuners
.pid_filter
.store(settings.tuner_pid_filter, Ordering::Relaxed);
let http = reqwest::Client::builder()
.user_agent(concat!("simply-dvb/", env!("CARGO_PKG_VERSION")))
.timeout(Duration::from_secs(120))
@@ -141,6 +146,7 @@ impl AppState {
ffmpeg: Mutex::new(None),
acl_refresh: Notify::new(),
probing: AtomicBool::new(false),
signal_hold: Mutex::new(HashMap::new()),
});
state.detect_ffmpeg().await;
state.refresh_adapters().await?;
@@ -184,17 +190,43 @@ impl AppState {
self.db
.set_setting("config", &serde_json::to_string(&s)?)
.await?;
self.apply_settings(s).await;
Ok(())
}
/// Picks up settings changed in the database by the command line tool
/// (`simply-dvb settings set …`, `access reset-panel`) – checked every few seconds.
pub async fn settings_watch(self: Arc<Self>) {
loop {
tokio::time::sleep(Duration::from_secs(3)).await;
let Ok(Some(raw)) = self.db.get_setting("config").await else {
continue;
};
let Ok(mut s) = serde_json::from_str::<Settings>(&raw) else {
continue;
};
if s.validate().is_err() || s == self.settings() {
continue;
}
tracing::info!("settings changed outside the panel (command line) – applied");
self.apply_settings(s).await;
}
}
async fn apply_settings(&self, s: Settings) {
self.tuners
.epg_enabled
.store(s.epg_ota_enabled, Ordering::Relaxed);
*self.tuners.linger.lock().unwrap() = Duration::from_secs(s.tuner_linger_seconds as u64);
self.tuners
.pid_filter
.store(s.tuner_pid_filter, Ordering::Relaxed);
let ffmpeg_changed = self.settings.read().unwrap().ffmpeg_path != s.ffmpeg_path;
*self.settings.write().unwrap() = s;
self.acl_refresh.notify_one();
if ffmpeg_changed {
self.detect_ffmpeg().await;
}
Ok(())
}
/// Discovers adapters (Linux DVB + virtual) and updates the tuner manager.