summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/flac.rs10
-rw-r--r--src/main.rs30
2 files changed, 28 insertions, 12 deletions
diff --git a/src/flac.rs b/src/flac.rs
index febdd3d..1c647d6 100644
--- a/src/flac.rs
+++ b/src/flac.rs
@@ -132,7 +132,15 @@ pub fn encode_file(file: &std::path::Path) -> Result<()> {
})
.collect::<Vec<_>>();
}
- Bps::_32 => return Err(anyhow!("how did you get here")),
+ Bps::_32 => {
+ let _ = buf
+ .iter_interleaved()
+ .map(|sample| {
+ hasher.update(sample.to_le_bytes());
+ sample_buf.push(sample);
+ })
+ .collect::<Vec<_>>();
+ }
}
enc.process_interleaved(
diff --git a/src/main.rs b/src/main.rs
index 07b1c89..3f73a25 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,7 @@ mod db;
mod flac;
fn main() {
- if let Err(err) = flac::encode_file(std::path::Path::new("16bit.flac")) {
+ if let Err(err) = flac::encode_file(std::path::Path::new("32bit.flac")) {
println!("{}", err)
};
}
@@ -11,56 +11,64 @@ fn main() {
mod tests {
use super::*;
use metaflac::Tag;
+
#[test]
fn bit16() {
+ std::fs::copy("16bit.flac", "16bit.flac.temp").unwrap();
flac::encode_file(std::path::Path::new("16bit.flac")).unwrap();
- let target_md5 = Tag::read_from_path("16bit.flac.tmp")
+ let target_md5 = Tag::read_from_path("16bit.flac.temp")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- let source_md5 = Tag::read_from_path("16bit.flac")
+ let encoded_md5 = Tag::read_from_path("16bit.flac")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- assert_eq!(target_md5, source_md5);
+ std::fs::remove_file("16bit.flac.temp").unwrap();
+ assert_eq!(target_md5, encoded_md5);
}
+
#[test]
fn bit24() {
+ std::fs::copy("24bit.flac", "24bit.flac.temp").unwrap();
flac::encode_file(std::path::Path::new("24bit.flac")).unwrap();
- let target_md5 = Tag::read_from_path("24bit.flac.tmp")
+ let target_md5 = Tag::read_from_path("24bit.flac.temp")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- let source_md5 = Tag::read_from_path("24bit.flac")
+ let encoded_md5 = Tag::read_from_path("24bit.flac")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- assert_eq!(target_md5, source_md5);
+ std::fs::remove_file("24bit.flac.temp").unwrap();
+ assert_eq!(target_md5, encoded_md5);
}
+
#[test]
- #[should_panic]
fn bit32() {
+ std::fs::copy("32bit.flac", "32bit.flac.temp").unwrap();
flac::encode_file(std::path::Path::new("32bit.flac")).unwrap();
- let target_md5 = Tag::read_from_path("32bit.flac.tmp")
+ let target_md5 = Tag::read_from_path("32bit.flac.temp")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- let source_md5 = Tag::read_from_path("32bit.flac")
+ let encoded_md5 = Tag::read_from_path("32bit.flac")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- assert_eq!(target_md5, source_md5);
+ std::fs::remove_file("32bit.flac.temp").unwrap();
+ assert_eq!(target_md5, encoded_md5);
}
}