1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::AudioInfo;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;

glib::wrapper! {
    /// This base class is for audio decoders turning encoded data into
    /// raw audio samples.
    ///
    /// GstAudioDecoder and subclass should cooperate as follows.
    ///
    /// ## Configuration
    ///
    ///  * Initially, GstAudioDecoder calls `start` when the decoder element
    ///  is activated, which allows subclass to perform any global setup.
    ///  Base class (context) parameters can already be set according to subclass
    ///  capabilities (or possibly upon receive more information in subsequent
    ///  `set_format`).
    ///  * GstAudioDecoder calls `set_format` to inform subclass of the format
    ///  of input audio data that it is about to receive.
    ///  While unlikely, it might be called more than once, if changing input
    ///  parameters require reconfiguration.
    ///  * GstAudioDecoder calls `stop` at end of all processing.
    ///
    /// As of configuration stage, and throughout processing, GstAudioDecoder
    /// provides various (context) parameters, e.g. describing the format of
    /// output audio data (valid when output caps have been set) or current parsing state.
    /// Conversely, subclass can and should configure context to inform
    /// base class of its expectation w.r.t. buffer handling.
    ///
    /// ## Data processing
    ///  * Base class gathers input data, and optionally allows subclass
    ///  to parse this into subsequently manageable (as defined by subclass)
    ///  chunks. Such chunks are subsequently referred to as 'frames',
    ///  though they may or may not correspond to 1 (or more) audio format frame.
    ///  * Input frame is provided to subclass' `handle_frame`.
    ///  * If codec processing results in decoded data, subclass should call
    ///  [`Self::finish_frame`] to have decoded data pushed
    ///  downstream.
    ///  * Just prior to actually pushing a buffer downstream,
    ///  it is passed to `pre_push`. Subclass should either use this callback
    ///  to arrange for additional downstream pushing or otherwise ensure such
    ///  custom pushing occurs after at least a method call has finished since
    ///  setting src pad caps.
    ///  * During the parsing process GstAudioDecoderClass will handle both
    ///  srcpad and sinkpad events. Sink events will be passed to subclass
    ///  if `event` callback has been provided.
    ///
    /// ## Shutdown phase
    ///
    ///  * GstAudioDecoder class calls `stop` to inform the subclass that data
    ///  parsing will be stopped.
    ///
    /// Subclass is responsible for providing pad template caps for
    /// source and sink pads. The pads need to be named "sink" and "src". It also
    /// needs to set the fixed caps on srcpad, when the format is ensured. This
    /// is typically when base class calls subclass' `set_format` function, though
    /// it might be delayed until calling [`Self::finish_frame`].
    ///
    /// In summary, above process should have subclass concentrating on
    /// codec data processing while leaving other matters to base class,
    /// such as most notably timestamp handling. While it may exert more control
    /// in this area (see e.g. `pre_push`), it is very much not recommended.
    ///
    /// In particular, base class will try to arrange for perfect output timestamps
    /// as much as possible while tracking upstream timestamps.
    /// To this end, if deviation between the next ideal expected perfect timestamp
    /// and upstream exceeds [`crate::AudioDecoder:tolerance`], then resync to upstream
    /// occurs (which would happen always if the tolerance mechanism is disabled).
    ///
    /// In non-live pipelines, baseclass can also (configurably) arrange for
    /// output buffer aggregation which may help to redue large(r) numbers of
    /// small(er) buffers being pushed and processed downstream. Note that this
    /// feature is only available if the buffer layout is interleaved. For planar
    /// buffers, the decoder implementation is fully responsible for the output
    /// buffer size.
    ///
    /// On the other hand, it should be noted that baseclass only provides limited
    /// seeking support (upon explicit subclass request), as full-fledged support
    /// should rather be left to upstream demuxer, parser or alike. This simple
    /// approach caters for seeking and duration reporting using estimated input
    /// bitrates.
    ///
    /// Things that subclass need to take care of:
    ///
    ///  * Provide pad templates
    ///  * Set source pad caps when appropriate
    ///  * Set user-configurable properties to sane defaults for format and
    ///  implementing codec at hand, and convey some subclass capabilities and
    ///  expectations in context.
    ///
    ///  * Accept data in `handle_frame` and provide encoded results to
    ///  [`Self::finish_frame`]. If it is prepared to perform
    ///  PLC, it should also accept NULL data in `handle_frame` and provide for
    ///  data for indicated duration.
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// # Implements
    ///
    /// [`trait@crate::prelude::AudioDecoderExt`], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::object::ObjectExt`], [`trait@crate::prelude::AudioDecoderExtManual`]
    pub struct AudioDecoder(Object<ffi::GstAudioDecoder, ffi::GstAudioDecoderClass>) @extends gst::Element, gst::Object;

    match fn {
        type_ => || ffi::gst_audio_decoder_get_type(),
    }
}

