From 9f066c52e4dcc8e6d8a84c86d490bdc2672f1078 Mon Sep 17 00:00:00 2001 From: Alban_Moizan_WaveSystem Date: Wed, 31 Jul 2024 14:33:49 +0200 Subject: [PATCH 1/3] Allow retrieving the queue signal in a sink when using crossbeam-channel feature --- src/sink.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/sink.rs b/src/sink.rs index 2de077d1..06de9dcb 100644 --- a/src/sink.rs +++ b/src/sink.rs @@ -102,6 +102,19 @@ impl Sink { /// Appends a sound to the queue of sounds to play. #[inline] pub fn append(&self, source: S) + where + S: Source + Send + 'static, + f32: FromSample, + S::Item: Sample + Send, + { + self.append_with_signal(source); + } + + /// Appends a sound to the queue of sounds to play + /// + /// When using the feature flag `crossbeam-channel` in rodio the `crossbeam_channel::Receiver` will be returned when the sound has finished playing. + #[inline] + pub fn append_with_signal(&self, source: S) -> Option> where S: Source + Send + 'static, f32: FromSample, @@ -159,7 +172,19 @@ impl Sink { .convert_samples(); self.sound_count.fetch_add(1, Ordering::Relaxed); let source = Done::new(source, self.sound_count.clone()); - *self.sleep_until_end.lock().unwrap() = Some(self.queue_tx.append_with_signal(source)); + let rx = self.queue_tx.append_with_signal(source); + + #[cfg(not(feature = "crossbeam-channel"))] + { + *self.sleep_until_end.lock().unwrap() = Some(rx); + None + } + + #[cfg(feature = "crossbeam-channel")] + { + *self.sleep_until_end.lock().unwrap() = Some(rx.clone()); + Some(rx) + } } /// Gets the volume of the sound. From b69d64c198ae72c55f624f3b01e03aaa7f32022e Mon Sep 17 00:00:00 2001 From: Alban_Moizan_WaveSystem Date: Wed, 31 Jul 2024 14:55:01 +0200 Subject: [PATCH 2/3] lint: CI: fixed clippy doc list item missing indentation --- src/conversions/sample.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conversions/sample.rs b/src/conversions/sample.rs index 7ee97624..7f593f7a 100644 --- a/src/conversions/sample.rs +++ b/src/conversions/sample.rs @@ -67,7 +67,7 @@ where /// - For `u16`, silence corresponds to the value `u16::max_value() / 2`. The minimum and maximum /// amplitudes are represented by `0` and `u16::max_value()` respectively. /// - For `f32`, silence corresponds to the value `0.0`. The minimum and maximum amplitudes are -/// represented by `-1.0` and `1.0` respectively. +/// represented by `-1.0` and `1.0` respectively. /// /// You can implement this trait on your own type as well if you wish so. /// From a9254ff2ccc1ab2a141cd2187a5d5786df2cda47 Mon Sep 17 00:00:00 2001 From: Alban_Moizan_WaveSystem Date: Wed, 31 Jul 2024 15:00:15 +0200 Subject: [PATCH 3/3] lint: CI: fixed flt doc comment issue --- src/sink.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sink.rs b/src/sink.rs index 06de9dcb..ac197708 100644 --- a/src/sink.rs +++ b/src/sink.rs @@ -112,7 +112,7 @@ impl Sink { /// Appends a sound to the queue of sounds to play /// - /// When using the feature flag `crossbeam-channel` in rodio the `crossbeam_channel::Receiver` will be returned when the sound has finished playing. + /// When using the feature flag `crossbeam-channel` in rodio the `crossbeam_channel::Receiver` will be returned when the sound has finished playing. #[inline] pub fn append_with_signal(&self, source: S) -> Option> where