From 92833c21cef4ad413aa45e274ed0cc8a7f6b12cc Mon Sep 17 00:00:00 2001 From: Didier Date: Sun, 7 May 2023 21:16:12 +0200 Subject: [PATCH] fix: made threads and niceness also optional. --- src/configuration/ffmpeg.rs | 4 ++-- src/configuration/mod.rs | 10 +++++----- src/main.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/configuration/ffmpeg.rs b/src/configuration/ffmpeg.rs index 8b4dde3..7fb802d 100644 --- a/src/configuration/ffmpeg.rs +++ b/src/configuration/ffmpeg.rs @@ -14,8 +14,8 @@ impl ConfigFFmpeg { audio_codec: self.output.audio.codec.clone(), audio_bitrate: if self.output.audio.bitrate > 0 { Some(self.output.audio.bitrate) } else { None }, - threads: if self.process.threads > 0 { Some(self.process.threads) } else { None }, - niceness: if self.process.niceness > 0 { Some(self.process.niceness) } else { None }, + threads: if self.process.threads.unwrap_or(0) > 0 { Some(self.process.threads.unwrap_or(0)) } else { None }, + niceness: if self.process.niceness.unwrap_or(0) > 0 { Some(self.process.niceness.unwrap_or(0)) } else { None }, } } } \ No newline at end of file diff --git a/src/configuration/mod.rs b/src/configuration/mod.rs index b1ea78b..d99717c 100644 --- a/src/configuration/mod.rs +++ b/src/configuration/mod.rs @@ -44,8 +44,8 @@ pub struct ConfigFiles { #[derive(Serialize, Deserialize, Debug)] pub struct ConfigFFmpegProcess { - pub threads: u8, - pub niceness: u8, + pub threads: Option, + pub niceness: Option, } #[derive(Serialize, Deserialize, Debug)] @@ -106,8 +106,8 @@ impl Config { ffmpeg: ConfigFFmpeg { path: String::from("/usr/bin/ffmpeg"), process: ConfigFFmpegProcess { - threads: 0, - niceness: 0, + threads: Some(0), + niceness: Some(0), }, output: ConfigFFmpegOutput { format: String::from("webm"), @@ -134,7 +134,7 @@ impl Config { } } } - + pub fn is_debug(&self) -> bool { match self.debug { Some(debug) => debug, diff --git a/src/main.rs b/src/main.rs index 62fd18a..8a94ad1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,8 +44,8 @@ fn main() { info!("Processing file {}.", job.input); let mut child = job.run(&config.ffmpeg).unwrap(); - if (config.ffmpeg.process.niceness > 0) { - renice(child.id(), config.ffmpeg.process.niceness) + if (config.ffmpeg.process.niceness.unwrap_or(0)) > 0 { + renice(child.id(), config.ffmpeg.process.niceness.unwrap_or(0)) .expect("Failed to renice process."); } child.wait().expect("Failed to wait for process.");