diff --git a/src/main.rs b/src/main.rs index a14d580..366e1e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,7 +50,7 @@ use crate::recording_state::RecordingState; const AUDIO_SHEBANG: u16 = 1; const EXPECTED_RP2040_FIRMWARE_HASH: &str = include_str!("../_releases/tc2-firmware.sha256"); -const EXPECTED_RP2040_FIRMWARE_VERSION: u32 = 16; +const EXPECTED_RP2040_FIRMWARE_VERSION: u32 = 17; const EXPECTED_ATTINY_FIRMWARE_VERSION: u8 = 1; const SEGMENT_LENGTH: usize = 9760; diff --git a/src/save_cptv.rs b/src/save_cptv.rs index 117f9bf..04b574a 100644 --- a/src/save_cptv.rs +++ b/src/save_cptv.rs @@ -8,7 +8,10 @@ use std::io::prelude::*; use std::{fs, thread}; use thread_priority::{ThreadBuilderExt, ThreadPriority}; -pub fn save_cptv_file_to_disk(cptv_bytes: Vec, output_dir: &str) { +pub fn save_cptv_file_to_disk(mut cptv_bytes: Vec, output_dir: &str) { + { + cptv_bytes.shrink_to_fit(); + } let output_dir = String::from(output_dir); let _ = thread::Builder::new().name("cptv-save".to_string()).spawn_with_priority( ThreadPriority::Min, @@ -29,22 +32,23 @@ pub fn save_cptv_file_to_disk(cptv_bytes: Vec, output_dir: &str) { output_dir, recording_date_time.format("%Y-%m-%d--%H-%M-%S") ); - let decoder = MultiGzDecoder::new(&cptv_bytes[..]); - let mut encoder = GzEncoder::new(decoder, Compression::default()); - let mut new_cptv_bytes = Vec::new(); - encoder.read_to_end(&mut new_cptv_bytes).unwrap(); + //very slow and cpu intensive offered 18% saving on a 10 minute recording + // let decoder = MultiGzDecoder::new(&cptv_bytes[..]); + // let mut encoder = GzEncoder::new(decoder, Compression::default()); + // let mut new_cptv_bytes = Vec::new(); + // encoder.read_to_end(&mut new_cptv_bytes).unwrap(); - // Only use the re-compressed file if it actually got smaller. - if new_cptv_bytes.len() > cptv_bytes.len() { - new_cptv_bytes = cptv_bytes; - } + // // Only use the re-compressed file if it actually got smaller. + // if new_cptv_bytes.len() > cptv_bytes.len() { + // new_cptv_bytes = cptv_bytes; + // } // If the file already exists, don't re-save it. let is_existing_file = match fs::metadata(&path) { - Ok(metadata) => metadata.len() as usize == new_cptv_bytes.len(), + Ok(metadata) => metadata.len() as usize == cptv_bytes.len(), Err(_) => false, }; if !is_existing_file { - match fs::write(&path, &new_cptv_bytes) { + match fs::write(&path, &cptv_bytes) { Ok(()) => { info!("Saved CPTV file {}", path); }