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
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 let f: &F = &*(f as *const F);
210 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
211 }
212 unsafe {
213 let f: Box_<F> = Box_::new(f);
214 connect_raw(
215 self.as_ptr() as *mut _,
216 c"notify::actual-buffer-time".as_ptr() as *const _,
217 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218 notify_actual_buffer_time_trampoline::<Self, F> as *const (),
219 )),
220 Box_::into_raw(f),
221 )
222 }
223 }
224
225 #[doc(alias = "actual-latency-time")]
226 fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
227 &self,
228 f: F,
229 ) -> SignalHandlerId {
230 unsafe extern "C" fn notify_actual_latency_time_trampoline<
231 P: IsA<AudioBaseSrc>,
232 F: Fn(&P) + Send + Sync + 'static,
233 >(
234 this: *mut ffi::GstAudioBaseSrc,
235 _param_spec: glib::ffi::gpointer,
236 f: glib::ffi::gpointer,
237 ) {
238 let f: &F = &*(f as *const F);
239 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
240 }
241 unsafe {
242 let f: Box_<F> = Box_::new(f);
243 connect_raw(
244 self.as_ptr() as *mut _,
245 c"notify::actual-latency-time".as_ptr() as *const _,
246 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247 notify_actual_latency_time_trampoline::<Self, F> as *const (),
248 )),
249 Box_::into_raw(f),
250 )
251 }
252 }
253
254 #[doc(alias = "buffer-time")]
255 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
256 &self,
257 f: F,
258 ) -> SignalHandlerId {
259 unsafe extern "C" fn notify_buffer_time_trampoline<
260 P: IsA<AudioBaseSrc>,
261 F: Fn(&P) + Send + Sync + 'static,
262 >(
263 this: *mut ffi::GstAudioBaseSrc,
264 _param_spec: glib::ffi::gpointer,
265 f: glib::ffi::gpointer,
266 ) {
267 let f: &F = &*(f as *const F);
268 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
269 }
270 unsafe {
271 let f: Box_<F> = Box_::new(f);
272 connect_raw(
273 self.as_ptr() as *mut _,
274 c"notify::buffer-time".as_ptr() as *const _,
275 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
276 notify_buffer_time_trampoline::<Self, F> as *const (),
277 )),
278 Box_::into_raw(f),
279 )
280 }
281 }
282
283 #[doc(alias = "latency-time")]
284 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
285 &self,
286 f: F,
287 ) -> SignalHandlerId {
288 unsafe extern "C" fn notify_latency_time_trampoline<
289 P: IsA<AudioBaseSrc>,
290 F: Fn(&P) + Send + Sync + 'static,
291 >(
292 this: *mut ffi::GstAudioBaseSrc,
293 _param_spec: glib::ffi::gpointer,
294 f: glib::ffi::gpointer,
295 ) {
296 let f: &F = &*(f as *const F);
297 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
298 }
299 unsafe {
300 let f: Box_<F> = Box_::new(f);
301 connect_raw(
302 self.as_ptr() as *mut _,
303 c"notify::latency-time".as_ptr() as *const _,
304 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
305 notify_latency_time_trampoline::<Self, F> as *const (),
306 )),
307 Box_::into_raw(f),
308 )
309 }
310 }
311
312 #[doc(alias = "provide-clock")]
313 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
314 &self,
315 f: F,
316 ) -> SignalHandlerId {
317 unsafe extern "C" fn notify_provide_clock_trampoline<
318 P: IsA<AudioBaseSrc>,
319 F: Fn(&P) + Send + Sync + 'static,
320 >(
321 this: *mut ffi::GstAudioBaseSrc,
322 _param_spec: glib::ffi::gpointer,
323 f: glib::ffi::gpointer,
324 ) {
325 let f: &F = &*(f as *const F);
326 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
327 }
328 unsafe {
329 let f: Box_<F> = Box_::new(f);
330 connect_raw(
331 self.as_ptr() as *mut _,
332 c"notify::provide-clock".as_ptr() as *const _,
333 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334 notify_provide_clock_trampoline::<Self, F> as *const (),
335 )),
336 Box_::into_raw(f),
337 )
338 }
339 }
340
341 #[doc(alias = "slave-method")]
342 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
343 &self,
344 f: F,
345 ) -> SignalHandlerId {
346 unsafe extern "C" fn notify_slave_method_trampoline<
347 P: IsA<AudioBaseSrc>,
348 F: Fn(&P) + Send + Sync + 'static,
349 >(
350 this: *mut ffi::GstAudioBaseSrc,
351 _param_spec: glib::ffi::gpointer,
352 f: glib::ffi::gpointer,
353 ) {
354 let f: &F = &*(f as *const F);
355 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
356 }
357 unsafe {
358 let f: Box_<F> = Box_::new(f);
359 connect_raw(
360 self.as_ptr() as *mut _,
361 c"notify::slave-method".as_ptr() as *const _,
362 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
363 notify_slave_method_trampoline::<Self, F> as *const (),
364 )),
365 Box_::into_raw(f),
366 )
367 }
368 }
369}
370
371impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}