1 | use std::mem::transmute; |
2 | |
3 | use glib::{ |
4 | object::IsA, |
5 | signal::{connect_raw, SignalHandlerId}, |
6 | translate::*, |
7 | Cast, |
8 | }; |
9 | |
10 | use crate::auto::AudioAggregatorConvertPad; |
11 | |
12 | mod sealed { |
13 | pub trait Sealed {} |
14 | impl<T: super::IsA<super::AudioAggregatorConvertPad>> Sealed for T {} |
15 | } |
16 | |
17 | pub trait AudioAggregatorConvertPadExtManual: |
18 | sealed::Sealed + IsA<AudioAggregatorConvertPad> + 'static |
19 | { |
20 | #[doc (alias = "converter-config" )] |
21 | fn converter_config(&self) -> Option<crate::AudioConverterConfig> { |
22 | glib::ObjectExt::property::<Option<gst::Structure>>(self.as_ref(), "converter-config" ) |
23 | .map(|c| c.try_into().unwrap()) |
24 | } |
25 | |
26 | #[doc (alias = "converter-config" )] |
27 | fn set_converter_config(&self, converter_config: Option<&crate::AudioConverterConfig>) { |
28 | glib::ObjectExt::set_property( |
29 | self.as_ref(), |
30 | "converter-config" , |
31 | converter_config.map(|s| s.as_ref()), |
32 | ) |
33 | } |
34 | |
35 | #[doc (alias = "converter-config" )] |
36 | fn connect_converter_config_notify<F: Fn(&Self) + Send + Sync + 'static>( |
37 | &self, |
38 | f: F, |
39 | ) -> SignalHandlerId { |
40 | unsafe extern "C" fn notify_converter_config_trampoline< |
41 | P: IsA<AudioAggregatorConvertPad>, |
42 | F: Fn(&P) + Send + Sync + 'static, |
43 | >( |
44 | this: *mut ffi::GstAudioAggregatorConvertPad, |
45 | _param_spec: glib::ffi::gpointer, |
46 | f: glib::ffi::gpointer, |
47 | ) { |
48 | let f: &F = &*(f as *const F); |
49 | f(AudioAggregatorConvertPad::from_glib_borrow(this).unsafe_cast_ref()) |
50 | } |
51 | unsafe { |
52 | let f: Box<F> = Box::new(f); |
53 | connect_raw( |
54 | self.as_ptr() as *mut _, |
55 | b"notify::converter-config \0" .as_ptr() as *const _, |
56 | Some(transmute::<_, unsafe extern "C" fn()>( |
57 | notify_converter_config_trampoline::<Self, F> as *const (), |
58 | )), |
59 | Box::into_raw(f), |
60 | ) |
61 | } |
62 | } |
63 | } |
64 | |
65 | impl<O: IsA<AudioAggregatorConvertPad>> AudioAggregatorConvertPadExtManual for O {} |
66 | |