diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-01-08 16:14:22 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-01-08 16:15:13 +0100 |
commit | 212dfb23548ed79ba759cbe1d9f1cc189dab9f5a (patch) | |
tree | 6cae01dbab115b02023f9767964e6f4602c09803 /src/main.rs | |
parent | c00dbb4579b98e248e99d546268782fa0f72bff0 (diff) | |
download | fl2k_ampliphase-212dfb23548ed79ba759cbe1d9f1cc189dab9f5a.tar.gz fl2k_ampliphase-212dfb23548ed79ba759cbe1d9f1cc189dab9f5a.tar.bz2 fl2k_ampliphase-212dfb23548ed79ba759cbe1d9f1cc189dab9f5a.zip |
Rework fl2k buffer size
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 18 insertions, 8 deletions
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 <matthias.braendli@mpb.li> + * Copyright (C) 2023 by Matthias P. Braendli <matthias.braendli@mpb.li> * * Based on previous work by * Copyright (C) 2022 by Felix Erckenbrecht <eligs@eligs.de> @@ -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<f32> = 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 |