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
This commit is contained in:
Mathieu Duponchelle 2014-11-28 15:06:27 +01:00
parent 4e228e0a1f
commit b2413d46ed
2 changed files with 38 additions and 1 deletions

View file

@ -2089,6 +2089,8 @@ gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
/* Forward EOS because no buffer or serialized event will come after /* Forward EOS because no buffer or serialized event will come after
* EOS and nothing could trigger another _finish_frame() call. */ * 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); ret = gst_audio_decoder_push_event (dec, event);
break; break;

View file

@ -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); fail_unless (GST_EVENT_TYPE (eos_event) == GST_EVENT_EOS);
events_iter = g_list_next (events_iter); 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); g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
buffers = NULL; buffers = NULL;
@ -551,6 +555,36 @@ _audiodecoder_flush_events (gboolean send_buffers)
cleanup_audiodecodertest (); 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) GST_START_TEST (audiodecoder_flush_events_no_buffers)
{ {
_audiodecoder_flush_events (FALSE); _audiodecoder_flush_events (FALSE);
@ -695,6 +729,7 @@ gst_audiodecoder_suite (void)
suite_add_tcase (s, tc); suite_add_tcase (s, tc);
tcase_add_test (tc, audiodecoder_playback); tcase_add_test (tc, audiodecoder_playback);
tcase_add_test (tc, audiodecoder_flush_events_no_buffers); 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_flush_events);
tcase_add_test (tc, audiodecoder_negotiation_with_buffer); tcase_add_test (tc, audiodecoder_negotiation_with_buffer);
tcase_add_test (tc, audiodecoder_negotiation_with_gap_event); tcase_add_test (tc, audiodecoder_negotiation_with_gap_event);