From 36bd8cbc97d3b22aca311a5e272556ed179581be Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Fri, 10 Jul 2020 12:24:14 +0000 Subject: [PATCH] Bug 1561207 - Update audio_thread_priority to 0.23.3 and use MOZ_ENABLE_DBUS to enable dbus usage. r=kinetik Differential Revision: https://phabricator.services.mozilla.com/D82718 --- media/audioipc/README_MOZILLA | 2 +- media/audioipc/audioipc/Cargo.toml | 2 +- media/audioipc/client/Cargo.toml | 2 +- media/audioipc/client/src/context.rs | 53 +++++++++++++------ media/audioipc/client/src/stream.rs | 16 ++++-- media/audioipc/server/Cargo.toml | 2 +- toolkit/library/rust/Cargo.toml | 1 + toolkit/library/rust/gkrust-features.mozbuild | 3 ++ toolkit/library/rust/shared/Cargo.toml | 3 +- 9 files changed, 60 insertions(+), 24 deletions(-) diff --git a/media/audioipc/README_MOZILLA b/media/audioipc/README_MOZILLA index d6f1e0487af7..35d3283a2a79 100644 --- a/media/audioipc/README_MOZILLA +++ b/media/audioipc/README_MOZILLA @@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system. The audioipc-2 git repository is: https://github.com/djg/audioipc-2.git -The git commit ID used was c04a660a1fbb728de0833c87f1c92e97021359d9 (2020-06-18 11:24:15 +1200) +The git commit ID used was 91df250365bb188211e5532fa35cd9555894c727 (2020-07-10 14:07:36 +1200) diff --git a/media/audioipc/audioipc/Cargo.toml b/media/audioipc/audioipc/Cargo.toml index dfffa97f245b..b810ea083368 100644 --- a/media/audioipc/audioipc/Cargo.toml +++ b/media/audioipc/audioipc/Cargo.toml @@ -19,7 +19,7 @@ serde = "1" serde_derive = "1" tokio = "0.1" tokio-io = "0.1" -audio_thread_priority = "0.22" +audio_thread_priority = "0.23.3" [target.'cfg(unix)'.dependencies] iovec = "0.1" diff --git a/media/audioipc/client/Cargo.toml b/media/audioipc/client/Cargo.toml index 4a55c0162ea6..538633bb5057 100644 --- a/media/audioipc/client/Cargo.toml +++ b/media/audioipc/client/Cargo.toml @@ -9,7 +9,7 @@ description = "Cubeb Backend for talking to remote cubeb server." edition = "2018" [dependencies] -audio_thread_priority = "0.22" +audio_thread_priority = "0.23.3" audioipc = { path="../audioipc" } cubeb-backend = "0.7" futures = { version="0.1.18", default-features=false, features=["use_std"] } diff --git a/media/audioipc/client/src/context.rs b/media/audioipc/client/src/context.rs index 6b13900c5421..7441d0c0e081 100644 --- a/media/audioipc/client/src/context.rs +++ b/media/audioipc/client/src/context.rs @@ -14,10 +14,13 @@ 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}; +use audioipc::{ + messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage, + ServerMessage, +}; use cubeb_backend::{ - ffi, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceType, Error, Ops, Result, Stream, StreamParams, - StreamParamsRef, + ffi, Context, ContextOps, DeviceCollectionRef, DeviceId, DeviceType, Error, Ops, Result, + Stream, StreamParams, StreamParamsRef, }; use futures::Future; use futures_cpupool::{CpuFuture, CpuPool}; @@ -35,8 +38,10 @@ struct CubebClient; impl rpc::Client for CubebClient { type Request = ServerMessage; type Response = ClientMessage; - type Transport = - FramedWithPlatformHandles>; + type Transport = FramedWithPlatformHandles< + audioipc::AsyncMessageStream, + LengthDelimitedCodec, + >; } pub const CLIENT_OPS: Ops = capi_new!(ClientContext, ClientStream); @@ -136,12 +141,16 @@ impl rpc::Server for DeviceCollectionServer { type Request = DeviceCollectionReq; type Response = DeviceCollectionResp; type Future = CpuFuture; - type Transport = Framed>; + type Transport = + Framed>; fn process(&mut self, req: Self::Request) -> Self::Future { match req { DeviceCollectionReq::DeviceChange(device_type) => { - trace!("ctx_thread: DeviceChange Callback: device_type={}", device_type); + trace!( + "ctx_thread: DeviceChange Callback: device_type={}", + device_type + ); let devtype = cubeb_backend::DeviceType::from_bits_truncate(device_type); @@ -157,10 +166,14 @@ impl rpc::Server for DeviceCollectionServer { self.cpu_pool.spawn_fn(move || { run_in_callback(|| { if devtype.contains(cubeb_backend::DeviceType::INPUT) { - unsafe { input_cb.unwrap()(ptr::null_mut(), input_user_ptr as *mut c_void) } + unsafe { + input_cb.unwrap()(ptr::null_mut(), input_user_ptr as *mut c_void) + } } if devtype.contains(cubeb_backend::DeviceType::OUTPUT) { - unsafe { output_cb.unwrap()(ptr::null_mut(), output_user_ptr as *mut c_void) } + unsafe { + output_cb.unwrap()(ptr::null_mut(), output_user_ptr as *mut c_void) + } } }); @@ -193,7 +206,8 @@ impl ContextOps for ClientContext { let thread_create_callback = params.thread_create_callback; let thread_destroy_callback = params.thread_destroy_callback; - let server_stream = unsafe { audioipc::MessageStream::from_raw_fd(params.server_connection) }; + let server_stream = + unsafe { audioipc::MessageStream::from_raw_fd(params.server_connection) }; let core = core::spawn_thread( "AudioIPC Client RPC", @@ -217,8 +231,8 @@ impl ContextOps for ClientContext { // will return errors the caller expects to handle. let _ = send_recv!(rpc, ClientConnect(std::process::id()) => ClientConnected); - let backend_id = - send_recv!(rpc, ContextGetBackendId => ContextBackendId()).unwrap_or_else(|_| "(remote error)".to_string()); + let backend_id = send_recv!(rpc, ContextGetBackendId => ContextBackendId()) + .unwrap_or_else(|_| "(remote error)".to_string()); let backend_id = CString::new(backend_id).expect("backend_id query failed"); let cpu_pool = futures_cpupool::Builder::new() @@ -263,7 +277,11 @@ impl ContextOps for ClientContext { send_recv!(self.rpc(), ContextGetPreferredSampleRate => ContextPreferredSampleRate()) } - fn enumerate_devices(&mut self, devtype: DeviceType, collection: &DeviceCollectionRef) -> Result<()> { + fn enumerate_devices( + &mut self, + devtype: DeviceType, + collection: &DeviceCollectionRef, + ) -> Result<()> { assert_not_in_callback(); let v: Vec = match send_recv!(self.rpc(), ContextGetDeviceEnumeration(devtype.bits()) => @@ -286,7 +304,11 @@ impl ContextOps for ClientContext { assert_not_in_callback(); unsafe { let coll = &mut *collection.as_ptr(); - let mut devices = Vec::from_raw_parts(coll.device as *mut ffi::cubeb_device_info, coll.count, coll.count); + let mut devices = Vec::from_raw_parts( + coll.device as *mut ffi::cubeb_device_info, + coll.count, + coll.count, + ); for dev in &mut devices { if !dev.device_id.is_null() { let _ = CString::from_raw(dev.device_id as *mut _); @@ -361,7 +383,8 @@ impl ContextOps for ClientContext { ContextSetupDeviceCollectionCallback => ContextSetupDeviceCollectionCallback())?; - let stream = unsafe { audioipc::MessageStream::from_raw_fd(fds.platform_handles[0].into_raw()) }; + let stream = + unsafe { audioipc::MessageStream::from_raw_fd(fds.platform_handles[0].into_raw()) }; // TODO: The lowest comms layer expects exactly 3 PlatformHandles, but we only // need one here. Drop the dummy handles the other side sent us to discard. diff --git a/media/audioipc/client/src/stream.rs b/media/audioipc/client/src/stream.rs index 483fb3e5934c..1db9899f2d44 100644 --- a/media/audioipc/client/src/stream.rs +++ b/media/audioipc/client/src/stream.rs @@ -62,7 +62,8 @@ impl rpc::Server for CallbackServer { type Request = CallbackReq; type Response = CallbackResp; type Future = CpuFuture; - type Transport = Framed>; + type Transport = + Framed>; fn process(&mut self, req: Self::Request) -> Self::Future { match req { @@ -93,7 +94,10 @@ impl rpc::Server for CallbackServer { self.cpu_pool.spawn_fn(move || { // TODO: This is proof-of-concept. Make it better. let input_ptr: *const u8 = match input_shm { - Some(shm) => shm.get_slice(nframes as usize * input_frame_size).unwrap().as_ptr(), + Some(shm) => shm + .get_slice(nframes as usize * input_frame_size) + .unwrap() + .as_ptr(), None => ptr::null(), }; let output_ptr: *mut u8 = match output_shm { @@ -169,9 +173,13 @@ impl<'ctx> ClientStream<'ctx> { let rpc = ctx.rpc(); let data = send_recv!(rpc, StreamInit(init_params) => StreamCreated())?; - debug!("token = {}, handles = {:?}", data.token, data.platform_handles); + debug!( + "token = {}, handles = {:?}", + data.token, data.platform_handles + ); - let stream = unsafe { audioipc::MessageStream::from_raw_fd(data.platform_handles[0].into_raw()) }; + let stream = + unsafe { audioipc::MessageStream::from_raw_fd(data.platform_handles[0].into_raw()) }; let input_file = unsafe { data.platform_handles[1].into_file() }; let input_shm = if has_input { diff --git a/media/audioipc/server/Cargo.toml b/media/audioipc/server/Cargo.toml index 99afe549390c..e0b222e6f315 100644 --- a/media/audioipc/server/Cargo.toml +++ b/media/audioipc/server/Cargo.toml @@ -9,7 +9,7 @@ description = "Remote cubeb server" edition = "2018" [dependencies] -audio_thread_priority = "0.22" +audio_thread_priority = "0.23.3" audioipc = { path = "../audioipc" } cubeb-core = "0.7.0" futures = "0.1.29" diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml index ccb696cf3d8a..4187a0030891 100644 --- a/toolkit/library/rust/Cargo.toml +++ b/toolkit/library/rust/Cargo.toml @@ -35,6 +35,7 @@ remote_agent = ["gkrust-shared/remote"] glean = ["gkrust-shared/glean"] glean_with_gecko = ["gkrust-shared/glean_with_gecko"] rust_fxa_client = ["gkrust-shared/rust_fxa_client"] +with_dbus = ["gkrust-shared/with_dbus"] [dependencies] gkrust-shared = { path = "shared" } diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild index c4d82120b374..82ecf8e4592c 100644 --- a/toolkit/library/rust/gkrust-features.mozbuild +++ b/toolkit/library/rust/gkrust-features.mozbuild @@ -82,3 +82,6 @@ if CONFIG['MOZ_RUST_FXA_CLIENT']: if CONFIG['MOZ_USING_WASM_SANDBOXING']: gkrust_features += ['wasm_library_sandboxing'] + +if CONFIG['MOZ_ENABLE_DBUS']: + gkrust_features += ['with_dbus'] diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 0413a722cb23..1c1cac98c19f 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -41,7 +41,7 @@ storage = { path = "../../../../storage/rust" } bookmark_sync = { path = "../../../components/places/bookmark_sync", optional = true } shift_or_euc_c = "0.1.0" chardetng_c = "0.1.1" -audio_thread_priority = "0.22.1" +audio_thread_priority = "0.23.3" mdns_service = { path="../../../../media/mtransport/mdns_service", optional = true } neqo_glue = { path = "../../../../netwerk/socket/neqo_glue" } rlbox_lucet_sandbox = { version = "0.1.0", optional = true } @@ -103,6 +103,7 @@ remote_agent = ["remote"] glean = ["fog"] glean_with_gecko = ["fog/with_gecko"] rust_fxa_client = ["firefox-accounts-bridge"] +with_dbus = ["audio_thread_priority/with_dbus"] [lib] path = "lib.rs"