diff --git a/CHANGELOG.md b/CHANGELOG.md index 807e75e7..eac8a7d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +# Version 0.18.1 (2024-05-23) + +### Fixed +- Seek no longer hangs if the sink is empty. + # Version 0.18.0 (2024-05-05) ### Changed diff --git a/Cargo.toml b/Cargo.toml index 036ac170..7b7fa6b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rodio" -version = "0.18.0" +version = "0.18.1" license = "MIT OR Apache-2.0" description = "Audio playback library" keywords = ["audio", "playback", "gamedev"] diff --git a/examples/seek_mp3.rs b/examples/seek_mp3.rs index a384d047..5042003c 100644 --- a/examples/seek_mp3.rs +++ b/examples/seek_mp3.rs @@ -15,4 +15,8 @@ fn main() { sink.try_seek(Duration::from_secs(4)).unwrap(); sink.sleep_until_end(); + + // wont do anything since the sound has ended already + sink.try_seek(Duration::from_secs(5)).unwrap(); + println!("seek example ended"); } diff --git a/src/sink.rs b/src/sink.rs index 056b8e65..2d7478b9 100644 --- a/src/sink.rs +++ b/src/sink.rs @@ -53,7 +53,7 @@ impl SeekOrder { S::Item: Sample + Send, { let res = maybe_seekable.try_seek(self.pos); - let _ignore_reciever_dropped = self.feedback.send(res); + let _ignore_receiver_dropped = self.feedback.send(res); } } @@ -222,6 +222,12 @@ impl Sink { pub fn try_seek(&self, pos: Duration) -> Result<(), SeekError> { let (order, feedback) = SeekOrder::new(pos); *self.controls.seek.lock().unwrap() = Some(order); + + if self.sound_count.load(Ordering::Acquire) == 0 { + // No sound is playing, seek will not be performed + return Ok(()); + } + match feedback.recv() { Ok(seek_res) => seek_res, // The feedback channel closed. Probably another seekorder was set diff --git a/tests/seek.rs b/tests/seek.rs index ccbf3cce..27e2d0d3 100644 --- a/tests/seek.rs +++ b/tests/seek.rs @@ -8,7 +8,7 @@ use rstest_reuse::{self, *}; #[template] #[rstest] -// note: disabled, broken decoder see issue: #516 +// note: disabled, broken decoder see issue: #516 and #539 // #[cfg_attr(feature = "symphonia-vorbis"), case("ogg", true, "symphonia")], #[cfg_attr( all(feature = "minimp3", not(feature = "symphonia-mp3")), @@ -23,7 +23,8 @@ use rstest_reuse::{self, *}; case("flac", false, "claxon") )] #[cfg_attr(feature = "symphonia-mp3", case("mp3", true, "symphonia"))] -#[cfg_attr(feature = "symphonia-isomp4", case("m4a", true, "symphonia"))] +// note: disabled, broken decoder see issue: #577 +// #[cfg_attr(feature = "symphonia-isomp4", case("m4a", true, "symphonia"))] #[cfg_attr(feature = "symphonia-wav", case("wav", true, "symphonia"))] #[cfg_attr(feature = "symphonia-flac", case("flac", true, "symphonia"))] fn all_decoders( @@ -35,14 +36,15 @@ fn all_decoders( #[template] #[rstest] -// note: disabled, broken decoder see issue: #516 +// note: disabled, broken decoder see issue: #516 and #539 // #[cfg_attr(feature = "symphonia-vorbis"), case("ogg", true, "symphonia")], #[cfg_attr( all(feature = "wav", not(feature = "symphonia-wav")), case("wav", "hound") )] #[cfg_attr(feature = "symphonia-mp3", case("mp3", "symphonia"))] -#[cfg_attr(feature = "symphonia-isomp4", case("m4a", "symphonia"))] +// note: disabled, broken decoder see issue: #577 +// #[cfg_attr(feature = "symphonia-isomp4", case("m4a", "symphonia"))] #[cfg_attr(feature = "symphonia-wav", case("wav", "symphonia"))] #[cfg_attr(feature = "symphonia-flac", case("flac", "symphonia"))] fn supported_decoders(#[case] format: &'static str, #[case] decoder_name: &'static str) {}