diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 54d6a29b8..7033e5070 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -155,35 +155,6 @@ impl ClockId { &*((&(*ptr).status) as *const i32 as *const AtomicClockReturn) } } - - pub fn wake_up(&self, clock: &Clock) { - #[cfg(feature = "v1_16")] - { - assert!(self.uses_clock(clock)); - } - #[cfg(not(feature = "v1_16"))] - { - unsafe { - let ptr: *mut gst_sys::GstClockEntry = self.to_glib_none().0 as *mut _; - assert_eq!((*ptr).clock, clock.to_glib_none().0); - } - } - - unsafe { - let ptr: *mut gst_sys::GstClockEntry = self.to_glib_none().0 as *mut _; - if let Some(func) = (*ptr).func { - func( - clock.to_glib_none().0, - (*ptr).time, - ptr as gst_sys::GstClockID, - (*ptr).user_data, - ); - } - if (*ptr).type_ == gst_sys::GST_CLOCK_ENTRY_PERIODIC { - (*ptr).time += (*ptr).interval; - } - } - } } #[repr(C)] diff --git a/gstreamer/src/subclass/clock.rs b/gstreamer/src/subclass/clock.rs index 3153c1f84..1c03e30dc 100644 --- a/gstreamer/src/subclass/clock.rs +++ b/gstreamer/src/subclass/clock.rs @@ -9,9 +9,9 @@ use gst_sys; use glib; -use glib::translate::*; - +use glib::prelude::*; use glib::subclass::prelude::*; +use glib::translate::*; use Clock; use ClockClass; @@ -78,6 +78,11 @@ pub trait ClockImplExt { fn parent_wait_async(&self, clock: &Clock, id: &ClockId) -> Result; fn parent_unschedule(&self, clock: &Clock, id: &ClockId); + + fn wake_id(&self, id: &ClockId) + where + Self: ObjectSubclass, + ::ParentType: IsA; } impl ClockImplExt for T { @@ -191,6 +196,41 @@ impl ClockImplExt for T { } } } + + fn wake_id(&self, id: &ClockId) + where + Self: ObjectSubclass, + ::ParentType: IsA, + { + let clock = self.get_instance(); + + #[cfg(feature = "v1_16")] + { + assert!(id.uses_clock(&clock)); + } + #[cfg(not(feature = "v1_16"))] + { + unsafe { + let ptr: *mut gst_sys::GstClockEntry = id.to_glib_none().0 as *mut _; + assert_eq!((*ptr).clock, clock.as_ref().to_glib_none().0); + } + } + + unsafe { + let ptr: *mut gst_sys::GstClockEntry = id.to_glib_none().0 as *mut _; + if let Some(func) = (*ptr).func { + func( + clock.as_ref().to_glib_none().0, + (*ptr).time, + ptr as gst_sys::GstClockID, + (*ptr).user_data, + ); + } + if (*ptr).type_ == gst_sys::GST_CLOCK_ENTRY_PERIODIC { + (*ptr).time += (*ptr).interval; + } + } + } } unsafe impl IsSubclassable for ClockClass {