kateenc: Don't error on empty input buffers

This commit is contained in:
David Schleef 2011-08-04 13:05:22 -07:00
parent c92efe38e9
commit 6786f8c7bf

View file

@ -952,27 +952,25 @@ gst_kate_enc_chain_text (GstKateEnc * ke, GstBuffer * buf,
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else { } else {
const char *text = (const char *) GST_BUFFER_DATA (buf); const char *text = (const char *) GST_BUFFER_DATA (buf);
if (text) { size_t text_len = GST_BUFFER_SIZE (buf);
size_t text_len = GST_BUFFER_SIZE (buf); kate_float t0 = start / (double) GST_SECOND;
kate_float t0 = start / (double) GST_SECOND; kate_float t1 = stop / (double) GST_SECOND;
kate_float t1 = stop / (double) GST_SECOND;
GST_LOG_OBJECT (ke, "Encoding text: %*.*s (%u bytes) from %f to %f", if (text == NULL) {
(int) text_len, (int) text_len, GST_BUFFER_DATA (buf), text = "";
GST_BUFFER_SIZE (buf), t0, t1); text_len = 0;
ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp); }
if (G_UNLIKELY (ret < 0)) {
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_LOG_OBJECT (ke, "Encoding text: %*.*s (%u bytes) from %f to %f",
("Failed to encode text: %d", ret)); (int) text_len, (int) text_len, GST_BUFFER_DATA (buf),
rflow = GST_FLOW_ERROR; GST_BUFFER_SIZE (buf), t0, t1);
} else { ret = kate_encode_text (&ke->k, t0, t1, text, text_len, &kp);
rflow = if (G_UNLIKELY (ret < 0)) {
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 */
GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL), GST_ELEMENT_ERROR (ke, STREAM, ENCODE, (NULL),
("no text in text packet")); ("Failed to encode text: %d", ret));
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} else {
rflow = gst_kate_enc_chain_push_packet (ke, &kp, start, stop - start + 1);
} }
} }