Fix Servo taking a long time to start on MacOS after a recompile (#30726)

* update init as we initialize media in the background now

With [#405](https://github.com/servo/media/pull/405) changes in
servo/media we move initialization of the media engine to a
background thread. This PR updates the init function in libservo
to adapt that behaviour.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* review fix: simplify code

* Update media

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
atbrakhi 2023-11-14 11:15:02 +01:00 committed by GitHub
parent 098e6a1580
commit 1e5db618d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 23 deletions

View file

@ -112,24 +112,25 @@ mod media_platform {
#[cfg(any(windows, target_os = "macos"))]
pub fn init() {
let mut plugin_dir = std::env::current_exe().unwrap();
plugin_dir.pop();
ServoMedia::init_with_backend(|| {
let mut plugin_dir = std::env::current_exe().unwrap();
plugin_dir.pop();
if cfg!(target_os = "macos") {
plugin_dir.push("lib");
}
if cfg!(target_os = "macos") {
plugin_dir.push("lib");
}
let backend = match GStreamerBackend::init_with_plugins(
plugin_dir,
&gstreamer_plugins::GSTREAMER_PLUGINS,
) {
Ok(b) => b,
Err(e) => {
eprintln!("Error initializing GStreamer: {:?}", e);
std::process::exit(1);
},
};
ServoMedia::init_with_backend(backend);
match GStreamerBackend::init_with_plugins(
plugin_dir,
&gstreamer_plugins::GSTREAMER_PLUGINS,
) {
Ok(b) => b,
Err(e) => {
eprintln!("Error initializing GStreamer: {:?}", e);
std::process::exit(1);
},
}
});
}
#[cfg(not(any(windows, target_os = "macos")))]