gstreamer: clock: Manually implement bindings for calibration related function

The rate is using two clock times in C but this is really just a u64.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1470>
This commit is contained in:
Sebastian Dröge 2024-06-21 16:34:27 +03:00
parent cfb0fe6a17
commit 7a5096b1e4
3 changed files with 59 additions and 81 deletions

View file

@ -668,6 +668,14 @@ manual_traits = ["ClockExtManual"]
name = "unadjust_with_calibration"
# Associated function
manual = true
[[object.function]]
name = "get_calibration"
# Wrong types for the rate
manual = true
[[object.function]]
name = "set_calibration"
# Wrong types for the rate
manual = true
[[object.function]]
name = "new_periodic_id"
@ -718,21 +726,6 @@ manual_traits = ["ClockExtManual"]
name = "internal"
mandatory = true
[[object.function]]
name = "get_calibration"
[[object.function.parameter]]
name = "internal"
mandatory = true
[[object.function.parameter]]
name = "external"
mandatory = true
[[object.function.parameter]]
name = "rate_num"
mandatory = true
[[object.function.parameter]]
name = "rate_denom"
mandatory = true
[[object.function]]
name = "get_internal_time"
[object.function.return]
@ -743,21 +736,6 @@ manual_traits = ["ClockExtManual"]
[object.function.return]
mandatory = true
[[object.function]]
name = "set_calibration"
[[object.function.parameter]]
name = "internal"
mandatory = true
[[object.function.parameter]]
name = "external"
mandatory = true
[[object.function.parameter]]
name = "rate_num"
mandatory = true
[[object.function.parameter]]
name = "rate_denom"
mandatory = true
[[object.function]]
name = "set_master"
[object.function.return]

View file

@ -146,30 +146,6 @@ pub trait ClockExt: IsA<Clock> + sealed::Sealed + 'static {
}
}
#[doc(alias = "gst_clock_get_calibration")]
#[doc(alias = "get_calibration")]
fn calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime) {
unsafe {
let mut internal = std::mem::MaybeUninit::uninit();
let mut external = std::mem::MaybeUninit::uninit();
let mut rate_num = std::mem::MaybeUninit::uninit();
let mut rate_denom = std::mem::MaybeUninit::uninit();
ffi::gst_clock_get_calibration(
self.as_ref().to_glib_none().0,
internal.as_mut_ptr(),
external.as_mut_ptr(),
rate_num.as_mut_ptr(),
rate_denom.as_mut_ptr(),
);
(
try_from_glib(internal.assume_init()).expect("mandatory glib value is None"),
try_from_glib(external.assume_init()).expect("mandatory glib value is None"),
try_from_glib(rate_num.assume_init()).expect("mandatory glib value is None"),
try_from_glib(rate_denom.assume_init()).expect("mandatory glib value is None"),
)
}
}
#[doc(alias = "gst_clock_get_internal_time")]
#[doc(alias = "get_internal_time")]
fn internal_time(&self) -> ClockTime {
@ -216,25 +192,6 @@ pub trait ClockExt: IsA<Clock> + sealed::Sealed + 'static {
unsafe { from_glib(ffi::gst_clock_is_synced(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "gst_clock_set_calibration")]
fn set_calibration(
&self,
internal: ClockTime,
external: ClockTime,
rate_num: ClockTime,
rate_denom: ClockTime,
) {
unsafe {
ffi::gst_clock_set_calibration(
self.as_ref().to_glib_none().0,
internal.into_glib(),
external.into_glib(),
rate_num.into_glib(),
rate_denom.into_glib(),
);
}
}
#[doc(alias = "gst_clock_set_master")]
fn set_master(&self, master: Option<&impl IsA<Clock>>) -> Result<(), glib::error::BoolError> {
unsafe {

View file

@ -380,8 +380,8 @@ impl Clock {
internal_target: ClockTime,
cinternal: ClockTime,
cexternal: ClockTime,
cnum: ClockTime,
cdenom: ClockTime,
cnum: u64,
cdenom: u64,
) -> ClockTime {
skip_assert_initialized!();
unsafe {
@ -390,8 +390,8 @@ impl Clock {
internal_target.into_glib(),
cinternal.into_glib(),
cexternal.into_glib(),
cnum.into_glib(),
cdenom.into_glib(),
cnum,
cdenom,
))
.expect("undefined ClockTime")
}
@ -402,8 +402,8 @@ impl Clock {
external_target: ClockTime,
cinternal: ClockTime,
cexternal: ClockTime,
cnum: ClockTime,
cdenom: ClockTime,
cnum: u64,
cdenom: u64,
) -> ClockTime {
skip_assert_initialized!();
unsafe {
@ -412,8 +412,8 @@ impl Clock {
external_target.into_glib(),
cinternal.into_glib(),
cexternal.into_glib(),
cnum.into_glib(),
cdenom.into_glib(),
cnum,
cdenom,
))
.expect("undefined ClockTime")
}
@ -515,6 +515,49 @@ pub trait ClockExtManual: sealed::Sealed + IsA<Clock> + 'static {
from_glib((*ptr).flags)
}
}
#[doc(alias = "gst_clock_get_calibration")]
#[doc(alias = "get_calibration")]
fn calibration(&self) -> (ClockTime, ClockTime, u64, u64) {
unsafe {
let mut internal = std::mem::MaybeUninit::uninit();
let mut external = std::mem::MaybeUninit::uninit();
let mut rate_num = std::mem::MaybeUninit::uninit();
let mut rate_denom = std::mem::MaybeUninit::uninit();
ffi::gst_clock_get_calibration(
self.as_ref().to_glib_none().0,
internal.as_mut_ptr(),
external.as_mut_ptr(),
rate_num.as_mut_ptr(),
rate_denom.as_mut_ptr(),
);
(
try_from_glib(internal.assume_init()).expect("mandatory glib value is None"),
try_from_glib(external.assume_init()).expect("mandatory glib value is None"),
rate_num.assume_init(),
rate_denom.assume_init(),
)
}
}
#[doc(alias = "gst_clock_set_calibration")]
fn set_calibration(
&self,
internal: ClockTime,
external: ClockTime,
rate_num: u64,
rate_denom: u64,
) {
unsafe {
ffi::gst_clock_set_calibration(
self.as_ref().to_glib_none().0,
internal.into_glib(),
external.into_glib(),
rate_num,
rate_denom,
);
}
}
}
impl<O: IsA<Clock>> ClockExtManual for O {}