Skip to content
Permalink
Browse files

AudioContext shutdown

  • Loading branch information...
ferjm committed Jul 5, 2019
1 parent 8e0160f commit 7ff47365ed6a26d3ed5b55b8b4db7c7edbbda830
Showing with 14 additions and 0 deletions.
  1. +14 −0 components/script/dom/baseaudiocontext.rs
@@ -81,6 +81,7 @@ pub struct BaseAudioContext {
eventtarget: EventTarget,
#[ignore_malloc_size_of = "servo_media"]
audio_context_impl: Arc<Mutex<AudioContext>>,
browsing_context_id: BrowsingContextId,
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
destination: MutNullableDom<AudioDestinationNode>,
listener: MutNullableDom<AudioListener>,
@@ -125,6 +126,7 @@ impl BaseAudioContext {
audio_context_impl: ServoMedia::get()
.unwrap()
.create_audio_context(&client_context_id, options.into()),
browsing_context_id,
destination: Default::default(),
listener: Default::default(),
in_flight_resume_promises_queue: Default::default(),
@@ -542,6 +544,18 @@ impl BaseAudioContextMethods for BaseAudioContext {
}
}

impl Drop for BaseAudioContext {
fn drop(&mut self) {
let client_context_id = ClientContextId::build(
self.browsing_context_id.namespace_id.0,
self.browsing_context_id.index.0.get(),
);
ServoMedia::get()
.unwrap()
.shutdown_audio_context(&client_context_id, self.audio_context_impl.clone());
}
}

impl From<BaseAudioContextOptions> for AudioContextOptions {
fn from(options: BaseAudioContextOptions) -> Self {
match options {

0 comments on commit 7ff4736

Please sign in to comment.
You can’t perform that action at this time.