From 28046d514263ca5e15dc5e25c16a287ffdb0be3a Mon Sep 17 00:00:00 2001 From: Hank Jordan Date: Wed, 5 Apr 2023 17:54:14 -0400 Subject: [PATCH] Expose `AudioSink::empty()` (#8145) # Objective Exposes `empty()` method for `AudioSink`. Based on `0.10.0`, should be a non-breaking change. --- ## Changelog - Expose `empty()` method for `AudioSink` - Add `AudioSink::empty()` example --------- Co-authored-by: hank Co-authored-by: Carter Anderson --- crates/bevy_audio/src/sinks.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/bevy_audio/src/sinks.rs b/crates/bevy_audio/src/sinks.rs index e5847a0fee79c..c84ae6fbd60bd 100644 --- a/crates/bevy_audio/src/sinks.rs +++ b/crates/bevy_audio/src/sinks.rs @@ -60,6 +60,9 @@ pub trait AudioSinkPlayback { /// /// It won't be possible to restart it afterwards. fn stop(&self); + + /// Returns true if this sink has no more sounds to play. + fn empty(&self) -> bool; } /// Asset controlling the playback of a sound @@ -130,6 +133,10 @@ impl AudioSinkPlayback for AudioSink { fn stop(&self) { self.sink.as_ref().unwrap().stop(); } + + fn empty(&self) -> bool { + self.sink.as_ref().unwrap().empty() + } } /// Asset controlling the playback of a sound, or the locations of its listener and emitter. @@ -197,6 +204,10 @@ impl AudioSinkPlayback for SpatialAudioSink { fn stop(&self) { self.sink.as_ref().unwrap().stop(); } + + fn empty(&self) -> bool { + self.sink.as_ref().unwrap().empty() + } } impl SpatialAudioSink {