Bug 1432869 - Update cubeb-pulse-rs to git commit deadde7. r=kamidphish

MozReview-Commit-ID: EdtwDx2r2Ta

--HG--
extra : rebase_source : 04324b3269ee38fdf1c9afca980a18d3bc42a853
This commit is contained in:
Bryce Van Dyk 2018-01-25 10:51:03 -05:00
Родитель d198f884a0
Коммит 099cc51efe
5 изменённых файлов: 64 добавлений и 54 удалений

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

@ -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 git commit ID used was cb7141e3aae5471b3a8ac1e4524f35d04edcdf4e (2018-01-17 13:10:58 +1000)
The git commit ID used was deadde7d14e0010628471e33a538a0a1e59765ff (2018-01-25 10:00:16 +1000)

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

@ -51,6 +51,16 @@ pub const LAYOUT_3F3R_LFE: ChannelLayout = 17;
pub const LAYOUT_3F4_LFE: ChannelLayout = 18;
pub const LAYOUT_MAX: ChannelLayout = 256;
// These need to match cubeb_device_type
bitflags! {
#[repr(C)]
pub struct StreamPrefs : u32 {
const STREAM_PREF_NONE = 0x00;
const STREAM_PREF_LOOPBACK = 0x01;
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct StreamParams {
@ -58,6 +68,7 @@ pub struct StreamParams {
pub rate: u32,
pub channels: u32,
pub layout: ChannelLayout,
pub prefs: StreamPrefs,
}
#[repr(C)]
@ -308,7 +319,7 @@ extern "C" {
#[test]
fn bindgen_test_layout_stream_params() {
assert_eq!(::std::mem::size_of::<StreamParams>(),
16usize,
20usize,
concat!("Size of: ", stringify!(StreamParams)));
assert_eq!(::std::mem::align_of::<StreamParams>(),
4usize,
@ -337,6 +348,12 @@ fn bindgen_test_layout_stream_params() {
stringify!(StreamParams),
"::",
stringify!(layout)));
assert_eq!(unsafe { &(*(0 as *const StreamParams)).prefs as *const _ as usize },
16usize,
concat!("Alignment of field: ",
stringify!(StreamParams),
"::",
stringify!(layout)));
}
#[test]

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

@ -370,7 +370,7 @@ impl SubscriptionEvent {
}
pub fn event_type(self) -> SubscriptionEventType {
unsafe { ::std::mem::transmute(((self.0 & ffi::PA_SUBSCRIPTION_EVENT_TYPE_MASK) >> 4)) }
unsafe { ::std::mem::transmute((self.0 & ffi::PA_SUBSCRIPTION_EVENT_TYPE_MASK) >> 4) }
}
}

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

@ -37,7 +37,7 @@ fn pa_channel_to_cubeb_channel(channel: pulse::ChannelPosition) -> cubeb::Channe
fn channel_map_to_layout(cm: &pulse::ChannelMap) -> cubeb::ChannelLayout {
use pulse::ChannelPosition;
let mut cubeb_map: cubeb::ChannelMap = Default::default();
cubeb_map.channels = cm.channels as u32;
cubeb_map.channels = u32::from(cm.channels);
for i in 0usize..cm.channels as usize {
cubeb_map.map[i] = pa_channel_to_cubeb_channel(ChannelPosition::try_from(cm.map[i])
.unwrap_or(ChannelPosition::Invalid));
@ -176,6 +176,7 @@ impl Context {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new_stream(&mut self,
stream_name: &CStr,
input_device: cubeb::DeviceId,
@ -205,7 +206,7 @@ impl Context {
pub fn max_channel_count(&self) -> Result<u32> {
match self.default_sink_info {
Some(ref info) => Ok(info.channel_map.channels as u32),
Some(ref info) => Ok(u32::from(info.channel_map.channels)),
None => Err(cubeb::ERROR),
}
}
@ -276,7 +277,7 @@ impl Context {
preferred: preferred,
format: cubeb::DeviceFmt::all(),
default_format: pulse_format_to_cubeb_format(info.sample_spec.format),
max_channels: info.channel_map.channels as u32,
max_channels: u32::from(info.channel_map.channels),
min_rate: 1,
max_rate: PA_RATE_MAX,
default_rate: info.sample_spec.rate,
@ -332,7 +333,7 @@ impl Context {
preferred: preferred,
format: cubeb::DeviceFmt::all(),
default_format: pulse_format_to_cubeb_format(info.sample_spec.format),
max_channels: info.channel_map.channels as u32,
max_channels: u32::from(info.channel_map.channels),
min_rate: 1,
max_rate: PA_RATE_MAX,
default_rate: info.sample_spec.rate,
@ -341,7 +342,6 @@ impl Context {
};
list_data.devinfo.push(devinfo);
}
fn default_device_names(_: &pulse::Context, info: &pulse::ServerInfo, user_data: *mut c_void) {
@ -403,7 +403,7 @@ impl Context {
let mut devices = Vec::from_raw_parts(coll.device as *mut cubeb::DeviceInfo,
coll.count,
coll.count);
for dev in devices.iter_mut() {
for dev in &mut devices {
if !dev.group_id.is_null() {
let _ = CString::from_raw(dev.group_id as *mut _);
}
@ -558,18 +558,15 @@ impl Context {
}
let context_ptr: *mut c_void = self as *mut _ as *mut _;
match self.context.take() {
Some(ctx) => {
self.mainloop.lock();
if let Ok(o) = ctx.drain(drain_complete, context_ptr) {
self.operation_wait(None, &o);
}
ctx.clear_state_callback();
ctx.disconnect();
ctx.unref();
self.mainloop.unlock();
},
_ => {},
if let Some(ctx) = self.context.take() {
self.mainloop.lock();
if let Ok(o) = ctx.drain(drain_complete, context_ptr) {
self.operation_wait(None, &o);
}
ctx.clear_state_callback();
ctx.disconnect();
ctx.unref();
self.mainloop.unlock();
}
}

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

@ -34,7 +34,7 @@ fn cubeb_channel_to_pa_channel(channel: cubeb::Channel) -> pa_channel_position_t
PA_CHANNEL_POSITION_LFE // CHANNEL_LFE
];
let idx: i32 = channel.into();
let idx: i32 = channel;
MAP[idx as usize]
}
@ -89,6 +89,7 @@ impl<'ctx> Drop for Stream<'ctx> {
}
impl<'ctx> Stream<'ctx> {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new(context: &'ctx Context,
stream_name: &CStr,
input_device: cubeb::DeviceId,
@ -114,10 +115,8 @@ impl<'ctx> Stream<'ctx> {
let readable_size: i32 = s.readable_size()
.and_then(|s| Ok(s as i32))
.unwrap_or(-1);
if readable_size > 0 {
if unsafe { s.peek(buffer, size).is_err() } {
return -1;
}
if readable_size > 0 && unsafe { s.peek(buffer, size).is_err() } {
return -1;
}
readable_size
}
@ -230,7 +229,6 @@ impl<'ctx> Stream<'ctx> {
return Err(e);
},
}
}
// Set up input stream
@ -258,7 +256,6 @@ impl<'ctx> Stream<'ctx> {
return Err(e);
},
}
}
let r = if stm.wait_until_ready() {
@ -309,31 +306,25 @@ impl<'ctx> Stream<'ctx> {
self.context.mainloop.lock();
{
match self.output_stream.take() {
Some(stm) => {
if !self.drain_timer.is_null() {
/* there's no pa_rttime_free, so use this instead. */
self.context
.mainloop
.get_api()
.time_free(self.drain_timer);
}
stm.clear_state_callback();
stm.clear_write_callback();
let _ = stm.disconnect();
stm.unref();
},
_ => {},
if let Some(stm) = self.output_stream.take() {
if !self.drain_timer.is_null() {
/* there's no pa_rttime_free, so use this instead. */
self.context
.mainloop
.get_api()
.time_free(self.drain_timer);
}
stm.clear_state_callback();
stm.clear_write_callback();
let _ = stm.disconnect();
stm.unref();
}
match self.input_stream.take() {
Some(stm) => {
stm.clear_state_callback();
stm.clear_read_callback();
let _ = stm.disconnect();
stm.unref();
},
_ => {},
if let Some(stm) = self.input_stream.take() {
stm.clear_state_callback();
stm.clear_read_callback();
let _ = stm.disconnect();
stm.unref();
}
}
self.context.mainloop.unlock();
@ -416,7 +407,7 @@ impl<'ctx> Stream<'ctx> {
Some(ref stm) => {
match stm.get_latency() {
Ok(StreamLatency::Positive(r_usec)) => {
let latency = (r_usec * self.output_sample_spec.rate as pa_usec_t / PA_USEC_PER_SEC) as u32;
let latency = (r_usec * pa_usec_t::from(self.output_sample_spec.rate) / PA_USEC_PER_SEC) as u32;
Ok(latency)
},
Ok(_) => {
@ -451,8 +442,8 @@ impl<'ctx> Stream<'ctx> {
self.volume = volume;
} else {
let channels = stm.get_sample_spec().channels;
let vol = pulse::sw_volume_from_linear(volume as f64);
cvol.set(channels as u32, vol);
let vol = pulse::sw_volume_from_linear(f64::from(volume));
cvol.set(u32::from(channels), vol);
let index = stm.get_index();
@ -564,6 +555,10 @@ impl<'ctx> Stream<'ctx> {
stream_name: &CStr)
-> Result<pulse::Stream> {
if stream_params.prefs == cubeb::StreamPrefs::STREAM_PREF_LOOPBACK {
return Err(cubeb::ERROR_NOT_SUPPORTED);
}
fn to_pulse_format(format: cubeb::SampleFormat) -> pulse::SampleFormat {
match format {
cubeb::SAMPLE_S16LE => pulse::SampleFormat::Signed16LE,
@ -689,6 +684,7 @@ impl<'ctx> Stream<'ctx> {
true
}
#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
fn trigger_user_callback(&mut self, input_data: *const c_void, nbytes: usize) {
fn drained_cb(a: &pulse::MainloopApi, e: *mut pa_time_event, _tv: &pulse::TimeVal, u: *mut c_void) {
let stm = unsafe { &mut *(u as *mut Stream) };