mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
audiodecoder: Keep still meaningfull pending events on FLUSH_STOP
Only EOS and segment should be deleted in that case. https://bugzilla.gnome.org/show_bug.cgi?id=709868
This commit is contained in:
parent
2843f358d9
commit
12df7fa49d
2 changed files with 124 additions and 3 deletions
|
@ -2000,6 +2000,24 @@ not_negotiated:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
_flush_events (GstPad * pad, GList * events)
|
||||||
|
{
|
||||||
|
GList *tmp;
|
||||||
|
|
||||||
|
for (tmp = events; tmp; tmp = tmp->next) {
|
||||||
|
if (GST_EVENT_TYPE (tmp->data) == GST_EVENT_EOS ||
|
||||||
|
GST_EVENT_TYPE (tmp->data) == GST_EVENT_SEGMENT ||
|
||||||
|
!GST_EVENT_IS_STICKY (tmp->data)) {
|
||||||
|
gst_event_unref (tmp->data);
|
||||||
|
} else {
|
||||||
|
gst_pad_store_sticky_event (pad, GST_EVENT_CAST (tmp->data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
|
gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
|
||||||
{
|
{
|
||||||
|
@ -2095,9 +2113,8 @@ gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
|
||||||
/* prepare for fresh start */
|
/* prepare for fresh start */
|
||||||
gst_audio_decoder_flush (dec, TRUE);
|
gst_audio_decoder_flush (dec, TRUE);
|
||||||
|
|
||||||
g_list_foreach (dec->priv->pending_events, (GFunc) gst_event_unref, NULL);
|
dec->priv->pending_events = _flush_events (dec->srcpad,
|
||||||
g_list_free (dec->priv->pending_events);
|
dec->priv->pending_events);
|
||||||
dec->priv->pending_events = NULL;
|
|
||||||
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
|
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
|
||||||
|
|
||||||
/* Forward FLUSH_STOP, it is expected to be forwarded immediately
|
/* Forward FLUSH_STOP, it is expected to be forwarded immediately
|
||||||
|
|
|
@ -415,6 +415,109 @@ GST_START_TEST (audiodecoder_delayed_negotiation_with_gap_event)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (audiodecoder_flush_events)
|
||||||
|
{
|
||||||
|
GstSegment segment;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
guint64 i;
|
||||||
|
GList *events_iter;
|
||||||
|
|
||||||
|
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 ();
|
||||||
|
|
||||||
|
/* push a new segment */
|
||||||
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||||
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
|
||||||
|
|
||||||
|
/* push buffers, the data is actually a number so we can track them */
|
||||||
|
for (i = 0; i < NUM_BUFFERS; i++) {
|
||||||
|
if (i % 10 == 0) {
|
||||||
|
GstTagList *tags;
|
||||||
|
|
||||||
|
tags = gst_tag_list_new (GST_TAG_TRACK_NUMBER, i, NULL);
|
||||||
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_tag (tags)));
|
||||||
|
} else {
|
||||||
|
buffer = create_test_buffer (i);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
||||||
|
|
||||||
|
events_iter = events;
|
||||||
|
/* make sure the usual events have been received */
|
||||||
|
{
|
||||||
|
GstEvent *sstart = events_iter->data;
|
||||||
|
fail_unless (GST_EVENT_TYPE (sstart) == GST_EVENT_STREAM_START);
|
||||||
|
events_iter = g_list_next (events_iter);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
GstEvent *caps_event = events_iter->data;
|
||||||
|
fail_unless (GST_EVENT_TYPE (caps_event) == GST_EVENT_CAPS);
|
||||||
|
events_iter = g_list_next (events_iter);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
GstEvent *segment_event = events_iter->data;
|
||||||
|
fail_unless (GST_EVENT_TYPE (segment_event) == GST_EVENT_SEGMENT);
|
||||||
|
events_iter = g_list_next (events_iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check that EOS was received */
|
||||||
|
fail_unless (GST_PAD_IS_EOS (mysrcpad));
|
||||||
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_flush_start ()));
|
||||||
|
fail_unless (GST_PAD_IS_EOS (mysrcpad));
|
||||||
|
|
||||||
|
/* Check that we have tags */
|
||||||
|
{
|
||||||
|
GstEvent *tags = gst_pad_get_sticky_event (mysrcpad, GST_EVENT_TAG, 0);
|
||||||
|
|
||||||
|
fail_unless (tags != NULL);
|
||||||
|
gst_event_unref (tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that we still have a segment set */
|
||||||
|
{
|
||||||
|
GstEvent *segment =
|
||||||
|
gst_pad_get_sticky_event (mysrcpad, GST_EVENT_SEGMENT, 0);
|
||||||
|
|
||||||
|
fail_unless (segment != NULL);
|
||||||
|
gst_event_unref (segment);
|
||||||
|
}
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_flush_stop (TRUE)));
|
||||||
|
fail_if (GST_PAD_IS_EOS (mysrcpad));
|
||||||
|
|
||||||
|
/* Check that the segment was flushed on FLUSH_STOP */
|
||||||
|
{
|
||||||
|
GstEvent *segment =
|
||||||
|
gst_pad_get_sticky_event (mysrcpad, GST_EVENT_SEGMENT, 0);
|
||||||
|
|
||||||
|
fail_unless (segment == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the tags were not lost on FLUSH_STOP */
|
||||||
|
{
|
||||||
|
GstEvent *tags = gst_pad_get_sticky_event (mysrcpad, GST_EVENT_TAG, 0);
|
||||||
|
|
||||||
|
fail_unless (tags != NULL);
|
||||||
|
gst_event_unref (tags);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
|
||||||
|
buffers = NULL;
|
||||||
|
|
||||||
|
cleanup_audiodecodertest ();
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
GST_START_TEST (audiodecoder_buffer_after_segment)
|
GST_START_TEST (audiodecoder_buffer_after_segment)
|
||||||
{
|
{
|
||||||
|
@ -487,6 +590,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);
|
||||||
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);
|
||||||
tcase_add_test (tc, audiodecoder_delayed_negotiation_with_gap_event);
|
tcase_add_test (tc, audiodecoder_delayed_negotiation_with_gap_event);
|
||||||
|
|
Loading…
Reference in a new issue