mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
tests: handle unscheduled entries correctly
Make the testclock return GST_CLOCK_UNSCHEDULED when an unscheduled entry is used for gst_clock_wait() or gst_clock_wait_async(). Fixes https://bugzilla.gnome.org/show_bug.cgi?id=708605
This commit is contained in:
parent
3e4b4eb59b
commit
cba26c9ed9
2 changed files with 29 additions and 0 deletions
|
@ -423,6 +423,9 @@ gst_test_clock_wait (GstClock * clock,
|
||||||
"requesting synchronous clock notification at %" GST_TIME_FORMAT,
|
"requesting synchronous clock notification at %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_CLOCK_ENTRY_TIME (entry)));
|
GST_TIME_ARGS (GST_CLOCK_ENTRY_TIME (entry)));
|
||||||
|
|
||||||
|
if (GST_CLOCK_ENTRY_STATUS (entry) == GST_CLOCK_UNSCHEDULED)
|
||||||
|
goto was_unscheduled;
|
||||||
|
|
||||||
if (gst_test_clock_lookup_entry_context (test_clock, entry) == NULL)
|
if (gst_test_clock_lookup_entry_context (test_clock, entry) == NULL)
|
||||||
gst_test_clock_add_entry (test_clock, entry, jitter);
|
gst_test_clock_add_entry (test_clock, entry, jitter);
|
||||||
|
|
||||||
|
@ -434,6 +437,15 @@ gst_test_clock_wait (GstClock * clock,
|
||||||
GST_OBJECT_UNLOCK (test_clock);
|
GST_OBJECT_UNLOCK (test_clock);
|
||||||
|
|
||||||
return GST_CLOCK_ENTRY_STATUS (entry);
|
return GST_CLOCK_ENTRY_STATUS (entry);
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
was_unscheduled:
|
||||||
|
{
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_TEST_CLOCK, test_clock,
|
||||||
|
"entry was unscheduled");
|
||||||
|
GST_OBJECT_UNLOCK (test_clock);
|
||||||
|
return GST_CLOCK_UNSCHEDULED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstClockReturn
|
static GstClockReturn
|
||||||
|
@ -443,6 +455,9 @@ gst_test_clock_wait_async (GstClock * clock, GstClockEntry * entry)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (test_clock);
|
GST_OBJECT_LOCK (test_clock);
|
||||||
|
|
||||||
|
if (GST_CLOCK_ENTRY_STATUS (entry) == GST_CLOCK_UNSCHEDULED)
|
||||||
|
goto was_unscheduled;
|
||||||
|
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_TEST_CLOCK, test_clock,
|
GST_CAT_DEBUG_OBJECT (GST_CAT_TEST_CLOCK, test_clock,
|
||||||
"requesting asynchronous clock notification at %" GST_TIME_FORMAT,
|
"requesting asynchronous clock notification at %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_CLOCK_ENTRY_TIME (entry)));
|
GST_TIME_ARGS (GST_CLOCK_ENTRY_TIME (entry)));
|
||||||
|
@ -452,6 +467,15 @@ gst_test_clock_wait_async (GstClock * clock, GstClockEntry * entry)
|
||||||
GST_OBJECT_UNLOCK (test_clock);
|
GST_OBJECT_UNLOCK (test_clock);
|
||||||
|
|
||||||
return GST_CLOCK_OK;
|
return GST_CLOCK_OK;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
was_unscheduled:
|
||||||
|
{
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_TEST_CLOCK, test_clock,
|
||||||
|
"entry was unscheduled");
|
||||||
|
GST_OBJECT_UNLOCK (test_clock);
|
||||||
|
return GST_CLOCK_UNSCHEDULED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -513,12 +513,17 @@ GST_START_TEST (test_single_shot_sync_unschedule)
|
||||||
GstTestClock *test_clock;
|
GstTestClock *test_clock;
|
||||||
GstClockID clock_id;
|
GstClockID clock_id;
|
||||||
GtuClockWaitContext *wait_ctx;
|
GtuClockWaitContext *wait_ctx;
|
||||||
|
gboolean wait_complete = FALSE;
|
||||||
|
|
||||||
clock = gst_test_clock_new_with_start_time (GST_SECOND);
|
clock = gst_test_clock_new_with_start_time (GST_SECOND);
|
||||||
test_clock = GST_TEST_CLOCK (clock);
|
test_clock = GST_TEST_CLOCK (clock);
|
||||||
|
|
||||||
clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
|
clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
|
||||||
gst_clock_id_unschedule (clock_id);
|
gst_clock_id_unschedule (clock_id);
|
||||||
|
/* any wait should timeout immediately */
|
||||||
|
g_assert (gst_clock_id_wait_async (clock_id, test_async_wait_cb,
|
||||||
|
&wait_complete, NULL) == GST_CLOCK_UNSCHEDULED);
|
||||||
|
g_assert (gst_clock_id_wait (clock_id, NULL) == GST_CLOCK_UNSCHEDULED);
|
||||||
gst_clock_id_unref (clock_id);
|
gst_clock_id_unref (clock_id);
|
||||||
|
|
||||||
clock_id = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
|
clock_id = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
|
||||||
|
|
Loading…
Reference in a new issue