audio: Remove AudioBackend::stop_sounds_with_handle/is_sound_playing_with_handle
This commit is contained in:
parent
da2dd3b36c
commit
95ce2abf17
|
@ -535,7 +535,8 @@ fn stop<'gc>(
|
|||
.character_by_export_name(&name)
|
||||
{
|
||||
// Stop all sounds with the given name.
|
||||
activation.context.audio.stop_sounds_with_handle(*sound);
|
||||
let sound = *sound;
|
||||
activation.context.stop_sounds_with_handle(sound);
|
||||
} else {
|
||||
avm_warn!(activation, "Sound.stop: Sound '{}' not found", name);
|
||||
}
|
||||
|
|
|
@ -69,15 +69,6 @@ pub trait AudioBackend: Downcast {
|
|||
/// Good ol' stopAllSounds() :-)
|
||||
fn stop_all_sounds(&mut self);
|
||||
|
||||
/// Stops all active sound instances of a particular sound.
|
||||
/// Used by SWF `StartSound` tag with `SoundEvent::Stop`.
|
||||
fn stop_sounds_with_handle(&mut self, handle: SoundHandle);
|
||||
|
||||
/// Returns whether a sound clip is playing.
|
||||
/// Used by SWF `StartSouynd` tag with `SoundEvent:Start`,
|
||||
/// which only plays a sound if that sound is not already playing.
|
||||
fn is_sound_playing_with_handle(&mut self, handle: SoundHandle) -> bool;
|
||||
|
||||
/// Get the position of a sound instance in milliseconds.
|
||||
/// Returns `None` if ther sound is not/no longer playing
|
||||
fn get_sound_position(&self, instance: SoundInstanceHandle) -> Option<u32>;
|
||||
|
@ -151,11 +142,6 @@ impl AudioBackend for NullAudioBackend {
|
|||
self.streams.remove(stream);
|
||||
}
|
||||
fn stop_all_sounds(&mut self) {}
|
||||
fn stop_sounds_with_handle(&mut self, _handle: SoundHandle) {}
|
||||
fn is_sound_playing_with_handle(&mut self, _handle: SoundHandle) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn get_sound_position(&self, _instance: SoundInstanceHandle) -> Option<u32> {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -424,12 +424,6 @@ impl AudioBackend for CpalAudioBackend {
|
|||
sound_instances.clear();
|
||||
}
|
||||
|
||||
fn stop_sounds_with_handle(&mut self, handle: SoundHandle) {
|
||||
let mut sound_instances = self.sound_instances.lock().unwrap();
|
||||
let handle = Some(handle);
|
||||
sound_instances.retain(|_, instance| instance.handle != handle);
|
||||
}
|
||||
|
||||
fn get_sound_position(&self, instance: SoundInstanceHandle) -> Option<u32> {
|
||||
let sound_instances = self.sound_instances.lock().unwrap();
|
||||
if let Some(_instance) = sound_instances.get(instance) {
|
||||
|
|
|
@ -77,6 +77,7 @@ type Decoder = Box<dyn Iterator<Item = [i16; 2]>>;
|
|||
/// a stream sound (`SoundStreamBlock`).
|
||||
struct SoundInstance {
|
||||
/// Handle to the sound clip.
|
||||
#[allow(dead_code)]
|
||||
handle: Option<SoundHandle>,
|
||||
|
||||
/// Format of the sound.
|
||||
|
@ -986,24 +987,6 @@ impl AudioBackend for WebAudioBackend {
|
|||
})
|
||||
}
|
||||
|
||||
fn stop_sounds_with_handle(&mut self, handle: SoundHandle) {
|
||||
SOUND_INSTANCES.with(|instances| {
|
||||
let mut instances = instances.borrow_mut();
|
||||
let handle = Some(handle);
|
||||
instances.retain(|_, instance| instance.handle != handle);
|
||||
})
|
||||
}
|
||||
|
||||
fn is_sound_playing_with_handle(&mut self, handle: SoundHandle) -> bool {
|
||||
SOUND_INSTANCES.with(|instances| {
|
||||
let instances = instances.borrow();
|
||||
let handle = Some(handle);
|
||||
instances
|
||||
.iter()
|
||||
.any(|(_, instance)| instance.handle == handle)
|
||||
})
|
||||
}
|
||||
|
||||
fn get_sound_position(&self, instance: SoundInstanceHandle) -> Option<u32> {
|
||||
SOUND_INSTANCES.with(|instances| {
|
||||
let instances = instances.borrow();
|
||||
|
|
Loading…
Reference in New Issue