From ab96505bcec80b9602a7edb35dcb206a760ecdb4 Mon Sep 17 00:00:00 2001 From: Andy Wingo <wingo@pobox.com> Date: Fri, 7 Oct 2005 15:22:38 +0000 Subject: [PATCH] check/elements/fakesrc.c (test_no_preroll): New check, checks that setting a live fakesrc to PAUSED returns NO_PREROL... Original commit message from CVS: 2005-10-07 Andy Wingo <wingo@pobox.com> * check/elements/fakesrc.c (test_no_preroll): New check, checks that setting a live fakesrc to PAUSED returns NO_PREROLL both times. * gst/base/gstbasesrc.c (gst_base_src_change_state): Allow a NO_PREROLL from gst_element_change_state to fall through. --- ChangeLog | 9 +++++++++ check/elements/fakesrc.c | 25 +++++++++++++++++++++++++ gst/base/gstbasesrc.c | 17 ++++++++++------- libs/gst/base/gstbasesrc.c | 17 ++++++++++------- tests/check/elements/fakesrc.c | 25 +++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54214b5cc0..4469309bb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-10-07 Andy Wingo <wingo@pobox.com> + + * check/elements/fakesrc.c (test_no_preroll): New check, checks + that setting a live fakesrc to PAUSED returns NO_PREROLL both + times. + + * gst/base/gstbasesrc.c (gst_base_src_change_state): Allow a + NO_PREROLL from gst_element_change_state to fall through. + 2005-10-07 Wim Taymans <wim@fluendo.com> * gst/gstghostpad.c: (gst_ghost_pad_get_internal), diff --git a/check/elements/fakesrc.c b/check/elements/fakesrc.c index 1770e819e7..1b96dd2cb4 100644 --- a/check/elements/fakesrc.c +++ b/check/elements/fakesrc.c @@ -203,6 +203,30 @@ GST_START_TEST (test_sizetype_random) GST_END_TEST; +GST_START_TEST (test_no_preroll) +{ + GstElement *src; + GstStateChangeReturn ret; + + src = setup_fakesrc (); + + g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); + + ret = gst_element_set_state (src, GST_STATE_PAUSED); + + fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, + "error going to paused the first time"); + + ret = gst_element_set_state (src, GST_STATE_PAUSED); + + fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, + "error going to paused the second time"); + + /* cleanup */ + cleanup_fakesrc (src); +} + +GST_END_TEST; Suite * fakesrc_suite (void) @@ -215,6 +239,7 @@ fakesrc_suite (void) tcase_add_test (tc_chain, test_sizetype_empty); tcase_add_test (tc_chain, test_sizetype_fixed); tcase_add_test (tc_chain, test_sizetype_random); + tcase_add_test (tc_chain, test_no_preroll); return s; } diff --git a/gst/base/gstbasesrc.c b/gst/base/gstbasesrc.c index 79718501a2..6290f1e9e3 100644 --- a/gst/base/gstbasesrc.c +++ b/gst/base/gstbasesrc.c @@ -1066,8 +1066,8 @@ static GstStateChangeReturn gst_base_src_change_state (GstElement * element, GstStateChange transition) { GstBaseSrc *basesrc; - GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS; - GstStateChangeReturn presult; + GstStateChangeReturn result; + gboolean no_preroll = FALSE; basesrc = GST_BASE_SRC (element); @@ -1078,7 +1078,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_PAUSED: GST_LIVE_LOCK (element); if (basesrc->is_live) { - result = GST_STATE_CHANGE_NO_PREROLL; + no_preroll = TRUE; basesrc->live_running = FALSE; } GST_LIVE_UNLOCK (element); @@ -1095,7 +1095,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) break; } - if ((presult = + if ((result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition)) == GST_STATE_CHANGE_FAILURE) goto failure; @@ -1104,7 +1104,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_PLAYING_TO_PAUSED: GST_LIVE_LOCK (element); if (basesrc->is_live) { - result = GST_STATE_CHANGE_NO_PREROLL; + no_preroll = TRUE; basesrc->live_running = FALSE; } GST_LIVE_UNLOCK (element); @@ -1119,12 +1119,15 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) break; } - return result; + if (no_preroll && result == GST_STATE_CHANGE_SUCCESS) + return GST_STATE_CHANGE_NO_PREROLL; + else + return result; /* ERRORS */ failure: { gst_base_src_stop (basesrc); - return presult; + return result; } } diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 79718501a2..6290f1e9e3 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -1066,8 +1066,8 @@ static GstStateChangeReturn gst_base_src_change_state (GstElement * element, GstStateChange transition) { GstBaseSrc *basesrc; - GstStateChangeReturn result = GST_STATE_CHANGE_SUCCESS; - GstStateChangeReturn presult; + GstStateChangeReturn result; + gboolean no_preroll = FALSE; basesrc = GST_BASE_SRC (element); @@ -1078,7 +1078,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_PAUSED: GST_LIVE_LOCK (element); if (basesrc->is_live) { - result = GST_STATE_CHANGE_NO_PREROLL; + no_preroll = TRUE; basesrc->live_running = FALSE; } GST_LIVE_UNLOCK (element); @@ -1095,7 +1095,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) break; } - if ((presult = + if ((result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition)) == GST_STATE_CHANGE_FAILURE) goto failure; @@ -1104,7 +1104,7 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_PLAYING_TO_PAUSED: GST_LIVE_LOCK (element); if (basesrc->is_live) { - result = GST_STATE_CHANGE_NO_PREROLL; + no_preroll = TRUE; basesrc->live_running = FALSE; } GST_LIVE_UNLOCK (element); @@ -1119,12 +1119,15 @@ gst_base_src_change_state (GstElement * element, GstStateChange transition) break; } - return result; + if (no_preroll && result == GST_STATE_CHANGE_SUCCESS) + return GST_STATE_CHANGE_NO_PREROLL; + else + return result; /* ERRORS */ failure: { gst_base_src_stop (basesrc); - return presult; + return result; } } diff --git a/tests/check/elements/fakesrc.c b/tests/check/elements/fakesrc.c index 1770e819e7..1b96dd2cb4 100644 --- a/tests/check/elements/fakesrc.c +++ b/tests/check/elements/fakesrc.c @@ -203,6 +203,30 @@ GST_START_TEST (test_sizetype_random) GST_END_TEST; +GST_START_TEST (test_no_preroll) +{ + GstElement *src; + GstStateChangeReturn ret; + + src = setup_fakesrc (); + + g_object_set (G_OBJECT (src), "is-live", TRUE, NULL); + + ret = gst_element_set_state (src, GST_STATE_PAUSED); + + fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, + "error going to paused the first time"); + + ret = gst_element_set_state (src, GST_STATE_PAUSED); + + fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL, + "error going to paused the second time"); + + /* cleanup */ + cleanup_fakesrc (src); +} + +GST_END_TEST; Suite * fakesrc_suite (void) @@ -215,6 +239,7 @@ fakesrc_suite (void) tcase_add_test (tc_chain, test_sizetype_empty); tcase_add_test (tc_chain, test_sizetype_fixed); tcase_add_test (tc_chain, test_sizetype_random); + tcase_add_test (tc_chain, test_no_preroll); return s; }