static void
gst_test_clock_add_entry (GstTestClock * test_clock,
    GstClockEntry * entry, GstClockTimeDiff * jitter)
{
  GstTestClockPrivate *priv = GST_TEST_CLOCK_GET_PRIVATE (test_clock);
  GstClockTime now;
  GstClockEntryContext *ctx;

  now = gst_clock_adjust_unlocked (GST_CLOCK (test_clock), priv->internal_time);

  if (jitter != NULL)
    *jitter = GST_CLOCK_DIFF (GST_CLOCK_ENTRY_TIME (entry), now);

  ctx = g_slice_new (GstClockEntryContext);
  ctx->clock_entry = GST_CLOCK_ENTRY (gst_clock_id_ref (entry));
  ctx->time_diff = GST_CLOCK_DIFF (now, GST_CLOCK_ENTRY_TIME (entry));

  priv->entry_contexts = g_list_insert_sorted (priv->entry_contexts, ctx,
      gst_clock_entry_context_compare_func);

  g_cond_broadcast (&priv->entry_added_cond);
}
Beispiel #2
0
/*
 * 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;
}