Bug 1430996 - P1: Update cubeb-pulse-rs to commit cb7141e. r=kinetik

MozReview-Commit-ID: 2wrPNI9rvKF

--HG--
extra : rebase_source : 2a009c40dfdfd06a20b704ed033a47b93788edf4
This commit is contained in:
Dan Glastonbury 2018-01-17 15:24:43 +10:00
Родитель d68ecb1cb9
Коммит a539d73ba3
12 изменённых файлов: 141 добавлений и 143 удалений

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

@ -1,6 +1,6 @@
[package] [package]
name = "cubeb-pulse" name = "cubeb-pulse"
version = "0.0.1" version = "0.0.2"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"] authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
description = "Cubeb backed for PulseAudio written in Rust" description = "Cubeb backed for PulseAudio written in Rust"

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

@ -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 2e22e5359000f11c47346c54b34182bb350fe9d3 (2017-09-26 15:30:09 +1300) The git commit ID used was cb7141e3aae5471b3a8ac1e4524f35d04edcdf4e (2018-01-17 13:10:58 +1000)

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

@ -1,8 +1,8 @@
[package] [package]
name = "cubeb-ffi" name = "cubeb-ffi"
version = "0.0.1" version = "0.0.2"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"] authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
description = "FFI bindings for implementing cubeb backends" description = "FFI bindings for implementing cubeb backends"
[dependencies] [dependencies]
bitflags = "^0.7.0" bitflags = "1.0"

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

@ -93,11 +93,11 @@ pub const ERROR_DEVICE_UNAVAILABLE: i32 = -5;
// These need to match cubeb_device_type // These need to match cubeb_device_type
bitflags! { bitflags! {
#[repr(C)] #[repr(C)]
pub flags DeviceType : u32 { pub struct DeviceType : u32 {
const DEVICE_TYPE_UNKNOWN = 0b00, const UNKNOWN = 0b00;
const DEVICE_TYPE_INPUT = 0b01, const INPUT = 0b01;
const DEVICE_TYPE_OUTPUT = 0b10, const OUTPUT = 0b10;
const DEVICE_TYPE_ALL = 0b11, const ALL = 0b11;
} }
} }
@ -112,36 +112,33 @@ pub enum DeviceState {
// These need to match cubeb_device_fmt // These need to match cubeb_device_fmt
bitflags! { bitflags! {
#[repr(C)] #[repr(C)]
pub flags DeviceFmt: u32 { pub struct DeviceFmt: u32 {
const DEVICE_FMT_S16LE = 0x0010, const S16LE = 0x0010;
const DEVICE_FMT_S16BE = 0x0020, const S16BE = 0x0020;
const DEVICE_FMT_F32LE = 0x1000, const S16NE = {
const DEVICE_FMT_F32BE = 0x2000, #[cfg(target_endian = "little")] { DeviceFmt::S16LE }
const DEVICE_FMT_S16_MASK = DEVICE_FMT_S16LE.bits | DEVICE_FMT_S16BE.bits, #[cfg(target_endian = "big")] { DeviceFmt::S16BE }
const DEVICE_FMT_F32_MASK = DEVICE_FMT_F32LE.bits | DEVICE_FMT_F32BE.bits, }.bits;
const DEVICE_FMT_ALL = DEVICE_FMT_S16_MASK.bits | DEVICE_FMT_F32_MASK.bits, const F32LE = 0x1000;
const F32BE = 0x2000;
const F32NE = {
#[cfg(target_endian = "little")] { DeviceFmt::F32LE }
#[cfg(target_endian = "big")] { DeviceFmt::F32BE }
}.bits;
const S16_MASK = DeviceFmt::S16LE.bits | DeviceFmt::S16BE.bits;
const F32_MASK = DeviceFmt::F32LE.bits | DeviceFmt::F32BE.bits;
const ALL = DeviceFmt::S16_MASK.bits | DeviceFmt::F32_MASK.bits;
} }
} }
// Ideally these would be defined as part of `flags DeviceFmt` but
// that doesn't work with current bitflags crate.
#[cfg(target_endian = "little")]
pub const CUBEB_FMT_S16NE: DeviceFmt = DEVICE_FMT_S16LE;
#[cfg(target_endian = "little")]
pub const CUBEB_FMT_F32NE: DeviceFmt = DEVICE_FMT_F32LE;
#[cfg(target_endian = "big")]
pub const CUBEB_FMT_S16NE: DeviceFmt = DEVICE_FMT_S16BE;
#[cfg(target_endian = "big")]
pub const CUBEB_FMT_F32NE: DeviceFmt = DEVICE_FMT_F32BE;
// These need to match cubeb_device_pref // These need to match cubeb_device_pref
bitflags! { bitflags! {
#[repr(C)] #[repr(C)]
pub flags DevicePref : u32 { pub struct DevicePref : u32 {
const DEVICE_PREF_MULTIMEDIA = 0x1, const MULTIMEDIA = 0x1;
const DEVICE_PREF_VOICE = 0x2, const VOICE = 0x2;
const DEVICE_PREF_NOTIFICATION = 0x4, const NOTIFICATION = 0x4;
const DEVICE_PREF_ALL = 0xF const ALL = 0xF;
} }
} }

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

@ -18,8 +18,8 @@ macro_rules! log_internal {
unsafe { unsafe {
if $level <= $crate::g_cubeb_log_level { if $level <= $crate::g_cubeb_log_level {
if let Some(log_callback) = $crate::g_cubeb_log_callback { if let Some(log_callback) = $crate::g_cubeb_log_callback {
let cstr = ::std::ffi::CString::new(concat!("%s:%d: ", $fmt, "\n")).unwrap(); let cstr = ::std::ffi::CString::new(format!(concat!("%s:%d: ", $fmt, "\n"), $($arg)+)).unwrap();
log_callback(cstr.as_ptr(), file!(), line!(), $($arg)+); log_callback(cstr.as_ptr(), file!(), line!());
} }
} }
} }

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

@ -1,8 +1,8 @@
[package] [package]
name = "pulse" name = "pulse"
version = "0.1.0" version = "0.2.0"
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"] authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
[dependencies] [dependencies]
bitflags = "^0.7.0" bitflags = "1.0"
pulse-ffi = { path = "../pulse-ffi" } pulse-ffi = { path = "../pulse-ffi" }

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

@ -181,9 +181,9 @@ impl Into<ffi::pa_operation_state_t> for OperationState {
} }
bitflags! { bitflags! {
pub flags ContextFlags: u32 { pub struct ContextFlags: u32 {
const CONTEXT_FLAGS_NOAUTOSPAWN = ffi::PA_CONTEXT_NOAUTOSPAWN, const NOAUTOSPAWN = ffi::PA_CONTEXT_NOAUTOSPAWN;
const CONTEXT_FLAGS_NOFAIL = ffi::PA_CONTEXT_NOFAIL, const NOFAIL = ffi::PA_CONTEXT_NOFAIL;
} }
} }
@ -243,27 +243,27 @@ impl Into<ffi::pa_stream_direction_t> for StreamDirection {
} }
bitflags! { bitflags! {
pub flags StreamFlags : u32 { pub struct StreamFlags : u32 {
const STREAM_START_CORKED = ffi::PA_STREAM_START_CORKED, const START_CORKED = ffi::PA_STREAM_START_CORKED;
const STREAM_INTERPOLATE_TIMING = ffi::PA_STREAM_INTERPOLATE_TIMING, const INTERPOLATE_TIMING = ffi::PA_STREAM_INTERPOLATE_TIMING;
const STREAM_NOT_MONOTONIC = ffi::PA_STREAM_NOT_MONOTONIC, const NOT_MONOTONIC = ffi::PA_STREAM_NOT_MONOTONIC;
const STREAM_AUTO_TIMING_UPDATE = ffi::PA_STREAM_AUTO_TIMING_UPDATE, const AUTO_TIMING_UPDATE = ffi::PA_STREAM_AUTO_TIMING_UPDATE;
const STREAM_NO_REMAP_CHANNELS = ffi::PA_STREAM_NO_REMAP_CHANNELS, const NO_REMAP_CHANNELS = ffi::PA_STREAM_NO_REMAP_CHANNELS;
const STREAM_NO_REMIX_CHANNELS = ffi::PA_STREAM_NO_REMIX_CHANNELS, const NO_REMIX_CHANNELS = ffi::PA_STREAM_NO_REMIX_CHANNELS;
const STREAM_FIX_FORMAT = ffi::PA_STREAM_FIX_FORMAT, const FIX_FORMAT = ffi::PA_STREAM_FIX_FORMAT;
const STREAM_FIX_RATE = ffi::PA_STREAM_FIX_RATE, const FIX_RATE = ffi::PA_STREAM_FIX_RATE;
const STREAM_FIX_CHANNELS = ffi::PA_STREAM_FIX_CHANNELS, const FIX_CHANNELS = ffi::PA_STREAM_FIX_CHANNELS;
const STREAM_DONT_MOVE = ffi::PA_STREAM_DONT_MOVE, const DONT_MOVE = ffi::PA_STREAM_DONT_MOVE;
const STREAM_VARIABLE_RATE = ffi::PA_STREAM_VARIABLE_RATE, const VARIABLE_RATE = ffi::PA_STREAM_VARIABLE_RATE;
const STREAM_PEAK_DETECT = ffi::PA_STREAM_PEAK_DETECT, const PEAK_DETECT = ffi::PA_STREAM_PEAK_DETECT;
const STREAM_START_MUTED = ffi::PA_STREAM_START_MUTED, const START_MUTED = ffi::PA_STREAM_START_MUTED;
const STREAM_ADJUST_LATENCY = ffi::PA_STREAM_ADJUST_LATENCY, const ADJUST_LATENCY = ffi::PA_STREAM_ADJUST_LATENCY;
const STREAM_EARLY_REQUESTS = ffi::PA_STREAM_EARLY_REQUESTS, const EARLY_REQUESTS = ffi::PA_STREAM_EARLY_REQUESTS;
const STREAM_DONT_INHIBIT_AUTO_SUSPEND = ffi::PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND, const DONT_INHIBIT_AUTO_SUSPEND = ffi::PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND;
const STREAM_START_UNMUTED = ffi::PA_STREAM_START_UNMUTED, const START_UNMUTED = ffi::PA_STREAM_START_UNMUTED;
const STREAM_FAIL_ON_SUSPEND = ffi::PA_STREAM_FAIL_ON_SUSPEND, const FAIL_ON_SUSPEND = ffi::PA_STREAM_FAIL_ON_SUSPEND;
const STREAM_RELATIVE_VOLUME = ffi::PA_STREAM_RELATIVE_VOLUME, const RELATIVE_VOLUME = ffi::PA_STREAM_RELATIVE_VOLUME;
const STREAM_PASSTHROUGH = ffi::PA_STREAM_PASSTHROUGH, const PASSTHROUGH = ffi::PA_STREAM_PASSTHROUGH;
} }
} }
@ -300,17 +300,17 @@ pub enum StreamLatency {
} }
bitflags!{ bitflags!{
pub flags SubscriptionMask : u32 { pub struct SubscriptionMask : u32 {
const SUBSCRIPTION_MASK_SINK = ffi::PA_SUBSCRIPTION_MASK_SINK, const SINK = ffi::PA_SUBSCRIPTION_MASK_SINK;
const SUBSCRIPTION_MASK_SOURCE = ffi::PA_SUBSCRIPTION_MASK_SOURCE, const SOURCE = ffi::PA_SUBSCRIPTION_MASK_SOURCE;
const SUBSCRIPTION_MASK_SINK_INPUT = ffi::PA_SUBSCRIPTION_MASK_SINK_INPUT, const SINK_INPUT = ffi::PA_SUBSCRIPTION_MASK_SINK_INPUT;
const SUBSCRIPTION_MASK_SOURCE_OUTPUT = ffi::PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, const SOURCE_OUTPUT = ffi::PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT;
const SUBSCRIPTION_MASK_MODULE = ffi::PA_SUBSCRIPTION_MASK_MODULE, const MODULE = ffi::PA_SUBSCRIPTION_MASK_MODULE;
const SUBSCRIPTION_MASK_CLIENT = ffi::PA_SUBSCRIPTION_MASK_CLIENT, const CLIENT = ffi::PA_SUBSCRIPTION_MASK_CLIENT;
const SUBSCRIPTION_MASK_SAMPLE_CACHE = ffi::PA_SUBSCRIPTION_MASK_SAMPLE_CACHE, const SAMPLE_CACHE = ffi::PA_SUBSCRIPTION_MASK_SAMPLE_CACHE;
const SUBSCRIPTION_MASK_SERVER = ffi::PA_SUBSCRIPTION_MASK_SERVER, const SERVER = ffi::PA_SUBSCRIPTION_MASK_SERVER;
const SUBSCRIPTION_MASK_AUTOLOAD = ffi::PA_SUBSCRIPTION_MASK_AUTOLOAD, const AUTOLOAD = ffi::PA_SUBSCRIPTION_MASK_AUTOLOAD;
const SUBSCRIPTION_MASK_CARD = ffi::PA_SUBSCRIPTION_MASK_CARD, const CARD = ffi::PA_SUBSCRIPTION_MASK_CARD;
} }
} }
@ -400,16 +400,16 @@ impl Into<ffi::pa_seek_mode_t> for SeekMode {
} }
bitflags! { bitflags! {
pub flags SinkFlags: u32 { pub struct SinkFlags: u32 {
const SINK_HW_VOLUME_CTRL = ffi::PA_SINK_HW_VOLUME_CTRL, const HW_VOLUME_CTRL = ffi::PA_SINK_HW_VOLUME_CTRL;
const SINK_LATENCY = ffi::PA_SINK_LATENCY, const LATENCY = ffi::PA_SINK_LATENCY;
const SINK_HARDWARE = ffi::PA_SINK_HARDWARE, const HARDWARE = ffi::PA_SINK_HARDWARE;
const SINK_NETWORK = ffi::PA_SINK_NETWORK, const NETWORK = ffi::PA_SINK_NETWORK;
const SINK_HW_MUTE_CTRL = ffi::PA_SINK_HW_MUTE_CTRL, const HW_MUTE_CTRL = ffi::PA_SINK_HW_MUTE_CTRL;
const SINK_DECIBEL_VOLUME = ffi::PA_SINK_DECIBEL_VOLUME, const DECIBEL_VOLUME = ffi::PA_SINK_DECIBEL_VOLUME;
const SINK_FLAT_VOLUME = ffi::PA_SINK_FLAT_VOLUME, const FLAT_VOLUME = ffi::PA_SINK_FLAT_VOLUME;
const SINK_DYNAMIC_LATENCY = ffi::PA_SINK_DYNAMIC_LATENCY, const DYNAMIC_LATENCY = ffi::PA_SINK_DYNAMIC_LATENCY;
const SINK_SET_FORMATS = ffi::PA_SINK_SET_FORMATS, const SET_FORMATS = ffi::PA_SINK_SET_FORMATS;
} }
} }
@ -439,15 +439,15 @@ pub enum SinkState {
} }
bitflags!{ bitflags!{
pub flags SourceFlags: u32 { pub struct SourceFlags: u32 {
const SOURCE_FLAGS_HW_VOLUME_CTRL = ffi::PA_SOURCE_HW_VOLUME_CTRL, const HW_VOLUME_CTRL = ffi::PA_SOURCE_HW_VOLUME_CTRL;
const SOURCE_FLAGS_LATENCY = ffi::PA_SOURCE_LATENCY, const LATENCY = ffi::PA_SOURCE_LATENCY;
const SOURCE_FLAGS_HARDWARE = ffi::PA_SOURCE_HARDWARE, const HARDWARE = ffi::PA_SOURCE_HARDWARE;
const SOURCE_FLAGS_NETWORK = ffi::PA_SOURCE_NETWORK, const NETWORK = ffi::PA_SOURCE_NETWORK;
const SOURCE_FLAGS_HW_MUTE_CTRL = ffi::PA_SOURCE_HW_MUTE_CTRL, const HW_MUTE_CTRL = ffi::PA_SOURCE_HW_MUTE_CTRL;
const SOURCE_FLAGS_DECIBEL_VOLUME = ffi::PA_SOURCE_DECIBEL_VOLUME, const DECIBEL_VOLUME = ffi::PA_SOURCE_DECIBEL_VOLUME;
const SOURCE_FLAGS_DYNAMIC_LATENCY = ffi::PA_SOURCE_DYNAMIC_LATENCY, const DYNAMIC_LATENCY = ffi::PA_SOURCE_DYNAMIC_LATENCY;
const SOURCE_FLAGS_FLAT_VOLUME = ffi::PA_SOURCE_FLAT_VOLUME, const FLAT_VOLUME = ffi::PA_SOURCE_FLAT_VOLUME;
} }
} }

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

