1use cubeb_core::{
7 DeviceId, DeviceInfo, DeviceRef, DeviceType, InputProcessingParams, Result, Stream,
8 StreamParams, StreamParamsRef,
9};
10use ffi;
11use std::ffi::CStr;
12use std::os::raw::c_void;
13
14pub trait ContextOps {
15 fn init(context_name: Option<&CStr>) -> Result<Box<Self>>;
16 fn backend_id(&mut self) -> &CStr;
17 fn max_channel_count(&mut self) -> Result<u32>;
18 fn min_latency(&mut self, params: StreamParams) -> Result<u32>;
19 fn preferred_sample_rate(&mut self) -> Result<u32>;
20 fn supported_input_processing_params(&mut self) -> Result<InputProcessingParams>;
21 fn enumerate_devices(&mut self, devtype: DeviceType) -> Result<Box<[DeviceInfo]>>;
22 fn device_collection_destroy(&mut self, collection: Box<[DeviceInfo]>) -> Result<()>;
23 #[allow(clippy::too_many_arguments)]
24 fn stream_init(
25 &mut self,
26 stream_name: Option<&CStr>,
27 input_device: DeviceId,
28 input_stream_params: Option<&StreamParamsRef>,
29 output_device: DeviceId,
30 output_stream_params: Option<&StreamParamsRef>,
31 latency_frames: u32,
32 data_callback: ffi::cubeb_data_callback,
33 state_callback: ffi::cubeb_state_callback,
34 user_ptr: *mut c_void,
35 ) -> Result<Stream>;
36 fn register_device_collection_changed(
37 &mut self,
38 devtype: DeviceType,
39 cb: ffi::cubeb_device_collection_changed_callback,
40 user_ptr: *mut c_void,
41 ) -> Result<()>;
42}
43
44pub trait StreamOps {
45 fn start(&mut self) -> Result<()>;
46 fn stop(&mut self) -> Result<()>;
47 fn position(&mut self) -> Result<u64>;
48 fn latency(&mut self) -> Result<u32>;
49 fn input_latency(&mut self) -> Result<u32>;
50 fn set_volume(&mut self, volume: f32) -> Result<()>;
51 fn set_name(&mut self, name: &CStr) -> Result<()>;
52 fn current_device(&mut self) -> Result<&DeviceRef>;
53 fn set_input_mute(&mut self, mute: bool) -> Result<()>;
54 fn set_input_processing_params(&mut self, params: InputProcessingParams) -> Result<()>;
55 fn device_destroy(&mut self, device: &DeviceRef) -> Result<()>;
56 fn register_device_changed_callback(
57 &mut self,
58 device_changed_callback: ffi::cubeb_device_changed_callback,
59 ) -> Result<()>;
60}