mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
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
This commit is contained in:
parent
c3cc492c7e
commit
6d0be74351
24 changed files with 153 additions and 268 deletions
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
||||||
|
2005-10-12 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* 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 <wingo@pobox.com>
|
2005-10-12 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
* gst/gstpad.c (gst_pad_pause_task): Actually return FALSE if
|
* gst/gstpad.c (gst_pad_pause_task): Actually return FALSE if
|
||||||
|
|
|
@ -264,7 +264,8 @@ GST_START_TEST (test_message_state_changed_children)
|
||||||
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
|
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
||||||
ret =
|
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 (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
fail_unless (current == GST_STATE_PAUSED);
|
fail_unless (current == GST_STATE_PAUSED);
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING);
|
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);
|
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
ret =
|
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 (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
fail_unless (current == GST_STATE_PLAYING);
|
fail_unless (current == GST_STATE_PLAYING);
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING);
|
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 */
|
/* change state, spawning two times three messages */
|
||||||
ret = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
ret = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
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);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
pop_messages (bus, 6);
|
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 */
|
/* this one might return either SUCCESS or ASYNC, likely SUCCESS */
|
||||||
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
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);
|
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);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_if (ret != GST_STATE_CHANGE_ASYNC,
|
fail_if (ret != GST_STATE_CHANGE_ASYNC,
|
||||||
"State change to PLAYING did not return 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 (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed");
|
||||||
fail_if (current != GST_STATE_PLAYING, "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");
|
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 */
|
/* don't set to NULL that will set the bus flushing and kill our messages */
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_READY);
|
ret = gst_element_set_state (pipeline, GST_STATE_READY);
|
||||||
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed");
|
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");
|
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed");
|
||||||
|
|
||||||
/* TODO: do we need to check downwards state change order as well? */
|
/* 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);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_if (ret != GST_STATE_CHANGE_ASYNC, "State change to PLAYING not ASYNC");
|
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 (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed");
|
||||||
fail_if (current != GST_STATE_PLAYING, "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");
|
fail_if (pending != GST_STATE_VOID_PENDING, "State change to PLAYING failed");
|
||||||
|
|
|
@ -109,7 +109,7 @@ GST_START_TEST (test_link)
|
||||||
gst_element_set_state (src, GST_STATE_PAUSED);
|
gst_element_set_state (src, GST_STATE_PAUSED);
|
||||||
|
|
||||||
/* wait for preroll */
|
/* 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 */
|
/* play some more */
|
||||||
gst_element_set_state (sink, GST_STATE_PLAYING);
|
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);
|
gst_element_set_state (src, GST_STATE_PAUSED);
|
||||||
|
|
||||||
/* wait for preroll */
|
/* 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 (sink, GST_STATE_NULL);
|
||||||
gst_element_set_state (src, GST_STATE_NULL);
|
gst_element_set_state (src, GST_STATE_NULL);
|
||||||
|
|
|
@ -245,7 +245,8 @@ static void test_event
|
||||||
got_event_before_q = got_event_after_q = NULL;
|
got_event_before_q = got_event_after_q = NULL;
|
||||||
|
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
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,
|
event = gst_event_new_custom (type,
|
||||||
gst_structure_empty_new ("application/x-custom"));
|
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_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)
|
if (got_event_before_q)
|
||||||
gst_event_unref (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));
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||||
|
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
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);
|
gst_object_unref (pipeline);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,11 +248,11 @@ GST_START_TEST (test_ghost_pads)
|
||||||
assert_gstrefcount (isrc, 3); /* parent and gsrc */
|
assert_gstrefcount (isrc, 3); /* parent and gsrc */
|
||||||
|
|
||||||
ret = gst_element_set_state (b1, GST_STATE_PLAYING);
|
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);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
ret = gst_element_set_state (b1, GST_STATE_NULL);
|
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);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
gst_object_unref (b1);
|
gst_object_unref (b1);
|
||||||
|
|
|
@ -167,6 +167,7 @@ GST_START_TEST (test_bus)
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
guint id;
|
guint id;
|
||||||
GstState current;
|
GstState current;
|
||||||
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
pipeline = gst_pipeline_new (NULL);
|
pipeline = gst_pipeline_new (NULL);
|
||||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
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 (pipeline, "pipeline after add_watch", 1);
|
||||||
ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3);
|
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);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
GST_DEBUG ("going into main loop");
|
GST_DEBUG ("going into main loop");
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
@ -202,23 +205,22 @@ GST_START_TEST (test_bus)
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
GST_DEBUG ("cleanup");
|
GST_DEBUG ("cleanup");
|
||||||
|
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
ret = gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
fail_unless (gst_element_get_state (pipeline, ¤t, NULL, NULL) ==
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
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);
|
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 (pipeline, "pipeline at start of cleanup", 1);
|
ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
||||||
// ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
|
||||||
|
|
||||||
fail_unless (g_source_remove (id));
|
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_DEBUG ("unreffing pipeline");
|
||||||
gst_object_unref (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);
|
gst_object_unref (bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ run_pipeline (GstElement * pipeline, gchar * descr,
|
||||||
g_assert (bus);
|
g_assert (bus);
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
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) {
|
if (ret != GST_STATE_CHANGE_SUCCESS) {
|
||||||
g_critical ("Couldn't set pipeline to PLAYING");
|
g_critical ("Couldn't set pipeline to PLAYING");
|
||||||
|
|
|
@ -28,7 +28,6 @@ GST_START_TEST (test_sink)
|
||||||
GstElement *sink;
|
GstElement *sink;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
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);
|
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change");
|
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, 0);
|
||||||
|
|
||||||
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
||||||
fail_unless (current == GST_STATE_READY, "bad current state");
|
fail_unless (current == GST_STATE_READY, "bad current state");
|
||||||
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
|
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
|
||||||
|
@ -65,16 +62,13 @@ GST_START_TEST (test_sink_completion)
|
||||||
GstElement *sink, *src;
|
GstElement *sink, *src;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
|
|
||||||
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
|
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, 0);
|
||||||
|
|
||||||
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
||||||
fail_unless (current == GST_STATE_READY, "bad current state");
|
fail_unless (current == GST_STATE_READY, "bad current state");
|
||||||
fail_unless (pending == GST_STATE_PLAYING, "bad pending 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");
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");
|
||||||
|
|
||||||
/* now wait for final state */
|
/* 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 (ret == GST_STATE_CHANGE_SUCCESS, "failed to change state");
|
||||||
fail_unless (current == GST_STATE_PLAYING, "bad current state");
|
fail_unless (current == GST_STATE_PLAYING, "bad current state");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "bad pending 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);
|
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
|
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");
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play");
|
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 (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
|
||||||
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
@ -153,7 +148,6 @@ GST_START_TEST (test_livesrc_remove)
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad, *sinkpad;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
src = gst_element_factory_make ("fakesrc", "src");
|
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,
|
fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
|
||||||
"no no_preroll state return");
|
"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 (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
||||||
gst_bin_remove (GST_BIN (pipeline), src);
|
gst_bin_remove (GST_BIN (pipeline), src);
|
||||||
|
|
||||||
GST_TIME_TO_TIMEVAL (0, tv);
|
ret = gst_element_get_state (pipeline, ¤t, &pending, 0);
|
||||||
ret = gst_element_get_state (pipeline, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == 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;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad, *sinkpad;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
src = gst_element_factory_make ("fakesrc", "src");
|
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,
|
fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
|
||||||
"no no_preroll state return");
|
"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 (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
||||||
/* don't block here */
|
/* don't block here */
|
||||||
GST_TIME_TO_TIMEVAL (0, tv);
|
ret = gst_element_get_state (sink, ¤t, &pending, 0);
|
||||||
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
||||||
fail_unless (current == GST_STATE_READY, "not ready");
|
fail_unless (current == GST_STATE_READY, "not ready");
|
||||||
fail_unless (pending == GST_STATE_PAUSED, "not paused");
|
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 (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
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 (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
|
||||||
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
|
@ -410,7 +410,8 @@ stop_typefinding (GstTypeFindElement * typefind)
|
||||||
GstState state;
|
GstState state;
|
||||||
gboolean push_cached_buffers;
|
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);
|
push_cached_buffers = (state >= GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ static void gst_bin_recalc_state (GstBin * bin, gboolean force);
|
||||||
static GstStateChangeReturn gst_bin_change_state_func (GstElement * element,
|
static GstStateChangeReturn gst_bin_change_state_func (GstElement * element,
|
||||||
GstStateChange transition);
|
GstStateChange transition);
|
||||||
static GstStateChangeReturn gst_bin_get_state_func (GstElement * element,
|
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_add_func (GstBin * bin, GstElement * element);
|
||||||
static gboolean gst_bin_remove_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
|
static GstStateChangeReturn
|
||||||
gst_bin_get_state_func (GstElement * element, GstState * state,
|
gst_bin_get_state_func (GstElement * element, GstState * state,
|
||||||
GstState * pending, GTimeVal * timeout)
|
GstState * pending, GstClockTime timeout)
|
||||||
{
|
{
|
||||||
GstBin *bin = GST_BIN (element);
|
GstBin *bin = GST_BIN (element);
|
||||||
|
|
||||||
|
@ -928,7 +928,6 @@ gst_bin_recalc_state (GstBin * bin, gboolean force)
|
||||||
guint32 children_cookie;
|
guint32 children_cookie;
|
||||||
gboolean have_no_preroll;
|
gboolean have_no_preroll;
|
||||||
gboolean have_async;
|
gboolean have_async;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
ret = GST_STATE_CHANGE_SUCCESS;
|
ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
|
|
||||||
|
@ -962,7 +961,6 @@ restart:
|
||||||
|
|
||||||
/* scan all element states with a zero timeout so we don't block on
|
/* scan all element states with a zero timeout so we don't block on
|
||||||
* anything */
|
* anything */
|
||||||
GST_TIME_TO_TIMEVAL (0, tv);
|
|
||||||
children = bin->children;
|
children = bin->children;
|
||||||
children_cookie = bin->children_cookie;
|
children_cookie = bin->children_cookie;
|
||||||
while (children) {
|
while (children) {
|
||||||
|
@ -973,7 +971,7 @@ restart:
|
||||||
* release the lock anyway since we can. */
|
* release the lock anyway since we can. */
|
||||||
GST_UNLOCK (bin);
|
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);
|
gst_object_unref (child);
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ static GstStateChangeReturn gst_element_change_state_func (GstElement * element,
|
||||||
static GstStateChangeReturn gst_element_change_state_func (GstElement * element,
|
static GstStateChangeReturn gst_element_change_state_func (GstElement * element,
|
||||||
GstStateChange transition);
|
GstStateChange transition);
|
||||||
static GstStateChangeReturn gst_element_get_state_func (GstElement * element,
|
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);
|
static void gst_element_set_bus_func (GstElement * element, GstBus * bus);
|
||||||
|
|
||||||
#ifndef GST_DISABLE_LOADSAVE
|
#ifndef GST_DISABLE_LOADSAVE
|
||||||
|
@ -1604,7 +1604,7 @@ failed:
|
||||||
/* MT safe */
|
/* MT safe */
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
gst_element_get_state_func (GstElement * element,
|
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;
|
GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
|
||||||
GstState old_pending;
|
GstState old_pending;
|
||||||
|
@ -1630,8 +1630,8 @@ gst_element_get_state_func (GstElement * element,
|
||||||
if (old_pending != GST_STATE_VOID_PENDING) {
|
if (old_pending != GST_STATE_VOID_PENDING) {
|
||||||
GTimeVal *timeval, abstimeout;
|
GTimeVal *timeval, abstimeout;
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout != GST_CLOCK_TIME_NONE) {
|
||||||
glong add = timeout->tv_sec * G_USEC_PER_SEC + timeout->tv_usec;
|
glong add = timeout / 1000;
|
||||||
|
|
||||||
if (add == 0)
|
if (add == 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1688,8 +1688,8 @@ done:
|
||||||
* @state: a pointer to #GstState to hold the state. Can be NULL.
|
* @state: a pointer to #GstState to hold the state. Can be NULL.
|
||||||
* @pending: a pointer to #GstState to hold the pending state.
|
* @pending: a pointer to #GstState to hold the pending state.
|
||||||
* Can be NULL.
|
* Can be NULL.
|
||||||
* @timeout: a #GTimeVal to specify the timeout for an async
|
* @timeout: a #GstClockTime to specify the timeout for an async
|
||||||
* state change or NULL for infinite timeout.
|
* state change or GST_CLOCK_TIME_NONE for infinite timeout.
|
||||||
*
|
*
|
||||||
* Gets the state of the element.
|
* Gets the state of the element.
|
||||||
*
|
*
|
||||||
|
@ -1712,7 +1712,7 @@ done:
|
||||||
*/
|
*/
|
||||||
GstStateChangeReturn
|
GstStateChangeReturn
|
||||||
gst_element_get_state (GstElement * element,
|
gst_element_get_state (GstElement * element,
|
||||||
GstState * state, GstState * pending, GTimeVal * timeout)
|
GstState * state, GstState * pending, GstClockTime timeout)
|
||||||
{
|
{
|
||||||
GstElementClass *oclass;
|
GstElementClass *oclass;
|
||||||
GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE;
|
GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE;
|
||||||
|
|
|
@ -355,7 +355,7 @@ struct _GstElementClass
|
||||||
|
|
||||||
/* state changes */
|
/* state changes */
|
||||||
GstStateChangeReturn (*get_state) (GstElement * element, GstState * state,
|
GstStateChangeReturn (*get_state) (GstElement * element, GstState * state,
|
||||||
GstState * pending, GTimeVal * timeout);
|
GstState * pending, GstClockTime timeout);
|
||||||
GstStateChangeReturn (*change_state) (GstElement *element, GstStateChange transition);
|
GstStateChangeReturn (*change_state) (GstElement *element, GstStateChange transition);
|
||||||
|
|
||||||
/* bus */
|
/* bus */
|
||||||
|
@ -485,7 +485,7 @@ gboolean gst_element_sync_state_with_parent (GstElement *element);
|
||||||
GstStateChangeReturn gst_element_get_state (GstElement * element,
|
GstStateChangeReturn gst_element_get_state (GstElement * element,
|
||||||
GstState * state,
|
GstState * state,
|
||||||
GstState * pending,
|
GstState * pending,
|
||||||
GTimeVal * timeout);
|
GstClockTime timeout);
|
||||||
GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state);
|
GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state);
|
||||||
|
|
||||||
void gst_element_abort_state (GstElement * element);
|
void gst_element_abort_state (GstElement * element);
|
||||||
|
|
|
@ -226,12 +226,10 @@ do_pipeline_seek (GstElement * element, GstEvent * event)
|
||||||
|
|
||||||
if (flush) {
|
if (flush) {
|
||||||
GstState state;
|
GstState state;
|
||||||
GTimeVal timeout;
|
|
||||||
|
|
||||||
GST_TIME_TO_TIMEVAL (0, timeout);
|
|
||||||
/* need to call _get_state() since a bin state is only updated
|
/* need to call _get_state() since a bin state is only updated
|
||||||
* with this call. */
|
* 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;
|
was_playing = state == GST_STATE_PLAYING;
|
||||||
|
|
||||||
if (was_playing) {
|
if (was_playing) {
|
||||||
|
|
152
gst/gstutils.c
152
gst/gstutils.c
|
@ -1337,7 +1337,6 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
|
||||||
GstElement *capsfilter;
|
GstElement *capsfilter;
|
||||||
GstObject *parent;
|
GstObject *parent;
|
||||||
GstState state, pending;
|
GstState state, pending;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
capsfilter = gst_element_factory_make ("capsfilter", NULL);
|
capsfilter = gst_element_factory_make ("capsfilter", NULL);
|
||||||
if (!capsfilter) {
|
if (!capsfilter) {
|
||||||
|
@ -1348,8 +1347,7 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
|
||||||
parent = gst_object_get_parent (GST_OBJECT (src));
|
parent = gst_object_get_parent (GST_OBJECT (src));
|
||||||
g_return_val_if_fail (GST_IS_BIN (parent), FALSE);
|
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, 0);
|
||||||
gst_element_get_state (GST_ELEMENT_CAST (parent), &state, &pending, &tv);
|
|
||||||
|
|
||||||
if (!gst_bin_add (GST_BIN (parent), capsfilter)) {
|
if (!gst_bin_add (GST_BIN (parent), capsfilter)) {
|
||||||
GST_ERROR ("Could not add capsfilter");
|
GST_ERROR ("Could not add capsfilter");
|
||||||
|
@ -1920,154 +1918,6 @@ gst_bin_remove_many (GstBin * bin, GstElement * element_1, ...)
|
||||||
va_end (args);
|
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
|
static void
|
||||||
gst_element_populate_std_props (GObjectClass * klass, const gchar * prop_name,
|
gst_element_populate_std_props (GObjectClass * klass, const gchar * prop_name,
|
||||||
guint arg_id, GParamFlags flags)
|
guint arg_id, GParamFlags flags)
|
||||||
|
|
|
@ -410,7 +410,8 @@ stop_typefinding (GstTypeFindElement * typefind)
|
||||||
GstState state;
|
GstState state;
|
||||||
gboolean push_cached_buffers;
|
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);
|
push_cached_buffers = (state >= GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ GST_START_TEST (test_sink)
|
||||||
GstElement *sink;
|
GstElement *sink;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
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);
|
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no forced async state change");
|
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, 0);
|
||||||
|
|
||||||
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
||||||
fail_unless (current == GST_STATE_READY, "bad current state");
|
fail_unless (current == GST_STATE_READY, "bad current state");
|
||||||
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
|
fail_unless (pending == GST_STATE_PLAYING, "bad pending state");
|
||||||
|
@ -65,16 +62,13 @@ GST_START_TEST (test_sink_completion)
|
||||||
GstElement *sink, *src;
|
GstElement *sink, *src;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
|
|
||||||
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
|
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, 0);
|
||||||
|
|
||||||
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not changing state async");
|
||||||
fail_unless (current == GST_STATE_READY, "bad current state");
|
fail_unless (current == GST_STATE_READY, "bad current state");
|
||||||
fail_unless (pending == GST_STATE_PLAYING, "bad pending 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");
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");
|
||||||
|
|
||||||
/* now wait for final state */
|
/* 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 (ret == GST_STATE_CHANGE_SUCCESS, "failed to change state");
|
||||||
fail_unless (current == GST_STATE_PLAYING, "bad current state");
|
fail_unless (current == GST_STATE_PLAYING, "bad current state");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "bad pending 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);
|
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "no async state return");
|
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");
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "no success state return");
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot start play");
|
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 (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
|
||||||
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
@ -153,7 +148,6 @@ GST_START_TEST (test_livesrc_remove)
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad, *sinkpad;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
src = gst_element_factory_make ("fakesrc", "src");
|
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,
|
fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
|
||||||
"no no_preroll state return");
|
"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 (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
||||||
gst_bin_remove (GST_BIN (pipeline), src);
|
gst_bin_remove (GST_BIN (pipeline), src);
|
||||||
|
|
||||||
GST_TIME_TO_TIMEVAL (0, tv);
|
ret = gst_element_get_state (pipeline, ¤t, &pending, 0);
|
||||||
ret = gst_element_get_state (pipeline, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == 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;
|
GstStateChangeReturn ret;
|
||||||
GstState current, pending;
|
GstState current, pending;
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad, *sinkpad;
|
||||||
GTimeVal tv;
|
|
||||||
|
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
src = gst_element_factory_make ("fakesrc", "src");
|
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,
|
fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
|
||||||
"no no_preroll state return");
|
"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 (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
||||||
/* don't block here */
|
/* don't block here */
|
||||||
GST_TIME_TO_TIMEVAL (0, tv);
|
ret = gst_element_get_state (sink, ¤t, &pending, 0);
|
||||||
ret = gst_element_get_state (sink, ¤t, &pending, &tv);
|
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
||||||
fail_unless (current == GST_STATE_READY, "not ready");
|
fail_unless (current == GST_STATE_READY, "not ready");
|
||||||
fail_unless (pending == GST_STATE_PAUSED, "not paused");
|
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 (ret == GST_STATE_CHANGE_NO_PREROLL, "not paused");
|
||||||
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not async");
|
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 (ret == GST_STATE_CHANGE_SUCCESS, "not playing");
|
||||||
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
||||||
|
|
|
@ -264,7 +264,8 @@ GST_START_TEST (test_message_state_changed_children)
|
||||||
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
|
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
||||||
ret =
|
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 (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
fail_unless (current == GST_STATE_PAUSED);
|
fail_unless (current == GST_STATE_PAUSED);
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING);
|
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);
|
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
ret =
|
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 (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
fail_unless (current == GST_STATE_PLAYING);
|
fail_unless (current == GST_STATE_PLAYING);
|
||||||
fail_unless (pending == GST_STATE_VOID_PENDING);
|
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 */
|
/* change state, spawning two times three messages */
|
||||||
ret = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
ret = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
|
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);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
pop_messages (bus, 6);
|
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 */
|
/* this one might return either SUCCESS or ASYNC, likely SUCCESS */
|
||||||
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
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);
|
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);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_if (ret != GST_STATE_CHANGE_ASYNC,
|
fail_if (ret != GST_STATE_CHANGE_ASYNC,
|
||||||
"State change to PLAYING did not return 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 (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed");
|
||||||
fail_if (current != GST_STATE_PLAYING, "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");
|
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 */
|
/* don't set to NULL that will set the bus flushing and kill our messages */
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_READY);
|
ret = gst_element_set_state (pipeline, GST_STATE_READY);
|
||||||
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed");
|
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");
|
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "State change to READY failed");
|
||||||
|
|
||||||
/* TODO: do we need to check downwards state change order as well? */
|
/* 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);
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
fail_if (ret != GST_STATE_CHANGE_ASYNC, "State change to PLAYING not ASYNC");
|
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 (ret != GST_STATE_CHANGE_SUCCESS, "State change to PLAYING failed");
|
||||||
fail_if (current != GST_STATE_PLAYING, "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");
|
fail_if (pending != GST_STATE_VOID_PENDING, "State change to PLAYING failed");
|
||||||
|
|
|
@ -109,7 +109,7 @@ GST_START_TEST (test_link)
|
||||||
gst_element_set_state (src, GST_STATE_PAUSED);
|
gst_element_set_state (src, GST_STATE_PAUSED);
|
||||||
|
|
||||||
/* wait for preroll */
|
/* 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 */
|
/* play some more */
|
||||||
gst_element_set_state (sink, GST_STATE_PLAYING);
|
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);
|
gst_element_set_state (src, GST_STATE_PAUSED);
|
||||||
|
|
||||||
/* wait for preroll */
|
/* 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 (sink, GST_STATE_NULL);
|
||||||
gst_element_set_state (src, GST_STATE_NULL);
|
gst_element_set_state (src, GST_STATE_NULL);
|
||||||
|
|
|
@ -245,7 +245,8 @@ static void test_event
|
||||||
got_event_before_q = got_event_after_q = NULL;
|
got_event_before_q = got_event_after_q = NULL;
|
||||||
|
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
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,
|
event = gst_event_new_custom (type,
|
||||||
gst_structure_empty_new ("application/x-custom"));
|
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_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)
|
if (got_event_before_q)
|
||||||
gst_event_unref (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));
|
G_GINT64_FORMAT " us", timediff (&got_event_time, &sent_event_time));
|
||||||
|
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
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);
|
gst_object_unref (pipeline);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,11 +248,11 @@ GST_START_TEST (test_ghost_pads)
|
||||||
assert_gstrefcount (isrc, 3); /* parent and gsrc */
|
assert_gstrefcount (isrc, 3); /* parent and gsrc */
|
||||||
|
|
||||||
ret = gst_element_set_state (b1, GST_STATE_PLAYING);
|
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);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
ret = gst_element_set_state (b1, GST_STATE_NULL);
|
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);
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
gst_object_unref (b1);
|
gst_object_unref (b1);
|
||||||
|
|
|
@ -167,6 +167,7 @@ GST_START_TEST (test_bus)
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
guint id;
|
guint id;
|
||||||
GstState current;
|
GstState current;
|
||||||
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
pipeline = gst_pipeline_new (NULL);
|
pipeline = gst_pipeline_new (NULL);
|
||||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
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 (pipeline, "pipeline after add_watch", 1);
|
||||||
ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3);
|
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);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
GST_DEBUG ("going into main loop");
|
GST_DEBUG ("going into main loop");
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
@ -202,23 +205,22 @@ GST_START_TEST (test_bus)
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
GST_DEBUG ("cleanup");
|
GST_DEBUG ("cleanup");
|
||||||
|
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
ret = gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
fail_unless (gst_element_get_state (pipeline, ¤t, NULL, NULL) ==
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
|
||||||
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);
|
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 (pipeline, "pipeline at start of cleanup", 1);
|
ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
||||||
// ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
|
||||||
|
|
||||||
fail_unless (g_source_remove (id));
|
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_DEBUG ("unreffing pipeline");
|
||||||
gst_object_unref (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);
|
gst_object_unref (bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ run_pipeline (GstElement * pipeline, gchar * descr,
|
||||||
g_assert (bus);
|
g_assert (bus);
|
||||||
|
|
||||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
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) {
|
if (ret != GST_STATE_CHANGE_SUCCESS) {
|
||||||
g_critical ("Couldn't set pipeline to PLAYING");
|
g_critical ("Couldn't set pipeline to PLAYING");
|
||||||
|
|
|
@ -642,7 +642,7 @@ main (int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_ASYNC:
|
case GST_STATE_CHANGE_ASYNC:
|
||||||
fprintf (stderr, _("PREROLL pipeline ...\n"));
|
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 */
|
/* fallthrough */
|
||||||
case GST_STATE_CHANGE_SUCCESS:
|
case GST_STATE_CHANGE_SUCCESS:
|
||||||
fprintf (stderr, _("PREROLLED pipeline ...\n"));
|
fprintf (stderr, _("PREROLLED pipeline ...\n"));
|
||||||
|
@ -677,15 +677,15 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
fprintf (stderr, _("PAUSE pipeline ...\n"));
|
fprintf (stderr, _("PAUSE pipeline ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
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"));
|
fprintf (stderr, _("READY pipeline ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_READY);
|
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:
|
end:
|
||||||
fprintf (stderr, _("NULL pipeline ...\n"));
|
fprintf (stderr, _("NULL pipeline ...\n"));
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
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"));
|
fprintf (stderr, _("FREEING pipeline ...\n"));
|
||||||
|
|
|
@ -92,7 +92,8 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
if (GST_STATE_CHANGE_ASYNC == sret) {
|
if (GST_STATE_CHANGE_ASYNC == sret) {
|
||||||
if (GST_STATE_CHANGE_FAILURE ==
|
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;
|
break;
|
||||||
} else if (sret != GST_STATE_CHANGE_SUCCESS)
|
} else if (sret != GST_STATE_CHANGE_SUCCESS)
|
||||||
g_print ("%s - No type found\n", argv[i]);
|
g_print ("%s - No type found\n", argv[i]);
|
||||||
|
@ -100,7 +101,8 @@ main (int argc, char *argv[])
|
||||||
if (GST_STATE_CHANGE_ASYNC ==
|
if (GST_STATE_CHANGE_ASYNC ==
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL)) {
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL)) {
|
||||||
if (GST_STATE_CHANGE_FAILURE ==
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue