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
// Take a look at the license at the top of the repository in the LICENSE file.
use std::mem;
use glib::translate::*;
use crate::AudioStreamAlign;
impl AudioStreamAlign {
/// Processes data with `timestamp` and `n_samples`, and returns the output
/// timestamp, duration and sample position together with a boolean to signal
/// whether a discontinuity was detected or not. All non-discontinuous data
/// will have perfect timestamps and durations.
///
/// A discontinuity is detected once the difference between the actual
/// timestamp and the timestamp calculated from the sample count since the last
/// discontinuity differs by more than the alignment threshold for a duration
/// longer than discont wait.
///
/// Note: In reverse playback, every buffer is considered discontinuous in the
/// context of buffer flags because the last sample of the previous buffer is
/// discontinuous with the first sample of the current one. However for this
/// function they are only considered discontinuous in reverse playback if the
/// first sample of the previous buffer is discontinuous with the last sample
/// of the current one.
/// ## `discont`
/// if this data is considered to be discontinuous
/// ## `timestamp`
/// a `GstClockTime` of the start of the data
/// ## `n_samples`
/// number of samples to process
///
/// # Returns
///
/// [`true`] if a discontinuity was detected, [`false`] otherwise.
///
/// ## `out_timestamp`
/// output timestamp of the data
///
/// ## `out_duration`
/// output duration of the data
///
/// ## `out_sample_position`
/// output sample position of the start of the data
#[doc(alias = "gst_audio_stream_align_process")]
pub fn process(
&mut self,
discont: bool,
timestamp: gst::ClockTime,
n_samples: u32,
) -> (bool, gst::ClockTime, gst::ClockTime, u64) {
unsafe {
let mut out_timestamp = mem::MaybeUninit::uninit();
let mut out_duration = mem::MaybeUninit::uninit();
let mut out_sample_position = mem::MaybeUninit::uninit();
let ret = from_glib(crate::ffi::gst_audio_stream_align_process(
self.to_glib_none_mut().0,
discont.into_glib(),
timestamp.into_glib(),
n_samples,
out_timestamp.as_mut_ptr(),
out_duration.as_mut_ptr(),
out_sample_position.as_mut_ptr(),
));
(
ret,
try_from_glib(out_timestamp.assume_init()).expect("undefined out_timestamp"),
try_from_glib(out_duration.assume_init()).expect("undefined out_duration"),
out_sample_position.assume_init(),
)
}
}
}