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

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
ffplayout-engine/src

@ -93,6 +93,12 @@ impl CurrentProgram {
if let Some(file) = &self.json_playlist.path {
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
@ -179,6 +185,12 @@ impl CurrentProgram {
}
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
.current_date
.lock()
@ -232,10 +244,7 @@ impl CurrentProgram {
let mut time_sec = self.get_current_time();
let shift = *self.playout_stat.time_shift.lock().unwrap();
if *self.playout_stat.current_date.lock().unwrap()
== *self.playout_stat.date.lock().unwrap()
&& shift != 0.0
{
if shift != 0.0 {
info!("Shift playlist start for <yellow>{shift:.3}</> seconds");
time_sec += shift;
}

@ -1,6 +1,6 @@
use std::{
fs::{self, File},
path::PathBuf,
path::Path,
process::exit,
sync::{atomic::AtomicBool, Arc, Mutex},
thread,
@ -47,7 +47,7 @@ struct StatusData {
fn status_file(stat_file: &str, playout_stat: &PlayoutStatus) -> Result<(), ProcError> {
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!({
"time_shift": 0.0,
"date": String::new(),

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