use crate::Channel;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "SpiceRecordChannel")]
pub struct RecordChannel(Object<ffi::SpiceRecordChannel, ffi::SpiceRecordChannelClass>) @extends Channel;
match fn {
type_ => || ffi::spice_record_channel_get_type(),
}
}
impl RecordChannel {
pub fn is_muted(&self) -> bool {
ObjectExt::property(self, "mute")
}
pub fn set_mute(&self, mute: bool) {
ObjectExt::set_property(self, "mute", mute)
}
pub fn nchannels(&self) -> u32 {
ObjectExt::property(self, "nchannels")
}
pub fn set_nchannels(&self, nchannels: u32) {
ObjectExt::set_property(self, "nchannels", nchannels)
}
#[doc(alias = "record-start")]
pub fn connect_record_start<F: Fn(&Self, i32, i32, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn record_start_trampoline<
F: Fn(&RecordChannel, i32, i32, i32) + 'static,
>(
this: *mut ffi::SpiceRecordChannel,
format: libc::c_int,
channels: libc::c_int,
rate: libc::c_int,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), format, channels, rate)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"record-start\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
record_start_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "record-stop")]
pub fn connect_record_stop<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn record_stop_trampoline<F: Fn(&RecordChannel) + 'static>(
this: *mut ffi::SpiceRecordChannel,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"record-stop\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
record_stop_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "mute")]
pub fn connect_mute_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_mute_trampoline<F: Fn(&RecordChannel) + 'static>(
this: *mut ffi::SpiceRecordChannel,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::mute\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_mute_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "nchannels")]
pub fn connect_nchannels_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_nchannels_trampoline<F: Fn(&RecordChannel) + 'static>(
this: *mut ffi::SpiceRecordChannel,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::nchannels\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_nchannels_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "volume")]
pub fn connect_volume_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_volume_trampoline<F: Fn(&RecordChannel) + 'static>(
this: *mut ffi::SpiceRecordChannel,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::volume\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_volume_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}