Merge pull request #408 from jb-alvarado/master

fix break loop, when cmd is None, fix loop filler when filler duration is smaller then original clip
This commit is contained in:
jb-alvarado 2023-10-16 07:16:41 +00:00 committed by GitHub
commit 8a285bfc40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 28 deletions

View File

@ -612,13 +612,9 @@ pub fn gen_source(
filler_media.add_probe(); filler_media.add_probe();
} }
if node.duration > duration && filler_media.duration > duration {
filler_media.out = duration;
}
node.source = filler_media.source; node.source = filler_media.source;
node.out = duration;
node.duration = filler_media.duration; node.duration = filler_media.duration;
node.out = filler_media.out;
node.cmd = Some(loop_filler(&node)); node.cmd = Some(loop_filler(&node));
node.probe = filler_media.probe; node.probe = filler_media.probe;
} else if filler_source.is_file() { } else if filler_source.is_file() {
@ -645,13 +641,7 @@ pub fn gen_source(
{ {
// Create placeholder from config filler. // Create placeholder from config filler.
node.source = config.storage.filler.clone().to_string_lossy().to_string(); node.source = config.storage.filler.clone().to_string_lossy().to_string();
node.out = duration;
node.out = if node.duration > duration && filler_duration > duration {
duration
} else {
filler_duration
};
node.duration = filler_duration; node.duration = filler_duration;
node.cmd = Some(loop_filler(&node)); node.cmd = Some(loop_filler(&node));
node.probe = Some(probe); node.probe = Some(probe);

View File

@ -89,7 +89,17 @@ pub fn player(
break; break;
} }
trace!("Decoder CMD: {:?}", node.cmd);
let mut cmd = match &node.cmd {
Some(cmd) => cmd.clone(),
None => break,
};
if !node.process.unwrap() { 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; 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]; let mut dec_cmd = vec_strings!["-hide_banner", "-nostats", "-v", &ff_log_format];
dec_cmd.append(&mut cmd); dec_cmd.append(&mut cmd);

View File

@ -3,6 +3,7 @@ use std::sync::{
{Arc, Mutex}, {Arc, Mutex},
}; };
use lexical_sort::natural_lexical_cmp;
use rand::{seq::SliceRandom, thread_rng}; use rand::{seq::SliceRandom, thread_rng};
use simplelog::*; use simplelog::*;
use walkdir::WalkDir; use walkdir::WalkDir;
@ -190,35 +191,39 @@ pub fn fill_filler_list(
{ {
let mut media = Media::new(index, &entry.path().to_string_lossy(), false); let mut media = Media::new(index, &entry.path().to_string_lossy(), false);
if let Some(control) = player_control.as_ref() { if player_control.is_none() {
control.filler_list.lock().unwrap().push(media);
} else {
media.add_probe(); media.add_probe();
}
filler_list.push(media); filler_list.push(media);
} }
}
if config.storage.shuffle { if config.storage.shuffle {
let mut rng = thread_rng(); let mut rng = thread_rng();
filler_list.shuffle(&mut rng); filler_list.shuffle(&mut rng);
} else { } 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() { for (index, item) in filler_list.iter_mut().enumerate() {
item.index = Some(index); 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() { } else if filler_path.is_file() {
let mut media = Media::new(0, &config.storage.filler.to_string_lossy(), false); let mut media = Media::new(0, &config.storage.filler.to_string_lossy(), false);
if let Some(control) = player_control.as_ref() { if player_control.is_none() {
control.filler_list.lock().unwrap().push(media);
} else {
media.add_probe(); 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();
} }
} }

View File

@ -186,10 +186,10 @@ pub fn init_logging(
.set_thread_level(LevelFilter::Off) .set_thread_level(LevelFilter::Off)
.set_target_level(LevelFilter::Off) .set_target_level(LevelFilter::Off)
.add_filter_ignore_str("hyper") .add_filter_ignore_str("hyper")
.add_filter_ignore_str("rustls")
.add_filter_ignore_str("sqlx")
.add_filter_ignore_str("reqwest") .add_filter_ignore_str("reqwest")
.add_filter_ignore_str("rpc") .add_filter_ignore_str("rpc")
.add_filter_ignore_str("rustls")
.add_filter_ignore_str("sqlx")
.add_filter_ignore_str("tiny_http") .add_filter_ignore_str("tiny_http")
.set_level_padding(LevelPadding::Left) .set_level_padding(LevelPadding::Left)
.set_time_level(time_level) .set_time_level(time_level)