[0.10] gst-plugins-good: jpegenc: check _alloc_buffer result and perform fallback alloc if needed

Tim Müller tpm at kemper.freedesktop.org
Mon Jan 23 15:40:59 PST 2012


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

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Fri Jan 20 16:44:21 2012 +0100

jpegenc: check _alloc_buffer result and perform fallback alloc if needed

... rather than carrying on with NULL buffer.

---

 ext/jpeg/gstjpegenc.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c
index 98c7e09..c44cb2e 100644
--- a/ext/jpeg/gstjpegenc.c
+++ b/ext/jpeg/gstjpegenc.c
@@ -210,15 +210,23 @@ gst_jpegenc_flush_destination (j_compress_ptr cinfo)
   GstBuffer *overflow_buffer;
   guint32 old_buffer_size;
   GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
+  GstFlowReturn ret;
+
   GST_DEBUG_OBJECT (jpegenc,
       "gst_jpegenc_chain: flush_destination: buffer too small");
 
   /* Our output buffer wasn't big enough.
    * Make a new buffer that's twice the size, */
   old_buffer_size = GST_BUFFER_SIZE (jpegenc->output_buffer);
-  gst_pad_alloc_buffer_and_set_caps (jpegenc->srcpad,
+  ret = gst_pad_alloc_buffer_and_set_caps (jpegenc->srcpad,
       GST_BUFFER_OFFSET_NONE, old_buffer_size * 2,
       GST_PAD_CAPS (jpegenc->srcpad), &overflow_buffer);
+  /* handle here if needed */
+  if (ret != GST_FLOW_OK) {
+    overflow_buffer = gst_buffer_new_and_alloc (old_buffer_size * 2);
+    gst_buffer_set_caps (overflow_buffer, GST_PAD_CAPS (jpegenc->srcpad));
+  }
+
   memcpy (GST_BUFFER_DATA (overflow_buffer),
       GST_BUFFER_DATA (jpegenc->output_buffer), old_buffer_size);
 



More information about the gstreamer-commits mailing list