[0.10] gst-plugins-bad: kateenc: Don't error on empty input buffers

Tim Müller tpm at kemper.freedesktop.org
Mon Jan 30 04:41:44 PST 2012


Module: gst-plugins-bad
Branch: 0.10
Commit: 6f60610f911294e969aec614c8f06be0fe036fe1
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=6f60610f911294e969aec614c8f06be0fe036fe1

Author: David Schleef <ds at schleef.org>
Date:   Thu Aug  4 13:05:22 2011 -0700

kateenc: Don't error on empty input buffers

---

 ext/kate/gstkateenc.c |   36 +++++++++++++++++-------------------
 1 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/ext/kate/gstkateenc.c b/ext/kate/gstkateenc.c
index e378a5c..8b782c6 100644
--- a/ext/kate/gstkateenc.c
+++ b/ext/kate/gstkateenc.c
@@ -952,27 +952,25 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
     rflow = GST_FLOW_ERROR;
   } else {
     const char *text = (const char *) GST_BUFFER_DATA (buf);
-    if (text) {
-      size_t text_len = GST_BUFFER_SIZE (buf);
-      kate_float t0 = start / (double) GST_SECOND;
-      kate_float t1 = stop / (double) GST_SECOND;
-      GST_LOG_OBJECT (ke, "Encoding text: %*.*s (%u bytes) from %f to %f",
-          (int) text_len, (int) text_len, GST_BUFFER_DATA (buf),
-          GST_BUFFER_SIZE (buf), t0, t1);
-      ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp);
-      if (G_UNLIKELY (ret < 0)) {
-        GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
-            ("Failed to encode text: %d", ret));
-        rflow = GST_FLOW_ERROR;
-      } else {
-        rflow =
-            gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1);
-      }
-    } else {
-      /* FIXME: this should not be an error, we should ignore it and move on */
+    size_t text_len = GST_BUFFER_SIZE (buf);
+    kate_float t0 = start / (double) GST_SECOND;
+    kate_float t1 = stop / (double) GST_SECOND;
+
+    if (text == NULL) {
+      text = "";
+      text_len = 0;
+    }
+
+    GST_LOG_OBJECT (ke, "Encoding text: %*.*s (%u bytes) from %f to %f",
+        (int) text_len, (int) text_len, GST_BUFFER_DATA (buf),
+        GST_BUFFER_SIZE (buf), t0, t1);
+    ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp);
+    if (G_UNLIKELY (ret < 0)) {
       GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
-          ("no text in text packet"));
+          ("Failed to encode text: %d", ret));
       rflow = GST_FLOW_ERROR;
+    } else {
+      rflow = gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1);
     }
   }
 



More information about the gstreamer-commits mailing list