check/elements/fakesrc.c (test_no_preroll): New check, checks that setting a live...
authorAndy Wingo <wingo@pobox.com>
Fri, 7 Oct 2005 15:22:38 +0000 (15:22 +0000)
committerAndy Wingo <wingo@pobox.com>
Fri, 7 Oct 2005 15:22:38 +0000 (15:22 +0000)
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
check/elements/fakesrc.c
gst/base/gstbasesrc.c
libs/gst/base/gstbasesrc.c
tests/check/elements/fakesrc.c

index 54214b5..4469309 100644 (file)
--- 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),
index 1770e81..1b96dd2 100644 (file)
@@ -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;
 }
index 7971850..6290f1e 100644 (file)
@@ -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;
   }
 }
index 7971850..6290f1e 100644 (file)
@@ -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;
   }
 }
index 1770e81..1b96dd2 100644 (file)
@@ -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;
 }