Bug 1407487 - P5: Support connections from within chrome process in audioipc. r?kamidphish draft
authorMatthew Gregan <kinetik@flim.org>
Thu, 19 Oct 2017 16:46:02 +1300
changeset 683010 daa970ee4c33d63b4e570a6e9a605f71908e828c
parent 682128 d8acc5c42dc47683ce77c26442a127e4d7781fa9
child 736498 fc6a4cb1e2b123d767b3355bfec9510c4c465de7
push id85218
push userbmo:kinetik@flim.org
push dateThu, 19 Oct 2017 03:57:39 +0000
reviewerskamidphish
bugs1407487
milestone58.0a1
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 _)
     }