Migrate `set_frame_rate` into the core `AudioBackend` trait
This commit is contained in:
parent
c1cf73ccb3
commit
2137b9f1fd
|
@ -76,6 +76,13 @@ pub trait AudioBackend {
|
|||
true
|
||||
}
|
||||
fn tick(&mut self) {}
|
||||
|
||||
/// Inform the audio backend of the current stage frame rate.
|
||||
///
|
||||
/// This is only necessary if your particular audio backend needs to know
|
||||
/// what the stage frame rate is. Otherwise, you are free to avoid
|
||||
/// implementing it.
|
||||
fn set_frame_rate(&mut self, frame_rate: f64) {}
|
||||
}
|
||||
|
||||
/// Rust does not auto-impl a Trait for Box<Trait> or Deref<Target=Trait>
|
||||
|
|
|
@ -123,10 +123,6 @@ impl WebAudioBackend {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_frame_rate(&mut self, frame_rate: f64) {
|
||||
self.frame_rate = frame_rate
|
||||
}
|
||||
|
||||
fn start_sound_internal(
|
||||
&mut self,
|
||||
handle: SoundHandle,
|
||||
|
@ -542,6 +538,10 @@ impl WebAudioBackend {
|
|||
}
|
||||
|
||||
impl AudioBackend for WebAudioBackend {
|
||||
fn set_frame_rate(&mut self, frame_rate: f64) {
|
||||
self.frame_rate = frame_rate
|
||||
}
|
||||
|
||||
fn register_sound(&mut self, sound: &swf::Sound) -> Result<SoundHandle, Error> {
|
||||
// Slice off latency seek for MP3 data.
|
||||
let (skip_sample_frames, data) = if sound.format.compression == AudioCompression::Mp3 {
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
};
|
||||
use generational_arena::{Arena, Index};
|
||||
use js_sys::Uint8Array;
|
||||
use ruffle_core::{backend::render::RenderBackend, PlayerEvent};
|
||||
use ruffle_core::{backend::audio::AudioBackend, backend::render::RenderBackend, PlayerEvent};
|
||||
use std::{cell::RefCell, error::Error, num::NonZeroI32};
|
||||
use wasm_bindgen::{prelude::*, JsCast, JsValue};
|
||||
use web_sys::{Element, EventTarget, HtmlCanvasElement, KeyboardEvent, PointerEvent};
|
||||
|
|
Loading…
Reference in New Issue