From: <wt...@ke...> - 2007-08-14 13:37:39
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: wtay Date: Tue Aug 14 2007 13:37:30 UTC Log message: * gst/gstbin.c: (gst_bin_element_set_state): Always change the state of a NO_PREROLL element even if it has ASYNC elements inside (in case of a bin). * tests/check/generic/sinks.c: (GST_START_TEST), (gst_sinks_suite): Unit test for this case. Modified files: . : ChangeLog gst : gstbin.c tests/check/generic: sinks.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.3370&r2=1.3371 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstbin.c.diff?r1=1.361&r2=1.362 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/tests/check/generic/sinks.c.diff?r1=1.21&r2=1.22 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.3370 retrieving revision 1.3371 diff -u -d -r1.3370 -r1.3371 --- ChangeLog 13 Aug 2007 13:33:05 -0000 1.3370 +++ ChangeLog 14 Aug 2007 13:37:15 -0000 1.3371 @@ -1,3 +1,12 @@ +2007-08-14 Wim Taymans <wim...@gm...> + + * gst/gstbin.c: (gst_bin_element_set_state): + Always change the state of a NO_PREROLL element even if it has ASYNC + elements inside (in case of a bin). + * tests/check/generic/sinks.c: (GST_START_TEST), (gst_sinks_suite): + Unit test for this case. 2007-08-13 Stefan Kost <en...@us...> * libs/gst/check/gstbufferstraw.c: Index: gstbin.c RCS file: /cvs/gstreamer/gstreamer/gst/gstbin.c,v retrieving revision 1.361 retrieving revision 1.362 diff -u -d -r1.361 -r1.362 --- gstbin.c 7 Aug 2007 09:56:08 -0000 1.361 +++ gstbin.c 14 Aug 2007 13:37:16 -0000 1.362 @@ -1834,6 +1834,14 @@ if (G_UNLIKELY (locked)) goto locked; + /* if the element was no preroll, just start changing the state regardless + * if it had async elements (in the case of a bin) because they won't preroll + * anyway. */ + if (G_UNLIKELY (ret == GST_STATE_CHANGE_NO_PREROLL)) { + GST_DEBUG_OBJECT (element, "element is NO_PREROLL, ignore async elements"); + goto no_preroll; + } GST_OBJECT_LOCK (bin); /* the element was busy with an upwards async state change, we must wait for * an ASYNC_DONE message before we attemp to change the state. */ @@ -1864,6 +1872,7 @@ no_latency: GST_OBJECT_UNLOCK (bin); +no_preroll: GST_DEBUG_OBJECT (bin, "setting element %s to %s, base_time %" GST_TIME_FORMAT, GST_ELEMENT_NAME (element), gst_element_state_get_name (next), Index: sinks.c RCS file: /cvs/gstreamer/gstreamer/tests/check/generic/sinks.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- sinks.c 18 Jun 2007 15:12:28 -0000 1.21 +++ sinks.c 14 Aug 2007 13:37:16 -0000 1.22 @@ -846,9 +846,59 @@ GST_END_TEST; +GST_START_TEST (test_bin_live) +{ + GstElement *sink, *src, *pipeline, *bin; + GstStateChangeReturn ret; + GstState current, pending; + GstPad *srcpad, *sinkpad; + pipeline = gst_pipeline_new ("pipeline"); + bin = gst_bin_new ("bin"); + src = gst_element_factory_make ("fakesrc", "src"); + g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); + sink = gst_element_factory_make ("fakesink", "sink"); + gst_bin_add (GST_BIN (bin), src); + gst_bin_add (GST_BIN (bin), sink); + gst_bin_add (GST_BIN (pipeline), bin); + srcpad = gst_element_get_pad (src, "src"); + sinkpad = gst_element_get_pad (sink, "sink"); + gst_pad_link (srcpad, sinkpad); + gst_object_unref (srcpad); + gst_object_unref (sinkpad); + /* PAUSED returns NO_PREROLL because of the live source */ + ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); + fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, + "no NO_PREROLL state return"); + ret = + gst_element_get_state (pipeline, ¤t, &pending, GST_CLOCK_TIME_NONE); + fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, "not NO_PREROLL"); + fail_unless (current == GST_STATE_PAUSED, "not paused"); + fail_unless (pending == GST_STATE_VOID_PENDING, "not void pending"); + /* when going to PLAYING, the sink should go to PLAYING ASYNC */ + ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); + fail_unless (ret == GST_STATE_CHANGE_ASYNC, "not ASYNC"); + /* now wait for PLAYING to complete */ + fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "not playing"); + fail_unless (current == GST_STATE_PLAYING, "not playing"); + ret = gst_element_set_state (pipeline, GST_STATE_NULL); + fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "cannot null pipeline"); + gst_object_unref (pipeline); +} +GST_END_TEST /* test: try changing state of sinks */ -Suite * -gst_sinks_suite (void) + Suite * gst_sinks_suite (void) { Suite *s = suite_create ("Sinks"); TCase *tc_chain = tcase_create ("general"); @@ -868,6 +918,7 @@ tcase_add_test (tc_chain, test_added_async2); tcase_add_test (tc_chain, test_add_live); tcase_add_test (tc_chain, test_add_live2); + tcase_add_test (tc_chain, test_bin_live); return s; } |