From 212dfb23548ed79ba759cbe1d9f1cc189dab9f5a Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 8 Jan 2023 16:14:22 +0100 Subject: Rework fl2k buffer size --- src/main.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 38a34d4..0814506 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 by Matthias P. Braendli + * Copyright (C) 2023 by Matthias P. Braendli * * Based on previous work by * Copyright (C) 2022 by Felix Erckenbrecht @@ -245,14 +245,20 @@ fn main() { ) }; - if let Err(e) = source_file.read_exact(&mut buf_u8) { - if e.kind() != std::io::ErrorKind::UnexpectedEof { - eprintln!("Input file read stopped {:?}", e); - } - else { - eprintln!("Input file EOF reached"); + match source_file.read(&mut buf_u8) { + Ok(len) => { + if len == 0 { + if let Err(e_seek) = source_file.rewind() { + eprintln!("Failed to rewind source file: {}", e_seek); + break; + } + } + buf.resize(len, 0); + }, + Err(e) => { + eprintln!("Failed to read source file: {}", e); + break; } - break; } let buf: Vec = buf @@ -271,6 +277,8 @@ fn main() { break; } } + + eprintln!("Leaving input thread"); }); // Read samples, calculate PD and PDSLOPE @@ -326,6 +334,7 @@ fn main() { break; } } + eprintln!("Leaving pd thread"); }); // Read PD and PDSLOPE, interpolate to higher rate @@ -374,6 +383,7 @@ fn main() { } } } + eprintln!("Leaving dds thread"); }); // Main thread, output to file/device -- cgit v1.2.3