From 3971461280b15d910a9fdf073372678b0939c9a2 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 16 Oct 2023 09:03:40 +0200 Subject: [PATCH] fix break loop, when cmd is None, fix loop filler when filler duration is smaller then original clip --- ffplayout-engine/src/input/playlist.rs | 14 ++------------ ffplayout-engine/src/output/mod.rs | 14 ++++++++++---- lib/src/utils/folder.rs | 25 +++++++++++++++---------- lib/src/utils/logging.rs | 4 ++-- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/ffplayout-engine/src/input/playlist.rs b/ffplayout-engine/src/input/playlist.rs index 38ee38d9..0a702710 100644 --- a/ffplayout-engine/src/input/playlist.rs +++ b/ffplayout-engine/src/input/playlist.rs @@ -612,13 +612,9 @@ pub fn gen_source( filler_media.add_probe(); } - if node.duration > duration && filler_media.duration > duration { - filler_media.out = duration; - } - node.source = filler_media.source; + node.out = duration; node.duration = filler_media.duration; - node.out = filler_media.out; node.cmd = Some(loop_filler(&node)); node.probe = filler_media.probe; } else if filler_source.is_file() { @@ -645,13 +641,7 @@ pub fn gen_source( { // Create placeholder from config filler. node.source = config.storage.filler.clone().to_string_lossy().to_string(); - - node.out = if node.duration > duration && filler_duration > duration { - duration - } else { - filler_duration - }; - + node.out = duration; node.duration = filler_duration; node.cmd = Some(loop_filler(&node)); node.probe = Some(probe); diff --git a/ffplayout-engine/src/output/mod.rs b/ffplayout-engine/src/output/mod.rs index 9cde8c90..f05b6a5a 100644 --- a/ffplayout-engine/src/output/mod.rs +++ b/ffplayout-engine/src/output/mod.rs @@ -89,7 +89,17 @@ pub fn player( break; } + trace!("Decoder CMD: {:?}", node.cmd); + + let mut cmd = match &node.cmd { + Some(cmd) => cmd.clone(), + None => break, + }; + if !node.process.unwrap() { + // process true/false differs from node.cmd = None in that way, + // that source is valid but to show for playing, + // so better skip it and jump to the next one. continue; } @@ -115,10 +125,6 @@ pub fn player( } } - trace!("Decoder CMD: {:?}", node.cmd); - - let mut cmd = if let Some(cmd) = node.cmd { cmd } else { break }; - let mut dec_cmd = vec_strings!["-hide_banner", "-nostats", "-v", &ff_log_format]; dec_cmd.append(&mut cmd); diff --git a/lib/src/utils/folder.rs b/lib/src/utils/folder.rs index 0489a617..74cd251e 100644 --- a/lib/src/utils/folder.rs +++ b/lib/src/utils/folder.rs @@ -3,6 +3,7 @@ use std::sync::{ {Arc, Mutex}, }; +use lexical_sort::natural_lexical_cmp; use rand::{seq::SliceRandom, thread_rng}; use simplelog::*; use walkdir::WalkDir; @@ -190,13 +191,11 @@ pub fn fill_filler_list( { let mut media = Media::new(index, &entry.path().to_string_lossy(), false); - if let Some(control) = player_control.as_ref() { - control.filler_list.lock().unwrap().push(media); - } else { + if player_control.is_none() { media.add_probe(); - - filler_list.push(media); } + + filler_list.push(media); } if config.storage.shuffle { @@ -204,21 +203,27 @@ pub fn fill_filler_list( filler_list.shuffle(&mut rng); } else { - filler_list.sort_by(|d1, d2| d1.source.cmp(&d2.source)); + filler_list.sort_by(|d1, d2| natural_lexical_cmp(&d1.source, &d2.source)); } for (index, item) in filler_list.iter_mut().enumerate() { item.index = Some(index); } + + if let Some(control) = player_control.as_ref() { + *control.filler_list.lock().unwrap() = filler_list.clone(); + } } else if filler_path.is_file() { let mut media = Media::new(0, &config.storage.filler.to_string_lossy(), false); - if let Some(control) = player_control.as_ref() { - control.filler_list.lock().unwrap().push(media); - } else { + if player_control.is_none() { media.add_probe(); + } - filler_list.push(media); + filler_list.push(media); + + if let Some(control) = player_control.as_ref() { + *control.filler_list.lock().unwrap() = filler_list.clone(); } } diff --git a/lib/src/utils/logging.rs b/lib/src/utils/logging.rs index d2e20b4f..88cfafe9 100644 --- a/lib/src/utils/logging.rs +++ b/lib/src/utils/logging.rs @@ -186,10 +186,10 @@ pub fn init_logging( .set_thread_level(LevelFilter::Off) .set_target_level(LevelFilter::Off) .add_filter_ignore_str("hyper") - .add_filter_ignore_str("rustls") - .add_filter_ignore_str("sqlx") .add_filter_ignore_str("reqwest") .add_filter_ignore_str("rpc") + .add_filter_ignore_str("rustls") + .add_filter_ignore_str("sqlx") .add_filter_ignore_str("tiny_http") .set_level_padding(LevelPadding::Left) .set_time_level(time_level)