diff --git a/CHANGELOG.md b/CHANGELOG.md index 172605d..3800ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## bliss 0.3.2 +* Fixed a rare ffmpeg multithreading bug. + ## bliss 0.3.1 * Show error message when song storage fails in the Library trait. * Added a `distance` module containing euclidean and cosine distance. diff --git a/Cargo.lock b/Cargo.lock index 69e3815..4436fdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,7 +75,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bliss-audio" -version = "0.3.1" +version = "0.3.2" dependencies = [ "bliss-audio-aubio-rs", "crossbeam", diff --git a/Cargo.toml b/Cargo.toml index fc433f5..41a2e7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bliss-audio" -version = "0.3.1" +version = "0.3.2" authors = ["Polochon-street "] edition = "2018" license = "GPL-3.0-only" diff --git a/src/song.rs b/src/song.rs index 7530312..6bb69fc 100644 --- a/src/song.rs +++ b/src/song.rs @@ -23,7 +23,6 @@ use ::log::warn; use core::ops::Index; use crossbeam::thread; use ffmpeg_next::codec::threading::{Config, Type as ThreadingType}; -use ffmpeg_next::software::resampling::context::Context; use ffmpeg_next::util; use ffmpeg_next::util::channel_layout::ChannelLayout; use ffmpeg_next::util::error::Error; @@ -437,23 +436,19 @@ impl Song { } }; codec.set_channel_layout(in_channel_layout); - let resample_context = ffmpeg::software::resampling::context::Context::get( - codec.format(), - in_channel_layout, - codec.rate(), - Sample::F32(Type::Packed), - ffmpeg::util::channel_layout::ChannelLayout::MONO, - SAMPLE_RATE, - ) - .map_err(|e| { - BlissError::DecodingError(format!( - "while trying to allocate resampling context: {:?}", - e - )) - })?; let (tx, rx) = mpsc::channel(); - let child = std_thread::spawn(move || resample_frame(rx, resample_context, sample_array)); + let in_codec_format = codec.format(); + let in_codec_rate = codec.rate(); + let child = std_thread::spawn(move || { + resample_frame( + rx, + in_codec_format, + in_channel_layout, + in_codec_rate, + sample_array, + ) + }); for (s, packet) in format.packets() { if s.index() != stream { continue; @@ -542,9 +537,25 @@ pub(crate) struct InternalSong { fn resample_frame( rx: Receiver