Bug 1563877 - Update cubeb-pulse-rs to 9d1c1292. r=me

--HG--
extra : rebase_source : 73b6fe84fcaf1ca4aebc2e915d7052f03c94b40c
This commit is contained in:
Matthew Gregan 2019-07-12 12:15:35 +12:00
Родитель 53443837f2
Коммит d251dd57b2
3 изменённых файлов: 51 добавлений и 50 удалений

Просмотреть файл

@ -5,4 +5,4 @@ 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 cubeb-pulse-rs git repository is: https://github.com/djg/cubeb-pulse-rs.git
The git commit ID used was 17c1629c323ff24d656ff9449bf50d6758aafc1a (2019-01-24 07:50:09 +1300) The git commit ID used was 9d1c1292a11cf90f9450a97a1aa4604849263c45 (2019-07-11 09:49:33 +1200)

Просмотреть файл

@ -6,6 +6,7 @@
use ::*; use ::*;
use ffi; use ffi;
use std::ffi::CStr; use std::ffi::CStr;
use std::mem::{forget, MaybeUninit};
use std::os::raw::{c_int, c_void}; use std::os::raw::{c_int, c_void};
use std::ptr; use std::ptr;
use util::UnwrapCStr; use util::UnwrapCStr;
@ -95,15 +96,15 @@ impl Context {
pub fn set_state_callback<CB>(&self, _: CB, userdata: *mut c_void) pub fn set_state_callback<CB>(&self, _: CB, userdata: *mut c_void)
where CB: Fn(&Context, *mut c_void) where CB: Fn(&Context, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, userdata: *mut c_void)
where F: Fn(&Context, *mut c_void) where F: Fn(&Context, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, userdata);
forget(ctx); forget(ctx);
result result
@ -146,15 +147,15 @@ impl Context {
pub fn drain<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn drain<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Context, *mut c_void) where CB: Fn(&Context, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, userdata: *mut c_void)
where F: Fn(&Context, *mut c_void) where F: Fn(&Context, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, userdata);
forget(ctx); forget(ctx);
result result
@ -167,7 +168,7 @@ impl Context {
pub fn rttime_new<CB>(&self, usec: USec, _: CB, userdata: *mut c_void) -> *mut ffi::pa_time_event pub fn rttime_new<CB>(&self, usec: USec, _: CB, userdata: *mut c_void) -> *mut ffi::pa_time_event
where CB: Fn(&MainloopApi, *mut ffi::pa_time_event, &TimeVal, *mut c_void) where CB: Fn(&MainloopApi, *mut ffi::pa_time_event, &TimeVal, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(a: *mut ffi::pa_mainloop_api, unsafe extern "C" fn wrapped<F>(a: *mut ffi::pa_mainloop_api,
@ -176,10 +177,10 @@ impl Context {
userdata: *mut c_void) userdata: *mut c_void)
where F: Fn(&MainloopApi, *mut ffi::pa_time_event, &TimeVal, *mut c_void) where F: Fn(&MainloopApi, *mut ffi::pa_time_event, &TimeVal, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let api = mainloop_api::from_raw_ptr(a); let api = mainloop_api::from_raw_ptr(a);
let timeval = &*tv; let timeval = &*tv;
let result = uninitialized::<F>()(&api, e, timeval, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&api, e, timeval, userdata);
forget(api); forget(api);
result result
@ -191,20 +192,20 @@ impl Context {
pub fn get_server_info<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn get_server_info<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Context, Option<&ServerInfo>, *mut c_void) where CB: Fn(&Context, Option<&ServerInfo>, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, i: *const ffi::pa_server_info, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, i: *const ffi::pa_server_info, userdata: *mut c_void)
where F: Fn(&Context, Option<&ServerInfo>, *mut c_void) where F: Fn(&Context, Option<&ServerInfo>, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let info = if i.is_null() { let info = if i.is_null() {
None None
} else { } else {
Some(&*i) Some(&*i)
}; };
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, info, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, userdata);
forget(ctx); forget(ctx);
result result
@ -219,7 +220,7 @@ impl Context {
CB: Fn(&Context, *const SinkInfo, i32, *mut c_void), CB: Fn(&Context, *const SinkInfo, i32, *mut c_void),
CS: Into<Option<&'str CStr>>, CS: Into<Option<&'str CStr>>,
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
@ -228,9 +229,9 @@ impl Context {
userdata: *mut c_void) userdata: *mut c_void)
where F: Fn(&Context, *const SinkInfo, i32, *mut c_void) where F: Fn(&Context, *const SinkInfo, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, info, eol, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
forget(ctx); forget(ctx);
result result
@ -246,7 +247,7 @@ impl Context {
pub fn get_sink_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn get_sink_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Context, *const SinkInfo, i32, *mut c_void) where CB: Fn(&Context, *const SinkInfo, i32, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
@ -255,9 +256,9 @@ impl Context {
userdata: *mut c_void) userdata: *mut c_void)
where F: Fn(&Context, *const SinkInfo, i32, *mut c_void) where F: Fn(&Context, *const SinkInfo, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, info, eol, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
forget(ctx); forget(ctx);
result result
@ -270,7 +271,7 @@ impl Context {
pub fn get_sink_input_info<CB>(&self, idx: u32, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn get_sink_input_info<CB>(&self, idx: u32, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Context, *const SinkInputInfo, i32, *mut c_void) where CB: Fn(&Context, *const SinkInputInfo, i32, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
@ -279,9 +280,9 @@ impl Context {
userdata: *mut c_void) userdata: *mut c_void)
where F: Fn(&Context, *const SinkInputInfo, i32, *mut c_void) where F: Fn(&Context, *const SinkInputInfo, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, info, eol, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
forget(ctx); forget(ctx);
result result
@ -294,7 +295,7 @@ impl Context {
pub fn get_source_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn get_source_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Context, *const SourceInfo, i32, *mut c_void) where CB: Fn(&Context, *const SourceInfo, i32, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
@ -303,9 +304,9 @@ impl Context {
userdata: *mut c_void) userdata: *mut c_void)
where F: Fn(&Context, *const SourceInfo, i32, *mut c_void) where F: Fn(&Context, *const SourceInfo, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, info, eol, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, info, eol, userdata);
forget(ctx); forget(ctx);
result result
@ -323,15 +324,15 @@ impl Context {
-> Result<Operation> -> Result<Operation>
where CB: Fn(&Context, i32, *mut c_void) where CB: Fn(&Context, i32, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, success: c_int, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, success: c_int, userdata: *mut c_void)
where F: Fn(&Context, i32, *mut c_void) where F: Fn(&Context, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, success, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, success, userdata);
forget(ctx); forget(ctx);
result result
@ -344,15 +345,15 @@ impl Context {
pub fn subscribe<CB>(&self, m: SubscriptionMask, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn subscribe<CB>(&self, m: SubscriptionMask, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Context, i32, *mut c_void) where CB: Fn(&Context, i32, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, success: c_int, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, success: c_int, userdata: *mut c_void)
where F: Fn(&Context, i32, *mut c_void) where F: Fn(&Context, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let result = uninitialized::<F>()(&ctx, success, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, success, userdata);
forget(ctx); forget(ctx);
result result
@ -371,7 +372,7 @@ impl Context {
pub fn set_subscribe_callback<CB>(&self, _: CB, userdata: *mut c_void) pub fn set_subscribe_callback<CB>(&self, _: CB, userdata: *mut c_void)
where CB: Fn(&Context, SubscriptionEvent, u32, *mut c_void) where CB: Fn(&Context, SubscriptionEvent, u32, *mut c_void)
{ {
debug_assert_eq!(::std::mem::size_of::<CB>(), 0); assert_eq!(::std::mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
@ -380,11 +381,11 @@ impl Context {
userdata: *mut c_void) userdata: *mut c_void)
where F: Fn(&Context, SubscriptionEvent, u32, *mut c_void) where F: Fn(&Context, SubscriptionEvent, u32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let ctx = context::from_raw_ptr(c); let ctx = context::from_raw_ptr(c);
let event = SubscriptionEvent::try_from(t) let event = SubscriptionEvent::try_from(t)
.expect("pa_context_subscribe_cb_t passed invalid pa_subscription_event_type_t"); .expect("pa_context_subscribe_cb_t passed invalid pa_subscription_event_type_t");
let result = uninitialized::<F>()(&ctx, event, idx, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&ctx, event, idx, userdata);
forget(ctx); forget(ctx);
result result

Просмотреть файл

@ -8,7 +8,7 @@ use context;
use ffi; use ffi;
use operation; use operation;
use std::ffi::CStr; use std::ffi::CStr;
use std::mem; use std::mem::{self, forget, MaybeUninit};
use std::os::raw::{c_int, c_void}; use std::os::raw::{c_int, c_void};
use std::ptr; use std::ptr;
use util::*; use util::*;
@ -184,15 +184,15 @@ impl Stream {
pub fn update_timing_info<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn update_timing_info<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Stream, i32, *mut c_void) where CB: Fn(&Stream, i32, *mut c_void)
{ {
debug_assert_eq!(mem::size_of::<CB>(), 0); assert_eq!(mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, success: c_int, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, success: c_int, userdata: *mut c_void)
where F: Fn(&Stream, i32, *mut c_void) where F: Fn(&Stream, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let mut stm = stream::from_raw_ptr(s); let mut stm = stream::from_raw_ptr(s);
let result = uninitialized::<F>()(&mut stm, success, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&mut stm, success, userdata);
forget(stm); forget(stm);
result result
@ -219,15 +219,15 @@ impl Stream {
pub fn set_state_callback<CB>(&self, _: CB, userdata: *mut c_void) pub fn set_state_callback<CB>(&self, _: CB, userdata: *mut c_void)
where CB: Fn(&Stream, *mut c_void) where CB: Fn(&Stream, *mut c_void)
{ {
debug_assert_eq!(mem::size_of::<CB>(), 0); assert_eq!(mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, userdata: *mut c_void)
where F: Fn(&Stream, *mut c_void) where F: Fn(&Stream, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let mut stm = stream::from_raw_ptr(s); let mut stm = stream::from_raw_ptr(s);
let result = uninitialized::<F>()(&mut stm, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&mut stm, userdata);
forget(stm); forget(stm);
result result
@ -247,15 +247,15 @@ impl Stream {
pub fn set_write_callback<CB>(&self, _: CB, userdata: *mut c_void) pub fn set_write_callback<CB>(&self, _: CB, userdata: *mut c_void)
where CB: Fn(&Stream, usize, *mut c_void) where CB: Fn(&Stream, usize, *mut c_void)
{ {
debug_assert_eq!(mem::size_of::<CB>(), 0); assert_eq!(mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, nbytes: usize, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, nbytes: usize, userdata: *mut c_void)
where F: Fn(&Stream, usize, *mut c_void) where F: Fn(&Stream, usize, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let mut stm = stream::from_raw_ptr(s); let mut stm = stream::from_raw_ptr(s);
let result = uninitialized::<F>()(&mut stm, nbytes, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&mut stm, nbytes, userdata);
forget(stm); forget(stm);
result result
@ -275,15 +275,15 @@ impl Stream {
pub fn set_read_callback<CB>(&self, _: CB, userdata: *mut c_void) pub fn set_read_callback<CB>(&self, _: CB, userdata: *mut c_void)
where CB: Fn(&Stream, usize, *mut c_void) where CB: Fn(&Stream, usize, *mut c_void)
{ {
debug_assert_eq!(mem::size_of::<CB>(), 0); assert_eq!(mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, nbytes: usize, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, nbytes: usize, userdata: *mut c_void)
where F: Fn(&Stream, usize, *mut c_void) where F: Fn(&Stream, usize, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let mut stm = stream::from_raw_ptr(s); let mut stm = stream::from_raw_ptr(s);
let result = uninitialized::<F>()(&mut stm, nbytes, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&mut stm, nbytes, userdata);
forget(stm); forget(stm);
result result
@ -297,15 +297,15 @@ impl Stream {
pub fn cork<CB>(&self, b: i32, _: CB, userdata: *mut c_void) -> Result<Operation> pub fn cork<CB>(&self, b: i32, _: CB, userdata: *mut c_void) -> Result<Operation>
where CB: Fn(&Stream, i32, *mut c_void) where CB: Fn(&Stream, i32, *mut c_void)
{ {
debug_assert_eq!(mem::size_of::<CB>(), 0); assert_eq!(mem::size_of::<CB>(), 0);
// See: A note about `wrapped` functions // See: A note about `wrapped` functions
unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, success: c_int, userdata: *mut c_void) unsafe extern "C" fn wrapped<F>(s: *mut ffi::pa_stream, success: c_int, userdata: *mut c_void)
where F: Fn(&Stream, i32, *mut c_void) where F: Fn(&Stream, i32, *mut c_void)
{ {
use std::mem::{forget, uninitialized};
let mut stm = stream::from_raw_ptr(s); let mut stm = stream::from_raw_ptr(s);
let result = uninitialized::<F>()(&mut stm, success, userdata); let cb = MaybeUninit::<F>::uninit();
let result = (*cb.as_ptr())(&mut stm, success, userdata);
forget(stm); forget(stm);
result result