1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
pub mod fvad { #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] include!(concat!("../output", "/bindings.rs")); pub struct Vad { fvad: *mut Fvad } impl Vad { pub unsafe fn new(sample_rate: i32) -> Vad { let fvad: *mut Fvad = fvad_new(); fvad_set_sample_rate(fvad, sample_rate); Vad { fvad } } pub unsafe fn is_silent(&self, buffers: &[i16]) -> ::std::os::raw::c_int { let buffer = &buffers[0] as *const i16; fvad_process(self.fvad, buffer, buffers.len()) } pub unsafe fn set_mode(&self, mode: i32) { assert!(mode <= 3); fvad_set_mode(self.fvad, mode); } } impl Drop for Vad { fn drop(&mut self) { unsafe { fvad_free(self.fvad); } } } }