+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),
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)
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;
}
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);
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);
break;
}
- if ((presult =
+ if ((result =
GST_ELEMENT_CLASS (parent_class)->change_state (element,
transition)) == GST_STATE_CHANGE_FAILURE)
goto failure;
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);
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;
}
}
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);
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);
break;
}
- if ((presult =
+ if ((result =
GST_ELEMENT_CLASS (parent_class)->change_state (element,
transition)) == GST_STATE_CHANGE_FAILURE)
goto failure;
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);
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;
}
}
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)
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;
}