| 1 |
// Copyright © 2017-2018 Mozilla Foundation |
| 2 |
// |
| 3 |
// This program is made available under an ISC-style license. See the |
| 4 |
// accompanying file LICENSE for details. |
| 5 |
|
| 6 |
use callbacks::cubeb_device_changed_callback; |
| 7 |
use channel::cubeb_channel_layout; |
| 8 |
use device::cubeb_device; |
| 9 |
use format::cubeb_sample_format; |
| 10 |
use std::os::raw::{c_char, c_float, c_int, c_uint, c_void}; |
| 11 |
use std::{fmt, mem}; |
| 12 |
|
| 13 |
cubeb_enum! { |
| 14 |
pub enum cubeb_input_processing_params { |
| 15 |
CUBEB_INPUT_PROCESSING_PARAM_NONE = 0x00, |
| 16 |
CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION = 0x01, |
| 17 |
CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION = 0x02, |
| 18 |
CUBEB_INPUT_PROCESSING_PARAM_AUTOMATIC_GAIN_CONTROL = 0x04, |
| 19 |
CUBEB_INPUT_PROCESSING_PARAM_VOICE_ISOLATION = 0x08, |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
cubeb_enum! { |
| 24 |
pub enum cubeb_stream_prefs { |
| 25 |
CUBEB_STREAM_PREF_NONE = 0x00, |
| 26 |
CUBEB_STREAM_PREF_LOOPBACK = 0x01, |
| 27 |
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, |
| 28 |
CUBEB_STREAM_PREF_VOICE = 0x04, |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
cubeb_enum! { |
| 33 |
pub enum cubeb_state { |
| 34 |
CUBEB_STATE_STARTED, |
| 35 |
CUBEB_STATE_STOPPED, |
| 36 |
CUBEB_STATE_DRAINED, |
| 37 |
CUBEB_STATE_ERROR, |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
pub enum cubeb_stream {} |
| 42 |
|
| 43 |
#[repr(C)] |
| 44 |
#[derive(Clone, Copy)] |
| 45 |
pub struct cubeb_stream_params { |
| 46 |
pub format: cubeb_sample_format, |
| 47 |
pub rate: c_uint, |
| 48 |
pub channels: c_uint, |
| 49 |
pub layout: cubeb_channel_layout, |
| 50 |
pub prefs: cubeb_stream_prefs, |
| 51 |
} |
| 52 |
|
| 53 |
impl Default for cubeb_stream_params { |
| 54 |
fn default() -> Self { |
| 55 |
unsafe { mem::zeroed() } |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
// Explicit Debug impl to work around bug in ctest |
| 60 |
impl fmt::Debug for cubeb_stream_params { |
| 61 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 62 |
f.debug_struct("cubeb_stream_params") |
| 63 |
.field("format", &self.format) |
| 64 |
.field("rate", &self.rate) |
| 65 |
.field("channels", &self.channels) |
| 66 |
.field("layout", &self.layout) |
| 67 |
.field("prefs", &self.prefs) |
| 68 |
.finish() |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
extern "C" { |
| 73 |
pub fn cubeb_stream_destroy(stream: *mut cubeb_stream); |
| 74 |
pub fn cubeb_stream_start(stream: *mut cubeb_stream) -> c_int; |
| 75 |
pub fn cubeb_stream_stop(stream: *mut cubeb_stream) -> c_int; |
| 76 |
pub fn cubeb_stream_get_position(stream: *mut cubeb_stream, position: *mut u64) -> c_int; |
| 77 |
pub fn cubeb_stream_get_latency(stream: *mut cubeb_stream, latency: *mut c_uint) -> c_int; |
| 78 |
pub fn cubeb_stream_get_input_latency(stream: *mut cubeb_stream, latency: *mut c_uint) |
| 79 |
-> c_int; |
| 80 |
pub fn cubeb_stream_set_volume(stream: *mut cubeb_stream, volume: c_float) -> c_int; |
| 81 |
pub fn cubeb_stream_set_name(stream: *mut cubeb_stream, name: *const c_char) -> c_int; |
| 82 |
pub fn cubeb_stream_get_current_device( |
| 83 |
stream: *mut cubeb_stream, |
| 84 |
device: *mut *mut cubeb_device, |
| 85 |
) -> c_int; |
| 86 |
pub fn cubeb_stream_set_input_mute(stream: *mut cubeb_stream, mute: c_int) -> c_int; |
| 87 |
pub fn cubeb_stream_set_input_processing_params( |
| 88 |
stream: *mut cubeb_stream, |
| 89 |
params: cubeb_input_processing_params, |
| 90 |
) -> c_int; |
| 91 |
pub fn cubeb_stream_device_destroy( |
| 92 |
stream: *mut cubeb_stream, |
| 93 |
devices: *mut cubeb_device, |
| 94 |
) -> c_int; |
| 95 |
pub fn cubeb_stream_register_device_changed_callback( |
| 96 |
stream: *mut cubeb_stream, |
| 97 |
device_changed_callback: cubeb_device_changed_callback, |
| 98 |
) -> c_int; |
| 99 |
pub fn cubeb_stream_user_ptr(stream: *mut cubeb_stream) -> *mut c_void; |
| 100 |
} |