зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
d68ecb1cb9
Коммит
a539d73ba3
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "cubeb-pulse"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
|
||||
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 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]
|
||||
name = "cubeb-ffi"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
|
||||
description = "FFI bindings for implementing cubeb backends"
|
||||
|
||||
[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
|
||||
bitflags! {
|
||||
#[repr(C)]
|
||||
pub flags DeviceType : u32 {
|
||||
const DEVICE_TYPE_UNKNOWN = 0b00,
|
||||
const DEVICE_TYPE_INPUT = 0b01,
|
||||
const DEVICE_TYPE_OUTPUT = 0b10,
|
||||
const DEVICE_TYPE_ALL = 0b11,
|
||||
pub struct DeviceType : u32 {
|
||||
const UNKNOWN = 0b00;
|
||||
const INPUT = 0b01;
|
||||
const OUTPUT = 0b10;
|
||||
const ALL = 0b11;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,36 +112,33 @@ pub enum DeviceState {
|
|||
// These need to match cubeb_device_fmt
|
||||
bitflags! {
|
||||
#[repr(C)]
|
||||
pub flags DeviceFmt: u32 {
|
||||
const DEVICE_FMT_S16LE = 0x0010,
|
||||
const DEVICE_FMT_S16BE = 0x0020,
|
||||
const DEVICE_FMT_F32LE = 0x1000,
|
||||
const DEVICE_FMT_F32BE = 0x2000,
|
||||
const DEVICE_FMT_S16_MASK = DEVICE_FMT_S16LE.bits | DEVICE_FMT_S16BE.bits,
|
||||
const DEVICE_FMT_F32_MASK = DEVICE_FMT_F32LE.bits | DEVICE_FMT_F32BE.bits,
|
||||
const DEVICE_FMT_ALL = DEVICE_FMT_S16_MASK.bits | DEVICE_FMT_F32_MASK.bits,
|
||||
pub struct DeviceFmt: u32 {
|
||||
const S16LE = 0x0010;
|
||||
const S16BE = 0x0020;
|
||||
const S16NE = {
|
||||
#[cfg(target_endian = "little")] { DeviceFmt::S16LE }
|
||||
#[cfg(target_endian = "big")] { DeviceFmt::S16BE }
|
||||
}.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
|
||||
bitflags! {
|
||||
#[repr(C)]
|
||||
pub flags DevicePref : u32 {
|
||||
const DEVICE_PREF_MULTIMEDIA = 0x1,
|
||||
const DEVICE_PREF_VOICE = 0x2,
|
||||
const DEVICE_PREF_NOTIFICATION = 0x4,
|
||||
const DEVICE_PREF_ALL = 0xF
|
||||
pub struct DevicePref : u32 {
|
||||
const MULTIMEDIA = 0x1;
|
||||
const VOICE = 0x2;
|
||||
const NOTIFICATION = 0x4;
|
||||
const ALL = 0xF;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ macro_rules! log_internal {
|
|||
unsafe {
|
||||
if $level <= $crate::g_cubeb_log_level {
|
||||
if let Some(log_callback) = $crate::g_cubeb_log_callback {
|
||||
let cstr = ::std::ffi::CString::new(concat!("%s:%d: ", $fmt, "\n")).unwrap();
|
||||
log_callback(cstr.as_ptr(), file!(), line!(), $($arg)+);
|
||||
let cstr = ::std::ffi::CString::new(format!(concat!("%s:%d: ", $fmt, "\n"), $($arg)+)).unwrap();
|
||||
log_callback(cstr.as_ptr(), file!(), line!());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[package]
|
||||
name = "pulse"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
|
||||
|
||||
[dependencies]
|
||||
bitflags = "^0.7.0"
|
||||
bitflags = "1.0"
|
||||
pulse-ffi = { path = "../pulse-ffi" }
|
||||
|
|
|
@ -181,9 +181,9 @@ impl Into<ffi::pa_operation_state_t> for OperationState {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
pub flags ContextFlags: u32 {
|
||||
const CONTEXT_FLAGS_NOAUTOSPAWN = ffi::PA_CONTEXT_NOAUTOSPAWN,
|
||||
const CONTEXT_FLAGS_NOFAIL = ffi::PA_CONTEXT_NOFAIL,
|
||||
pub struct ContextFlags: u32 {
|
||||
const NOAUTOSPAWN = ffi::PA_CONTEXT_NOAUTOSPAWN;
|
||||
const NOFAIL = ffi::PA_CONTEXT_NOFAIL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,27 +243,27 @@ impl Into<ffi::pa_stream_direction_t> for StreamDirection {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
pub flags StreamFlags : u32 {
|
||||
const STREAM_START_CORKED = ffi::PA_STREAM_START_CORKED,
|
||||
const STREAM_INTERPOLATE_TIMING = ffi::PA_STREAM_INTERPOLATE_TIMING,
|
||||
const STREAM_NOT_MONOTONIC = ffi::PA_STREAM_NOT_MONOTONIC,
|
||||
const STREAM_AUTO_TIMING_UPDATE = ffi::PA_STREAM_AUTO_TIMING_UPDATE,
|
||||
const STREAM_NO_REMAP_CHANNELS = ffi::PA_STREAM_NO_REMAP_CHANNELS,
|
||||
const STREAM_NO_REMIX_CHANNELS = ffi::PA_STREAM_NO_REMIX_CHANNELS,
|
||||
const STREAM_FIX_FORMAT = ffi::PA_STREAM_FIX_FORMAT,
|
||||
const STREAM_FIX_RATE = ffi::PA_STREAM_FIX_RATE,
|
||||
const STREAM_FIX_CHANNELS = ffi::PA_STREAM_FIX_CHANNELS,
|
||||
const STREAM_DONT_MOVE = ffi::PA_STREAM_DONT_MOVE,
|
||||
const STREAM_VARIABLE_RATE = ffi::PA_STREAM_VARIABLE_RATE,
|
||||
const STREAM_PEAK_DETECT = ffi::PA_STREAM_PEAK_DETECT,
|
||||
const STREAM_START_MUTED = ffi::PA_STREAM_START_MUTED,
|
||||
const STREAM_ADJUST_LATENCY = ffi::PA_STREAM_ADJUST_LATENCY,
|
||||
const STREAM_EARLY_REQUESTS = ffi::PA_STREAM_EARLY_REQUESTS,
|
||||
const STREAM_DONT_INHIBIT_AUTO_SUSPEND = ffi::PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND,
|
||||
const STREAM_START_UNMUTED = ffi::PA_STREAM_START_UNMUTED,
|
||||
const STREAM_FAIL_ON_SUSPEND = ffi::PA_STREAM_FAIL_ON_SUSPEND,
|
||||
const STREAM_RELATIVE_VOLUME = ffi::PA_STREAM_RELATIVE_VOLUME,
|
||||
const STREAM_PASSTHROUGH = ffi::PA_STREAM_PASSTHROUGH,
|
||||
pub struct StreamFlags : u32 {
|
||||
const START_CORKED = ffi::PA_STREAM_START_CORKED;
|
||||
const INTERPOLATE_TIMING = ffi::PA_STREAM_INTERPOLATE_TIMING;
|
||||
const NOT_MONOTONIC = ffi::PA_STREAM_NOT_MONOTONIC;
|
||||
const AUTO_TIMING_UPDATE = ffi::PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
const NO_REMAP_CHANNELS = ffi::PA_STREAM_NO_REMAP_CHANNELS;
|
||||
const NO_REMIX_CHANNELS = ffi::PA_STREAM_NO_REMIX_CHANNELS;
|
||||
const FIX_FORMAT = ffi::PA_STREAM_FIX_FORMAT;
|
||||
const FIX_RATE = ffi::PA_STREAM_FIX_RATE;
|
||||
const FIX_CHANNELS = ffi::PA_STREAM_FIX_CHANNELS;
|
||||
const DONT_MOVE = ffi::PA_STREAM_DONT_MOVE;
|
||||
const VARIABLE_RATE = ffi::PA_STREAM_VARIABLE_RATE;
|
||||
const PEAK_DETECT = ffi::PA_STREAM_PEAK_DETECT;
|
||||
const START_MUTED = ffi::PA_STREAM_START_MUTED;
|
||||
const ADJUST_LATENCY = ffi::PA_STREAM_ADJUST_LATENCY;
|
||||
const EARLY_REQUESTS = ffi::PA_STREAM_EARLY_REQUESTS;
|
||||
const DONT_INHIBIT_AUTO_SUSPEND = ffi::PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND;
|
||||
const START_UNMUTED = ffi::PA_STREAM_START_UNMUTED;
|
||||
const FAIL_ON_SUSPEND = ffi::PA_STREAM_FAIL_ON_SUSPEND;
|
||||
const RELATIVE_VOLUME = ffi::PA_STREAM_RELATIVE_VOLUME;
|
||||
const PASSTHROUGH = ffi::PA_STREAM_PASSTHROUGH;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,17 +300,17 @@ pub enum StreamLatency {
|
|||
}
|
||||
|
||||
bitflags!{
|
||||
pub flags SubscriptionMask : u32 {
|
||||
const SUBSCRIPTION_MASK_SINK = ffi::PA_SUBSCRIPTION_MASK_SINK,
|
||||
const SUBSCRIPTION_MASK_SOURCE = ffi::PA_SUBSCRIPTION_MASK_SOURCE,
|
||||
const SUBSCRIPTION_MASK_SINK_INPUT = ffi::PA_SUBSCRIPTION_MASK_SINK_INPUT,
|
||||
const SUBSCRIPTION_MASK_SOURCE_OUTPUT = ffi::PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT,
|
||||
const SUBSCRIPTION_MASK_MODULE = ffi::PA_SUBSCRIPTION_MASK_MODULE,
|
||||
const SUBSCRIPTION_MASK_CLIENT = ffi::PA_SUBSCRIPTION_MASK_CLIENT,
|
||||
const SUBSCRIPTION_MASK_SAMPLE_CACHE = ffi::PA_SUBSCRIPTION_MASK_SAMPLE_CACHE,
|
||||
const SUBSCRIPTION_MASK_SERVER = ffi::PA_SUBSCRIPTION_MASK_SERVER,
|
||||
const SUBSCRIPTION_MASK_AUTOLOAD = ffi::PA_SUBSCRIPTION_MASK_AUTOLOAD,
|
||||
const SUBSCRIPTION_MASK_CARD = ffi::PA_SUBSCRIPTION_MASK_CARD,
|
||||
pub struct SubscriptionMask : u32 {
|
||||
const SINK = ffi::PA_SUBSCRIPTION_MASK_SINK;
|
||||
const SOURCE = ffi::PA_SUBSCRIPTION_MASK_SOURCE;
|
||||
const SINK_INPUT = ffi::PA_SUBSCRIPTION_MASK_SINK_INPUT;
|
||||
const SOURCE_OUTPUT = ffi::PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT;
|
||||
const MODULE = ffi::PA_SUBSCRIPTION_MASK_MODULE;
|
||||
const CLIENT = ffi::PA_SUBSCRIPTION_MASK_CLIENT;
|
||||
const SAMPLE_CACHE = ffi::PA_SUBSCRIPTION_MASK_SAMPLE_CACHE;
|
||||
const SERVER = ffi::PA_SUBSCRIPTION_MASK_SERVER;
|
||||
const AUTOLOAD = ffi::PA_SUBSCRIPTION_MASK_AUTOLOAD;
|
||||
const CARD = ffi::PA_SUBSCRIPTION_MASK_CARD;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,16 +400,16 @@ impl Into<ffi::pa_seek_mode_t> for SeekMode {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
pub flags SinkFlags: u32 {
|
||||
const SINK_HW_VOLUME_CTRL = ffi::PA_SINK_HW_VOLUME_CTRL,
|
||||
const SINK_LATENCY = ffi::PA_SINK_LATENCY,
|
||||
const SINK_HARDWARE = ffi::PA_SINK_HARDWARE,
|
||||
const SINK_NETWORK = ffi::PA_SINK_NETWORK,
|
||||
const SINK_HW_MUTE_CTRL = ffi::PA_SINK_HW_MUTE_CTRL,
|
||||
const SINK_DECIBEL_VOLUME = ffi::PA_SINK_DECIBEL_VOLUME,
|
||||
const SINK_FLAT_VOLUME = ffi::PA_SINK_FLAT_VOLUME,
|
||||
const SINK_DYNAMIC_LATENCY = ffi::PA_SINK_DYNAMIC_LATENCY,
|
||||
const SINK_SET_FORMATS = ffi::PA_SINK_SET_FORMATS,
|
||||
pub struct SinkFlags: u32 {
|
||||
const HW_VOLUME_CTRL = ffi::PA_SINK_HW_VOLUME_CTRL;
|
||||
const LATENCY = ffi::PA_SINK_LATENCY;
|
||||
const HARDWARE = ffi::PA_SINK_HARDWARE;
|
||||
const NETWORK = ffi::PA_SINK_NETWORK;
|
||||
const HW_MUTE_CTRL = ffi::PA_SINK_HW_MUTE_CTRL;
|
||||
const DECIBEL_VOLUME = ffi::PA_SINK_DECIBEL_VOLUME;
|
||||
const FLAT_VOLUME = ffi::PA_SINK_FLAT_VOLUME;
|
||||
const DYNAMIC_LATENCY = ffi::PA_SINK_DYNAMIC_LATENCY;
|
||||
const SET_FORMATS = ffi::PA_SINK_SET_FORMATS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,15 +439,15 @@ pub enum SinkState {
|
|||
}
|
||||
|
||||
bitflags!{
|
||||
pub flags SourceFlags: u32 {
|
||||
const SOURCE_FLAGS_HW_VOLUME_CTRL = ffi::PA_SOURCE_HW_VOLUME_CTRL,
|
||||
const SOURCE_FLAGS_LATENCY = ffi::PA_SOURCE_LATENCY,
|
||||
const SOURCE_FLAGS_HARDWARE = ffi::PA_SOURCE_HARDWARE,
|
||||
const SOURCE_FLAGS_NETWORK = ffi::PA_SOURCE_NETWORK,
|
||||
const SOURCE_FLAGS_HW_MUTE_CTRL = ffi::PA_SOURCE_HW_MUTE_CTRL,
|
||||
const SOURCE_FLAGS_DECIBEL_VOLUME = ffi::PA_SOURCE_DECIBEL_VOLUME,
|
||||
const SOURCE_FLAGS_DYNAMIC_LATENCY = ffi::PA_SOURCE_DYNAMIC_LATENCY,
|
||||
const SOURCE_FLAGS_FLAT_VOLUME = ffi::PA_SOURCE_FLAT_VOLUME,
|
||||
pub struct SourceFlags: u32 {
|
||||
const HW_VOLUME_CTRL = ffi::PA_SOURCE_HW_VOLUME_CTRL;
|
||||
const LATENCY = ffi::PA_SOURCE_LATENCY;
|
||||
const HARDWARE = ffi::PA_SOURCE_HARDWARE;
|
||||
const NETWORK = ffi::PA_SOURCE_NETWORK;
|
||||
const HW_MUTE_CTRL = ffi::PA_SOURCE_HW_MUTE_CTRL;
|
||||
const DECIBEL_VOLUME = ffi::PA_SOURCE_DECIBEL_VOLUME;
|
||||
const DYNAMIC_LATENCY = ffi::PA_SOURCE_DYNAMIC_LATENCY;
|
||||
const FLAT_VOLUME = ffi::PA_SOURCE_FLAT_VOLUME;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ impl Context {
|
|||
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 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 {
|
||||
let info = unsafe { &*i };
|
||||
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> {
|
||||
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);
|
||||
|
||||
if eol != 0 {
|
||||
|
@ -258,7 +258,7 @@ impl Context {
|
|||
let info_description = unsafe { CStr::from_ptr(info.description) }.to_owned();
|
||||
|
||||
let preferred = if *info_name == *list_data.default_sink_name {
|
||||
cubeb::DEVICE_PREF_ALL
|
||||
cubeb::DevicePref::ALL
|
||||
} else {
|
||||
cubeb::DevicePref::empty()
|
||||
};
|
||||
|
@ -271,7 +271,7 @@ impl Context {
|
|||
friendly_name: friendly_name,
|
||||
group_id: group_id,
|
||||
vendor_name: vendor_name,
|
||||
devtype: cubeb::DEVICE_TYPE_OUTPUT,
|
||||
devtype: cubeb::DeviceType::OUTPUT,
|
||||
state: ctx.state_from_port(info.active_port),
|
||||
preferred: preferred,
|
||||
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) {
|
||||
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);
|
||||
|
||||
if eol != 0 {
|
||||
|
@ -314,7 +314,7 @@ impl Context {
|
|||
let info_description = unsafe { CStr::from_ptr(info.description) }.to_owned();
|
||||
|
||||
let preferred = if *info_name == *list_data.default_source_name {
|
||||
cubeb::DEVICE_PREF_ALL
|
||||
cubeb::DevicePref::ALL
|
||||
} else {
|
||||
cubeb::DevicePref::empty()
|
||||
};
|
||||
|
@ -327,7 +327,7 @@ impl Context {
|
|||
friendly_name: friendly_name,
|
||||
group_id: group_id,
|
||||
vendor_name: vendor_name,
|
||||
devtype: cubeb::DEVICE_TYPE_INPUT,
|
||||
devtype: cubeb::DeviceType::INPUT,
|
||||
state: ctx.state_from_port(info.active_port),
|
||||
preferred: preferred,
|
||||
format: cubeb::DeviceFmt::all(),
|
||||
|
@ -366,13 +366,13 @@ impl Context {
|
|||
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 _) {
|
||||
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 _) {
|
||||
self.operation_wait(None, &o);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ impl Context {
|
|||
user_ptr: *mut c_void)
|
||||
-> i32 {
|
||||
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());
|
||||
match f {
|
||||
|
@ -477,17 +477,18 @@ impl Context {
|
|||
context.clear_subscribe_callback();
|
||||
} else {
|
||||
context.set_subscribe_callback(update_collection, user_data);
|
||||
if devtype.contains(cubeb::DEVICE_TYPE_INPUT) {
|
||||
mask |= pulse::SUBSCRIPTION_MASK_SOURCE
|
||||
if devtype.contains(cubeb::DeviceType::INPUT) {
|
||||
mask |= pulse::SubscriptionMask::SOURCE
|
||||
};
|
||||
if devtype.contains(cubeb::DEVICE_TYPE_OUTPUT) {
|
||||
mask = pulse::SUBSCRIPTION_MASK_SINK
|
||||
if devtype.contains(cubeb::DeviceType::OUTPUT) {
|
||||
mask = pulse::SubscriptionMask::SINK
|
||||
};
|
||||
}
|
||||
|
||||
if let Ok(o) = context.subscribe(mask, success, self as *const _ as *mut _) {
|
||||
self.operation_wait(None, &o);
|
||||
} else {
|
||||
self.mainloop.unlock();
|
||||
log!("Context subscribe failed");
|
||||
return cubeb::ERROR;
|
||||
}
|
||||
|
@ -500,7 +501,7 @@ impl Context {
|
|||
|
||||
pub fn context_init(&mut self) -> i32 {
|
||||
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() {
|
||||
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 {
|
||||
match format {
|
||||
PA_SAMPLE_S16LE => cubeb::DEVICE_FMT_S16LE,
|
||||
PA_SAMPLE_S16BE => cubeb::DEVICE_FMT_S16BE,
|
||||
PA_SAMPLE_FLOAT32LE => cubeb::DEVICE_FMT_F32LE,
|
||||
PA_SAMPLE_FLOAT32BE => cubeb::DEVICE_FMT_F32BE,
|
||||
PA_SAMPLE_S16LE => cubeb::DeviceFmt::S16LE,
|
||||
PA_SAMPLE_S16BE => cubeb::DeviceFmt::S16BE,
|
||||
PA_SAMPLE_FLOAT32LE => cubeb::DeviceFmt::F32LE,
|
||||
PA_SAMPLE_FLOAT32BE => cubeb::DeviceFmt::F32BE,
|
||||
// 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);
|
||||
let mut stm = unsafe { &mut *(u as *mut Stream) };
|
||||
let stm = unsafe { &mut *(u as *mut Stream) };
|
||||
if stm.shutdown {
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ impl<'ctx> Stream<'ctx> {
|
|||
|
||||
fn write_data(_: &pulse::Stream, nbytes: usize, u: *mut c_void) {
|
||||
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 {
|
||||
return;
|
||||
}
|
||||
|
@ -216,9 +216,9 @@ impl<'ctx> Stream<'ctx> {
|
|||
let device_name = super::try_cstr_from(output_device as *const _);
|
||||
let _ = s.connect_playback(device_name,
|
||||
&battr,
|
||||
pulse::STREAM_AUTO_TIMING_UPDATE | pulse::STREAM_INTERPOLATE_TIMING |
|
||||
pulse::STREAM_START_CORKED |
|
||||
pulse::STREAM_ADJUST_LATENCY,
|
||||
pulse::StreamFlags::AUTO_TIMING_UPDATE | pulse::StreamFlags::INTERPOLATE_TIMING |
|
||||
pulse::StreamFlags::START_CORKED |
|
||||
pulse::StreamFlags::ADJUST_LATENCY,
|
||||
None,
|
||||
None);
|
||||
|
||||
|
@ -246,9 +246,9 @@ impl<'ctx> Stream<'ctx> {
|
|||
let device_name = super::try_cstr_from(input_device as *const _);
|
||||
let _ = s.connect_record(device_name,
|
||||
&battr,
|
||||
pulse::STREAM_AUTO_TIMING_UPDATE | pulse::STREAM_INTERPOLATE_TIMING |
|
||||
pulse::STREAM_START_CORKED |
|
||||
pulse::STREAM_ADJUST_LATENCY);
|
||||
pulse::StreamFlags::AUTO_TIMING_UPDATE | pulse::StreamFlags::INTERPOLATE_TIMING |
|
||||
pulse::StreamFlags::START_CORKED |
|
||||
pulse::StreamFlags::ADJUST_LATENCY);
|
||||
|
||||
stm.input_stream = Some(s);
|
||||
},
|
||||
|
@ -341,7 +341,7 @@ impl<'ctx> Stream<'ctx> {
|
|||
|
||||
pub fn start(&mut self) -> i32 {
|
||||
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 {
|
||||
let size = stm.output_stream
|
||||
.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;
|
||||
} else {
|
||||
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) {
|
||||
let mut r = unsafe { &mut *(u as *mut SinkInputInfoResult) };
|
||||
let r = unsafe { &mut *(u as *mut SinkInputInfoResult) };
|
||||
if eol == 0 {
|
||||
let info = unsafe { *info };
|
||||
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 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);
|
||||
stm.state_change_callback(cubeb::STATE_DRAINED);
|
||||
/* 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 }) }
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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 {
|
||||
let mut stm = &mut *(s as *mut backend::Stream);
|
||||
let stm = &mut *(s as *mut backend::Stream);
|
||||
|
||||
stm.start()
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ unsafe extern "C" fn capi_register_device_collection_changed(c: *mut cubeb::Cont
|
|||
cubeb::DeviceCollectionChangedCallback,
|
||||
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 _)
|
||||
}
|
||||
|
||||
|
|
|
@ -329,17 +329,17 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cubeb-ffi"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
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]]
|
||||
name = "cubeb-pulse"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
dependencies = [
|
||||
"cubeb-ffi 0.0.1",
|
||||
"pulse 0.1.0",
|
||||
"cubeb-ffi 0.0.2",
|
||||
"pulse 0.2.0",
|
||||
"pulse-ffi 0.1.0",
|
||||
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -568,7 +568,7 @@ dependencies = [
|
|||
"cubeb 0.3.0",
|
||||
"cubeb-backend 0.2.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_glue 0.1.0",
|
||||
"geckoservo 0.0.1",
|
||||
|
@ -1023,9 +1023,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "pulse"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
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",
|
||||
]
|
||||
|
||||
|
|
|
@ -329,17 +329,17 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cubeb-ffi"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
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]]
|
||||
name = "cubeb-pulse"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
dependencies = [
|
||||
"cubeb-ffi 0.0.1",
|
||||
"pulse 0.1.0",
|
||||
"cubeb-ffi 0.0.2",
|
||||
"pulse 0.2.0",
|
||||
"pulse-ffi 0.1.0",
|
||||
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -567,7 +567,7 @@ dependencies = [
|
|||
"cubeb 0.3.0",
|
||||
"cubeb-backend 0.2.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_glue 0.1.0",
|
||||
"geckoservo 0.0.1",
|
||||
|
@ -1011,9 +1011,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "pulse"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
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",
|
||||
]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче