зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575883 - Backed out changeset 86f456156bd0. r=kinetik
Going over the RT budget is now handled by demoting the thread instead of crashing. Differential Revision: https://phabricator.services.mozilla.com/D47083 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f68abff937
Коммит
e489af208a
|
@ -8,6 +8,7 @@ use crate::stream;
|
|||
#[cfg(target_os = "linux")]
|
||||
use crate::G_THREAD_POOL;
|
||||
use crate::{ClientStream, CpuPoolInitParams, CPUPOOL_INIT_PARAMS, G_SERVER_FD};
|
||||
use audio_thread_priority::promote_current_thread_to_real_time;
|
||||
use audioipc::codec::LengthDelimitedCodec;
|
||||
use audioipc::frame::{framed, Framed};
|
||||
use audioipc::platformhandle_passing::{framed_with_platformhandles, FramedWithPlatformHandles};
|
||||
|
@ -90,6 +91,14 @@ fn open_server_stream() -> io::Result<audioipc::MessageStream> {
|
|||
}
|
||||
|
||||
fn register_thread(callback: Option<extern "C" fn(*const ::std::os::raw::c_char)>) {
|
||||
match promote_current_thread_to_real_time(0, 48000) {
|
||||
Ok(_) => {
|
||||
info!("Audio thread promoted to real-time.");
|
||||
}
|
||||
Err(_) => {
|
||||
warn!("Could not promote thread to real-time.");
|
||||
}
|
||||
}
|
||||
if let Some(func) = callback {
|
||||
let thr = thread::current();
|
||||
let name = CString::new(thr.name().unwrap()).unwrap();
|
||||
|
|
|
@ -18,6 +18,8 @@ mod stream;
|
|||
|
||||
use crate::context::ClientContext;
|
||||
use crate::stream::ClientStream;
|
||||
#[cfg(target_os = "linux")]
|
||||
use audio_thread_priority::promote_current_thread_to_real_time;
|
||||
use audio_thread_priority::RtPriorityHandle;
|
||||
use audioipc::{PlatformHandle, PlatformHandleType};
|
||||
use cubeb_backend::{capi, ffi};
|
||||
|
@ -107,6 +109,16 @@ pub unsafe extern "C" fn audioipc_init_threads(init_params: *const AudioIpcInitP
|
|||
|
||||
let register_thread = move || {
|
||||
if let Some(func) = thread_create_callback {
|
||||
match promote_current_thread_to_real_time(0, 48000) {
|
||||
Ok(handle) => {
|
||||
G_PRIORITY_HANDLES.with(|handles| {
|
||||
(handles.borrow_mut()).push(handle);
|
||||
});
|
||||
}
|
||||
Err(_) => {
|
||||
warn!("Could not promote audio threads to real-time during initialization.");
|
||||
}
|
||||
}
|
||||
let thr = thread::current();
|
||||
let name = CString::new(thr.name().unwrap()).unwrap();
|
||||
func(name.as_ptr());
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
diff --git a/media/audioipc/client/src/context.rs b/media/audioipc/client/src/context.rs
|
||||
--- a/media/audioipc/client/src/context.rs
|
||||
+++ b/media/audioipc/client/src/context.rs
|
||||
@@ -3,17 +3,16 @@
|
||||
// This program is made available under an ISC-style license. See the
|
||||
// accompanying file LICENSE for details
|
||||
|
||||
use crate::assert_not_in_callback;
|
||||
use crate::stream;
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::G_THREAD_POOL;
|
||||
use crate::{ClientStream, CpuPoolInitParams, CPUPOOL_INIT_PARAMS, G_SERVER_FD};
|
||||
-use audio_thread_priority::promote_current_thread_to_real_time;
|
||||
use audioipc::codec::LengthDelimitedCodec;
|
||||
use audioipc::frame::{framed, Framed};
|
||||
use audioipc::platformhandle_passing::{framed_with_platformhandles, FramedWithPlatformHandles};
|
||||
use audioipc::{core, rpc};
|
||||
use audioipc::{
|
||||
messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage,
|
||||
ServerMessage,
|
||||
};
|
||||
@@ -86,24 +85,16 @@ fn open_server_stream() -> io::Result<au
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Failed to get server connection.",
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn register_thread(callback: Option<extern "C" fn(*const ::std::os::raw::c_char)>) {
|
||||
- match promote_current_thread_to_real_time(0, 48000) {
|
||||
- Ok(_) => {
|
||||
- info!("Audio thread promoted to real-time.");
|
||||
- }
|
||||
- Err(_) => {
|
||||
- warn!("Could not promote thread to real-time.");
|
||||
- }
|
||||
- }
|
||||
if let Some(func) = callback {
|
||||
let thr = thread::current();
|
||||
let name = CString::new(thr.name().unwrap()).unwrap();
|
||||
func(name.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
fn create_thread_pool(init_params: CpuPoolInitParams) -> CpuPool {
|
||||
diff --git a/media/audioipc/client/src/lib.rs b/media/audioipc/client/src/lib.rs
|
||||
--- a/media/audioipc/client/src/lib.rs
|
||||
+++ b/media/audioipc/client/src/lib.rs
|
||||
@@ -13,18 +13,16 @@ extern crate lazy_static;
|
||||
|
||||
#[macro_use]
|
||||
mod send_recv;
|
||||
mod context;
|
||||
mod stream;
|
||||
|
||||
use crate::context::ClientContext;
|
||||
use crate::stream::ClientStream;
|
||||
-#[cfg(target_os = "linux")]
|
||||
-use audio_thread_priority::promote_current_thread_to_real_time;
|
||||
use audio_thread_priority::RtPriorityHandle;
|
||||
use audioipc::{PlatformHandle, PlatformHandleType};
|
||||
use cubeb_backend::{capi, ffi};
|
||||
use futures_cpupool::CpuPool;
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use std::sync::Mutex;
|
||||
@@ -104,26 +102,16 @@ pub unsafe extern "C" fn audioipc_init_t
|
||||
// It is critical that this function waits until the various threads are created, promoted to
|
||||
// real-time, and _then_ return, because the sandbox lockdown happens right after returning
|
||||
// from here.
|
||||
let pair = Arc::new((Mutex::new((*init_params).pool_size), Condvar::new()));
|
||||
let pair2 = pair.clone();
|
||||
|
||||
let register_thread = move || {
|
||||
if let Some(func) = thread_create_callback {
|
||||
- match promote_current_thread_to_real_time(0, 48000) {
|
||||
- Ok(handle) => {
|
||||
- G_PRIORITY_HANDLES.with(|handles| {
|
||||
- (handles.borrow_mut()).push(handle);
|
||||
- });
|
||||
- }
|
||||
- Err(_) => {
|
||||
- warn!("Could not promote audio threads to real-time during initialization.");
|
||||
- }
|
||||
- }
|
||||
let thr = thread::current();
|
||||
let name = CString::new(thr.name().unwrap()).unwrap();
|
||||
func(name.as_ptr());
|
||||
let &(ref lock, ref cvar) = &*pair2;
|
||||
let mut count = lock.lock().unwrap();
|
||||
*count -= 1;
|
||||
cvar.notify_one();
|
||||
}
|
||||
diff --git a/media/audioipc/server/src/lib.rs b/media/audioipc/server/src/lib.rs
|
||||
--- a/media/audioipc/server/src/lib.rs
|
||||
+++ b/media/audioipc/server/src/lib.rs
|
||||
@@ -6,17 +6,16 @@
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
-use audio_thread_priority::promote_current_thread_to_real_time;
|
||||
use audioipc::core;
|
||||
use audioipc::platformhandle_passing::framed_with_platformhandles;
|
||||
use audioipc::rpc;
|
||||
use audioipc::{MessageStream, PlatformHandle, PlatformHandleType};
|
||||
use futures::sync::oneshot;
|
||||
use futures::Future;
|
||||
use std::error::Error;
|
||||
use std::ffi::{CStr, CString};
|
||||
@@ -59,22 +58,16 @@ struct ServerWrapper {
|
||||
core_thread: core::CoreThread,
|
||||
callback_thread: core::CoreThread,
|
||||
}
|
||||
|
||||
fn run() -> Result<ServerWrapper> {
|
||||
trace!("Starting up cubeb audio server event loop thread...");
|
||||
|
||||
let callback_thread = core::spawn_thread("AudioIPC Callback RPC", || {
|
||||
- match promote_current_thread_to_real_time(0, 48000) {
|
||||
- Ok(_) => {}
|
||||
- Err(_) => {
|
||||
- debug!("Failed to promote audio callback thread to real-time.");
|
||||
- }
|
||||
- }
|
||||
trace!("Starting up cubeb audio callback event loop thread...");
|
||||
Ok(())
|
||||
})
|
||||
.or_else(|e| {
|
||||
debug!(
|
||||
"Failed to start cubeb audio callback event loop thread: {:?}",
|
||||
e.description()
|
||||
);
|
|
@ -11,6 +11,7 @@ extern crate log;
|
|||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
use audio_thread_priority::promote_current_thread_to_real_time;
|
||||
use audioipc::core;
|
||||
use audioipc::platformhandle_passing::framed_with_platformhandles;
|
||||
use audioipc::rpc;
|
||||
|
@ -63,6 +64,12 @@ fn run() -> Result<ServerWrapper> {
|
|||
trace!("Starting up cubeb audio server event loop thread...");
|
||||
|
||||
let callback_thread = core::spawn_thread("AudioIPC Callback RPC", || {
|
||||
match promote_current_thread_to_real_time(0, 48000) {
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
debug!("Failed to promote audio callback thread to real-time.");
|
||||
}
|
||||
}
|
||||
trace!("Starting up cubeb audio callback event loop thread...");
|
||||
Ok(())
|
||||
})
|
||||
|
|
|
@ -33,6 +33,4 @@ fi
|
|||
|
||||
echo "Applying gecko.patch on top of $rev"
|
||||
patch -p3 < gecko.patch
|
||||
echo "Applying disable-rt.patch on top of $rev"
|
||||
patch -p3 < disable-rt.patch
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче