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")]
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 unsafe {
115 let f: &F = &*(f as *const F);
116 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
117 }
118 }
119 unsafe {
120 let f: Box_<F> = Box_::new(f);
121 connect_raw(
122 self.as_ptr() as *mut _,
123 c"notify::actual-buffer-time".as_ptr(),
124 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
125 notify_actual_buffer_time_trampoline::<Self, F> as *const (),
126 )),
127 Box_::into_raw(f),
128 )
129 }
130 }
131
132 #[doc(alias = "actual-latency-time")]
133 fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
134 &self,
135 f: F,
136 ) -> SignalHandlerId {
137 unsafe extern "C" fn notify_actual_latency_time_trampoline<
138 P: IsA<AudioBaseSrc>,
139 F: Fn(&P) + Send + Sync + 'static,
140 >(
141 this: *mut ffi::GstAudioBaseSrc,
142 _param_spec: glib::ffi::gpointer,
143 f: glib::ffi::gpointer,
144 ) {
145 unsafe {
146 let f: &F = &*(f as *const F);
147 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
148 }
149 }
150 unsafe {
151 let f: Box_<F> = Box_::new(f);
152 connect_raw(
153 self.as_ptr() as *mut _,
154 c"notify::actual-latency-time".as_ptr(),
155 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
156 notify_actual_latency_time_trampoline::<Self, F> as *const (),
157 )),
158 Box_::into_raw(f),
159 )
160 }
161 }
162
163 #[doc(alias = "buffer-time")]
164 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
165 &self,
166 f: F,
167 ) -> SignalHandlerId {
168 unsafe extern "C" fn notify_buffer_time_trampoline<
169 P: IsA<AudioBaseSrc>,
170 F: Fn(&P) + Send + Sync + 'static,
171 >(
172 this: *mut ffi::GstAudioBaseSrc,
173 _param_spec: glib::ffi::gpointer,
174 f: glib::ffi::gpointer,
175 ) {
176 unsafe {
177 let f: &F = &*(f as *const F);
178 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
179 }
180 }
181 unsafe {
182 let f: Box_<F> = Box_::new(f);
183 connect_raw(
184 self.as_ptr() as *mut _,
185 c"notify::buffer-time".as_ptr(),
186 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
187 notify_buffer_time_trampoline::<Self, F> as *const (),
188 )),
189 Box_::into_raw(f),
190 )
191 }
192 }
193
194 #[doc(alias = "latency-time")]
195 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
196 &self,
197 f: F,
198 ) -> SignalHandlerId {
199 unsafe extern "C" fn notify_latency_time_trampoline<
200 P: IsA<AudioBaseSrc>,
201 F: Fn(&P) + Send + Sync + 'static,
202 >(
203 this: *mut ffi::GstAudioBaseSrc,
204 _param_spec: glib::ffi::gpointer,
205 f: glib::ffi::gpointer,
206 ) {
207 unsafe {
208 let f: &F = &*(f as *const F);
209 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
210 }
211 }
212 unsafe {
213 let f: Box_<F> = Box_::new(f);
214 connect_raw(
215 self.as_ptr() as *mut _,
216 c"notify::latency-time".as_ptr(),
217 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218 notify_latency_time_trampoline::<Self, F> as *const (),
219 )),
220 Box_::into_raw(f),
221 )
222 }
223 }
224
225 #[doc(alias = "provide-clock")]
226 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
227 &self,
228 f: F,
229 ) -> SignalHandlerId {
230 unsafe extern "C" fn notify_provide_clock_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 unsafe {
239 let f: &F = &*(f as *const F);
240 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
241 }
242 }
243 unsafe {
244 let f: Box_<F> = Box_::new(f);
245 connect_raw(
246 self.as_ptr() as *mut _,
247 c"notify::provide-clock".as_ptr(),
248 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
249 notify_provide_clock_trampoline::<Self, F> as *const (),
250 )),
251 Box_::into_raw(f),
252 )
253 }
254 }
255
256 #[doc(alias = "slave-method")]
257 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
258 &self,
259 f: F,
260 ) -> SignalHandlerId {
261 unsafe extern "C" fn notify_slave_method_trampoline<
262 P: IsA<AudioBaseSrc>,
263 F: Fn(&P) + Send + Sync + 'static,
264 >(
265 this: *mut ffi::GstAudioBaseSrc,
266 _param_spec: glib::ffi::gpointer,
267 f: glib::ffi::gpointer,
268 ) {
269 unsafe {
270 let f: &F = &*(f as *const F);
271 f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
272 }
273 }
274 unsafe {
275 let f: Box_<F> = Box_::new(f);
276 connect_raw(
277 self.as_ptr() as *mut _,
278 c"notify::slave-method".as_ptr(),
279 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
280 notify_slave_method_trampoline::<Self, F> as *const (),
281 )),
282 Box_::into_raw(f),
283 )
284 }
285 }
286}
287
288impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}