reset playout status when date differs, set time shift on init, fix #626

This commit is contained in:
jb-alvarado 2024-05-07 09:12:31 +02:00
parent 938c1d36f4
commit 627ac544b4
3 changed files with 16 additions and 7 deletions

View File

@ -93,6 +93,12 @@ impl CurrentProgram {
if let Some(file) = &self.json_playlist.path { if let Some(file) = &self.json_playlist.path {
info!("Read playlist: <b><magenta>{file}</></b>"); info!("Read playlist: <b><magenta>{file}</></b>");
} }
if *self.playout_stat.date.lock().unwrap() != self.json_playlist.date {
self.set_status(self.json_playlist.date.clone());
}
*self.playout_stat.current_date.lock().unwrap() = self.json_playlist.date.clone();
} }
self.player_control self.player_control
@ -179,6 +185,12 @@ impl CurrentProgram {
} }
fn set_status(&mut self, date: String) { fn set_status(&mut self, date: String) {
if *self.playout_stat.date.lock().unwrap() != date
&& *self.playout_stat.time_shift.lock().unwrap() != 0.0
{
info!("Reset playout status");
}
self.playout_stat self.playout_stat
.current_date .current_date
.lock() .lock()
@ -232,10 +244,7 @@ impl CurrentProgram {
let mut time_sec = self.get_current_time(); let mut time_sec = self.get_current_time();
let shift = *self.playout_stat.time_shift.lock().unwrap(); let shift = *self.playout_stat.time_shift.lock().unwrap();
if *self.playout_stat.current_date.lock().unwrap() if shift != 0.0 {
== *self.playout_stat.date.lock().unwrap()
&& shift != 0.0
{
info!("Shift playlist start for <yellow>{shift:.3}</> seconds"); info!("Shift playlist start for <yellow>{shift:.3}</> seconds");
time_sec += shift; time_sec += shift;
} }

View File

@ -1,6 +1,6 @@
use std::{ use std::{
fs::{self, File}, fs::{self, File},
path::PathBuf, path::Path,
process::exit, process::exit,
sync::{atomic::AtomicBool, Arc, Mutex}, sync::{atomic::AtomicBool, Arc, Mutex},
thread, thread,
@ -47,7 +47,7 @@ struct StatusData {
fn status_file(stat_file: &str, playout_stat: &PlayoutStatus) -> Result<(), ProcError> { fn status_file(stat_file: &str, playout_stat: &PlayoutStatus) -> Result<(), ProcError> {
debug!("Start ffplayout v{VERSION}, status file path: <b><magenta>{stat_file}</></b>"); debug!("Start ffplayout v{VERSION}, status file path: <b><magenta>{stat_file}</></b>");
if !PathBuf::from(stat_file).exists() { if !Path::new(stat_file).exists() {
let data = json!({ let data = json!({
"time_shift": 0.0, "time_shift": 0.0,
"date": String::new(), "date": String::new(),

View File

@ -251,7 +251,7 @@ pub fn player(
}; };
} }
debug!("Out of source loop"); trace!("Out of source loop");
sleep(Duration::from_secs(1)); sleep(Duration::from_secs(1));