summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock5
-rw-r--r--Cargo.toml3
-rw-r--r--src/flac.rs10
-rw-r--r--src/main.rs30
4 files changed, 30 insertions, 18 deletions
diff --git a/Cargo.lock b/Cargo.lock
index efe0215..dca53dc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -219,7 +219,6 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "symphonia"
version = "0.5.4"
-source = "git+https://github.com/pdeljanov/Symphonia.git?branch=dev-0.6#c7efbcb05dde274d13a50b4f7aac9db4c773f602"
dependencies = [
"lazy_static",
"symphonia-bundle-flac",
@@ -230,7 +229,6 @@ dependencies = [
[[package]]
name = "symphonia-bundle-flac"
version = "0.5.4"
-source = "git+https://github.com/pdeljanov/Symphonia.git?branch=dev-0.6#c7efbcb05dde274d13a50b4f7aac9db4c773f602"
dependencies = [
"log",
"symphonia-common",
@@ -241,7 +239,6 @@ dependencies = [
[[package]]
name = "symphonia-common"
version = "0.5.4"
-source = "git+https://github.com/pdeljanov/Symphonia.git?branch=dev-0.6#c7efbcb05dde274d13a50b4f7aac9db4c773f602"
dependencies = [
"symphonia-core",
"symphonia-metadata",
@@ -250,7 +247,6 @@ dependencies = [
[[package]]
name = "symphonia-core"
version = "0.5.4"
-source = "git+https://github.com/pdeljanov/Symphonia.git?branch=dev-0.6#c7efbcb05dde274d13a50b4f7aac9db4c773f602"
dependencies = [
"bitflags",
"bytemuck",
@@ -263,7 +259,6 @@ dependencies = [
[[package]]
name = "symphonia-metadata"
version = "0.5.4"
-source = "git+https://github.com/pdeljanov/Symphonia.git?branch=dev-0.6#c7efbcb05dde274d13a50b4f7aac9db4c773f602"
dependencies = [
"lazy_static",
"log",
diff --git a/Cargo.toml b/Cargo.toml
index 525b072..cdef9ba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,4 +10,5 @@ flac-bound = { version = "0.5.0", features = ["libflac-noogg"], default-features
i24 = "2.1.0"
md-5 = "0.10.6"
metaflac = "0.2.8"
-symphonia = { git = "https://github.com/pdeljanov/Symphonia.git", branch = "dev-0.6", default-features = false, features = ["flac"] }
+symphonia = { version = "0.5.4", path = "../Symphonia/symphonia", default-features = false, features = ["flac"] }
+#symphonia = { git = "https://github.com/pdeljanov/Symphonia.git", branch = "dev-0.6", default-features = false, features = ["flac"] }
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);
}
}