Merge pull request #639 from jb-alvarado/master

reset playout status when date differs, set time shift on init, fix #626
This commit is contained in:
jb-alvarado 2024-05-07 07:36:36 +00:00 committed by GitHub
commit c944b5750d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 8 deletions

View File

@ -93,6 +93,16 @@ 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()
.clone_from(&self.json_playlist.date);
}
self.player_control
@ -179,6 +189,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 +248,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;
}

View File

@ -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(),

View File

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

@ -1 +1 @@
Subproject commit 4fca1f262fbfbdaa618caeb1871e547a16770764
Subproject commit d07e284ba71f13a804ef7cbc438c451bcbc8824b