1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstAudioBaseSrc")]
16 pub struct AudioBaseSrc(Object<ffi::GstAudioBaseSrc, ffi::GstAudioBaseSrcClass>) @extends gst_base::BaseSrc, gst::Element, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_audio_base_src_get_type(),
20 }
21}
22
23impl AudioBaseSrc {
24 pub const NONE: Option<&'static AudioBaseSrc> = None;
25}
26
27unsafe impl Send for AudioBaseSrc {}
28unsafe impl Sync for AudioBaseSrc {}
29
30pub trait AudioBaseSrcExt: IsA<AudioBaseSrc> + 'static {
31 #[doc(alias = "gst_audio_base_src_get_provide_clock")]
37 #[doc(alias = "get_provide_clock")]
38 #[doc(alias = "provide-clock")]
39 fn is_provide_clock(&self) -> bool {
40 unsafe {
41 from_glib(ffi::gst_audio_base_src_get_provide_clock(
42 self.as_ref().to_glib_none().0,
43 ))
44 }
45 }
46
47 #[doc(alias = "gst_audio_base_src_set_provide_clock")]
55 #[doc(alias = "provide-clock")]
56 fn set_provide_clock(&self, provide: bool) {
57 unsafe {
58 ffi::gst_audio_base_src_set_provide_clock(
59 self.as_ref().to_glib_none().0,
60 provide.into_glib(),
61 );
62 }
63 }
64
65 #[doc(alias = "actual-buffer-time")]
72 fn actual_buffer_time(&self) -> i64 {
73 ObjectExt::property(self.as_ref(), "actual-buffer-time")
74 }
75
76 #[doc(alias = "actual-latency-time")]
77 fn actual_latency_time(&self) -> i64 {
78 ObjectExt::property(self.as_ref(), "actual-latency-time")
79 }
80
81 #[doc(alias = "buffer-time")]
82 fn buffer_time(&self) -> i64 {
83 ObjectExt::property(self.as_ref(), "buffer-time")
84 }
85
86 #[doc(alias = "buffer-time")]
87 fn set_buffer_time(&self, buffer_time: i64) {
88 ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
89 }
90
91 #[doc(alias = "latency-time")]
92 fn latency_time(&self) -> i64 {
93 ObjectExt::property(self.as_ref(), "latency-time")
94 }
95
96 #[doc(alias = "latency-time")]
97 fn set_latency_time(&self, latency_time: i64) {
98 ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
99 }
100
101 #[doc(alias = "actual-buffer-time")]
102 fn connect_actual_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
103 &self,
104 f: F,
105 ) -> SignalHandlerId {
106 unsafe extern "C" fn notify_actual_buffer_time_trampoline<
107 P: IsA<AudioBaseSrc>,
108 F: Fn(&P) + Send + Sync + 'static,
109 >(
110 this: *mut ffi::GstAudioBaseSrc,
111 _param_spec: glib::ffi::gpointer,
112 f: glib::ffi::gpointer,
113 ) {
114 let f: &F = &*(f as *const F);
115 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
116 }
117 unsafe {
118 let f: Box_<F> = Box_::new(f);
119 connect_raw(
120 self.as_ptr() as *mut _,
121 c"notify::actual-buffer-time".as_ptr() as *const _,
122 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
123 notify_actual_buffer_time_trampoline::<Self, F> as *const (),
124 )),
125 Box_::into_raw(f),
126 )
127 }
128 }
129
130 #[doc(alias = "actual-latency-time")]
131 fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
132 &self,
133 f: F,
134 ) -> SignalHandlerId {
135 unsafe extern "C" fn notify_actual_latency_time_trampoline<
136 P: IsA<AudioBaseSrc>,
137 F: Fn(&P) + Send + Sync + 'static,
138 >(
139 this: *mut ffi::GstAudioBaseSrc,
140 _param_spec: glib::ffi::gpointer,
141 f: glib::ffi::gpointer,
142 ) {
143 let f: &F = &*(f as *const F);
144 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
145 }
146 unsafe {
147 let f: Box_<F> = Box_::new(f);
148 connect_raw(
149 self.as_ptr() as *mut _,
150 c"notify::actual-latency-time".as_ptr() as *const _,
151 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
152 notify_actual_latency_time_trampoline::<Self, F> as *const (),
153 )),
154 Box_::into_raw(f),
155 )
156 }
157 }
158
159 #[doc(alias = "buffer-time")]
160 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
161 &self,
162 f: F,
163 ) -> SignalHandlerId {
164 unsafe extern "C" fn notify_buffer_time_trampoline<
165 P: IsA<AudioBaseSrc>,
166 F: Fn(&P) + Send + Sync + 'static,
167 >(
168 this: *mut ffi::GstAudioBaseSrc,
169 _param_spec: glib::ffi::gpointer,
170 f: glib::ffi::gpointer,
171 ) {
172 let f: &F = &*(f as *const F);
173 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
174 }
175 unsafe {
176 let f: Box_<F> = Box_::new(f);
177 connect_raw(
178 self.as_ptr() as *mut _,
179 c"notify::buffer-time".as_ptr() as *const _,
180 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
181 notify_buffer_time_trampoline::<Self, F> as *const (),
182 )),
183 Box_::into_raw(f),
184 )
185 }
186 }
187
188 #[doc(alias = "latency-time")]
189 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
190 &self,
191 f: F,
192 ) -> SignalHandlerId {
193 unsafe extern "C" fn notify_latency_time_trampoline<
194 P: IsA<AudioBaseSrc>,
195 F: Fn(&P) + Send + Sync + 'static,
196 >(
197 this: *mut ffi::GstAudioBaseSrc,
198 _param_spec: glib::ffi::gpointer,
199 f: glib::ffi::gpointer,
200 ) {
201 let f: &F = &*(f as *const F);
202 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
203 }
204 unsafe {
205 let f: Box_<F> = Box_::new(f);
206 connect_raw(
207 self.as_ptr() as *mut _,
208 c"notify::latency-time".as_ptr() as *const _,
209 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210 notify_latency_time_trampoline::<Self, F> as *const (),
211 )),
212 Box_::into_raw(f),
213 )
214 }
215 }
216
217 #[doc(alias = "provide-clock")]
218 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
219 &self,
220 f: F,
221 ) -> SignalHandlerId {
222 unsafe extern "C" fn notify_provide_clock_trampoline<
223 P: IsA<AudioBaseSrc>,
224 F: Fn(&P) + Send + Sync + 'static,
225 >(
226 this: *mut ffi::GstAudioBaseSrc,
227 _param_spec: glib::ffi::gpointer,
228 f: glib::ffi::gpointer,
229 ) {
230 let f: &F = &*(f as *const F);
231 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
232 }
233 unsafe {
234 let f: Box_<F> = Box_::new(f);
235 connect_raw(
236 self.as_ptr() as *mut _,
237 c"notify::provide-clock".as_ptr() as *const _,
238 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
239 notify_provide_clock_trampoline::<Self, F> as *const (),
240 )),
241 Box_::into_raw(f),
242 )
243 }
244 }
245
246 #[doc(alias = "slave-method")]
247 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
248 &self,
249 f: F,
250 ) -> SignalHandlerId {
251 unsafe extern "C" fn notify_slave_method_trampoline<
252 P: IsA<AudioBaseSrc>,
253 F: Fn(&P) + Send + Sync + 'static,
254 >(
255 this: *mut ffi::GstAudioBaseSrc,
256 _param_spec: glib::ffi::gpointer,
257 f: glib::ffi::gpointer,
258 ) {
259 let f: &F = &*(f as *const F);
260 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
261 }
262 unsafe {
263 let f: Box_<F> = Box_::new(f);
264 connect_raw(
265 self.as_ptr() as *mut _,
266 c"notify::slave-method".as_ptr() as *const _,
267 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
268 notify_slave_method_trampoline::<Self, F> as *const (),
269 )),
270 Box_::into_raw(f),
271 )
272 }
273 }
274}
275
276impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}