diff --git a/CHANGELOG.md b/CHANGELOG.md index fffef26..68e86b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ #Changelog +## bliss 0.6.7 +* Fix compatibility for ffmpeg 6.0, and bump ffmpeg version to 6.0 + ## bliss 0.6.6 * Add a `delete_everything_else` function in `library`'s update functions. * Use Rust 2021 diff --git a/Cargo.lock b/Cargo.lock index 9550991..281004d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,9 +71,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bindgen" -version = "0.59.2" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ "bitflags", "cexpr", @@ -86,6 +86,7 @@ dependencies = [ "regex 1.7.1", "rustc-hash", "shlex", + "syn", ] [[package]] @@ -96,7 +97,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bliss-audio" -version = "0.6.6" +version = "0.6.7" dependencies = [ "anyhow", "bliss-audio-aubio-rs", @@ -105,6 +106,7 @@ dependencies = [ "dirs", "env_logger", "ffmpeg-next", + "ffmpeg-sys-next", "glob", "indicatif", "lazy_static 1.4.0", @@ -456,9 +458,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "ffmpeg-next" -version = "5.1.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a80971eee67be0079a1c8890bde68226fe9bd0441740fd6ddd0cee131486b321" +checksum = "8af03c47ad26832ab3aabc4cdbf210af3d3b878783edd5a7ba044ba33aab7a60" dependencies = [ "bitflags", "ffmpeg-sys-next", @@ -467,9 +469,9 @@ dependencies = [ [[package]] name = "ffmpeg-sys-next" -version = "5.1.1" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d780b36e092254367e2f1f21191992735c8e23f31a5a5a8678db3a79f775021f" +checksum = "cf650f461ccf130f4eef4927affed703cc387b183bfc4a7dfee86a076c131127" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml index dd228f7..9528def 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "bliss-audio" -version = "0.6.6" +version = "0.6.7" +build = "build.rs" authors = ["Polochon-street "] edition = "2021" license = "GPL-3.0-only" @@ -41,7 +42,8 @@ lazy_static = "1.4.0" rayon = "1.5.0" crossbeam = "0.8.0" noisy_float = "0.2.0" -ffmpeg-next = "5.1.1" +ffmpeg-next = "6.0.0" +ffmpeg-sys-next = { version = "6.0.1", default-features = false } log = "0.4.14" env_logger = "0.8.3" thiserror = "1.0.24" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..a85e15c --- /dev/null +++ b/build.rs @@ -0,0 +1,12 @@ +use std::env; + +fn main() { + for (name, _value) in env::vars() { + if name.starts_with("DEP_FFMPEG_") { + println!( + r#"cargo:rustc-cfg=feature="{}""#, + name["DEP_FFMPEG_".len()..name.len()].to_lowercase() + ); + } + } +} diff --git a/src/library.rs b/src/library.rs index a3ce14a..a0d3b5d 100644 --- a/src/library.rs +++ b/src/library.rs @@ -1051,7 +1051,6 @@ impl Library { internal_analysis: stmt .query_map(params![song_path], |row| row.get(0)) .unwrap() - .into_iter() .map(|x| x.unwrap()) .collect::>() .try_into() diff --git a/src/song.rs b/src/song.rs index e269776..f134007 100644 --- a/src/song.rs +++ b/src/song.rs @@ -459,6 +459,7 @@ impl Song { context.set_threading(Config { kind: ThreadingType::Frame, count: 0, + #[cfg(not(feature = "ffmpeg_6_0"))] safe: true, }); let decoder = context.decoder().audio().map_err(|e| { @@ -519,11 +520,11 @@ impl Song { t => Some(t.to_string()), }; }; - let in_channel_layout = { + let (empty_in_channel_layout, in_channel_layout) = { if decoder.channel_layout() == ChannelLayout::empty() { - ChannelLayout::default(decoder.channels().into()) + (true, ChannelLayout::default(decoder.channels().into())) } else { - decoder.channel_layout() + (false, decoder.channel_layout()) } }; decoder.set_channel_layout(in_channel_layout); @@ -538,6 +539,7 @@ impl Song { in_channel_layout, in_codec_rate, sample_array, + empty_in_channel_layout, ) }); for (s, packet) in ictx.packets() { @@ -646,6 +648,7 @@ fn resample_frame( in_channel_layout: ChannelLayout, in_rate: u32, mut sample_array: Vec, + empty_in_channel_layout: bool, ) -> BlissResult> { let mut resample_context = ffmpeg::software::resampling::context::Context::get( in_codec_format, @@ -660,15 +663,17 @@ fn resample_frame( "while trying to allocate resampling context: {e:?}", )) })?; + let mut resampled = ffmpeg::frame::Audio::empty(); let mut something_happened = false; - for decoded in rx.iter() { - if in_codec_format != decoded.format() + for mut decoded in rx.iter() { + // If the decoded layout is empty, it means we forced the + // "in_channel_layout" to something default, not that + // the format is wrong. + if empty_in_channel_layout && decoded.channel_layout() == ChannelLayout::empty() { + decoded.set_channel_layout(in_channel_layout); + } else if in_codec_format != decoded.format() || (in_channel_layout != decoded.channel_layout()) - // If the decoded layout is empty, it means we forced the - // "in_channel_layout" to something default, not that - // the format is wrong. - && (decoded.channel_layout() != ChannelLayout::empty()) || in_rate != decoded.rate() { warn!("received decoded packet with wrong format; file might be corrupted.");