}
}
-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;
}
/**
* 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
*/
void
gst_test_clock_wait_for_multiple_pending_ids (GstTestClock * test_clock,
- guint count, GstTestClockIDList ** pending_list)
+ guint count, GList ** pending_list)
{
GstTestClockPrivate *priv;
/**
* 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.
*
*/
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);
/**
* 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)
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);
-}
typedef struct _GstTestClockClass GstTestClockClass;
typedef struct _GstTestClockPrivate GstTestClockPrivate;
-typedef struct _GstTestClockIDList GstTestClockIDList;
-
/**
* GstTestClock:
*
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);
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
gst_object_unref (clock);
}
+
GST_END_TEST;
GST_START_TEST (test_processing_multiple_ids)
SyncClockWaitContext context_b;
GThread *worker_thread_a;
GThread *worker_thread_b;
- GstTestClockIDList * pending_list;
+ GList *pending_list = NULL;
clock = gst_test_clock_new_with_start_time (GST_SECOND);
test_clock = GST_TEST_CLOCK (clock);
gst_test_clock_wait_for_multiple_pending_ids (test_clock, 2, &pending_list);
/* assert they are correct */
- assert_pending_id (pending_list->cur->data, clock_id_a, GST_CLOCK_ENTRY_SINGLE,
+ assert_pending_id (pending_list->data, clock_id_a, GST_CLOCK_ENTRY_SINGLE,
5 * GST_SECOND);
- assert_pending_id (pending_list->cur->next->data, clock_id_b, GST_CLOCK_ENTRY_SINGLE,
- 6 * GST_SECOND);
+ assert_pending_id (pending_list->next->data, clock_id_b,
+ GST_CLOCK_ENTRY_SINGLE, 6 * GST_SECOND);
/* verify we are waiting for 6 seconds as the latest time */
fail_unless_equals_int64 (6 * GST_SECOND,
/* process both ID's at the same time */
gst_test_clock_process_id_list (test_clock, pending_list);
- gst_test_clock_id_list_free (pending_list);
+ g_list_free_full (pending_list, (GDestroyNotify) gst_clock_id_unref);
g_thread_join (worker_thread_a);
g_thread_join (worker_thread_b);
gst_object_unref (clock);
}
+
GST_END_TEST;
GST_START_TEST (test_single_shot_async_past)