gstreamer-rs/gstreamer-audio/src/auto/stream_volume.rs

109 lines
3.5 KiB
Rust
Raw Normal View History

2018-03-15 08:03:01 +00:00
// This file was generated by gir (https://github.com/gtk-rs/gir @ d1e0127)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
2017-08-09 22:28:29 +00:00
// DO NOT EDIT
use StreamVolumeFormat;
use ffi;
2017-08-30 11:45:25 +00:00
use glib;
use glib::object::Downcast;
2017-08-09 22:28:29 +00:00
use glib::object::IsA;
2017-09-09 13:01:32 +00:00
use glib::signal::SignalHandlerId;
2017-08-30 11:45:25 +00:00
use glib::signal::connect;
2017-08-09 22:28:29 +00:00
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
2017-08-30 11:45:25 +00:00
use std::boxed::Box as Box_;
2017-08-09 22:28:29 +00:00
use std::mem;
2017-08-30 11:45:25 +00:00
use std::mem::transmute;
2017-08-09 22:28:29 +00:00
use std::ptr;
glib_wrapper! {
pub struct StreamVolume(Object<ffi::GstStreamVolume, ffi::GstStreamVolumeInterface>);
2017-08-09 22:28:29 +00:00
match fn {
get_type => || ffi::gst_stream_volume_get_type(),
}
}
impl StreamVolume {
pub fn convert_volume(from: StreamVolumeFormat, to: StreamVolumeFormat, val: f64) -> f64 {
assert_initialized_main_thread!();
unsafe {
ffi::gst_stream_volume_convert_volume(from.to_glib(), to.to_glib(), val)
}
}
}
unsafe impl Send for StreamVolume {}
unsafe impl Sync for StreamVolume {}
pub trait StreamVolumeExt {
fn get_mute(&self) -> bool;
fn get_volume(&self, format: StreamVolumeFormat) -> f64;
fn set_mute(&self, mute: bool);
fn set_volume(&self, format: StreamVolumeFormat, val: f64);
2017-08-30 11:45:25 +00:00
2017-09-09 13:01:32 +00:00
fn connect_property_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
2017-08-30 11:45:25 +00:00
2017-09-09 13:01:32 +00:00
fn connect_property_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
2017-08-09 22:28:29 +00:00
}
2017-08-30 11:45:25 +00:00
impl<O: IsA<StreamVolume> + IsA<glib::object::Object>> StreamVolumeExt for O {
2017-08-09 22:28:29 +00:00
fn get_mute(&self) -> bool {
unsafe {
from_glib(ffi::gst_stream_volume_get_mute(self.to_glib_none().0))
}
}
fn get_volume(&self, format: StreamVolumeFormat) -> f64 {
unsafe {
ffi::gst_stream_volume_get_volume(self.to_glib_none().0, format.to_glib())
}
}
fn set_mute(&self, mute: bool) {
unsafe {
ffi::gst_stream_volume_set_mute(self.to_glib_none().0, mute.to_glib());
}
}
fn set_volume(&self, format: StreamVolumeFormat, val: f64) {
unsafe {
ffi::gst_stream_volume_set_volume(self.to_glib_none().0, format.to_glib(), val);
}
}
2017-08-30 11:45:25 +00:00
2017-09-09 13:01:32 +00:00
fn connect_property_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2017-08-30 11:45:25 +00:00
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::mute",
transmute(notify_mute_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
2017-09-09 13:01:32 +00:00
fn connect_property_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2017-08-30 11:45:25 +00:00
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::volume",
transmute(notify_volume_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_mute_trampoline<P>(this: *mut ffi::GstStreamVolume, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<StreamVolume> {
2018-03-02 19:25:12 +00:00
callback_guard!();
2017-08-30 11:45:25 +00:00
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
2017-09-09 13:01:32 +00:00
f(&StreamVolume::from_glib_borrow(this).downcast_unchecked())
2017-08-30 11:45:25 +00:00
}
unsafe extern "C" fn notify_volume_trampoline<P>(this: *mut ffi::GstStreamVolume, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<StreamVolume> {
2018-03-02 19:25:12 +00:00
callback_guard!();
2017-08-30 11:45:25 +00:00
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
2017-09-09 13:01:32 +00:00
f(&StreamVolume::from_glib_borrow(this).downcast_unchecked())
2017-08-09 22:28:29 +00:00
}