Bug 1407487 - P5: Support connections from within chrome process in audioipc. r?kamidphish
MozReview-Commit-ID: 9SdUWlJ02DR
--- 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 _)
}