unsafe impl Send for AudioDecoder {}
unsafe impl Sync for AudioDecoder {}

pub const NONE_AUDIO_DECODER: Option<&AudioDecoder> = None;

/// Trait containing all `AudioDecoder` methods.
///
/// # Implementors
///
/// [`struct@crate::AudioDecoder`]
pub trait AudioDecoderExt: 'static {
    /// Helper function that allocates a buffer to hold an audio frame
    /// for `self`'s current output format.
    /// ## `size`
    /// size of the buffer
    ///
    /// # Returns
    ///
    /// allocated buffer
    #[doc(alias = "gst_audio_decoder_allocate_output_buffer")]
    fn allocate_output_buffer(&self, size: usize) -> Result<gst::Buffer, glib::BoolError>;

    ///
    /// # Returns
    ///
    /// a [`crate::AudioInfo`] describing the input audio format
    #[doc(alias = "gst_audio_decoder_get_audio_info")]
    #[doc(alias = "get_audio_info")]
    fn audio_info(&self) -> Option<AudioInfo>;

    ///
    /// # Returns
    ///
    /// currently configured decoder delay
    #[doc(alias = "gst_audio_decoder_get_delay")]
    #[doc(alias = "get_delay")]
    fn delay(&self) -> i32;

    /// Queries decoder drain handling.
    ///
    /// # Returns
    ///
    /// TRUE if drainable handling is enabled.
    ///
    /// MT safe.
    #[doc(alias = "gst_audio_decoder_get_drainable")]
    #[doc(alias = "get_drainable")]
    fn is_drainable(&self) -> bool;

    ///
    /// # Returns
    ///
    /// currently configured byte to time conversion setting
    #[doc(alias = "gst_audio_decoder_get_estimate_rate")]
    #[doc(alias = "get_estimate_rate")]
    fn estimate_rate(&self) -> i32;

    /// Sets the variables pointed to by `min` and `max` to the currently configured
    /// latency.
    /// ## `min`
    /// a pointer to storage to hold minimum latency
    /// ## `max`
    /// a pointer to storage to hold maximum latency
    #[doc(alias = "gst_audio_decoder_get_latency")]
    #[doc(alias = "get_latency")]
    fn latency(&self) -> (gst::ClockTime, gst::ClockTime);

    ///
    /// # Returns
    ///
    /// currently configured decoder tolerated error count.
    #[doc(alias = "gst_audio_decoder_get_max_errors")]
    #[doc(alias = "get_max_errors")]
    fn max_errors(&self) -> i32;

    /// Queries decoder's latency aggregation.
    ///
    /// # Returns
    ///
    /// aggregation latency.
    ///
    /// MT safe.
    #[doc(alias = "gst_audio_decoder_get_min_latency")]
    #[doc(alias = "get_min_latency")]
    fn min_latency(&self) -> gst::ClockTime;

    /// Queries decoder required format handling.
    ///
    /// # Returns
    ///
    /// TRUE if required format handling is enabled.
    ///
    /// MT safe.
    #[doc(alias = "gst_audio_decoder_get_needs_format")]
    #[doc(alias = "get_needs_format")]
    fn needs_format(&self) -> bool;

    /// Return current parsing (sync and eos) state.
    /// ## `sync`
    /// a pointer to a variable to hold the current sync state
    /// ## `eos`
    /// a pointer to a variable to hold the current eos state
    #[doc(alias = "gst_audio_decoder_get_parse_state")]
    #[doc(alias = "get_parse_state")]
    fn parse_state(&self) -> (bool, bool);

    /// Queries decoder packet loss concealment handling.
    ///
    /// # Returns
    ///
    /// TRUE if packet loss concealment is enabled.
    ///
    /// MT safe.
    #[doc(alias = "gst_audio_decoder_get_plc")]
    #[doc(alias = "get_plc")]
    fn is_plc(&self) -> bool;

    ///
    /// # Returns
    ///
    /// currently configured plc handling
    #[doc(alias = "gst_audio_decoder_get_plc_aware")]
    #[doc(alias = "get_plc_aware")]
    fn plc_aware(&self) -> i32;

    /// Queries current audio jitter tolerance threshold.
    ///
    /// # Returns
    ///
    /// decoder audio jitter tolerance threshold.
    ///
    /// MT safe.
    #[doc(alias = "gst_audio_decoder_get_tolerance")]
    #[doc(alias = "get_tolerance")]
    fn tolerance(&self) -> gst::ClockTime;

    /// Sets the audio decoder tags and how they should be merged with any
    /// upstream stream tags. This will override any tags previously-set
    /// with [`Self::merge_tags()`].
    ///
    /// Note that this is provided for convenience, and the subclass is
    /// not required to use this and can still do tag handling on its own.
    /// ## `tags`
    /// a [`crate::gst::TagList`] to merge, or NULL
    /// ## `mode`
    /// the [`crate::gst::TagMergeMode`] to use, usually [`crate::gst::TagMergeMode::Replace`]
    #[doc(alias = "gst_audio_decoder_merge_tags")]
    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode);

    /// Returns caps that express `caps` (or sink template caps if `caps` == NULL)
    /// restricted to rate/channels/... combinations supported by downstream
    /// elements.
    /// ## `caps`
    /// initial caps
    /// ## `filter`
    /// filter caps
    ///
    /// # Returns
    ///
    /// a [`crate::gst::Caps`] owned by caller
    #[doc(alias = "gst_audio_decoder_proxy_getcaps")]
    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps;

    /// Sets a caps in allocation query which are different from the set
    /// pad's caps. Use this function before calling
    /// [`crate::AudioDecoder::negotiate()`]. Setting to [`None`] the allocation
    /// query will use the caps from the pad.
    /// ## `allocation_caps`
    /// a [`crate::gst::Caps`] or [`None`]
    #[cfg(any(feature = "v1_10", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
    #[doc(alias = "gst_audio_decoder_set_allocation_caps")]
    fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>);

    /// Configures decoder drain handling. If drainable, subclass might
    /// be handed a NULL buffer to have it return any leftover decoded data.
    /// Otherwise, it is not considered so capable and will only ever be passed
    /// real data.
    ///
    /// MT safe.
    /// ## `enabled`
    /// new state
    #[doc(alias = "gst_audio_decoder_set_drainable")]
    fn set_drainable(&self, enabled: bool);

    /// Allows baseclass to perform byte to time estimated conversion.
    /// ## `enabled`
    /// whether to enable byte to time conversion
    #[doc(alias = "gst_audio_decoder_set_estimate_rate")]
    fn set_estimate_rate(&self, enabled: bool);

    /// Sets decoder latency.
    /// ## `min`
    /// minimum latency
    /// ## `max`
    /// maximum latency
    #[doc(alias = "gst_audio_decoder_set_latency")]
    fn set_latency(&self, min: gst::ClockTime, max: gst::ClockTime);

    /// Sets numbers of tolerated decoder errors, where a tolerated one is then only
    /// warned about, but more than tolerated will lead to fatal error. You can set
    /// -1 for never returning fatal errors. Default is set to
    /// GST_AUDIO_DECODER_MAX_ERRORS.
    /// ## `num`
    /// max tolerated errors
    #[doc(alias = "gst_audio_decoder_set_max_errors")]
    fn set_max_errors(&self, num: i32);

    /// Sets decoder minimum aggregation latency.
    ///
    /// MT safe.
    /// ## `num`
    /// new minimum latency
    #[doc(alias = "gst_audio_decoder_set_min_latency")]
    fn set_min_latency(&self, num: gst::ClockTime);

    /// Configures decoder format needs. If enabled, subclass needs to be
    /// negotiated with format caps before it can process any data. It will then
    /// never be handed any data before it has been configured.
    /// Otherwise, it might be handed data without having been configured and
    /// is then expected being able to do so either by default
    /// or based on the input data.
    ///
    /// MT safe.
    /// ## `enabled`
    /// new state
    #[doc(alias = "gst_audio_decoder_set_needs_format")]
    fn set_needs_format(&self, enabled: bool);

    /// Enable or disable decoder packet loss concealment, provided subclass
    /// and codec are capable and allow handling plc.
    ///
    /// MT safe.
    /// ## `enabled`
    /// new state
    #[doc(alias = "gst_audio_decoder_set_plc")]
    fn set_plc(&self, enabled: bool);

    /// Indicates whether or not subclass handles packet loss concealment (plc).
    /// ## `plc`
    /// new plc state
    #[doc(alias = "gst_audio_decoder_set_plc_aware")]
    fn set_plc_aware(&self, plc: bool);

    /// Configures decoder audio jitter tolerance threshold.
    ///
    /// MT safe.
    /// ## `tolerance`
    /// new tolerance
    #[doc(alias = "gst_audio_decoder_set_tolerance")]
    fn set_tolerance(&self, tolerance: gst::ClockTime);

    /// Lets [`crate::AudioDecoder`] sub-classes decide if they want the sink pad
    /// to use the default pad query handler to reply to accept-caps queries.
    ///
    /// By setting this to true it is possible to further customize the default
    /// handler with `GST_PAD_SET_ACCEPT_INTERSECT` and
    /// `GST_PAD_SET_ACCEPT_TEMPLATE`
    /// ## `use_`
    /// if the default pad accept-caps query handling should be used
    #[doc(alias = "gst_audio_decoder_set_use_default_pad_acceptcaps")]
    fn set_use_default_pad_acceptcaps(&self, use_: bool);

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "max-errors")]
    fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    #[doc(alias = "min-latency")]
    fn connect_min_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    #[doc(alias = "plc")]
    fn connect_plc_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "tolerance")]
    fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;
}

