From bbddac17ae27a93c8a20b2919371593759524d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 15 Dec 2005 10:15:10 +0000 Subject: [PATCH] ext/pango/gsttextoverlay.c: Don't operate on empty text buffers. Strip newlines and tabs only from the end of the tex... Original commit message from CVS: * ext/pango/gsttextoverlay.c: (gst_text_overlay_collected): Don't operate on empty text buffers. Strip newlines and tabs only from the end of the text, but leave them intact in the middle. Fix typo in gtk-doc description. --- ChangeLog | 7 +++++++ ext/pango/gsttextoverlay.c | 13 ++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4194584927..4be0111239 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-12-15 Tim-Philipp Müller + + * ext/pango/gsttextoverlay.c: (gst_text_overlay_collected): + Don't operate on empty text buffers. Strip newlines and + tabs only from the end of the text, but leave them intact + in the middle. Fix typo in gtk-doc description. + 2005-12-15 Tim-Philipp Müller * gst/playback/gstplaybasebin.c: diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index ec3fe4757e..150c128146 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -49,7 +49,7 @@ * * gst-launch -v filesrc location=subtitles.srt ! subparse ! txt. videotestsrc ! timeoverlay ! textoverlay name=txt shaded-background=yes ! xvimagesink * - * If you do not have such a subtitle file, create on looking like this + * If you do not have such a subtitle file, create one looking like this * in a text editor: * * 1 @@ -870,7 +870,6 @@ gst_text_overlay_collected (GstCollectPads * pads, gpointer data) GstBuffer *video_frame = NULL; GstBuffer *text_buf = NULL; gchar *text; - gint text_len; overlay = GST_TEXT_OVERLAY (data); klass = GST_TEXT_OVERLAY_GET_CLASS (data); @@ -983,10 +982,14 @@ gst_text_overlay_collected (GstCollectPads * pads, gpointer data) /* text duration overlaps video frame duration */ text = g_strndup ((gchar *) GST_BUFFER_DATA (text_buf), GST_BUFFER_SIZE (text_buf)); - g_strdelimit (text, "\n\r\t", ' '); - text_len = strlen (text); - if (text_len > 0) { + if (text != NULL && *text != '\0') { + gint text_len = strlen (text); + + while (text_len > 0 && (text[text_len - 1] == '\n' || + text[text_len - 1] == '\r')) { + --text_len; + } GST_DEBUG ("Rendering text '%*s'", text_len, text);; gst_text_overlay_render_text (overlay, text, text_len); } else {