mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 12:41:05 +00:00
adder: Do not try to wait for flush_stop after receiving a segment event
+ Add a simple test
This commit is contained in:
parent
fa9c0cdf6e
commit
fbe80a688d
3 changed files with 55 additions and 10 deletions
|
@ -819,7 +819,7 @@ gst_adder_sink_event (GstCollectPads * pads, GstCollectData * pad,
|
|||
}
|
||||
case GST_EVENT_FLUSH_START:
|
||||
/* ensure that we will send a flush stop */
|
||||
g_atomic_int_set (&adder->need_flush_stop, TRUE);
|
||||
g_atomic_int_set (&adder->flush_stop_pending, TRUE);
|
||||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
/* we received a flush-stop. We will only forward it when
|
||||
|
@ -852,13 +852,6 @@ gst_adder_sink_event (GstCollectPads * pads, GstCollectData * pad,
|
|||
* see FIXME in gst_adder_collected() */
|
||||
g_atomic_int_set (&adder->new_segment_pending, TRUE);
|
||||
}
|
||||
if (g_atomic_int_compare_and_exchange (&adder->need_flush_stop,
|
||||
TRUE, FALSE)) {
|
||||
/* ensure that we'll eventually send a flush-stop
|
||||
* (e.g. after a flushing seek directly sent to an upstream element) */
|
||||
g_atomic_int_set (&adder->flush_stop_pending, TRUE);
|
||||
GST_DEBUG_OBJECT (adder, "mark pending flush stop event");
|
||||
}
|
||||
discard = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -68,9 +68,7 @@ struct _GstAdder {
|
|||
GstSegment segment;
|
||||
volatile gboolean new_segment_pending;
|
||||
volatile gboolean wait_for_new_segment;
|
||||
/* src event handling */
|
||||
volatile gboolean flush_stop_pending;
|
||||
volatile gboolean need_flush_stop;
|
||||
|
||||
/* current caps */
|
||||
GstCaps *current_caps;
|
||||
|
|
|
@ -1192,6 +1192,59 @@ GST_START_TEST (test_loop)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_flush_start_flush_stop)
|
||||
{
|
||||
GstPadTemplate *sink_template;
|
||||
GstPad *tmppad, *sinkpad1, *sinkpad2, *adder_src;
|
||||
GstElement *pipeline, *src1, *src2, *adder, *sink;
|
||||
|
||||
GST_INFO ("preparing test");
|
||||
|
||||
/* build pipeline */
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
src1 = gst_element_factory_make ("audiotestsrc", "src1");
|
||||
g_object_set (src1, "wave", 4, NULL); /* silence */
|
||||
src2 = gst_element_factory_make ("audiotestsrc", "src2");
|
||||
g_object_set (src2, "wave", 4, NULL); /* silence */
|
||||
adder = gst_element_factory_make ("adder", "adder");
|
||||
sink = gst_element_factory_make ("fakesink", "sink");
|
||||
gst_bin_add_many (GST_BIN (pipeline), src1, src2, adder, sink, NULL);
|
||||
|
||||
sink_template =
|
||||
gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (adder),
|
||||
"sink_%u");
|
||||
fail_unless (GST_IS_PAD_TEMPLATE (sink_template));
|
||||
sinkpad1 = gst_element_request_pad (adder, sink_template, NULL, NULL);
|
||||
tmppad = gst_element_get_static_pad (src1, "src");
|
||||
gst_pad_link (tmppad, sinkpad1);
|
||||
gst_object_unref (tmppad);
|
||||
|
||||
sinkpad2 = gst_element_request_pad (adder, sink_template, NULL, NULL);
|
||||
tmppad = gst_element_get_static_pad (src2, "src");
|
||||
gst_pad_link (tmppad, sinkpad2);
|
||||
gst_object_unref (tmppad);
|
||||
|
||||
gst_element_link (adder, sink);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
fail_unless (gst_element_get_state (pipeline, NULL, NULL,
|
||||
GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_SUCCESS);
|
||||
|
||||
adder_src = gst_element_get_static_pad (adder, "src");
|
||||
fail_if (GST_PAD_IS_FLUSHING (adder_src));
|
||||
gst_pad_send_event (sinkpad1, gst_event_new_flush_start ());
|
||||
fail_unless (GST_PAD_IS_FLUSHING (adder_src));
|
||||
gst_pad_send_event (sinkpad1, gst_event_new_flush_stop (TRUE));
|
||||
fail_if (GST_PAD_IS_FLUSHING (adder_src));
|
||||
gst_object_unref (adder_src);
|
||||
|
||||
/* cleanup */
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
adder_suite (void)
|
||||
|
@ -1212,6 +1265,7 @@ adder_suite (void)
|
|||
tcase_add_test (tc_chain, test_duration_is_max);
|
||||
tcase_add_test (tc_chain, test_duration_unknown_overrides);
|
||||
tcase_add_test (tc_chain, test_loop);
|
||||
tcase_add_test (tc_chain, test_flush_start_flush_stop);
|
||||
|
||||
/* Use a longer timeout */
|
||||
#ifdef HAVE_VALGRIND
|
||||
|
|
Loading…
Reference in a new issue