Bug 1628779 - Update audioipc to 1b27476950. r=cubeb-reviewers,kinetik
authorPaul Adenot <paul@paul.cx>
Thu, 28 May 2020 09:53:39 +0000
changeset 532727 016ee047a1917b3d878cc6d8d322c1ca8e53b12b
parent 532726 cc82aacadf8040bc92ab2fd97ec8b6d03bac1eb7
child 532728 de1e80b2020409b3003cc895da94957afd6e3f51
push id37457
push usernerli@mozilla.com
push dateThu, 28 May 2020 15:51:15 +0000
treeherdermozilla-central@272e3c98d002 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscubeb-reviewers, kinetik
bugs1628779
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1628779 - Update audioipc to 1b27476950. r=cubeb-reviewers,kinetik Differential Revision: https://phabricator.services.mozilla.com/D75336
media/audioipc/README_MOZILLA
media/audioipc/client/src/context.rs
media/audioipc/client/src/stream.rs
media/audioipc/server/src/server.rs
--- a/media/audioipc/README_MOZILLA
+++ b/media/audioipc/README_MOZILLA
@@ -1,8 +1,8 @@
 The source from this directory was copied from the audioipc-2
 git repository using the update.sh script.  The only changes
 made were those applied by update.sh and the addition of
 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 d5c07e962073841dc992a7848a9b1effaac9c25f (2020-05-01 09:16:04 +1200)
+The git commit ID used was 1b2747695088ee5f8216bda9a7a4c4bd7655608e (2020-05-14 09:40:35 +1200)
--- a/media/audioipc/client/src/context.rs
+++ b/media/audioipc/client/src/context.rs
@@ -9,20 +9,23 @@ use crate::{ClientStream, AUDIOIPC_INIT_
 #[cfg(target_os = "linux")]
 use audio_thread_priority::get_current_thread_info;
 #[cfg(not(target_os = "linux"))]
 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};
+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};
 use std::ffi::{CStr, CString};
 use std::os::raw::c_void;
 use std::sync::mpsc;
 use std::sync::{Arc, Mutex};
 use std::thread;
@@ -30,18 +33,20 @@ use std::{fmt, io, mem, ptr};
 use tokio::reactor;
 use tokio::runtime::current_thread;
 
 struct CubebClient;
 
 impl rpc::Client for CubebClient {
     type Request = ServerMessage;
     type Response = ClientMessage;
-    type Transport =
-        FramedWithPlatformHandles<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Request, Self::Response>>;
+    type Transport = FramedWithPlatformHandles<
+        audioipc::AsyncMessageStream,
+        LengthDelimitedCodec<Self::Request, Self::Response>,
+    >;
 }
 
 pub const CLIENT_OPS: Ops = capi_new!(ClientContext, ClientStream);
 
 // ClientContext's layout *must* match cubeb.c's `struct cubeb` for the
 // common fields.
 #[repr(C)]
 pub struct ClientContext {
@@ -131,41 +136,49 @@ struct DeviceCollectionServer {
     output_device_callback: Arc<Mutex<DeviceCollectionCallback>>,
     cpu_pool: CpuPool,
 }
 
 impl rpc::Server for DeviceCollectionServer {
     type Request = DeviceCollectionReq;
     type Response = DeviceCollectionResp;
     type Future = CpuFuture<Self::Response, ()>;
-    type Transport = Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
+    type Transport =
+        Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
 
     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);
 
                 let (input_cb, input_user_ptr) = {
                     let dcb = self.input_device_callback.lock().unwrap();
                     (dcb.cb, dcb.user_ptr)
                 };
                 let (output_cb, output_user_ptr) = {
                     let dcb = self.output_device_callback.lock().unwrap();
                     (dcb.cb, dcb.user_ptr)
                 };
 
                 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)
+                            }
                         }
                     });
 
                     Ok(DeviceCollectionResp::DeviceChange)
                 })
             }
         }
     }
