From eebd831ea5f3bb4ec44b9f85643689700a7ecbde Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 29 Mar 2019 15:31:01 -0400 Subject: [PATCH] Move media backend initialization to process startup. --- Cargo.lock | 3 ++- components/script/Cargo.toml | 1 - components/script/dom/baseaudiocontext.rs | 3 --- components/script/dom/htmlmediaelement.rs | 2 -- components/script/dom/mediadevices.rs | 2 -- components/script/dom/rtcpeerconnection.rs | 2 -- components/servo/Cargo.toml | 2 ++ components/servo/lib.rs | 8 ++++++++ 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9f0bc56820..00cd0de3030 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2398,6 +2398,8 @@ dependencies = [ "script 0.0.1", "script_layout_interface 0.0.1", "script_traits 0.0.1", + "servo-media 0.1.0 (git+https://github.com/servo/media)", + "servo-media-auto 0.1.0 (git+https://github.com/servo/media)", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_url 0.0.1", @@ -3531,7 +3533,6 @@ dependencies = [ "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "servo-media 0.1.0 (git+https://github.com/servo/media)", - "servo-media-auto 0.1.0 (git+https://github.com/servo/media)", "servo_allocator 0.0.1", "servo_arc 0.1.1", "servo_atoms 0.0.1", diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 75115883034..8076d77b7bb 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -97,7 +97,6 @@ servo_atoms = {path = "../atoms"} servo_config = {path = "../config"} servo_geometry = {path = "../geometry" } servo-media = {git = "https://github.com/servo/media"} -servo-media-auto = {git = "https://github.com/servo/media"} servo_rand = {path = "../rand"} servo_url = {path = "../url"} smallvec = { version = "0.6", features = ["std", "union"] } diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index cebda5a26dd..68d578519a9 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -51,7 +51,6 @@ use servo_media::audio::context::{OfflineAudioContextOptions, RealTimeAudioConte use servo_media::audio::decoder::AudioDecoderCallbacks; use servo_media::audio::graph::NodeId; use servo_media::ServoMedia; -use servo_media_auto::Backend; use std::cell::Cell; use std::collections::{HashMap, VecDeque}; use std::mem; @@ -109,8 +108,6 @@ impl BaseAudioContext { }, }; - ServoMedia::init::(); - let context = BaseAudioContext { eventtarget: EventTarget::new_inherited(), audio_context_impl: ServoMedia::get() diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 5b9dc56d03b..3d17b45357b 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -72,7 +72,6 @@ use servo_config::pref; use servo_media::player::frame::{Frame, FrameRenderer}; use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType}; use servo_media::ServoMedia; -use servo_media_auto::Backend; use servo_url::ServoUrl; use std::cell::Cell; use std::collections::VecDeque; @@ -276,7 +275,6 @@ pub enum ReadyState { impl HTMLMediaElement { pub fn new_inherited(tag_name: LocalName, prefix: Option, document: &Document) -> Self { - ServoMedia::init::(); Self { htmlelement: HTMLElement::new_inherited(tag_name, prefix, document), network_state: Cell::new(NetworkState::Empty), diff --git a/components/script/dom/mediadevices.rs b/components/script/dom/mediadevices.rs index 0c8049ff4d1..ab931b4d307 100644 --- a/components/script/dom/mediadevices.rs +++ b/components/script/dom/mediadevices.rs @@ -17,7 +17,6 @@ use crate::dom::promise::Promise; use dom_struct::dom_struct; use servo_media::streams::capture::{Constrain, ConstrainRange, MediaTrackConstraintSet}; use servo_media::ServoMedia; -use servo_media_auto::Backend; use std::rc::Rc; #[dom_struct] @@ -27,7 +26,6 @@ pub struct MediaDevices { impl MediaDevices { pub fn new_inherited() -> MediaDevices { - ServoMedia::init::(); MediaDevices { eventtarget: EventTarget::new_inherited(), } diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 496315f8563..9e5a08256e9 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -41,7 +41,6 @@ use servo_media::webrtc::{ SignalingState, WebRtcController, WebRtcSignaller, }; use servo_media::ServoMedia; -use servo_media_auto::Backend; use std::cell::Cell; use std::rc::Rc; @@ -159,7 +158,6 @@ impl RTCPeerConnection { RTCPeerConnectionBinding::Wrap, ); let signaller = this.make_signaller(); - ServoMedia::init::(); *this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller)); if let Some(ref servers) = config.iceServers { if let Some(ref server) = servers.get(0) { diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 331edb09d89..720408017d7 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -65,6 +65,8 @@ script_layout_interface = {path = "../script_layout_interface"} script_traits = {path = "../script_traits"} servo_config = {path = "../config"} servo_geometry = {path = "../geometry"} +servo-media = {git = "https://github.com/servo/media"} +servo-media-auto = {git = "https://github.com/servo/media"} servo_url = {path = "../url"} style = {path = "../style", features = ["servo"]} style_traits = {path = "../style_traits", features = ["servo"]} diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 5545d291afc..1ccff9db714 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -103,6 +103,8 @@ use profile_traits::time; use script_traits::{ConstellationMsg, SWManagerSenders, ScriptToConstellationChan}; use servo_config::opts; use servo_config::{pref, prefs}; +use servo_media::ServoMedia; +use servo_media_auto::Backend; use std::borrow::Cow; use std::cmp::max; use std::path::PathBuf; @@ -182,6 +184,10 @@ where // Global configuration options, parsed from the command line. let opts = opts::get(); + if !opts.multiprocess { + ServoMedia::init::(); + } + // Make sure the gl context is made current. window.prepare_for_composite(); @@ -751,6 +757,8 @@ pub fn run_content_process(token: String) { script::init(); script::init_service_workers(sw_senders); + ServoMedia::init::(); + unprivileged_content.start_all::(