@ -121,7 +121,7 @@ impl Context {
pub fn new(name: *const c_char) -> Result<Box<Self>> { pub fn new(name: *const c_char) -> Result<Box<Self>> {
fn server_info_cb(context: &pulse::Context, info: &pulse::ServerInfo, u: *mut c_void) { fn server_info_cb(context: &pulse::Context, info: &pulse::ServerInfo, u: *mut c_void) {
fn sink_info_cb(_: &pulse::Context, i: *const pulse::SinkInfo, eol: i32, u: *mut c_void) { fn sink_info_cb(_: &pulse::Context, i: *const pulse::SinkInfo, eol: i32, u: *mut c_void) {
let mut ctx = unsafe { &mut *(u as *mut Context) }; let ctx = unsafe { &mut *(u as *mut Context) };
if eol == 0 { if eol == 0 {
let info = unsafe { &*i }; let info = unsafe { &*i };
let flags = pulse::SinkFlags::from_bits_truncate(info.flags); let flags = pulse::SinkFlags::from_bits_truncate(info.flags);
@ -231,7 +231,7 @@ impl Context {
pub fn enumerate_devices(&self, devtype: cubeb::DeviceType) -> Result<cubeb::DeviceCollection> { pub fn enumerate_devices(&self, devtype: cubeb::DeviceType) -> Result<cubeb::DeviceCollection> {
fn add_output_device(_: &pulse::Context, i: *const pulse::SinkInfo, eol: i32, user_data: *mut c_void) { fn add_output_device(_: &pulse::Context, i: *const pulse::SinkInfo, eol: i32, user_data: *mut c_void) {
let mut list_data = unsafe { &mut *(user_data as *mut PulseDevListData) }; let list_data = unsafe { &mut *(user_data as *mut PulseDevListData) };
let ctx = &(*list_data.context); let ctx = &(*list_data.context);
if eol != 0 { if eol != 0 {
@ -258,7 +258,7 @@ impl Context {
let info_description = unsafe { CStr::from_ptr(info.description) }.to_owned(); let info_description = unsafe { CStr::from_ptr(info.description) }.to_owned();
let preferred = if *info_name == *list_data.default_sink_name { let preferred = if *info_name == *list_data.default_sink_name {
cubeb::DEVICE_PREF_ALL cubeb::DevicePref::ALL
} else { } else {
cubeb::DevicePref::empty() cubeb::DevicePref::empty()
}; };
@ -271,7 +271,7 @@ impl Context {
friendly_name: friendly_name, friendly_name: friendly_name,
group_id: group_id, group_id: group_id,
vendor_name: vendor_name, vendor_name: vendor_name,
devtype: cubeb::DEVICE_TYPE_OUTPUT, devtype: cubeb::DeviceType::OUTPUT,
state: ctx.state_from_port(info.active_port), state: ctx.state_from_port(info.active_port),
preferred: preferred, preferred: preferred,
format: cubeb::DeviceFmt::all(), format: cubeb::DeviceFmt::all(),
@ -287,7 +287,7 @@ impl Context {
} }
fn add_input_device(_: &pulse::Context, i: *const pulse::SourceInfo, eol: i32, user_data: *mut c_void) { fn add_input_device(_: &pulse::Context, i: *const pulse::SourceInfo, eol: i32, user_data: *mut c_void) {
let mut list_data = unsafe { &mut *(user_data as *mut PulseDevListData) }; let list_data = unsafe { &mut *(user_data as *mut PulseDevListData) };
let ctx = &(*list_data.context); let ctx = &(*list_data.context);
if eol != 0 { if eol != 0 {
@ -314,7 +314,7 @@ impl Context {
let info_description = unsafe { CStr::from_ptr(info.description) }.to_owned(); let info_description = unsafe { CStr::from_ptr(info.description) }.to_owned();
let preferred = if *info_name == *list_data.default_source_name { let preferred = if *info_name == *list_data.default_source_name {
cubeb::DEVICE_PREF_ALL cubeb::DevicePref::ALL
} else { } else {
cubeb::DevicePref::empty() cubeb::DevicePref::empty()
}; };
@ -327,7 +327,7 @@ impl Context {
friendly_name: friendly_name, friendly_name: friendly_name,
group_id: group_id, group_id: group_id,
vendor_name: vendor_name, vendor_name: vendor_name,
devtype: cubeb::DEVICE_TYPE_INPUT, devtype: cubeb::DeviceType::INPUT,
state: ctx.state_from_port(info.active_port), state: ctx.state_from_port(info.active_port),
preferred: preferred, preferred: preferred,
format: cubeb::DeviceFmt::all(), format: cubeb::DeviceFmt::all(),
@ -366,13 +366,13 @@ impl Context {
self.operation_wait(None, &o); self.operation_wait(None, &o);
} }
if devtype.contains(cubeb::DEVICE_TYPE_OUTPUT) { if devtype.contains(cubeb::DeviceType::OUTPUT) {
if let Ok(o) = context.get_sink_info_list(add_output_device, &mut user_data as *mut _ as *mut _) { if let Ok(o) = context.get_sink_info_list(add_output_device, &mut user_data as *mut _ as *mut _) {
self.operation_wait(None, &o); self.operation_wait(None, &o);
} }
} }
if devtype.contains(cubeb::DEVICE_TYPE_INPUT) { if devtype.contains(cubeb::DeviceType::INPUT) {
if let Ok(o) = context.get_source_info_list(add_input_device, &mut user_data as *mut _ as *mut _) { if let Ok(o) = context.get_source_info_list(add_input_device, &mut user_data as *mut _ as *mut _) {
self.operation_wait(None, &o); self.operation_wait(None, &o);
} }
@ -423,7 +423,7 @@ impl Context {
user_ptr: *mut c_void) user_ptr: *mut c_void)
-> i32 { -> i32 {
fn update_collection(_: &pulse::Context, event: pulse::SubscriptionEvent, index: u32, user_data: *mut c_void) { fn update_collection(_: &pulse::Context, event: pulse::SubscriptionEvent, index: u32, user_data: *mut c_void) {
let mut ctx = unsafe { &mut *(user_data as *mut Context) }; let ctx = unsafe { &mut *(user_data as *mut Context) };
let (f, t) = (event.event_facility(), event.event_type()); let (f, t) = (event.event_facility(), event.event_type());
match f { match f {
@ -477,17 +477,18 @@ impl Context {
context.clear_subscribe_callback(); context.clear_subscribe_callback();
} else { } else {
context.set_subscribe_callback(update_collection, user_data); context.set_subscribe_callback(update_collection, user_data);
if devtype.contains(cubeb::DEVICE_TYPE_INPUT) { if devtype.contains(cubeb::DeviceType::INPUT) {
mask |= pulse::SUBSCRIPTION_MASK_SOURCE mask |= pulse::SubscriptionMask::SOURCE
}; };
if devtype.contains(cubeb::DEVICE_TYPE_OUTPUT) { if devtype.contains(cubeb::DeviceType::OUTPUT) {
mask = pulse::SUBSCRIPTION_MASK_SINK mask = pulse::SubscriptionMask::SINK
}; };
} }
if let Ok(o) = context.subscribe(mask, success, self as *const _ as *mut _) { if let Ok(o) = context.subscribe(mask, success, self as *const _ as *mut _) {
self.operation_wait(None, &o); self.operation_wait(None, &o);
} else { } else {
self.mainloop.unlock();
log!("Context subscribe failed"); log!("Context subscribe failed");
return cubeb::ERROR; return cubeb::ERROR;
} }
@ -500,7 +501,7 @@ impl Context {
pub fn context_init(&mut self) -> i32 { pub fn context_init(&mut self) -> i32 {
fn error_state(c: &pulse::Context, u: *mut c_void) { fn error_state(c: &pulse::Context, u: *mut c_void) {
let mut ctx = unsafe { &mut *(u as *mut Context) }; let ctx = unsafe { &mut *(u as *mut Context) };
if !c.get_state().is_good() { if !c.get_state().is_good() {
ctx.error = true; ctx.error = true;
} }
@ -655,11 +656,11 @@ impl<'a> Drop for PulseDevListData<'a> {
fn pulse_format_to_cubeb_format(format: pa_sample_format_t) -> cubeb::DeviceFmt { fn pulse_format_to_cubeb_format(format: pa_sample_format_t) -> cubeb::DeviceFmt {
match format { match format {
PA_SAMPLE_S16LE => cubeb::DEVICE_FMT_S16LE, PA_SAMPLE_S16LE => cubeb::DeviceFmt::S16LE,
PA_SAMPLE_S16BE => cubeb::DEVICE_FMT_S16BE, PA_SAMPLE_S16BE => cubeb::DeviceFmt::S16BE,
PA_SAMPLE_FLOAT32LE => cubeb::DEVICE_FMT_F32LE, PA_SAMPLE_FLOAT32LE => cubeb::DeviceFmt::F32LE,
PA_SAMPLE_FLOAT32BE => cubeb::DEVICE_FMT_F32BE, PA_SAMPLE_FLOAT32BE => cubeb::DeviceFmt::F32BE,
// Unsupported format, return F32NE // Unsupported format, return F32NE
_ => cubeb::CUBEB_FMT_F32NE, _ => cubeb::DeviceFmt::F32NE,
} }
} }

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

@ -123,7 +123,7 @@ impl<'ctx> Stream<'ctx> {
} }
logv!("Input callback buffer size {}", nbytes); logv!("Input callback buffer size {}", nbytes);
let mut stm = unsafe { &mut *(u as *mut Stream) }; let stm = unsafe { &mut *(u as *mut Stream) };
if stm.shutdown { if stm.shutdown {
return; return;
} }
@ -172,7 +172,7 @@ impl<'ctx> Stream<'ctx> {
fn write_data(_: &pulse::Stream, nbytes: usize, u: *mut c_void) { fn write_data(_: &pulse::Stream, nbytes: usize, u: *mut c_void) {
logv!("Output callback to be written buffer size {}", nbytes); logv!("Output callback to be written buffer size {}", nbytes);
let mut stm = unsafe { &mut *(u as *mut Stream) }; let stm = unsafe { &mut *(u as *mut Stream) };
if stm.shutdown || stm.state != cubeb::STATE_STARTED { if stm.shutdown || stm.state != cubeb::STATE_STARTED {
return; return;
} }
@ -216,9 +216,9 @@ impl<'ctx> Stream<'ctx> {
let device_name = super::try_cstr_from(output_device as *const _); let device_name = super::try_cstr_from(output_device as *const _);
let _ = s.connect_playback(device_name, let _ = s.connect_playback(device_name,
&battr, &battr,
pulse::STREAM_AUTO_TIMING_UPDATE | pulse::STREAM_INTERPOLATE_TIMING | pulse::StreamFlags::AUTO_TIMING_UPDATE | pulse::StreamFlags::INTERPOLATE_TIMING |
pulse::STREAM_START_CORKED | pulse::StreamFlags::START_CORKED |
pulse::STREAM_ADJUST_LATENCY, pulse::StreamFlags::ADJUST_LATENCY,
None, None,
None); None);
@ -246,9 +246,9 @@ impl<'ctx> Stream<'ctx> {
let device_name = super::try_cstr_from(input_device as *const _); let device_name = super::try_cstr_from(input_device as *const _);
let _ = s.connect_record(device_name, let _ = s.connect_record(device_name,
&battr, &battr,
pulse::STREAM_AUTO_TIMING_UPDATE | pulse::STREAM_INTERPOLATE_TIMING | pulse::StreamFlags::AUTO_TIMING_UPDATE | pulse::StreamFlags::INTERPOLATE_TIMING |
pulse::STREAM_START_CORKED | pulse::StreamFlags::START_CORKED |
pulse::STREAM_ADJUST_LATENCY); pulse::StreamFlags::ADJUST_LATENCY);
stm.input_stream = Some(s); stm.input_stream = Some(s);
}, },
@ -341,7 +341,7 @@ impl<'ctx> Stream<'ctx> {
pub fn start(&mut self) -> i32 { pub fn start(&mut self) -> i32 {
fn output_preroll(_: &pulse::MainloopApi, u: *mut c_void) { fn output_preroll(_: &pulse::MainloopApi, u: *mut c_void) {
let mut stm = unsafe { &mut *(u as *mut Stream) }; let stm = unsafe { &mut *(u as *mut Stream) };
if !stm.shutdown { if !stm.shutdown {
let size = stm.output_stream let size = stm.output_stream
.as_ref() .as_ref()
@ -447,7 +447,7 @@ impl<'ctx> Stream<'ctx> {
} }
}; };
if flags.contains(pulse::SINK_FLAT_VOLUME) { if flags.contains(pulse::SinkFlags::FLAT_VOLUME) {
self.volume = volume; self.volume = volume;
} else { } else {
let channels = stm.get_sample_spec().channels; let channels = stm.get_sample_spec().channels;
@ -479,7 +479,7 @@ impl<'ctx> Stream<'ctx> {
} }
fn get_input_volume(_: &pulse::Context, info: *const pulse::SinkInputInfo, eol: i32, u: *mut c_void) { fn get_input_volume(_: &pulse::Context, info: *const pulse::SinkInputInfo, eol: i32, u: *mut c_void) {
let mut r = unsafe { &mut *(u as *mut SinkInputInfoResult) }; let r = unsafe { &mut *(u as *mut SinkInputInfoResult) };
if eol == 0 { if eol == 0 {
let info = unsafe { *info }; let info = unsafe { *info };
r.cvol = info.volume; r.cvol = info.volume;
@ -691,7 +691,7 @@ impl<'ctx> Stream<'ctx> {
fn trigger_user_callback(&mut self, input_data: *const c_void, nbytes: usize) { 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) { fn drained_cb(a: &pulse::MainloopApi, e: *mut pa_time_event, _tv: &pulse::TimeVal, u: *mut c_void) {
let mut stm = unsafe { &mut *(u as *mut Stream) }; let stm = unsafe { &mut *(u as *mut Stream) };
debug_assert_eq!(stm.drain_timer, e); debug_assert_eq!(stm.drain_timer, e);
stm.state_change_callback(cubeb::STATE_DRAINED); stm.state_change_callback(cubeb::STATE_DRAINED);
/* there's no pa_rttime_free, so use this instead. */ /* there's no pa_rttime_free, so use this instead. */

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

@ -119,7 +119,7 @@ unsafe extern "C" fn capi_stream_init(c: *mut cubeb::Context,
if sp.is_null() { None } else { Some(unsafe { *sp }) } if sp.is_null() { None } else { Some(unsafe { *sp }) }
} }
let mut ctx = &mut *(c as *mut backend::Context); let ctx = &mut *(c as *mut backend::Context);
let stream_name = CStr::from_ptr(stream_name); let stream_name = CStr::from_ptr(stream_name);
match ctx.new_stream(stream_name, match ctx.new_stream(stream_name,
@ -144,13 +144,13 @@ unsafe extern "C" fn capi_stream_destroy(s: *mut cubeb::Stream) {
} }
unsafe extern "C" fn capi_stream_start(s: *mut cubeb::Stream) -> i32 { unsafe extern "C" fn capi_stream_start(s: *mut cubeb::Stream) -> i32 {
let mut stm = &mut *(s as *mut backend::Stream); let stm = &mut *(s as *mut backend::Stream);
stm.start() stm.start()
} }
unsafe extern "C" fn capi_stream_stop(s: *mut cubeb::Stream) -> i32 { unsafe extern "C" fn capi_stream_stop(s: *mut cubeb::Stream) -> i32 {
let mut stm = &mut *(s as *mut backend::Stream); let stm = &mut *(s as *mut backend::Stream);
stm.stop() stm.stop()
} }
@ -214,7 +214,7 @@ unsafe extern "C" fn capi_register_device_collection_changed(c: *mut cubeb::Cont
cubeb::DeviceCollectionChangedCallback, cubeb::DeviceCollectionChangedCallback,
user_ptr: *mut c_void) -> i32 user_ptr: *mut c_void) -> i32
{ {
let mut ctx = &mut *(c as *mut backend::Context); let ctx = &mut *(c as *mut backend::Context);
ctx.register_device_collection_changed(devtype, collection_changed_callback, user_ptr as _) ctx.register_device_collection_changed(devtype, collection_changed_callback, user_ptr as _)
} }

16
toolkit/library/gtest/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -329,17 +329,17 @@ dependencies = [
[[package]] [[package]]
name = "cubeb-ffi" name = "cubeb-ffi"
version = "0.0.1" version = "0.0.2"
dependencies = [ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "cubeb-pulse" name = "cubeb-pulse"
version = "0.0.1" version = "0.0.2"
dependencies = [ dependencies = [
"cubeb-ffi 0.0.1", "cubeb-ffi 0.0.2",
"pulse 0.1.0", "pulse 0.2.0",
"pulse-ffi 0.1.0", "pulse-ffi 0.1.0",
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -568,7 +568,7 @@ dependencies = [
"cubeb 0.3.0", "cubeb 0.3.0",
"cubeb-backend 0.2.0", "cubeb-backend 0.2.0",
"cubeb-core 0.1.0", "cubeb-core 0.1.0",
"cubeb-pulse 0.0.1", "cubeb-pulse 0.0.2",
"encoding_c 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_c 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_glue 0.1.0", "encoding_glue 0.1.0",
"geckoservo 0.0.1", "geckoservo 0.0.1",
@ -1023,9 +1023,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "pulse" name = "pulse"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pulse-ffi 0.1.0", "pulse-ffi 0.1.0",
] ]

16
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -329,17 +329,17 @@ dependencies = [
[[package]] [[package]]
name = "cubeb-ffi" name = "cubeb-ffi"
version = "0.0.1" version = "0.0.2"
dependencies = [ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "cubeb-pulse" name = "cubeb-pulse"
version = "0.0.1" version = "0.0.2"
dependencies = [ dependencies = [
"cubeb-ffi 0.0.1", "cubeb-ffi 0.0.2",
"pulse 0.1.0", "pulse 0.2.0",
"pulse-ffi 0.1.0", "pulse-ffi 0.1.0",
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -567,7 +567,7 @@ dependencies = [
"cubeb 0.3.0", "cubeb 0.3.0",
"cubeb-backend 0.2.0", "cubeb-backend 0.2.0",
"cubeb-core 0.1.0", "cubeb-core 0.1.0",
"cubeb-pulse 0.0.1", "cubeb-pulse 0.0.2",
"encoding_c 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_c 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_glue 0.1.0", "encoding_glue 0.1.0",
"geckoservo 0.0.1", "geckoservo 0.0.1",
@ -1011,9 +1011,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "pulse" name = "pulse"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pulse-ffi 0.1.0", "pulse-ffi 0.1.0",
] ]