use cubeb_core; use ffi; use std::ffi::CString; use std::marker::PhantomData; use std::mem::ManuallyDrop; use std::os::raw::{c_long, c_void}; use std::slice::{from_raw_parts, from_raw_parts_mut}; use std::{ops, panic, ptr}; use {ContextRef, DeviceId, Error, Result, State, StreamParamsRef};
/// User supplied data callback. /// /// - Calling other cubeb functions from this callback is unsafe. /// - The code in the callback should be non-blocking. /// - Returning less than the number of frames this callback asks for or /// provides puts the stream in drain mode. This callback will not be called /// again, and the state callback will be called with CUBEB_STATE_DRAINED when /// all the frames have been output. /// /// # Arguments /// /// - `input_buffer`: A slice containing the input data, zero-len if this is an output-only stream. /// - `output_buffer`: A mutable slice to be filled with audio samples, zero-len if this is an input-only stream. /// /// # Return value /// /// If the stream has output, this is the number of frames written to the output buffer. In this /// case, if this number is less than the length of the output buffer, then the stream will start to /// drain. /// /// If the stream is input only, then returning the length of the input buffer indicates data has /// been read. In this case, a value less than that will result in the stream being stopped. pubtype DataCallback<F> = dyn FnMut(&[F], &mut [F]) -> isize + Send + Sync + 'static;
/// User supplied state callback. /// /// # Arguments /// /// `state`: The new state of the stream pubtype StateCallback = dyn FnMut(State) + Send + Sync + 'static;
/// User supplied callback called when the underlying device changed. pubtype DeviceChangedCallback = dyn FnMut() + Send + Sync + 'static;
/// User supplied data callback, see [`DataCallback`] pub fn data_callback<D>(&mutself, cb: D) -> &mutSelf where
D: FnMut(&[F], &mut [F]) -> isize + Send + Sync + 'static,
{ self.data_cb = Some(Box::new(cb) asBox<DataCallback<F>>); self
}
/// User supplied state callback, see [`StateCallback`] pub fn state_callback<S>(&mutself, cb: S) -> &>mutSelf where
S: FnMut(State) + Send + Sync + 'static,
{ self.state_cb = Some(Box::new(cb) asBox<StateCallback>); self
}
/// A name for this stream. pub fn name<T: Into<Vec<u8>>>(&mutself, name: T) -> &mutSelf { self.name = Some(CString::new(name).unwrap()); self
}
/// Use the default input device with `params` /// /// Optional if the stream is output only pub fn default_input(&mutself, params: &>'a StreamParamsRef) -> &mut Self { self.input = Some((ptr::null(), params)); self
}
/// Use a specific input device with `params` /// /// Optional if the stream is output only pub fn input(&mutself, device: DeviceId, params: &'a StreamParamsRef) -> &mut Self { self.input = Some((device, params)); self
}
/// Use the default output device with `params` /// /// Optional if the stream is input only pub fn default_output(&mutself, params: &'a StreamParamsRef) -> &mut Self { self.output = Some((ptr::null(), params)); self
}
/// Use a specific output device with `params` /// /// Optional if the stream is input only pub fn output(&mutself, device: DeviceId, params: &'a StreamParamsRef) -> &mut Self { self.output = Some((device, params)); self
}
/// Stream latency in frames. /// /// Valid range is [1, 96000]. pub fn latency(&mutself, latency: u32) -> &mutSelf { self.latency = Some(latency); self
}
/// User supplied callback called when the underlying device changed. /// /// See [`StateCallback`] /// /// Optional pub fn device_changed_cb<CB>(&mutself, cb: CB) -> &mutSelf where
CB: FnMut() + Send + Sync + 'static,
{ self.device_changed_cb = Some(Box::new(cb) asBox<DeviceChangedCallback>); self
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.