1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstAudioBaseSrc")]
93 pub struct AudioBaseSrc(Object<ffi::GstAudioBaseSrc, ffi::GstAudioBaseSrcClass>) @extends gst_base::BaseSrc, gst::Element, gst::Object;
94
95 match fn {
96 type_ => || ffi::gst_audio_base_src_get_type(),
97 }
98}
99
100impl AudioBaseSrc {
101 pub const NONE: Option<&'static AudioBaseSrc> = None;
102}
103
104unsafe impl Send for AudioBaseSrc {}
105unsafe impl Sync for AudioBaseSrc {}
106
107pub trait AudioBaseSrcExt: IsA<AudioBaseSrc> + 'static {
113 #[doc(alias = "gst_audio_base_src_get_provide_clock")]
125 #[doc(alias = "get_provide_clock")]
126 #[doc(alias = "provide-clock")]
127 fn is_provide_clock(&self) -> bool {
128 unsafe {
129 from_glib(ffi::gst_audio_base_src_get_provide_clock(
130 self.as_ref().to_glib_none().0,
131 ))
132 }
133 }
134
135 #[doc(alias = "gst_audio_base_src_set_provide_clock")]
148 #[doc(alias = "provide-clock")]
149 fn set_provide_clock(&self, provide: bool) {
150 unsafe {
151 ffi::gst_audio_base_src_set_provide_clock(
152 self.as_ref().to_glib_none().0,
153 provide.into_glib(),
154 );
155 }
156 }
157
158 #[doc(alias = "actual-buffer-time")]
166 fn actual_buffer_time(&self) -> i64 {
167 ObjectExt::property(self.as_ref(), "actual-buffer-time")
168 }
169
170 #[doc(alias = "actual-latency-time")]
172 fn actual_latency_time(&self) -> i64 {
173 ObjectExt::property(self.as_ref(), "actual-latency-time")
174 }
175
176 #[doc(alias = "buffer-time")]
177 fn buffer_time(&self) -> i64 {
178 ObjectExt::property(self.as_ref(), "buffer-time")
179 }
180
181 #[doc(alias = "buffer-time")]
182 fn set_buffer_time(&self, buffer_time: i64) {
183 ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
184 }
185
186 #[doc(alias = "latency-time")]
187 fn latency_time(&self) -> i64 {
188 ObjectExt::property(self.as_ref(), "latency-time")
189 }
190
191 #[doc(alias = "latency-time")]
192 fn set_latency_time(&self, latency_time: i64) {
193 ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
194 }
195
196 #[doc(alias = "actual-buffer-time")]
197 fn connect_actual_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
198 &self,
199 f: F,
200 ) -> SignalHandlerId {
201 unsafe extern "C" fn notify_actual_buffer_time_trampoline<
202 P: IsA<AudioBaseSrc>,
203 F: Fn(&P) + Send + Sync + 'static,
204 >(
205 this: *mut ffi::GstAudioBaseSrc,
206 _param_spec: glib::ffi::gpointer,
207 f: glib::ffi::gpointer,
208 ) {
209 unsafe {
210 let f: &F = &*(f as *const F);
211 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
212 }
213 }
214 unsafe {
215 let f: Box_<F> = Box_::new(f);
216 connect_raw(
217 self.as_ptr() as *mut _,
218 c"notify::actual-buffer-time".as_ptr(),
219 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220 notify_actual_buffer_time_trampoline::<Self, F> as *const (),
221 )),
222 Box_::into_raw(f),
223 )
224 }
225 }
226
227 #[doc(alias = "actual-latency-time")]
228 fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
229 &self,
230 f: F,
231 ) -> SignalHandlerId {
232 unsafe extern "C" fn notify_actual_latency_time_trampoline<
233 P: IsA<AudioBaseSrc>,
234 F: Fn(&P) + Send + Sync + 'static,
235 >(
236 this: *mut ffi::GstAudioBaseSrc,
237 _param_spec: glib::ffi::gpointer,
238 f: glib::ffi::gpointer,
239 ) {
240 unsafe {
241 let f: &F = &*(f as *const F);
242 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
243 }
244 }
245 unsafe {
246 let f: Box_<F> = Box_::new(f);
247 connect_raw(
248 self.as_ptr() as *mut _,
249 c"notify::actual-latency-time".as_ptr(),
250 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
251 notify_actual_latency_time_trampoline::<Self, F> as *const (),
252 )),
253 Box_::into_raw(f),
254 )
255 }
256 }
257
258 #[doc(alias = "buffer-time")]
259 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
260 &self,
261 f: F,
262 ) -> SignalHandlerId {
263 unsafe extern "C" fn notify_buffer_time_trampoline<
264 P: IsA<AudioBaseSrc>,
265 F: Fn(&P) + Send + Sync + 'static,
266 >(
267 this: *mut ffi::GstAudioBaseSrc,
268 _param_spec: glib::ffi::gpointer,
269 f: glib::ffi::gpointer,
270 ) {
271 unsafe {
272 let f: &F = &*(f as *const F);
273 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
274 }
275 }
276 unsafe {
277 let f: Box_<F> = Box_::new(f);
278 connect_raw(
279 self.as_ptr() as *mut _,
280 c"notify::buffer-time".as_ptr(),
281 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
282 notify_buffer_time_trampoline::<Self, F> as *const (),
283 )),
284 Box_::into_raw(f),
285 )
286 }
287 }
288
289 #[doc(alias = "latency-time")]
290 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
291 &self,
292 f: F,
293 ) -> SignalHandlerId {
294 unsafe extern "C" fn notify_latency_time_trampoline<
295 P: IsA<AudioBaseSrc>,
296 F: Fn(&P) + Send + Sync + 'static,
297 >(
298 this: *mut ffi::GstAudioBaseSrc,
299 _param_spec: glib::ffi::gpointer,
300 f: glib::ffi::gpointer,
301 ) {
302 unsafe {
303 let f: &F = &*(f as *const F);
304 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
305 }
306 }
307 unsafe {
308 let f: Box_<F> = Box_::new(f);
309 connect_raw(
310 self.as_ptr() as *mut _,
311 c"notify::latency-time".as_ptr(),
312 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
313 notify_latency_time_trampoline::<Self, F> as *const (),
314 )),
315 Box_::into_raw(f),
316 )
317 }
318 }
319
320 #[doc(alias = "provide-clock")]
321 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
322 &self,
323 f: F,
324 ) -> SignalHandlerId {
325 unsafe extern "C" fn notify_provide_clock_trampoline<
326 P: IsA<AudioBaseSrc>,
327 F: Fn(&P) + Send + Sync + 'static,
328 >(
329 this: *mut ffi::GstAudioBaseSrc,
330 _param_spec: glib::ffi::gpointer,
331 f: glib::ffi::gpointer,
332 ) {
333 unsafe {
334 let f: &F = &*(f as *const F);
335 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
336 }
337 }
338 unsafe {
339 let f: Box_<F> = Box_::new(f);
340 connect_raw(
341 self.as_ptr() as *mut _,
342 c"notify::provide-clock".as_ptr(),
343 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
344 notify_provide_clock_trampoline::<Self, F> as *const (),
345 )),
346 Box_::into_raw(f),
347 )
348 }
349 }
350
351 #[doc(alias = "slave-method")]
352 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
353 &self,
354 f: F,
355 ) -> SignalHandlerId {
356 unsafe extern "C" fn notify_slave_method_trampoline<
357 P: IsA<AudioBaseSrc>,
358 F: Fn(&P) + Send + Sync + 'static,
359 >(
360 this: *mut ffi::GstAudioBaseSrc,
361 _param_spec: glib::ffi::gpointer,
362 f: glib::ffi::gpointer,
363 ) {
364 unsafe {
365 let f: &F = &*(f as *const F);
366 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
367 }
368 }
369 unsafe {
370 let f: Box_<F> = Box_::new(f);
371 connect_raw(
372 self.as_ptr() as *mut _,
373 c"notify::slave-method".as_ptr(),
374 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375 notify_slave_method_trampoline::<Self, F> as *const (),
376 )),
377 Box_::into_raw(f),
378 )
379 }
380 }
381}
382
383impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}