From 6d0be743516377a17d148a5f35e33c0f0f3b4fda Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 12 Oct 2005 12:18:48 +0000 Subject: [PATCH] Use GstClockTime in _get_state() instead of GTimeVal. Original commit message from CVS: * check/gst/gstbin.c: (GST_START_TEST): * check/gst/gstelement.c: (GST_START_TEST): * check/gst/gstevent.c: (GST_START_TEST), (test_event): * check/gst/gstghostpad.c: (GST_START_TEST): * check/gst/gstpipeline.c: (GST_START_TEST): * check/pipelines/simple_launch_lines.c: (run_pipeline): * check/states/sinks.c: (GST_START_TEST): * gst/elements/gsttypefindelement.c: (stop_typefinding): * gst/gstbin.c: (gst_bin_provide_clock_func), (gst_bin_add_func), (gst_bin_remove_func), (gst_bin_get_state_func), (gst_bin_recalc_state), (gst_bin_change_state_func), (bin_bus_handler): * gst/gstelement.c: (gst_element_get_state_func), (gst_element_get_state), (gst_element_abort_state), (gst_element_commit_state), (gst_element_set_state), (gst_element_change_state), (gst_element_change_state_func): * gst/gstelement.h: * gst/gstpipeline.c: (gst_pipeline_class_init), (do_pipeline_seek), (gst_pipeline_provide_clock_func): * gst/gstutils.c: (gst_element_link_pads_filtered): * tools/gst-launch.c: (main): * tools/gst-typefind.c: (main): Use GstClockTime in _get_state() instead of GTimeVal. Remove old code in gstutils.c --- ChangeLog | 27 ++++ check/gst/gstbin.c | 20 ++- check/gst/gstelement.c | 4 +- check/gst/gstevent.c | 9 +- check/gst/gstghostpad.c | 4 +- check/gst/gstpipeline.c | 22 +-- check/pipelines/simple_launch_lines.c | 2 +- check/states/sinks.c | 35 ++--- gst/elements/gsttypefindelement.c | 3 +- gst/gstbin.c | 8 +- gst/gstelement.c | 14 +- gst/gstelement.h | 4 +- gst/gstpipeline.c | 4 +- gst/gstutils.c | 152 +------------------- plugins/elements/gsttypefindelement.c | 3 +- tests/check/generic/sinks.c | 35 ++--- tests/check/gst/gstbin.c | 20 ++- tests/check/gst/gstelement.c | 4 +- tests/check/gst/gstevent.c | 9 +- tests/check/gst/gstghostpad.c | 4 +- tests/check/gst/gstpipeline.c | 22 +-- tests/check/pipelines/simple-launch-lines.c | 2 +- tools/gst-launch.c | 8 +- tools/gst-typefind.c | 6 +- 24 files changed, 153 insertions(+), 268 deletions(-) diff --git a/ChangeLog b/ChangeLog index 687fdfa888..a0c3e4c4a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2005-10-12 Wim Taymans + + * check/gst/gstbin.c: (GST_START_TEST): + * check/gst/gstelement.c: (GST_START_TEST): + * check/gst/gstevent.c: (GST_START_TEST), (test_event): + * check/gst/gstghostpad.c: (GST_START_TEST): + * check/gst/gstpipeline.c: (GST_START_TEST): + * check/pipelines/simple_launch_lines.c: (run_pipeline): + * check/states/sinks.c: (GST_START_TEST): + * gst/elements/gsttypefindelement.c: (stop_typefinding): + * gst/gstbin.c: (gst_bin_provide_clock_func), (gst_bin_add_func), + (gst_bin_remove_func), (gst_bin_get_state_func), + (gst_bin_recalc_state), (gst_bin_change_state_func), + (bin_bus_handler): + * gst/gstelement.c: (gst_element_get_state_func), + (gst_element_get_state), (gst_element_abort_state), + (gst_element_commit_state), (gst_element_set_state), + (gst_element_change_state), (gst_element_change_state_func): + * gst/gstelement.h: + * gst/gstpipeline.c: (gst_pipeline_class_init), (do_pipeline_seek), + (gst_pipeline_provide_clock_func): + * gst/gstutils.c: (gst_element_link_pads_filtered): + * tools/gst-launch.c: (main): + * tools/gst-typefind.c: (main): + Use GstClockTime in _get_state() instead of GTimeVal. + Remove old code in gstutils.c + 2005-10-12 Andy Wingo * gst/gstpad.c (gst_pad_pause_task): Actually return FALSE if diff --git a/check/gst/gstbin.c b/check/gst/gstbin.c index e84608e47f..84da78daf5 100644 --- a/check/gst/gstbin.c +++ b/check/gst/gstbin.c @@ -264,7 +264,8 @@ GST_START_TEST (test_message_state_changed_children) ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); fail_unless (ret == GST_STATE_CHANGE_ASYNC); ret = - gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, + GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); fail_unless (current == GST_STATE_PAUSED); fail_unless (pending == GST_STATE_VOID_PENDING); @@ -289,7 +290,8 @@ GST_START_TEST (test_message_state_changed_children) ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); ret = - gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, + GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); fail_unless (current == GST_STATE_PLAYING); fail_unless (pending == GST_STATE_VOID_PENDING); @@ -367,7 +369,9 @@ GST_START_TEST (test_watch_for_state_change) /* change state, spawning two times three messages */ ret = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); fail_unless (ret == GST_STATE_CHANGE_ASYNC); - ret = gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, NULL); + ret = + gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, + GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); pop_messages (bus, 6); @@ -382,7 +386,7 @@ GST_START_TEST (test_watch_for_state_change) /* this one might return either SUCCESS or ASYNC, likely SUCCESS */ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, GST_CLOCK_TIME_NONE); pop_messages (bus, 3); @@ -502,7 +506,8 @@ GST_START_TEST (test_children_state_change_order_flagged_sink) ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_if (ret != GST_STATE_CHANGE_ASYNC, "State change to PLAYING did not return ASYNC"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed"); fail_if (current != GST_STATE_PLAYING, "State change to PLAYING failed"); fail_if (pending != GST_STATE_VOID_PENDING, "State change to PLAYING failed"); @@ -543,7 +548,7 @@ GST_START_TEST (test_children_state_change_order_flagged_sink) /* don't set to NULL that will set the bus flushing and kill our messages */ ret = gst_element_set_state (pipeline, GST_STATE_READY); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed"); - ret = gst_element_get_state (pipeline, NULL, NULL, NULL); + ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed"); /* TODO: do we need to check downwards state change order as well? */ @@ -602,7 +607,8 @@ GST_START_TEST (test_children_state_change_order_semi_sink) ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_if (ret != GST_STATE_CHANGE_ASYNC, "State change to PLAYING not ASYNC"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed"); fail_if (current != GST_STATE_PLAYING, "State change to PLAYING failed"); fail_if (pending != GST_STATE_VOID_PENDING, "State change to PLAYING failed"); diff --git a/check/gst/gstelement.c b/check/gst/gstelement.c index 44fbc7d50b..8d00af9b9f 100644 --- a/check/gst/gstelement.c +++ b/check/gst/gstelement.c @@ -109,7 +109,7 @@ GST_START_TEST (test_link) gst_element_set_state (src, GST_STATE_PAUSED); /* wait for preroll */ - gst_element_get_state (sink, NULL, NULL, NULL); + gst_element_get_state (sink, NULL, NULL, GST_CLOCK_TIME_NONE); /* play some more */ gst_element_set_state (sink, GST_STATE_PLAYING); @@ -122,7 +122,7 @@ GST_START_TEST (test_link) gst_element_set_state (src, GST_STATE_PAUSED); /* wait for preroll */ - gst_element_get_state (sink, NULL, NULL, NULL); + gst_element_get_state (sink, NULL, NULL, GST_CLOCK_TIME_NONE); gst_element_set_state (sink, GST_STATE_NULL); gst_element_set_state (src, GST_STATE_NULL); diff --git a/check/gst/gstevent.c b/check/gst/gstevent.c index 5960630e23..17e6afdf75 100644 --- a/check/gst/gstevent.c +++ b/check/gst/gstevent.c @@ -245,7 +245,8 @@ static void test_event got_event_before_q = got_event_after_q = NULL; gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, + GST_CLOCK_TIME_NONE); event = gst_event_new_custom (type, gst_structure_empty_new ("application/x-custom")); @@ -275,7 +276,8 @@ static void test_event } gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); - gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, + GST_CLOCK_TIME_NONE); if (got_event_before_q) gst_event_unref (got_event_before_q); @@ -372,7 +374,8 @@ GST_START_TEST (send_custom_events) G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time)); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, + GST_CLOCK_TIME_NONE); gst_object_unref (pipeline); } diff --git a/check/gst/gstghostpad.c b/check/gst/gstghostpad.c index aa4288d19c..a5fd4fe299 100644 --- a/check/gst/gstghostpad.c +++ b/check/gst/gstghostpad.c @@ -248,11 +248,11 @@ GST_START_TEST (test_ghost_pads) assert_gstrefcount (isrc, 3); /* parent and gsrc */ ret = gst_element_set_state (b1, GST_STATE_PLAYING); - ret = gst_element_get_state (b1, NULL, NULL, NULL); + ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); ret = gst_element_set_state (b1, GST_STATE_NULL); - ret = gst_element_get_state (b1, NULL, NULL, NULL); + ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); gst_object_unref (b1); diff --git a/check/gst/gstpipeline.c b/check/gst/gstpipeline.c index 127a940ca8..514d125d05 100644 --- a/check/gst/gstpipeline.c +++ b/check/gst/gstpipeline.c @@ -167,6 +167,7 @@ GST_START_TEST (test_bus) GstBus *bus; guint id; GstState current; + GstStateChangeReturn ret; pipeline = gst_pipeline_new (NULL); fail_unless (pipeline != NULL, "Could not create pipeline"); @@ -188,7 +189,9 @@ GST_START_TEST (test_bus) ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after add_watch", 1); ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3); - gst_element_set_state (pipeline, GST_STATE_PLAYING); + ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); + fail_unless (ret == GST_STATE_CHANGE_ASYNC); + loop = g_main_loop_new (NULL, FALSE); GST_DEBUG ("going into main loop"); g_main_loop_run (loop); @@ -202,23 +205,22 @@ GST_START_TEST (test_bus) /* cleanup */ GST_DEBUG ("cleanup"); - gst_element_set_state (pipeline, GST_STATE_NULL); - fail_unless (gst_element_get_state (pipeline, ¤t, NULL, NULL) == - GST_STATE_CHANGE_SUCCESS); + ret = gst_element_set_state (pipeline, GST_STATE_NULL); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); + ret = gst_element_get_state (pipeline, ¤t, NULL, GST_CLOCK_TIME_NONE); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); fail_unless (current == GST_STATE_NULL, "state is not NULL but %d", current); - /* FIXME: need to figure out an extra refcount, checks disabled */ -// ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1); -// ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3); + ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1); + ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3); fail_unless (g_source_remove (id)); -// ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2); + ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2); GST_DEBUG ("unreffing pipeline"); gst_object_unref (pipeline); - -// ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1); + ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1); gst_object_unref (bus); } diff --git a/check/pipelines/simple_launch_lines.c b/check/pipelines/simple_launch_lines.c index 66ae5f344d..7f8d8aaa57 100644 --- a/check/pipelines/simple_launch_lines.c +++ b/check/pipelines/simple_launch_lines.c @@ -55,7 +55,7 @@ run_pipeline (GstElement * pipeline, gchar * descr, g_assert (bus); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - ret = gst_element_get_state (pipeline, NULL, NULL, NULL); + ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); if (ret != GST_STATE_CHANGE_SUCCESS) { g_critical ("Couldn't set pipeline to PLAYING"); diff --git a/check/states/sinks.c b/check/states/sinks.c index 1add001a1b..7c97353ee2 100644 --- a/check/states/sinks.c +++ b/check/states/sinks.c @@ -28,7 +28,6 @@ GST_START_TEST (test_sink) GstElement *sink; GstStateChangeReturn ret; GstState current, pending; - GTimeVal tv; sink = gst_element_factory_make ("fakesink", "sink"); @@ -38,9 +37,7 @@ GST_START_TEST (test_sink) ret = gst_element_set_state (sink, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change"); - GST_TIME_TO_TIMEVAL ((GstClockTime) 0, tv); - - ret = gst_element_get_state (sink, ¤t, &pending, &tv); + ret = gst_element_get_state (sink, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async"); fail_unless (current == GST_STATE_READY, "bad current state"); fail_unless (pending == GST_STATE_PLAYING, "bad pending state"); @@ -65,16 +62,13 @@ GST_START_TEST (test_sink_completion) GstElement *sink, *src; GstStateChangeReturn ret; GstState current, pending; - GTimeVal tv; sink = gst_element_factory_make ("fakesink", "sink"); ret = gst_element_set_state (sink, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); - GST_TIME_TO_TIMEVAL ((GstClockTime) 0, tv); - - ret = gst_element_get_state (sink, ¤t, &pending, &tv); + ret = gst_element_get_state (sink, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async"); fail_unless (current == GST_STATE_READY, "bad current state"); fail_unless (pending == GST_STATE_PLAYING, "bad pending state"); @@ -86,7 +80,7 @@ GST_START_TEST (test_sink_completion) fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); /* now wait for final state */ - ret = gst_element_get_state (sink, ¤t, &pending, NULL); + ret = gst_element_get_state (sink, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to change state"); fail_unless (current == GST_STATE_PLAYING, "bad current state"); fail_unless (pending == GST_STATE_VOID_PENDING, "bad pending state"); @@ -126,13 +120,14 @@ GST_START_TEST (test_src_sink) ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); - ret = gst_element_get_state (pipeline, NULL, NULL, NULL); + ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); fail_unless (current == GST_STATE_PLAYING, "not playing"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); @@ -153,7 +148,6 @@ GST_START_TEST (test_livesrc_remove) GstStateChangeReturn ret; GstState current, pending; GstPad *srcpad, *sinkpad; - GTimeVal tv; pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); @@ -173,15 +167,14 @@ GST_START_TEST (test_livesrc_remove) fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "no no_preroll state return"); - ret = gst_element_get_state (src, ¤t, &pending, NULL); + ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); gst_bin_remove (GST_BIN (pipeline), src); - GST_TIME_TO_TIMEVAL (0, tv); - ret = gst_element_get_state (pipeline, ¤t, &pending, &tv); + ret = gst_element_get_state (pipeline, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_PAUSED, "not paused"); @@ -196,7 +189,6 @@ GST_START_TEST (test_livesrc_sink) GstStateChangeReturn ret; GstState current, pending; GstPad *srcpad, *sinkpad; - GTimeVal tv; pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); @@ -216,26 +208,27 @@ GST_START_TEST (test_livesrc_sink) fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "no no_preroll state return"); - ret = gst_element_get_state (src, ¤t, &pending, NULL); + ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); /* don't block here */ - GST_TIME_TO_TIMEVAL (0, tv); - ret = gst_element_get_state (sink, ¤t, &pending, &tv); + ret = gst_element_get_state (sink, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); fail_unless (current == GST_STATE_READY, "not ready"); fail_unless (pending == GST_STATE_PAUSED, "not paused"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); fail_unless (current == GST_STATE_PLAYING, "not playing"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); diff --git a/gst/elements/gsttypefindelement.c b/gst/elements/gsttypefindelement.c index a6e24a6e4d..b0affd51c7 100644 --- a/gst/elements/gsttypefindelement.c +++ b/gst/elements/gsttypefindelement.c @@ -410,7 +410,8 @@ stop_typefinding (GstTypeFindElement * typefind) GstState state; gboolean push_cached_buffers; - gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, NULL); + gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, + GST_CLOCK_TIME_NONE); push_cached_buffers = (state >= GST_STATE_PAUSED); diff --git a/gst/gstbin.c b/gst/gstbin.c index 0366713365..5739c45f93 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -84,7 +84,7 @@ static void gst_bin_recalc_state (GstBin * bin, gboolean force); static GstStateChangeReturn gst_bin_change_state_func (GstElement * element, GstStateChange transition); static GstStateChangeReturn gst_bin_get_state_func (GstElement * element, - GstState * state, GstState * pending, GTimeVal * timeout); + GstState * state, GstState * pending, GstClockTime timeout); static gboolean gst_bin_add_func (GstBin * bin, GstElement * element); static gboolean gst_bin_remove_func (GstBin * bin, GstElement * element); @@ -908,7 +908,7 @@ gst_bin_iterate_sinks (GstBin * bin) */ static GstStateChangeReturn gst_bin_get_state_func (GstElement * element, GstState * state, - GstState * pending, GTimeVal * timeout) + GstState * pending, GstClockTime timeout) { GstBin *bin = GST_BIN (element); @@ -928,7 +928,6 @@ gst_bin_recalc_state (GstBin * bin, gboolean force) guint32 children_cookie; gboolean have_no_preroll; gboolean have_async; - GTimeVal tv; ret = GST_STATE_CHANGE_SUCCESS; @@ -962,7 +961,6 @@ restart: /* scan all element states with a zero timeout so we don't block on * anything */ - GST_TIME_TO_TIMEVAL (0, tv); children = bin->children; children_cookie = bin->children_cookie; while (children) { @@ -973,7 +971,7 @@ restart: * release the lock anyway since we can. */ GST_UNLOCK (bin); - ret = gst_element_get_state (child, NULL, NULL, &tv); + ret = gst_element_get_state (child, NULL, NULL, 0); gst_object_unref (child); diff --git a/gst/gstelement.c b/gst/gstelement.c index 69625139a0..e8bec97d27 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -120,7 +120,7 @@ static GstStateChangeReturn gst_element_change_state_func (GstElement * element, static GstStateChangeReturn gst_element_change_state_func (GstElement * element, GstStateChange transition); static GstStateChangeReturn gst_element_get_state_func (GstElement * element, - GstState * state, GstState * pending, GTimeVal * timeout); + GstState * state, GstState * pending, GstClockTime timeout); static void gst_element_set_bus_func (GstElement * element, GstBus * bus); #ifndef GST_DISABLE_LOADSAVE @@ -1604,7 +1604,7 @@ failed: /* MT safe */ static GstStateChangeReturn gst_element_get_state_func (GstElement * element, - GstState * state, GstState * pending, GTimeVal * timeout) + GstState * state, GstState * pending, GstClockTime timeout) { GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE; GstState old_pending; @@ -1630,8 +1630,8 @@ gst_element_get_state_func (GstElement * element, if (old_pending != GST_STATE_VOID_PENDING) { GTimeVal *timeval, abstimeout; - if (timeout) { - glong add = timeout->tv_sec * G_USEC_PER_SEC + timeout->tv_usec; + if (timeout != GST_CLOCK_TIME_NONE) { + glong add = timeout / 1000; if (add == 0) goto done; @@ -1688,8 +1688,8 @@ done: * @state: a pointer to #GstState to hold the state. Can be NULL. * @pending: a pointer to #GstState to hold the pending state. * Can be NULL. - * @timeout: a #GTimeVal to specify the timeout for an async - * state change or NULL for infinite timeout. + * @timeout: a #GstClockTime to specify the timeout for an async + * state change or GST_CLOCK_TIME_NONE for infinite timeout. * * Gets the state of the element. * @@ -1712,7 +1712,7 @@ done: */ GstStateChangeReturn gst_element_get_state (GstElement * element, - GstState * state, GstState * pending, GTimeVal * timeout) + GstState * state, GstState * pending, GstClockTime timeout) { GstElementClass *oclass; GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE; diff --git a/gst/gstelement.h b/gst/gstelement.h index 4e6f470717..c48b06c58d 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -355,7 +355,7 @@ struct _GstElementClass /* state changes */ GstStateChangeReturn (*get_state) (GstElement * element, GstState * state, - GstState * pending, GTimeVal * timeout); + GstState * pending, GstClockTime timeout); GstStateChangeReturn (*change_state) (GstElement *element, GstStateChange transition); /* bus */ @@ -485,7 +485,7 @@ gboolean gst_element_sync_state_with_parent (GstElement *element); GstStateChangeReturn gst_element_get_state (GstElement * element, GstState * state, GstState * pending, - GTimeVal * timeout); + GstClockTime timeout); GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state); void gst_element_abort_state (GstElement * element); diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index a00193159e..07790af1ef 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -226,12 +226,10 @@ do_pipeline_seek (GstElement * element, GstEvent * event) if (flush) { GstState state; - GTimeVal timeout; - GST_TIME_TO_TIMEVAL (0, timeout); /* need to call _get_state() since a bin state is only updated * with this call. */ - gst_element_get_state (element, &state, NULL, &timeout); + gst_element_get_state (element, &state, NULL, 0); was_playing = state == GST_STATE_PLAYING; if (was_playing) { diff --git a/gst/gstutils.c b/gst/gstutils.c index 7c4fa172b3..c729c838db 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -1337,7 +1337,6 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname, GstElement *capsfilter; GstObject *parent; GstState state, pending; - GTimeVal tv; capsfilter = gst_element_factory_make ("capsfilter", NULL); if (!capsfilter) { @@ -1348,8 +1347,7 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname, parent = gst_object_get_parent (GST_OBJECT (src)); g_return_val_if_fail (GST_IS_BIN (parent), FALSE); - GST_TIME_TO_TIMEVAL (0, tv); - gst_element_get_state (GST_ELEMENT_CAST (parent), &state, &pending, &tv); + gst_element_get_state (GST_ELEMENT_CAST (parent), &state, &pending, 0); if (!gst_bin_add (GST_BIN (parent), capsfilter)) { GST_ERROR ("Could not add capsfilter"); @@ -1920,154 +1918,6 @@ gst_bin_remove_many (GstBin * bin, GstElement * element_1, ...) va_end (args); } -static void -get_state_func (GstElement * element, gpointer unused) -{ - GstStateChangeReturn ret = GST_STATE_CHANGE_ASYNC; - - GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "new thread waiting on state change"); - - /* wait indefinitely */ - while (ret == GST_STATE_CHANGE_ASYNC) - ret = gst_element_get_state (element, NULL, NULL, NULL); - - GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "thread done waiting on state change"); - - gst_object_unref (element); -} - -/** - * gst_bin_watch_for_state_change: - * @bin: the bin to watch for state changes - * - * Spawns a thread calling gst_element_get_state on @bin with infinite timeout. - * - * In practice this is done because if a bin returns %GST_STATE_CHANGE_ASYNC - * from a state change, it will not commit its state until someone calls - * gst_element_get_state() on it. Thus having another thread checking the bin's - * state will ensure that a state-changed message gets posted on the bus - * eventually. - * - * This function is admittedly a bit of a hack. Bins should always post - * messages. However this behavior was broken out into this function to avoid - * spawning threads when scrubbing, when the bin's state is changing quickly and - * asynchronously. - */ -void -gst_bin_watch_for_state_change (GstBin * bin) -{ - static GThreadPool *pool = NULL; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - - g_static_mutex_lock (&mutex); - if (pool == NULL) - pool = g_thread_pool_new ((GFunc) get_state_func, NULL, -1, FALSE, NULL); - g_static_mutex_unlock (&mutex); - - g_thread_pool_push (pool, gst_object_ref (bin), NULL); -} - -struct _GstAsyncThreadData -{ - GstElement *element; - GstState state; -}; - -static void -set_state_async_thread_func (struct _GstAsyncThreadData *data, gpointer unused) -{ - GstState current, pending; - GstStateChangeReturn ret = GST_STATE_CHANGE_ASYNC; - - GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element, - "new thread ensuring state change to %s", - gst_element_state_get_name (data->state)); - - while (TRUE) { - /* wait indefinitely */ - ret = gst_element_get_state (data->element, ¤t, &pending, NULL); - GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element, - "get_state returned %d, current %s, pending %s", ret, - gst_element_state_get_name (current), - gst_element_state_get_name (pending)); - - /* can only be SUCCESS or FAILURE */ - if (ret == GST_STATE_CHANGE_FAILURE) { - /* we can only break, hopefully an error message was posted as well */ - GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element, - "FAILURE during state change"); - break; - } else if (ret == GST_STATE_CHANGE_SUCCESS) { - if (current == data->state) { - GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element, - "successfully reached final state"); - break; - } - GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element, - "setting target state %s again", - gst_element_state_get_name (data->state)); - gst_element_set_state (data->element, data->state); - } else { - g_assert_not_reached (); - } - } - - GST_CAT_INFO_OBJECT (GST_CAT_STATES, data->element, - "thread done waiting on state change"); - - gst_object_unref (data->element); - g_free (data); -} - -/** - * gst_element_set_state_async: - * @element: a #GstElement to change state of - * @state: the element's new #GstState - * - * Sets the state of the element. This function will try to set the - * requested state by going through all the intermediary states and calling - * the class's state change function for each. If the state change returns - * #GST_STATE_CHANGE_ASYNC at any time, a thread will be started to - * monitor the state change and make sure the element is brought to the - * requested state. - * - * Returns: Result of the state change using #GstStateChangeReturn. - * - * MT safe. - */ -GstStateChangeReturn -gst_element_set_state_async (GstElement * element, GstState state) -{ - GstStateChangeReturn ret; - struct _GstAsyncThreadData *data; - - ret = gst_element_set_state (element, state); - if (ret == GST_STATE_CHANGE_ASYNC) { - static GThreadPool *pool = NULL; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - - GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "starting new thread to ensure state change to %s", - gst_element_state_get_name (state)); - g_static_mutex_lock (&mutex); - if (pool == NULL) - pool = g_thread_pool_new ((GFunc) set_state_async_thread_func, - NULL, -1, FALSE, NULL); - g_static_mutex_unlock (&mutex); - - data = g_new0 (struct _GstAsyncThreadData, 1); - - gst_object_ref (element); - data->element = element; - data->state = state; - g_thread_pool_push (pool, data, NULL); - } - - return ret; -} - static void gst_element_populate_std_props (GObjectClass * klass, const gchar * prop_name, guint arg_id, GParamFlags flags) diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index a6e24a6e4d..b0affd51c7 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -410,7 +410,8 @@ stop_typefinding (GstTypeFindElement * typefind) GstState state; gboolean push_cached_buffers; - gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, NULL); + gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, + GST_CLOCK_TIME_NONE); push_cached_buffers = (state >= GST_STATE_PAUSED); diff --git a/tests/check/generic/sinks.c b/tests/check/generic/sinks.c index 1add001a1b..7c97353ee2 100644 --- a/tests/check/generic/sinks.c +++ b/tests/check/generic/sinks.c @@ -28,7 +28,6 @@ GST_START_TEST (test_sink) GstElement *sink; GstStateChangeReturn ret; GstState current, pending; - GTimeVal tv; sink = gst_element_factory_make ("fakesink", "sink"); @@ -38,9 +37,7 @@ GST_START_TEST (test_sink) ret = gst_element_set_state (sink, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change"); - GST_TIME_TO_TIMEVAL ((GstClockTime) 0, tv); - - ret = gst_element_get_state (sink, ¤t, &pending, &tv); + ret = gst_element_get_state (sink, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async"); fail_unless (current == GST_STATE_READY, "bad current state"); fail_unless (pending == GST_STATE_PLAYING, "bad pending state"); @@ -65,16 +62,13 @@ GST_START_TEST (test_sink_completion) GstElement *sink, *src; GstStateChangeReturn ret; GstState current, pending; - GTimeVal tv; sink = gst_element_factory_make ("fakesink", "sink"); ret = gst_element_set_state (sink, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); - GST_TIME_TO_TIMEVAL ((GstClockTime) 0, tv); - - ret = gst_element_get_state (sink, ¤t, &pending, &tv); + ret = gst_element_get_state (sink, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async"); fail_unless (current == GST_STATE_READY, "bad current state"); fail_unless (pending == GST_STATE_PLAYING, "bad pending state"); @@ -86,7 +80,7 @@ GST_START_TEST (test_sink_completion) fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); /* now wait for final state */ - ret = gst_element_get_state (sink, ¤t, &pending, NULL); + ret = gst_element_get_state (sink, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to change state"); fail_unless (current == GST_STATE_PLAYING, "bad current state"); fail_unless (pending == GST_STATE_VOID_PENDING, "bad pending state"); @@ -126,13 +120,14 @@ GST_START_TEST (test_src_sink) ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return"); - ret = gst_element_get_state (pipeline, NULL, NULL, NULL); + ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return"); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); fail_unless (current == GST_STATE_PLAYING, "not playing"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); @@ -153,7 +148,6 @@ GST_START_TEST (test_livesrc_remove) GstStateChangeReturn ret; GstState current, pending; GstPad *srcpad, *sinkpad; - GTimeVal tv; pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); @@ -173,15 +167,14 @@ GST_START_TEST (test_livesrc_remove) fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "no no_preroll state return"); - ret = gst_element_get_state (src, ¤t, &pending, NULL); + ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); gst_bin_remove (GST_BIN (pipeline), src); - GST_TIME_TO_TIMEVAL (0, tv); - ret = gst_element_get_state (pipeline, ¤t, &pending, &tv); + ret = gst_element_get_state (pipeline, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_PAUSED, "not paused"); @@ -196,7 +189,6 @@ GST_START_TEST (test_livesrc_sink) GstStateChangeReturn ret; GstState current, pending; GstPad *srcpad, *sinkpad; - GTimeVal tv; pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); @@ -216,26 +208,27 @@ GST_START_TEST (test_livesrc_sink) fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "no no_preroll state return"); - ret = gst_element_get_state (src, ¤t, &pending, NULL); + ret = gst_element_get_state (src, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); /* don't block here */ - GST_TIME_TO_TIMEVAL (0, tv); - ret = gst_element_get_state (sink, ¤t, &pending, &tv); + ret = gst_element_get_state (sink, ¤t, &pending, 0); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); fail_unless (current == GST_STATE_READY, "not ready"); fail_unless (pending == GST_STATE_PAUSED, "not paused"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused"); fail_unless (current == GST_STATE_PAUSED, "not paused"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); fail_unless (current == GST_STATE_PLAYING, "not playing"); fail_unless (pending == GST_STATE_VOID_PENDING, "not playing"); diff --git a/tests/check/gst/gstbin.c b/tests/check/gst/gstbin.c index e84608e47f..84da78daf5 100644 --- a/tests/check/gst/gstbin.c +++ b/tests/check/gst/gstbin.c @@ -264,7 +264,8 @@ GST_START_TEST (test_message_state_changed_children) ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); fail_unless (ret == GST_STATE_CHANGE_ASYNC); ret = - gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, + GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); fail_unless (current == GST_STATE_PAUSED); fail_unless (pending == GST_STATE_VOID_PENDING); @@ -289,7 +290,8 @@ GST_START_TEST (test_message_state_changed_children) ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); ret = - gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), ¤t, &pending, + GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); fail_unless (current == GST_STATE_PLAYING); fail_unless (pending == GST_STATE_VOID_PENDING); @@ -367,7 +369,9 @@ GST_START_TEST (test_watch_for_state_change) /* change state, spawning two times three messages */ ret = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); fail_unless (ret == GST_STATE_CHANGE_ASYNC); - ret = gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, NULL); + ret = + gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, + GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); pop_messages (bus, 6); @@ -382,7 +386,7 @@ GST_START_TEST (test_watch_for_state_change) /* this one might return either SUCCESS or ASYNC, likely SUCCESS */ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, GST_CLOCK_TIME_NONE); pop_messages (bus, 3); @@ -502,7 +506,8 @@ GST_START_TEST (test_children_state_change_order_flagged_sink) ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_if (ret != GST_STATE_CHANGE_ASYNC, "State change to PLAYING did not return ASYNC"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed"); fail_if (current != GST_STATE_PLAYING, "State change to PLAYING failed"); fail_if (pending != GST_STATE_VOID_PENDING, "State change to PLAYING failed"); @@ -543,7 +548,7 @@ GST_START_TEST (test_children_state_change_order_flagged_sink) /* don't set to NULL that will set the bus flushing and kill our messages */ ret = gst_element_set_state (pipeline, GST_STATE_READY); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed"); - ret = gst_element_get_state (pipeline, NULL, NULL, NULL); + ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed"); /* TODO: do we need to check downwards state change order as well? */ @@ -602,7 +607,8 @@ GST_START_TEST (test_children_state_change_order_semi_sink) ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); fail_if (ret != GST_STATE_CHANGE_ASYNC, "State change to PLAYING not ASYNC"); - ret = gst_element_get_state (pipeline, ¤t, &pending, NULL); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed"); fail_if (current != GST_STATE_PLAYING, "State change to PLAYING failed"); fail_if (pending != GST_STATE_VOID_PENDING, "State change to PLAYING failed"); diff --git a/tests/check/gst/gstelement.c b/tests/check/gst/gstelement.c index 44fbc7d50b..8d00af9b9f 100644 --- a/tests/check/gst/gstelement.c +++ b/tests/check/gst/gstelement.c @@ -109,7 +109,7 @@ GST_START_TEST (test_link) gst_element_set_state (src, GST_STATE_PAUSED); /* wait for preroll */ - gst_element_get_state (sink, NULL, NULL, NULL); + gst_element_get_state (sink, NULL, NULL, GST_CLOCK_TIME_NONE); /* play some more */ gst_element_set_state (sink, GST_STATE_PLAYING); @@ -122,7 +122,7 @@ GST_START_TEST (test_link) gst_element_set_state (src, GST_STATE_PAUSED); /* wait for preroll */ - gst_element_get_state (sink, NULL, NULL, NULL); + gst_element_get_state (sink, NULL, NULL, GST_CLOCK_TIME_NONE); gst_element_set_state (sink, GST_STATE_NULL); gst_element_set_state (src, GST_STATE_NULL); diff --git a/tests/check/gst/gstevent.c b/tests/check/gst/gstevent.c index 5960630e23..17e6afdf75 100644 --- a/tests/check/gst/gstevent.c +++ b/tests/check/gst/gstevent.c @@ -245,7 +245,8 @@ static void test_event got_event_before_q = got_event_after_q = NULL; gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, + GST_CLOCK_TIME_NONE); event = gst_event_new_custom (type, gst_structure_empty_new ("application/x-custom")); @@ -275,7 +276,8 @@ static void test_event } gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); - gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, + GST_CLOCK_TIME_NONE); if (got_event_before_q) gst_event_unref (got_event_before_q); @@ -372,7 +374,8 @@ GST_START_TEST (send_custom_events) G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time)); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, NULL); + gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, + GST_CLOCK_TIME_NONE); gst_object_unref (pipeline); } diff --git a/tests/check/gst/gstghostpad.c b/tests/check/gst/gstghostpad.c index aa4288d19c..a5fd4fe299 100644 --- a/tests/check/gst/gstghostpad.c +++ b/tests/check/gst/gstghostpad.c @@ -248,11 +248,11 @@ GST_START_TEST (test_ghost_pads) assert_gstrefcount (isrc, 3); /* parent and gsrc */ ret = gst_element_set_state (b1, GST_STATE_PLAYING); - ret = gst_element_get_state (b1, NULL, NULL, NULL); + ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); ret = gst_element_set_state (b1, GST_STATE_NULL); - ret = gst_element_get_state (b1, NULL, NULL, NULL); + ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE); fail_unless (ret == GST_STATE_CHANGE_SUCCESS); gst_object_unref (b1); diff --git a/tests/check/gst/gstpipeline.c b/tests/check/gst/gstpipeline.c index 127a940ca8..514d125d05 100644 --- a/tests/check/gst/gstpipeline.c +++ b/tests/check/gst/gstpipeline.c @@ -167,6 +167,7 @@ GST_START_TEST (test_bus) GstBus *bus; guint id; GstState current; + GstStateChangeReturn ret; pipeline = gst_pipeline_new (NULL); fail_unless (pipeline != NULL, "Could not create pipeline"); @@ -188,7 +189,9 @@ GST_START_TEST (test_bus) ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after add_watch", 1); ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3); - gst_element_set_state (pipeline, GST_STATE_PLAYING); + ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); + fail_unless (ret == GST_STATE_CHANGE_ASYNC); + loop = g_main_loop_new (NULL, FALSE); GST_DEBUG ("going into main loop"); g_main_loop_run (loop); @@ -202,23 +205,22 @@ GST_START_TEST (test_bus) /* cleanup */ GST_DEBUG ("cleanup"); - gst_element_set_state (pipeline, GST_STATE_NULL); - fail_unless (gst_element_get_state (pipeline, ¤t, NULL, NULL) == - GST_STATE_CHANGE_SUCCESS); + ret = gst_element_set_state (pipeline, GST_STATE_NULL); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); + ret = gst_element_get_state (pipeline, ¤t, NULL, GST_CLOCK_TIME_NONE); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS); fail_unless (current == GST_STATE_NULL, "state is not NULL but %d", current); - /* FIXME: need to figure out an extra refcount, checks disabled */ -// ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1); -// ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3); + ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1); + ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3); fail_unless (g_source_remove (id)); -// ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2); + ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2); GST_DEBUG ("unreffing pipeline"); gst_object_unref (pipeline); - -// ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1); + ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1); gst_object_unref (bus); } diff --git a/tests/check/pipelines/simple-launch-lines.c b/tests/check/pipelines/simple-launch-lines.c index 66ae5f344d..7f8d8aaa57 100644 --- a/tests/check/pipelines/simple-launch-lines.c +++ b/tests/check/pipelines/simple-launch-lines.c @@ -55,7 +55,7 @@ run_pipeline (GstElement * pipeline, gchar * descr, g_assert (bus); ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); - ret = gst_element_get_state (pipeline, NULL, NULL, NULL); + ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); if (ret != GST_STATE_CHANGE_SUCCESS) { g_critical ("Couldn't set pipeline to PLAYING"); diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 880696adfb..766af00788 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -642,7 +642,7 @@ main (int argc, char *argv[]) break; case GST_STATE_CHANGE_ASYNC: fprintf (stderr, _("PREROLL pipeline ...\n")); - gst_element_get_state (pipeline, &state, &pending, NULL); + gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE); /* fallthrough */ case GST_STATE_CHANGE_SUCCESS: fprintf (stderr, _("PREROLLED pipeline ...\n")); @@ -677,15 +677,15 @@ main (int argc, char *argv[]) fprintf (stderr, _("PAUSE pipeline ...\n")); gst_element_set_state (pipeline, GST_STATE_PAUSED); - gst_element_get_state (pipeline, &state, &pending, NULL); + gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE); fprintf (stderr, _("READY pipeline ...\n")); gst_element_set_state (pipeline, GST_STATE_READY); - gst_element_get_state (pipeline, &state, &pending, NULL); + gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE); end: fprintf (stderr, _("NULL pipeline ...\n")); gst_element_set_state (pipeline, GST_STATE_NULL); - gst_element_get_state (pipeline, &state, &pending, NULL); + gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE); } fprintf (stderr, _("FREEING pipeline ...\n")); diff --git a/tools/gst-typefind.c b/tools/gst-typefind.c index 59a08e5052..08413b4883 100644 --- a/tools/gst-typefind.c +++ b/tools/gst-typefind.c @@ -92,7 +92,8 @@ main (int argc, char *argv[]) if (GST_STATE_CHANGE_ASYNC == sret) { if (GST_STATE_CHANGE_FAILURE == - gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL)) + gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, + GST_CLOCK_TIME_NONE)) break; } else if (sret != GST_STATE_CHANGE_SUCCESS) g_print ("%s - No type found\n", argv[i]); @@ -100,7 +101,8 @@ main (int argc, char *argv[]) if (GST_STATE_CHANGE_ASYNC == gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL)) { if (GST_STATE_CHANGE_FAILURE == - gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, NULL)) + gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, + GST_CLOCK_TIME_NONE)) break; }