Merge pull request #579 from RustAudio/fix_hang_seek_on_empty_queue

Fix hang seek on empty queue
This commit is contained in:
David Kleingeld 2024-05-23 13:33:33 +02:00 committed by GitHub
commit ee73f6d97d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 6 deletions

View file

@ -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

View file

@ -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"]

View file

@ -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");
}

View file

@ -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

View file

@ -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) {}