From 4e60a0aea406a577674f06d1fc5229db4d781998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 25 Sep 2019 16:46:46 +0300 Subject: [PATCH] clock: Add support for setting/getting/unsetting clock flags --- gstreamer/src/clock.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 02d6ee214..9a75a211f 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -18,6 +18,7 @@ use std::cmp; use std::ptr; use Clock; use ClockError; +use ClockFlags; use ClockReturn; use ClockSuccess; use ClockTime; @@ -183,6 +184,12 @@ pub trait ClockExtManual: 'static { fn new_single_shot_id(&self, time: ClockTime) -> Option; fn single_shot_id_reinit(&self, id: &ClockId, time: ClockTime) -> Result<(), glib::BoolError>; + + fn set_clock_flags(&self, flags: ClockFlags); + + fn unset_clock_flags(&self, flags: ClockFlags); + + fn get_clock_flags(&self) -> ClockFlags; } impl> ClockExtManual for O { @@ -241,6 +248,30 @@ impl> ClockExtManual for O { } } } + + fn set_clock_flags(&self, flags: ClockFlags) { + unsafe { + let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; + let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + (*ptr).flags |= flags.to_glib(); + } + } + + fn unset_clock_flags(&self, flags: ClockFlags) { + unsafe { + let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; + let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + (*ptr).flags &= !flags.to_glib(); + } + } + + fn get_clock_flags(&self) -> ClockFlags { + unsafe { + let ptr: *mut gst_sys::GstObject = self.as_ptr() as *mut _; + let _guard = ::utils::MutexGuard::lock(&(*ptr).lock); + from_glib((*ptr).flags) + } + } } #[cfg(test)]