summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2014-11-28 15:06:27 +0100
committerTim-Philipp Müller <tim@centricular.com>2014-12-11 14:22:45 +0000
commit7084f7701bfe82ccf4e31e3600402df8b0bb080f (patch)
treeed3d0427978f5cebe26461083ba506eb0e4bb619
parent03dc6b82edaa9452c255411a5a94cede0e2785a2 (diff)
audiodecoder: Push pending events before sending EOS.
Segments are added to the pending events, and pushing a segment is mandatory before sending EOS. + Adds a test. https://bugzilla.gnome.org/show_bug.cgi?id=740853
-rw-r--r--gst-libs/gst/audio/gstaudiodecoder.c2
-rw-r--r--tests/check/libs/audiodecoder.c37
2 files changed, 38 insertions, 1 deletions
diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c
index df53c0ca9..08abf5a36 100644
--- a/gst-libs/gst/audio/gstaudiodecoder.c
+++ b/gst-libs/gst/audio/gstaudiodecoder.c
@@ -2130,6 +2130,8 @@ gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
/* Forward EOS because no buffer or serialized event will come after
* EOS and nothing could trigger another _finish_frame() call. */
+ if (dec->priv->pending_events)
+ send_pending_events (dec);
ret = gst_audio_decoder_push_event (dec, event);
break;
diff --git a/tests/check/libs/audiodecoder.c b/tests/check/libs/audiodecoder.c
index 99d4e9e4d..c2ef4d2ba 100644
--- a/tests/check/libs/audiodecoder.c
+++ b/tests/check/libs/audiodecoder.c
@@ -497,7 +497,8 @@ _audiodecoder_flush_events (gboolean send_buffers)
}
}
{
- GstEvent *eos_event = events_iter->data;
+ GstEvent *eos_event = g_list_last(events_iter)->data;
+
fail_unless (GST_EVENT_TYPE (eos_event) == GST_EVENT_EOS);
events_iter = g_list_next (events_iter);
}
@@ -544,6 +545,9 @@ _audiodecoder_flush_events (gboolean send_buffers)
}
+ g_list_free_full (events, (GDestroyNotify) gst_event_unref);
+ events = NULL;
+
g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
buffers = NULL;
@@ -551,6 +555,36 @@ _audiodecoder_flush_events (gboolean send_buffers)
cleanup_audiodecodertest ();
}
+/* An element should always push its segment before sending EOS */
+GST_START_TEST (audiodecoder_eos_events_no_buffers)
+{
+ GstSegment segment;
+ setup_audiodecodertester ();
+
+ gst_pad_set_active (mysrcpad, TRUE);
+ gst_element_set_state (dec, GST_STATE_PLAYING);
+ gst_pad_set_active (mysinkpad, TRUE);
+ send_startup_events ();
+
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
+
+ fail_unless (GST_PAD_IS_EOS (mysinkpad));
+
+ {
+ GstEvent *segment_event =
+ gst_pad_get_sticky_event (mysinkpad, GST_EVENT_SEGMENT, 0);
+ fail_unless (segment_event != NULL);
+ gst_event_unref (segment_event);
+ }
+
+ gst_element_set_state (dec, GST_STATE_NULL);
+ cleanup_audiodecodertest ();
+}
+
+GST_END_TEST;
+
GST_START_TEST (audiodecoder_flush_events_no_buffers)
{
_audiodecoder_flush_events (FALSE);
@@ -695,6 +729,7 @@ gst_audiodecoder_suite (void)
suite_add_tcase (s, tc);
tcase_add_test (tc, audiodecoder_playback);
tcase_add_test (tc, audiodecoder_flush_events_no_buffers);
+ tcase_add_test (tc, audiodecoder_eos_events_no_buffers);
tcase_add_test (tc, audiodecoder_flush_events);
tcase_add_test (tc, audiodecoder_negotiation_with_buffer);
tcase_add_test (tc, audiodecoder_negotiation_with_gap_event);