From 3219b704fd6a6f24daef5a66e9251ae2e159a4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 25 Jan 2018 18:39:11 +0000 Subject: [PATCH] subparse: fix pushing out of last chunk if last line has no newline With playbin the last subtitle chunk would not get displayed if the last chunk was missing a newline at the end. This is because streamsynchronizer will hold back the EOS event until the audio and video streams are finished too, so subparse would never forcefully push out the last chunk until the very end when it is too late. We get a STREAM_GROUP_DONE event from streamsynchronizer however, so handle that like EOS and force out any remaining text then. https://bugzilla.gnome.org/show_bug.cgi?id=771853 --- gst/subparse/gstsubparse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index 4cf354d9a4..cf29a564b8 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -1841,9 +1841,10 @@ gst_sub_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) GstSubParse *self = GST_SUBPARSE (parent); gboolean ret = FALSE; - GST_DEBUG ("Handling %s event", GST_EVENT_TYPE_NAME (event)); + GST_LOG_OBJECT (self, "%s event", GST_EVENT_TYPE_NAME (event)); switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_STREAM_GROUP_DONE: case GST_EVENT_EOS:{ /* Make sure the last subrip chunk is pushed out even * if the file does not have an empty line at the end */ @@ -1854,7 +1855,9 @@ gst_sub_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gchar term_chars[] = { '\n', '\n', '\0' }; GstBuffer *buf = gst_buffer_new_and_alloc (2 + 1); - GST_DEBUG ("EOS. Pushing remaining text (if any)"); + GST_DEBUG_OBJECT (self, "%s: force pushing of any remaining text", + GST_EVENT_TYPE_NAME (event)); + gst_buffer_fill (buf, 0, term_chars, 3); gst_buffer_set_size (buf, 2);