# HG changeset patch # User Dan Glastonbury # Date 1520315348 -36000 # Tue Mar 06 15:49:08 2018 +1000 # Node ID f56d6bee4412e82392e7bfdb7acf0c9e59da217b # Parent c483f8c3bf074db6be630993067e80c2bedd8f49 Bug 1443368 - Update cubeb-pulse-rs to commit 22cdde3. r=kinetik Pull for change to replace assert in get_server_info callback with proper handling for null pointer. MozReview-Commit-ID: 996HQw3FyYQ diff --git a/media/libcubeb/cubeb-pulse-rs/README_MOZILLA b/media/libcubeb/cubeb-pulse-rs/README_MOZILLA --- a/media/libcubeb/cubeb-pulse-rs/README_MOZILLA +++ b/media/libcubeb/cubeb-pulse-rs/README_MOZILLA @@ -1,8 +1,8 @@ The source from this directory was copied from the cubeb-pulse-rs 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 cubeb-pulse-rs git repository is: https://github.com/djg/cubeb-pulse-rs.git -The git commit ID used was f58dc34c5af519352aed4b4cd79bb34060e59c65 (2018-02-23 11:16:40 +1000) +The git commit ID used was 22cdde3e573303649a77e48a19f7ca2c4d308047 (2018-03-06 10:39:46 +1000) diff --git a/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs b/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs --- a/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs +++ b/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs @@ -184,27 +184,30 @@ impl Context { result } unsafe { ffi::pa_context_rttime_new(self.raw_mut(), usec, Some(wrapped::), userdata) } } pub fn get_server_info(&self, _: CB, userdata: *mut c_void) -> Result - where CB: Fn(&Context, &ServerInfo, *mut c_void) + where CB: Fn(&Context, Option<&ServerInfo>, *mut c_void) { debug_assert_eq!(::std::mem::size_of::(), 0); // See: A note about `wrapped` functions unsafe extern "C" fn wrapped(c: *mut ffi::pa_context, i: *const ffi::pa_server_info, userdata: *mut c_void) - where F: Fn(&Context, &ServerInfo, *mut c_void) + where F: Fn(&Context, Option<&ServerInfo>, *mut c_void) { use std::mem::{forget, uninitialized}; - debug_assert_ne!(i, ptr::null_mut()); - let info = &*i; + let info = if i.is_null() { + None + } else { + Some(&*i) + }; let ctx = context::from_raw_ptr(c); let result = uninitialized::()(&ctx, info, userdata); forget(ctx); result } op_or_err!(self, diff --git a/media/libcubeb/cubeb-pulse-rs/src/backend/context.rs b/media/libcubeb/cubeb-pulse-rs/src/backend/context.rs --- a/media/libcubeb/cubeb-pulse-rs/src/backend/context.rs +++ b/media/libcubeb/cubeb-pulse-rs/src/backend/context.rs @@ -113,17 +113,17 @@ impl PulseContext { error: true, version_0_9_8: false, version_2_0_0: false, devids: RefCell::new(Intern::new()), })) } fn new(name: Option<&CStr>) -> Result> { - fn server_info_cb(context: &pulse::Context, info: &pulse::ServerInfo, u: *mut c_void) { + fn server_info_cb(context: &pulse::Context, info: Option<&pulse::ServerInfo>, u: *mut c_void) { fn sink_info_cb( _: &pulse::Context, i: *const pulse::SinkInfo, eol: i32, u: *mut c_void, ) { let ctx = unsafe { &mut *(u as *mut PulseContext) }; if eol == 0 { @@ -133,21 +133,27 @@ impl PulseContext { sample_spec: info.sample_spec, channel_map: info.channel_map, flags: flags, }); } ctx.mainloop.signal(); } - let _ = context.get_sink_info_by_name( - try_cstr_from(info.default_sink_name), - sink_info_cb, - u, - ); + if let Some(info) = info { + let _ = context.get_sink_info_by_name( + try_cstr_from(info.default_sink_name), + sink_info_cb, + u, + ); + } else { + // If info is None, then an error occured. + let ctx = unsafe { &mut *(u as *mut PulseContext) }; + ctx.mainloop.signal(); + } } let name = name.map(|s| s.to_owned()); let mut ctx = try!(PulseContext::_new(name)); if ctx.mainloop.start().is_err() { ctx.destroy(); return Err(Error::error()); @@ -344,27 +350,29 @@ impl ContextOps for PulseContext { latency_hi: 0, }; list_data.devinfo.push(devinfo); } fn default_device_names( _: &pulse::Context, - info: &pulse::ServerInfo, + info: Option<&pulse::ServerInfo>, user_data: *mut c_void, ) { let list_data = unsafe { &mut *(user_data as *mut PulseDevListData) }; - list_data.default_sink_name = super::try_cstr_from(info.default_sink_name) - .map(|s| s.to_owned()) - .unwrap_or_default(); - list_data.default_source_name = super::try_cstr_from(info.default_source_name) - .map(|s| s.to_owned()) - .unwrap_or_default(); + if let Some(info) = info { + list_data.default_sink_name = super::try_cstr_from(info.default_sink_name) + .map(|s| s.to_owned()) + .unwrap_or_default(); + list_data.default_source_name = super::try_cstr_from(info.default_source_name) + .map(|s| s.to_owned()) + .unwrap_or_default(); + } (*list_data.context).mainloop.signal(); } let mut user_data = PulseDevListData::new(self); if let Some(ref context) = self.context { self.mainloop.lock();