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