Skip to content

Commit

Permalink
Auto merge of #23204 - jdm:media-backend-init, r=Manishearth
Browse files Browse the repository at this point in the history
Move media backend initialization to process startup

This makes tinkering with the gstreamer backend _way_ more efficient, because it is no longer necessary to rebuild the script crate after every change.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23127
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23204)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Apr 15, 2019
2 parents 1720454 + eebd831 commit 16db41f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
3 changes: 0 additions & 3 deletions components/script/dom/baseaudiocontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,8 +108,6 @@ impl BaseAudioContext {
},
};

ServoMedia::init::<Backend>();

let context = BaseAudioContext {
eventtarget: EventTarget::new_inherited(),
audio_context_impl: ServoMedia::get()
Expand Down
2 changes: 0 additions & 2 deletions components/script/dom/htmlmediaelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -276,7 +275,6 @@ pub enum ReadyState {

impl HTMLMediaElement {
pub fn new_inherited(tag_name: LocalName, prefix: Option<Prefix>, document: &Document) -> Self {
ServoMedia::init::<Backend>();
Self {
htmlelement: HTMLElement::new_inherited(tag_name, prefix, document),
network_state: Cell::new(NetworkState::Empty),
Expand Down
2 changes: 0 additions & 2 deletions components/script/dom/mediadevices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -27,7 +26,6 @@ pub struct MediaDevices {

impl MediaDevices {
pub fn new_inherited() -> MediaDevices {
ServoMedia::init::<Backend>();
MediaDevices {
eventtarget: EventTarget::new_inherited(),
}
Expand Down
2 changes: 0 additions & 2 deletions components/script/dom/rtcpeerconnection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -159,7 +158,6 @@ impl RTCPeerConnection {
RTCPeerConnectionBinding::Wrap,
);
let signaller = this.make_signaller();
ServoMedia::init::<Backend>();
*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) {
Expand Down
2 changes: 2 additions & 0 deletions components/servo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
8 changes: 8 additions & 0 deletions components/servo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -182,6 +184,10 @@ where
// Global configuration options, parsed from the command line.
let opts = opts::get();

if !opts.multiprocess {
ServoMedia::init::<Backend>();
}

// Make sure the gl context is made current.
window.prepare_for_composite();

Expand Down Expand Up @@ -751,6 +757,8 @@ pub fn run_content_process(token: String) {
script::init();
script::init_service_workers(sw_senders);

ServoMedia::init::<Backend>();

unprivileged_content.start_all::<script_layout_interface::message::Msg,
layout_thread::LayoutThread,
script::script_thread::ScriptThread>(
Expand Down

0 comments on commit 16db41f

Please sign in to comment.