gstclock: New API to re-use a single shot GstClockID
authorEdward Hervey <bilboed@bilboed.com>
Wed, 20 Oct 2010 15:40:43 +0000 (17:40 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Thu, 2 Dec 2010 18:04:56 +0000 (19:04 +0100)
API: gst_clock_single_shot_id_reinit

https://bugzilla.gnome.org/show_bug.cgi?id=632778

docs/gst/gstreamer-sections.txt
gst/gstclock.c
gst/gstclock.h
win32/common/libgstreamer.def

index 61adf21..967c8f0 100644 (file)
@@ -403,6 +403,7 @@ gst_clock_get_resolution
 gst_clock_get_time
 gst_clock_new_single_shot_id
 gst_clock_new_periodic_id
+gst_clock_single_shot_id_reinit
 gst_clock_get_internal_time
 gst_clock_adjust_unlocked
 gst_clock_unadjust_unlocked
index 00373d2..24f7dc5 100644 (file)
@@ -207,6 +207,43 @@ gst_clock_entry_new (GstClock * clock, GstClockTime time,
   return (GstClockID) entry;
 }
 
+/* WARNING : Does not modify the refoucnt
+ * WARNING : Do not use if a pending clock operation is happening on that entry */
+static gboolean
+gst_clock_entry_reinit (GstClock * clock, GstClockEntry * entry,
+    GstClockTime time, GstClockTime interval, GstClockEntryType type)
+{
+  g_return_val_if_fail (entry->status != GST_CLOCK_BUSY, FALSE);
+  g_return_val_if_fail (entry->clock == clock, FALSE);
+
+  entry->type = type;
+  entry->time = time;
+  entry->interval = interval;
+  entry->status = GST_CLOCK_OK;
+
+  return TRUE;
+}
+
+/**
+ * gst_clock_single_shot_id_reinit:
+ * @clock: a #GstClock
+ * @id: a #GstClockID
+ * @time: The requested time.
+ *
+ * Reinitializes the provided single shot @id to the provided time. Does not
+ * modify the reference count.
+ *
+ * Returns: %TRUE if the GstClockID could be reinitialized to the provided
+ * @time, else %FALSE.
+ */
+gboolean
+gst_clock_single_shot_id_reinit (GstClock * clock, GstClockID id,
+    GstClockTime time)
+{
+  return gst_clock_entry_reinit (clock, (GstClockEntry *) id, time,
+      GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE);
+}
+
 /**
  * gst_clock_id_ref:
  * @id: The #GstClockID to ref
index f83face..ee2e064 100644 (file)
@@ -553,6 +553,9 @@ GstClockReturn              gst_clock_id_wait_async_full    (GstClockID id,
                                                         GDestroyNotify destroy_data);
 void                   gst_clock_id_unschedule         (GstClockID id);
 
+gboolean                gst_clock_single_shot_id_reinit (GstClock * clock,
+                                                        GstClockID id,
+                                                        GstClockTime time);
 
 G_END_DECLS
 
index 44d83d5..5934a02 100644 (file)
@@ -224,6 +224,7 @@ EXPORTS
        gst_clock_set_calibration
        gst_clock_set_master
        gst_clock_set_resolution
+       gst_clock_single_shot_id_reinit
        gst_clock_type_get_type
        gst_clock_unadjust_unlocked
        gst_core_error_get_type