impl<O: IsA<AudioDecoder>> AudioDecoderExt for O {
    fn allocate_output_buffer(&self, size: usize) -> Result<gst::Buffer, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_full(ffi::gst_audio_decoder_allocate_output_buffer(
                self.as_ref().to_glib_none().0,
                size,
            ))
            .ok_or_else(|| glib::bool_error!("Failed to allocate output buffer"))
        }
    }

    fn audio_info(&self) -> Option<AudioInfo> {
        unsafe {
            from_glib_full(ffi::gst_audio_decoder_get_audio_info(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn delay(&self) -> i32 {
        unsafe { ffi::gst_audio_decoder_get_delay(self.as_ref().to_glib_none().0) }
    }

    fn is_drainable(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_audio_decoder_get_drainable(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn estimate_rate(&self) -> i32 {
        unsafe { ffi::gst_audio_decoder_get_estimate_rate(self.as_ref().to_glib_none().0) }
    }

    fn latency(&self) -> (gst::ClockTime, gst::ClockTime) {
        unsafe {
            let mut min = mem::MaybeUninit::uninit();
            let mut max = mem::MaybeUninit::uninit();
            ffi::gst_audio_decoder_get_latency(
                self.as_ref().to_glib_none().0,
                min.as_mut_ptr(),
                max.as_mut_ptr(),
            );
            let min = min.assume_init();
            let max = max.assume_init();
            (from_glib(min), from_glib(max))
        }
    }

    fn max_errors(&self) -> i32 {
        unsafe { ffi::gst_audio_decoder_get_max_errors(self.as_ref().to_glib_none().0) }
    }

    fn min_latency(&self) -> gst::ClockTime {
        unsafe {
            from_glib(ffi::gst_audio_decoder_get_min_latency(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn needs_format(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_audio_decoder_get_needs_format(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn parse_state(&self) -> (bool, bool) {
        unsafe {
            let mut sync = mem::MaybeUninit::uninit();
            let mut eos = mem::MaybeUninit::uninit();
            ffi::gst_audio_decoder_get_parse_state(
                self.as_ref().to_glib_none().0,
                sync.as_mut_ptr(),
                eos.as_mut_ptr(),
            );
            let sync = sync.assume_init();
            let eos = eos.assume_init();
            (from_glib(sync), from_glib(eos))
        }
    }

    fn is_plc(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_audio_decoder_get_plc(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn plc_aware(&self) -> i32 {
        unsafe { ffi::gst_audio_decoder_get_plc_aware(self.as_ref().to_glib_none().0) }
    }

    fn tolerance(&self) -> gst::ClockTime {
        unsafe {
            from_glib(ffi::gst_audio_decoder_get_tolerance(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
        unsafe {
            ffi::gst_audio_decoder_merge_tags(
                self.as_ref().to_glib_none().0,
                tags.to_glib_none().0,
                mode.into_glib(),
            );
        }
    }

    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
        unsafe {
            from_glib_full(ffi::gst_audio_decoder_proxy_getcaps(
                self.as_ref().to_glib_none().0,
                caps.to_glib_none().0,
                filter.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_10", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
    fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) {
        unsafe {
            ffi::gst_audio_decoder_set_allocation_caps(
                self.as_ref().to_glib_none().0,
                allocation_caps.to_glib_none().0,
            );
        }
    }

    fn set_drainable(&self, enabled: bool) {
        unsafe {
            ffi::gst_audio_decoder_set_drainable(
                self.as_ref().to_glib_none().0,
                enabled.into_glib(),
            );
        }
    }

    fn set_estimate_rate(&self, enabled: bool) {
        unsafe {
            ffi::gst_audio_decoder_set_estimate_rate(
                self.as_ref().to_glib_none().0,
                enabled.into_glib(),
            );
        }
    }

    fn set_latency(&self, min: gst::ClockTime, max: gst::ClockTime) {
        unsafe {
            ffi::gst_audio_decoder_set_latency(
                self.as_ref().to_glib_none().0,
                min.into_glib(),
                max.into_glib(),
            );
        }
    }

    fn set_max_errors(&self, num: i32) {
        unsafe {
            ffi::gst_audio_decoder_set_max_errors(self.as_ref().to_glib_none().0, num);
        }
    }

    fn set_min_latency(&self, num: gst::ClockTime) {
        unsafe {
            ffi::gst_audio_decoder_set_min_latency(self.as_ref().to_glib_none().0, num.into_glib());
        }
    }

    fn set_needs_format(&self, enabled: bool) {
        unsafe {
            ffi::gst_audio_decoder_set_needs_format(
                self.as_ref().to_glib_none().0,
                enabled.into_glib(),
            );
        }
    }

    fn set_plc(&self, enabled: bool) {
        unsafe {
            ffi::gst_audio_decoder_set_plc(self.as_ref().to_glib_none().0, enabled.into_glib());
        }
    }

    fn set_plc_aware(&self, plc: bool) {
        unsafe {
            ffi::gst_audio_decoder_set_plc_aware(self.as_ref().to_glib_none().0, plc.into_glib());
        }
    }

    fn set_tolerance(&self, tolerance: gst::ClockTime) {
        unsafe {
            ffi::gst_audio_decoder_set_tolerance(
                self.as_ref().to_glib_none().0,
                tolerance.into_glib(),
            );
        }
    }

    fn set_use_default_pad_acceptcaps(&self, use_: bool) {
        unsafe {
            ffi::gst_audio_decoder_set_use_default_pad_acceptcaps(
                self.as_ref().to_glib_none().0,
                use_.into_glib(),
            );
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "max-errors")]
    fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_errors_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut ffi::GstAudioDecoder,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<AudioDecoder>,
        {
            let f: &F = &*(f as *const F);
            f(&AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::max-errors\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_max_errors_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "min-latency")]
    fn connect_min_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_min_latency_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut ffi::GstAudioDecoder,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<AudioDecoder>,
        {
            let f: &F = &*(f as *const F);
            f(&AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::min-latency\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_min_latency_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "plc")]
    fn connect_plc_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_plc_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut ffi::GstAudioDecoder,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<AudioDecoder>,
        {
            let f: &F = &*(f as *const F);
            f(&AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::plc\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_plc_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "tolerance")]
    fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_tolerance_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut ffi::GstAudioDecoder,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<AudioDecoder>,
        {
            let f: &F = &*(f as *const F);
            f(&AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::tolerance\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_tolerance_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}