mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Shutdown player when HTMLMediaElement is dropped
This commit is contained in:
parent
7a67443fcb
commit
36825b82f3
8 changed files with 151 additions and 523 deletions
|
@ -50,7 +50,7 @@ use servo_media::audio::context::{AudioContext, AudioContextOptions, ProcessingS
|
|||
use servo_media::audio::context::{OfflineAudioContextOptions, RealTimeAudioContextOptions};
|
||||
use servo_media::audio::decoder::AudioDecoderCallbacks;
|
||||
use servo_media::audio::graph::NodeId;
|
||||
use servo_media::{Backend, ServoMedia};
|
||||
use servo_media::ServoMedia;
|
||||
use std::cell::Cell;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::mem;
|
||||
|
@ -75,7 +75,7 @@ struct DecodeResolver {
|
|||
pub struct BaseAudioContext {
|
||||
eventtarget: EventTarget,
|
||||
#[ignore_malloc_size_of = "servo_media"]
|
||||
audio_context_impl: AudioContext<Backend>,
|
||||
audio_context_impl: AudioContext,
|
||||
/// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-destination
|
||||
destination: MutNullableDom<AudioDestinationNode>,
|
||||
listener: MutNullableDom<AudioListener>,
|
||||
|
@ -131,7 +131,7 @@ impl BaseAudioContext {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn audio_context_impl(&self) -> &AudioContext<Backend> {
|
||||
pub fn audio_context_impl(&self) -> &AudioContext {
|
||||
&self.audio_context_impl
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ use servo_media::audio::param::ParamType;
|
|||
use servo_media::player::Player;
|
||||
use servo_media::streams::MediaStream as BackendMediaStream;
|
||||
use servo_media::webrtc::WebRtcController;
|
||||
use servo_media::Backend;
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::{Cell, RefCell, UnsafeCell};
|
||||
|
@ -481,7 +480,7 @@ unsafe_no_jsmanaged_fields!(InteractiveWindow);
|
|||
unsafe_no_jsmanaged_fields!(CanvasId);
|
||||
unsafe_no_jsmanaged_fields!(SourceSet);
|
||||
unsafe_no_jsmanaged_fields!(AudioBuffer);
|
||||
unsafe_no_jsmanaged_fields!(AudioContext<Backend>);
|
||||
unsafe_no_jsmanaged_fields!(AudioContext);
|
||||
unsafe_no_jsmanaged_fields!(NodeId);
|
||||
unsafe_no_jsmanaged_fields!(AnalysisEngine, DistanceModel, PanningModel, ParamType);
|
||||
unsafe_no_jsmanaged_fields!(dyn Player);
|
||||
|
|
|
@ -1147,15 +1147,16 @@ impl HTMLMediaElement {
|
|||
action_receiver.to_opaque(),
|
||||
Box::new(move |message| {
|
||||
let event: PlayerEvent = message.to().unwrap();
|
||||
trace!("Player event {:?}", event);
|
||||
let this = trusted_node.clone();
|
||||
task_source
|
||||
.queue_with_canceller(
|
||||
task!(handle_player_event: move || {
|
||||
this.root().handle_player_event(&event);
|
||||
}),
|
||||
&canceller,
|
||||
)
|
||||
.unwrap();
|
||||
if let Err(err) = task_source.queue_with_canceller(
|
||||
task!(handle_player_event: move || {
|
||||
this.root().handle_player_event(&event);
|
||||
}),
|
||||
&canceller,
|
||||
) {
|
||||
warn!("Could not queue player event handler task {:?}", err);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
|
@ -1489,6 +1490,14 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for HTMLMediaElement {
|
||||
fn drop(&mut self) {
|
||||
if let Err(err) = self.player.shutdown() {
|
||||
warn!("Error shutting down player {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-media-networkstate
|
||||
fn NetworkState(&self) -> u16 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue