summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2014-04-12 15:22:35 +0100
committerTim-Philipp Müller <tim@centricular.com>2014-04-12 15:33:50 +0100
commited9d0381b2aef7270d1bc41a70db5d06e99f6a90 (patch)
treea50a96971216098d2e2ed4016bf8d8d65179d1b4 /libs
parent2e4900ba9435142d6b7249a890cd44fe8d93c707 (diff)
downloadgstreamer-ed9d0381b2aef7270d1bc41a70db5d06e99f6a90.tar.gz
testclock: replace newly-added GstTestClockIDList structure with a simple GList
Keep it simple. Likely also makes things easier for bindings, and efficiency clearly has not been a consideration given how the existing code handled these lists.
Diffstat (limited to 'libs')
-rw-r--r--libs/gst/check/Makefile.am3
-rw-r--r--libs/gst/check/gsttestclock.c70
-rw-r--r--libs/gst/check/gsttestclock.h31
3 files changed, 30 insertions, 74 deletions
diff --git a/libs/gst/check/Makefile.am b/libs/gst/check/Makefile.am
index cf1328bf04..120a3b08af 100644
--- a/libs/gst/check/Makefile.am
+++ b/libs/gst/check/Makefile.am
@@ -107,8 +107,7 @@ LIBGSTCHECK_EXPORTED_FUNCS = \
gst_test_clock_get_next_entry_time \
gst_test_clock_wait_for_multiple_pending_ids \
gst_test_clock_process_id_list \
- gst_test_clock_id_list_get_latest_time \
- gst_test_clock_id_list_free
+ gst_test_clock_id_list_get_latest_time
LIBGSTCHECK_EXPORTED_SYMBOLS = \
diff --git a/libs/gst/check/gsttestclock.c b/libs/gst/check/gsttestclock.c
index 6bdde0632e..a609766861 100644
--- a/libs/gst/check/gsttestclock.c
+++ b/libs/gst/check/gsttestclock.c
@@ -624,24 +624,20 @@ process_entry_context_unlocked (GstTestClock * test_clock,
}
}
-static GstTestClockIDList *
+static GList *
gst_test_clock_get_pending_id_list_unlocked (GstTestClock * test_clock)
{
GstTestClockPrivate *priv = GST_TEST_CLOCK_GET_PRIVATE (test_clock);
- GstTestClockIDList *result = g_new0 (GstTestClockIDList, 1);
+ GQueue queue = G_QUEUE_INIT;
+ GList *cur;
- if (priv->entry_contexts != NULL) {
- GList *cur;
- for (cur = priv->entry_contexts; cur != NULL; cur = cur->next) {
- GstClockEntryContext *ctx = cur->data;
+ for (cur = priv->entry_contexts; cur != NULL; cur = cur->next) {
+ GstClockEntryContext *ctx = cur->data;
- result->cur =
- g_list_append (result->cur, gst_clock_id_ref (ctx->clock_entry));
- }
+ g_queue_push_tail (&queue, gst_clock_id_ref (ctx->clock_entry));
}
- result->length = g_list_length (result->cur);
- return result;
+ return queue.head;
}
/**
@@ -987,7 +983,9 @@ gst_test_clock_get_next_entry_time (GstTestClock * test_clock)
* gst_test_clock_wait_for_multiple_pending_ids:
* @test_clock: #GstTestClock for which to await having enough pending clock
* @count: the number of pending clock notifications to wait for
- * @pending_list: A #GstTestClockIDList with pending #GstClockIDs
+ * @pending_list: (out) (element-type Gst.ClockID) (transfer full) (allow-none): Address
+ * of a #GList pointer variable to store the list of pending #GstClockIDs
+ * that expired, or NULL
*
* Blocks until at least @count clock notifications have been requested from
* @test_clock. There is no timeout for this wait, see the main description of
@@ -999,7 +997,7 @@ gst_test_clock_get_next_entry_time (GstTestClock * test_clock)
*/
void
gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
- guint count, GstTestClockIDList ** pending_list)
+ guint count, GList ** pending_list)
{
GstTestClockPrivate *priv;
@@ -1020,9 +1018,10 @@ gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
/**
* gst_test_clock_process_id_list:
* @test_clock: #GstTestClock for which to process the pending IDs
- * @pending_list: A #GstTestClockIDList with pending #GstClockIDs
+ * @pending_list: (element-type Gst.ClockID) (transfer none) (allow-none): List
+ * of pending #GstClockIDs
*
- * Processes and releases the pending IDs in #GstTestClockIDList
+ * Processes and releases the pending IDs in the list.
*
* MT safe.
*
@@ -1030,16 +1029,16 @@ gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
*/
guint
gst_test_clock_process_id_list (GstTestClock * test_clock,
- GstTestClockIDList * pending_list)
+ const GList * pending_list)
{
- GList *cur;
+ const GList *cur;
guint result = 0;
g_return_val_if_fail (GST_IS_TEST_CLOCK (test_clock), 0);
GST_OBJECT_LOCK (test_clock);
- for (cur = pending_list->cur; cur != NULL; cur = cur->next) {
+ for (cur = pending_list; cur != NULL; cur = cur->next) {
GstClockID pending_id = cur->data;
GstClockEntryContext *ctx =
gst_test_clock_lookup_entry_context (test_clock, pending_id);
@@ -1055,21 +1054,22 @@ gst_test_clock_process_id_list (GstTestClock * test_clock,
/**
* gst_test_clock_id_list_get_latest_time:
- * @pending_list: A #GstTestClockIDList with pending #GstClockIDs
+ * @pending_list: (element-type Gst.ClockID) (transfer none) (allow-none): List
+ * of of pending #GstClockIDs
*
- * Finds the latest time inside the #GstTestClockIDList
+ * Finds the latest time inside the list.
*
* MT safe.
*
* Since: 1.4
*/
GstClockTime
-gst_test_clock_id_list_get_latest_time (GstTestClockIDList * pending_list)
+gst_test_clock_id_list_get_latest_time (const GList * pending_list)
{
- GList *cur;
+ const GList *cur;
GstClockTime result = 0;
- for (cur = pending_list->cur; cur != NULL; cur = cur->next) {
+ for (cur = pending_list; cur != NULL; cur = cur->next) {
GstClockID *pending_id = cur->data;
GstClockTime time = gst_clock_id_get_time (pending_id);
if (time > result)
@@ -1078,27 +1078,3 @@ gst_test_clock_id_list_get_latest_time (GstTestClockIDList * pending_list)
return result;
}
-
-/**
- * gst_test_clock_id_list_free:
- * @pending_list: A #GstTestClockIDList with pending #GstClockIDs
- *
- * Free the supplied #GstTestClockIDList
- *
- * MT safe.
- *
- * Since: 1.4
- */
-void
-gst_test_clock_id_list_free (GstTestClockIDList * pending_list)
-{
- GList *cur;
-
- for (cur = pending_list->cur; cur != NULL; cur = cur->next) {
- GstClockID *pending_id = cur->data;
- gst_clock_id_unref (pending_id);
- }
-
- g_list_free (pending_list->cur);
- g_free (pending_list);
-}
diff --git a/libs/gst/check/gsttestclock.h b/libs/gst/check/gsttestclock.h
index 7610335c16..af7a5f1d36 100644
--- a/libs/gst/check/gsttestclock.h
+++ b/libs/gst/check/gsttestclock.h
@@ -45,8 +45,6 @@ typedef struct _GstTestClock GstTestClock;
typedef struct _GstTestClockClass GstTestClockClass;
typedef struct _GstTestClockPrivate GstTestClockPrivate;
-typedef struct _GstTestClockIDList GstTestClockIDList;
-
/**
* GstTestClock:
*
@@ -76,21 +74,6 @@ struct _GstTestClockClass
GstClockClass parent_class;
};
-/**
- * GstTestClockIDList:
- * @cur: A #GList with all pending #GstClockID
- * @length: A #guint with the length of the list
- *
- * A #GstTestClockIDList structure, which is returned when waiting for multiple IDs
- *
- * Since: 1.4
- */
- struct _GstTestClockIDList
-{
- GList * cur;
- guint length;
-};
-
GType gst_test_clock_get_type (void);
GstClock * gst_test_clock_new (void);
@@ -122,16 +105,14 @@ GstClockID gst_test_clock_process_next_clock_id (GstTestClock * test_clock);
GstClockTime gst_test_clock_get_next_entry_time (GstTestClock * test_clock);
-void gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
- guint count,
- GstTestClockIDList ** pending_list);
-
-guint gst_test_clock_process_id_list (GstTestClock * test_clock,
- GstTestClockIDList * pending_list);
+void gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
+ guint count,
+ GList ** pending_list);
-GstClockTime gst_test_clock_id_list_get_latest_time (GstTestClockIDList * list);
+guint gst_test_clock_process_id_list (GstTestClock * test_clock,
+ const GList * pending_list);
-void gst_test_clock_id_list_free (GstTestClockIDList * list);
+GstClockTime gst_test_clock_id_list_get_latest_time (const GList * pending_list);
G_END_DECLS