@@ -188,17 +201,18 @@ impl ContextOps for ClientContext {
         assert_not_in_callback();
 
         let (tx_rpc, rx_rpc) = mpsc::channel();
 
         let params = AUDIOIPC_INIT_PARAMS.with(|p| p.replace(None).unwrap());
         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",
             move || {
                 let handle = reactor::Handle::default();
 
                 register_thread(thread_create_callback);
 
@@ -212,18 +226,18 @@ impl ContextOps for ClientContext {
 
         let rpc = rx_rpc.recv().map_err(|_| Error::default())?;
         let rpc2 = rpc.clone();
 
         // Don't let errors bubble from here.  Later calls against this context
         // 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()
             .name_prefix("AudioIPC")
             .after_start(move || promote_and_register_thread(&rpc2, thread_create_callback))
             .before_stop(move || unregister_thread(thread_destroy_callback))
             .pool_size(params.pool_size)
             .stack_size(params.stack_size)
@@ -258,17 +272,21 @@ impl ContextOps for ClientContext {
         send_recv!(self.rpc(), ContextGetMinLatency(params) => ContextMinLatency())
     }
 
     fn preferred_sample_rate(&mut self) -> Result<u32> {
         assert_not_in_callback();
         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<ffi::cubeb_device_info> = match send_recv!(self.rpc(),
                              ContextGetDeviceEnumeration(devtype.bits()) =>
                              ContextEnumeratedDevices())
         {
             Ok(mut v) => v.drain(..).map(|i| i.into()).collect(),
             Err(e) => return Err(e),
         };
@@ -281,17 +299,21 @@ impl ContextOps for ClientContext {
         mem::forget(vs);
         Ok(())
     }
 
     fn device_collection_destroy(&mut self, collection: &mut DeviceCollectionRef) -> Result<()> {
         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 _);
                 }
                 if !dev.group_id.is_null() {
                     let _ = CString::from_raw(dev.group_id as *mut _);
                 }
                 if !dev.vendor_name.is_null() {
@@ -356,17 +378,18 @@ impl ContextOps for ClientContext {
     ) -> Result<()> {
         assert_not_in_callback();
 
         if !self.device_collection_rpc {
             let fds = send_recv!(self.rpc(),
                                  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.
             unsafe {
                 fds.platform_handles[1].into_file();
                 fds.platform_handles[2].into_file();
             }
 
--- a/media/audioipc/client/src/stream.rs
+++ b/media/audioipc/client/src/stream.rs
@@ -57,17 +57,18 @@ struct CallbackServer {
     cpu_pool: CpuPool,
     device_change_cb: Arc<Mutex<ffi::cubeb_device_changed_callback>>,
 }
 
 impl rpc::Server for CallbackServer {
     type Request = CallbackReq;
     type Response = CallbackResp;
     type Future = CpuFuture<Self::Response, ()>;
-    type Transport = Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
+    type Transport =
+        Framed<audioipc::AsyncMessageStream, LengthDelimitedCodec<Self::Response, Self::Request>>;
 
     fn process(&mut self, req: Self::Request) -> Self::Future {
         match req {
             CallbackReq::Data {
                 nframes,
                 input_frame_size,
                 output_frame_size,
             } => {
@@ -88,17 +89,20 @@ impl rpc::Server for CallbackServer {
                     None => None,
                 };
                 let user_ptr = self.user_ptr;
                 let cb = self.data_cb.unwrap();
 
                 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 {
                         Some(ref mut shm) => shm
                             .get_mut_slice(nframes as usize * output_frame_size)
                             .unwrap()
                             .as_mut_ptr(),
                         None => ptr::null_mut(),
@@ -164,19 +168,23 @@ impl<'ctx> ClientStream<'ctx> {
         assert_not_in_callback();
 
         let has_input = init_params.input_stream_params.is_some();
         let has_output = init_params.output_stream_params.is_some();
 
         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 {
             match SharedMemSlice::from(&input_file, audioipc::SHM_AREA_SIZE) {
                 Ok(shm) => Some(shm),
                 Err(e) => {
                     debug!("Client failed to set up input shmem: {}", e);
                     return Err(Error::error());
--- a/media/audioipc/server/src/server.rs
+++ b/media/audioipc/server/src/server.rs
@@ -526,17 +526,17 @@ impl CubebServer {
                 .stream
                 .latency()
                 .map(ClientMessage::StreamLatency)
                 .unwrap_or_else(error),
 
             ServerMessage::StreamGetInputLatency(stm_tok) => try_stream!(self, stm_tok)
                 .stream
                 .input_latency()
-                .map(ClientMessage::StreamLatency)
+                .map(ClientMessage::StreamInputLatency)
                 .unwrap_or_else(error),
 
             ServerMessage::StreamSetVolume(stm_tok, volume) => try_stream!(self, stm_tok)
                 .stream
                 .set_volume(volume)
                 .map(|_| ClientMessage::StreamVolumeSet)
                 .unwrap_or_else(error),