use crate::Channel;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "SpicePlaybackChannel")]
pub struct PlaybackChannel(Object<ffi::SpicePlaybackChannel, ffi::SpicePlaybackChannelClass>) @extends Channel;
match fn {
type_ => || ffi::spice_playback_channel_get_type(),
}
}
impl PlaybackChannel {
#[doc(alias = "spice_playback_channel_set_delay")]
pub fn set_delay(&self, delay_ms: u32) {
unsafe {
ffi::spice_playback_channel_set_delay(self.to_glib_none().0, delay_ms);
}
}
#[doc(alias = "min-latency")]
pub fn min_latency(&self) -> u32 {
ObjectExt::property(self, "min-latency")
}
#[doc(alias = "min-latency")]
pub fn set_min_latency(&self, min_latency: u32) {
ObjectExt::set_property(self, "min-latency", min_latency)
}
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 = "playback-get-delay")]
pub fn connect_playback_get_delay<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn playback_get_delay_trampoline<F: Fn(&PlaybackChannel) + 'static>(
this: *mut ffi::SpicePlaybackChannel,
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"playback-get-delay\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
playback_get_delay_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "playback-start")]
pub fn connect_playback_start<F: Fn(&Self, i32, i32, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn playback_start_trampoline<
F: Fn(&PlaybackChannel, i32, i32, i32) + 'static,
>(
this: *mut ffi::SpicePlaybackChannel,
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"playback-start\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
playback_start_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "playback-stop")]
pub fn connect_playback_stop<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn playback_stop_trampoline<F: Fn(&PlaybackChannel) + 'static>(
this: *mut ffi::SpicePlaybackChannel,
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"playback-stop\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
playback_stop_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "min-latency")]
pub fn connect_min_latency_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_min_latency_trampoline<F: Fn(&PlaybackChannel) + 'static>(
this: *mut ffi::SpicePlaybackChannel,
_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::min-latency\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
notify_min_latency_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(&PlaybackChannel) + 'static>(
this: *mut ffi::SpicePlaybackChannel,
_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(&PlaybackChannel) + 'static>(
this: *mut ffi::SpicePlaybackChannel,
_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(&PlaybackChannel) + 'static>(
this: *mut ffi::SpicePlaybackChannel,
_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),
)
}
}
}