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")]
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
107mod sealed {
108 pub trait Sealed {}
109 impl<T: super::IsA<super::AudioBaseSrc>> Sealed for T {}
110}
111
112pub trait AudioBaseSrcExt: IsA<AudioBaseSrc> + sealed::Sealed + 'static {
118 #[doc(alias = "gst_audio_base_src_get_provide_clock")]
130 #[doc(alias = "get_provide_clock")]
131 #[doc(alias = "provide-clock")]
132 fn is_provide_clock(&self) -> bool {
133 unsafe {
134 from_glib(ffi::gst_audio_base_src_get_provide_clock(
135 self.as_ref().to_glib_none().0,
136 ))
137 }
138 }
139
140 #[doc(alias = "gst_audio_base_src_set_provide_clock")]
153 #[doc(alias = "provide-clock")]
154 fn set_provide_clock(&self, provide: bool) {
155 unsafe {
156 ffi::gst_audio_base_src_set_provide_clock(
157 self.as_ref().to_glib_none().0,
158 provide.into_glib(),
159 );
160 }
161 }
162
163 #[doc(alias = "actual-buffer-time")]
171 fn actual_buffer_time(&self) -> i64 {
172 ObjectExt::property(self.as_ref(), "actual-buffer-time")
173 }
174
175 #[doc(alias = "actual-latency-time")]
177 fn actual_latency_time(&self) -> i64 {
178 ObjectExt::property(self.as_ref(), "actual-latency-time")
179 }
180
181 #[doc(alias = "buffer-time")]
182 fn buffer_time(&self) -> i64 {
183 ObjectExt::property(self.as_ref(), "buffer-time")
184 }
185
186 #[doc(alias = "buffer-time")]
187 fn set_buffer_time(&self, buffer_time: i64) {
188 ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
189 }
190
191 #[doc(alias = "latency-time")]
192 fn latency_time(&self) -> i64 {
193 ObjectExt::property(self.as_ref(), "latency-time")
194 }
195
196 #[doc(alias = "latency-time")]
197 fn set_latency_time(&self, latency_time: i64) {
198 ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
199 }
200
201 #[doc(alias = "actual-buffer-time")]
202 fn connect_actual_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
203 &self,
204 f: F,
205 ) -> SignalHandlerId {
206 unsafe extern "C" fn notify_actual_buffer_time_trampoline<
207 P: IsA<AudioBaseSrc>,
208 F: Fn(&P) + Send + Sync + 'static,
209 >(
210 this: *mut ffi::GstAudioBaseSrc,
211 _param_spec: glib::ffi::gpointer,
212 f: glib::ffi::gpointer,
213 ) {
214 let f: &F = &*(f as *const F);
215 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
216 }
217 unsafe {
218 let f: Box_<F> = Box_::new(f);
219 connect_raw(
220 self.as_ptr() as *mut _,
221 b"notify::actual-buffer-time\0".as_ptr() as *const _,
222 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
223 notify_actual_buffer_time_trampoline::<Self, F> as *const (),
224 )),
225 Box_::into_raw(f),
226 )
227 }
228 }
229
230 #[doc(alias = "actual-latency-time")]
231 fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
232 &self,
233 f: F,
234 ) -> SignalHandlerId {
235 unsafe extern "C" fn notify_actual_latency_time_trampoline<
236 P: IsA<AudioBaseSrc>,
237 F: Fn(&P) + Send + Sync + 'static,
238 >(
239 this: *mut ffi::GstAudioBaseSrc,
240 _param_spec: glib::ffi::gpointer,
241 f: glib::ffi::gpointer,
242 ) {
243 let f: &F = &*(f as *const F);
244 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
245 }
246 unsafe {
247 let f: Box_<F> = Box_::new(f);
248 connect_raw(
249 self.as_ptr() as *mut _,
250 b"notify::actual-latency-time\0".as_ptr() as *const _,
251 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252 notify_actual_latency_time_trampoline::<Self, F> as *const (),
253 )),
254 Box_::into_raw(f),
255 )
256 }
257 }
258
259 #[doc(alias = "buffer-time")]
260 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
261 &self,
262 f: F,
263 ) -> SignalHandlerId {
264 unsafe extern "C" fn notify_buffer_time_trampoline<
265 P: IsA<AudioBaseSrc>,
266 F: Fn(&P) + Send + Sync + 'static,
267 >(
268 this: *mut ffi::GstAudioBaseSrc,
269 _param_spec: glib::ffi::gpointer,
270 f: glib::ffi::gpointer,
271 ) {
272 let f: &F = &*(f as *const F);
273 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
274 }
275 unsafe {
276 let f: Box_<F> = Box_::new(f);
277 connect_raw(
278 self.as_ptr() as *mut _,
279 b"notify::buffer-time\0".as_ptr() as *const _,
280 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
281 notify_buffer_time_trampoline::<Self, F> as *const (),
282 )),
283 Box_::into_raw(f),
284 )
285 }
286 }
287
288 #[doc(alias = "latency-time")]
289 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
290 &self,
291 f: F,
292 ) -> SignalHandlerId {
293 unsafe extern "C" fn notify_latency_time_trampoline<
294 P: IsA<AudioBaseSrc>,
295 F: Fn(&P) + Send + Sync + 'static,
296 >(
297 this: *mut ffi::GstAudioBaseSrc,
298 _param_spec: glib::ffi::gpointer,
299 f: glib::ffi::gpointer,
300 ) {
301 let f: &F = &*(f as *const F);
302 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
303 }
304 unsafe {
305 let f: Box_<F> = Box_::new(f);
306 connect_raw(
307 self.as_ptr() as *mut _,
308 b"notify::latency-time\0".as_ptr() as *const _,
309 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
310 notify_latency_time_trampoline::<Self, F> as *const (),
311 )),
312 Box_::into_raw(f),
313 )
314 }
315 }
316
317 #[doc(alias = "provide-clock")]
318 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
319 &self,
320 f: F,
321 ) -> SignalHandlerId {
322 unsafe extern "C" fn notify_provide_clock_trampoline<
323 P: IsA<AudioBaseSrc>,
324 F: Fn(&P) + Send + Sync + 'static,
325 >(
326 this: *mut ffi::GstAudioBaseSrc,
327 _param_spec: glib::ffi::gpointer,
328 f: glib::ffi::gpointer,
329 ) {
330 let f: &F = &*(f as *const F);
331 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
332 }
333 unsafe {
334 let f: Box_<F> = Box_::new(f);
335 connect_raw(
336 self.as_ptr() as *mut _,
337 b"notify::provide-clock\0".as_ptr() as *const _,
338 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
339 notify_provide_clock_trampoline::<Self, F> as *const (),
340 )),
341 Box_::into_raw(f),
342 )
343 }
344 }
345
346 #[doc(alias = "slave-method")]
347 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
348 &self,
349 f: F,
350 ) -> SignalHandlerId {
351 unsafe extern "C" fn notify_slave_method_trampoline<
352 P: IsA<AudioBaseSrc>,
353 F: Fn(&P) + Send + Sync + 'static,
354 >(
355 this: *mut ffi::GstAudioBaseSrc,
356 _param_spec: glib::ffi::gpointer,
357 f: glib::ffi::gpointer,
358 ) {
359 let f: &F = &*(f as *const F);
360 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
361 }
362 unsafe {
363 let f: Box_<F> = Box_::new(f);
364 connect_raw(
365 self.as_ptr() as *mut _,
366 b"notify::slave-method\0".as_ptr() as *const _,
367 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
368 notify_slave_method_trampoline::<Self, F> as *const (),
369 )),
370 Box_::into_raw(f),
371 )
372 }
373 }
374}
375
376impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}