mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-05 01:00:10 +00:00
clock: Move wake_id() from ClockId to ClockImpl
This shouldn't really be called on anything outside a Clock implementation.
This commit is contained in:
parent
6abb0d3506
commit
19b3427909
2 changed files with 42 additions and 31 deletions
|
@ -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)]
|
||||
|
|
|
@ -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<ClockSuccess, ClockError>;
|
||||
|
||||
fn parent_unschedule(&self, clock: &Clock, id: &ClockId);
|
||||
|
||||
fn wake_id(&self, id: &ClockId)
|
||||
where
|
||||
Self: ObjectSubclass,
|
||||
<Self as ObjectSubclass>::ParentType: IsA<Clock>;
|
||||
}
|
||||
|
||||
impl<T: ClockImpl + ObjectImpl> ClockImplExt for T {
|
||||
|
@ -191,6 +196,41 @@ impl<T: ClockImpl + ObjectImpl> ClockImplExt for T {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn wake_id(&self, id: &ClockId)
|
||||
where
|
||||
Self: ObjectSubclass,
|
||||
<Self as ObjectSubclass>::ParentType: IsA<Clock>,
|
||||
{
|
||||
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<T: ObjectSubclass + ClockImpl> IsSubclassable<T> for ClockClass {
|
||||
|
|
Loading…
Reference in a new issue