static GstClockReturn _wait (GstClock * clock, GstClockEntry * entry, GstClockTimeDiff * jitter) { GstCpuThrottlingClock *self = GST_CPU_THROTTLING_CLOCK (clock); if (!self->priv->evaluate_wait_time) { if (!(self->priv->sclock)) { GST_ERROR_OBJECT (clock, "Could not find any system clock" " to start the wait time evaluation task"); } else { self->priv->evaluate_wait_time = gst_clock_new_periodic_id (self->priv->sclock, gst_clock_get_time (self->priv->sclock), self->priv->time_between_evals); gst_clock_id_wait_async (self->priv->evaluate_wait_time, (GstClockCallback) gst_transcoder_adjust_wait_time, (gpointer) self, NULL); } } if (G_UNLIKELY (GST_CLOCK_ENTRY_STATUS (entry) == GST_CLOCK_UNSCHEDULED)) return GST_CLOCK_UNSCHEDULED; if (gst_poll_wait (self->priv->timer, self->priv->current_wait_time)) { GST_INFO_OBJECT (self, "Something happened on the poll"); } return GST_CLOCK_ENTRY_STATUS (entry); }
/** * gst_clock_set_master: * @clock: a #GstClock * @master: (allow-none): a master #GstClock * * Set @master as the master clock for @clock. @clock will be automatically * calibrated so that gst_clock_get_time() reports the same time as the * master clock. * * A clock provider that slaves its clock to a master can get the current * calibration values with gst_clock_get_calibration(). * * @master can be %NULL in which case @clock will not be slaved anymore. It will * however keep reporting its time adjusted with the last configured rate * and time offsets. * * Returns: %TRUE if the clock is capable of being slaved to a master clock. * Trying to set a master on a clock without the * #GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return %FALSE. * * MT safe. */ gboolean gst_clock_set_master (GstClock * clock, GstClock * master) { GstClock **master_p; GstClockPrivate *priv; g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE); g_return_val_if_fail (master != clock, FALSE); GST_OBJECT_LOCK (clock); /* we always allow setting the master to NULL */ if (master && !GST_OBJECT_FLAG_IS_SET (clock, GST_CLOCK_FLAG_CAN_SET_MASTER)) goto not_supported; GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock, "slaving %p to master clock %p", clock, master); GST_OBJECT_UNLOCK (clock); priv = clock->priv; GST_CLOCK_SLAVE_LOCK (clock); if (priv->clockid) { gst_clock_id_unschedule (priv->clockid); gst_clock_id_unref (priv->clockid); priv->clockid = NULL; } if (master) { priv->filling = TRUE; priv->time_index = 0; /* use the master periodic id to schedule sampling and * clock calibration. */ priv->clockid = gst_clock_new_periodic_id (master, gst_clock_get_time (master), priv->timeout); gst_clock_id_wait_async (priv->clockid, (GstClockCallback) gst_clock_slave_callback, gst_object_ref (clock), (GDestroyNotify) gst_object_unref); } GST_CLOCK_SLAVE_UNLOCK (clock); GST_OBJECT_LOCK (clock); master_p = &priv->master; gst_object_replace ((GstObject **) master_p, (GstObject *) master); GST_OBJECT_UNLOCK (clock); return TRUE; /* ERRORS */ not_supported: { GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock, "cannot be slaved to a master clock"); GST_OBJECT_UNLOCK (clock); return FALSE; } }
/* * Class method: new(clock, time, interval=nil) * clock: a Gst::Clock. * time: a time period, in nanoseconds. * interval: an interval period, in nanoseconds. * * Creates a new Gst::ClockEntry object based on the given Gst::Clock. * * Two types of Gst::ClockEntry objects can be created: * * * One-shot: if the interval is ommited or nil, the entry will trigger a single shot notification, at the requested time (in nanoseconds); * * Periodic: if the interval is not nil, the timer entry will trigger a periodic notification, starting at time (in nanoseconds), and be fired with the given interval (also in nanoseconds). * * The timer will be issued after Gst::ClockEntry#wait or * Gst::ClockEntry#wait_async. * * Returns: a new Gst::ClockEntry object. */ static VALUE rg_initialize (int argc, VALUE * argv, VALUE self) { VALUE clock, time, interval; GstClockID id; rb_scan_args (argc, argv, "21", &clock, &time, &interval); /* * Single-shot */ if (NIL_P (interval)) id = gst_clock_new_single_shot_id (RVAL2GST_CLOCK (clock), NUM2ULL (time)); /* * Periodic */ else id = gst_clock_new_periodic_id (RVAL2GST_CLOCK (clock), NUM2ULL (time), NUM2ULL (interval)); G_INITIALIZE (self, GST_CLOCK_ENTRY (id)); return Qnil; }