Bug 1407487 - P5: Support connections from within chrome process in audioipc. r=kamidphish
authorMatthew Gregan <kinetik@flim.org>
Thu, 19 Oct 2017 16:46:02 +1300
changeset 387055 64cecfd341a1ff9375316d3b3565124def78f257
parent 387054 2b88b91f35f9c47a9c3cf1838c2d9961fe5b9a8a
child 387056 c5ee99a2c4c83edf6d19294618102b763b96c4a5
push id96356
push usermgregan@mozilla.com
push dateThu, 19 Oct 2017 05:05:32 +0000
treeherdermozilla-inbound@64cecfd341a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish
bugs1407487
milestone58.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 1407487 - P5: Support connections from within chrome process in audioipc. r=kamidphish MozReview-Commit-ID: 9SdUWlJ02DR
media/audioipc/client/src/context.rs
--- a/media/audioipc/client/src/context.rs
+++ b/media/audioipc/client/src/context.rs
@@ -39,21 +39,26 @@ impl ClientContext {
         self.connection.lock().unwrap()
     }
 }
 
 impl Context for ClientContext {
     fn init(_context_name: Option<&CStr>) -> Result<*mut ffi::cubeb> {
         assert_not_in_callback();
         // TODO: encapsulate connect, etc inside audioipc.
+        // TODO: explicit setup of connection so we don't have to guess the
+        // path.  For now, we try our parent, ourself, and the default path.
         let ppid = unsafe { libc::getppid() };
-        let path = audioipc::get_uds_path(ppid as u64);
-        let stream = match UnixStream::connect(path) {
+        let pid = unsafe { libc::getpid() };
+        let stream = match UnixStream::connect(audioipc::get_uds_path(ppid as u64)) {
             Ok(stream) => stream,
-            _ => t!(UnixStream::connect(audioipc::get_uds_path(1)))
+            _ => match UnixStream::connect(audioipc::get_uds_path(pid as u64)) {
+                Ok(stream) => stream,
+                _ => t!(UnixStream::connect(audioipc::get_uds_path(1)))
+            }
         };
         let ctx = Box::new(ClientContext {
             _ops: &CLIENT_OPS as *const _,
             connection: Mutex::new(Connection::new(stream))
         });
         Ok(Box::into_raw(ctx) as *mut _)
     }