Skip to content

Commit

Permalink
Expose AudioSink::empty() (#8145)
Browse files Browse the repository at this point in the history
# 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 <hank@hank.co.in>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
  • Loading branch information
3 people committed Apr 5, 2023
1 parent 6e67d3e commit 28046d5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/bevy_audio/src/sinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 28046d5

Please sign in to comment.