diff options
| author | Edgard Lima <edgard.lima@indt.org.br> | 2005-10-28 19:19:40 +0000 | 
|---|---|---|
| committer | Edgard Lima <edgard.lima@indt.org.br> | 2005-10-28 19:19:40 +0000 | 
| commit | 758cd8fd1855f26d4e59ca1036e71d043aa9aaa1 (patch) | |
| tree | 87470c6b9e2f18c2cb89a24b20fec3d65e83b5c4 | |
| parent | 0166570e093c14e10a5c0e64ada784357dc8aa0f (diff) | |
Add checks for return values from gst_pad_push and gst_pad_alloc_buffer.
Original commit message from CVS:
Add checks for return values from gst_pad_push and gst_pad_alloc_buffer.
| -rw-r--r-- | ChangeLog | 7 | ||||
| m--------- | common | 0 | ||||
| -rw-r--r-- | ext/speex/gstspeexenc.c | 46 | 
3 files changed, 40 insertions, 13 deletions
@@ -1,3 +1,10 @@ +2005-10-28  Edgard Lima <edgard.lima@cin.ufpe.br> + +	* ext/speex/gstspeexenc.c: (gst_speexenc_chain),  +	(gst_speexenc_push_buffer): +	Add checks for return values from gst_pad_push and +	gst_pad_alloc_buffer. +  2005-10-28  Michal Benes  <michal dot benes at xeris dot cz>  	Reviewed by: Tim-Philipp Müller  <tim at centricular dot net> diff --git a/common b/common -Subproject 1cb5d7b76a01c711674c752015089e70c394fa9 +Subproject a0c6a14dbc3cb62bf513502eaef83d0600a7c1c diff --git a/ext/speex/gstspeexenc.c b/ext/speex/gstspeexenc.c index bd84ea7f..8dea5a07 100644 --- a/ext/speex/gstspeexenc.c +++ b/ext/speex/gstspeexenc.c @@ -813,17 +813,15 @@ gst_speexenc_buffer_from_data (GstSpeexEnc * speexenc, guchar * data,    return outbuf;  } +  /* push out the buffer and do internal bookkeeping */ -static void +static GstFlowReturn  gst_speexenc_push_buffer (GstSpeexEnc * speexenc, GstBuffer * buffer)  {    speexenc->bytes_out += GST_BUFFER_SIZE (buffer); -  if (GST_PAD_IS_USABLE (speexenc->srcpad)) { -    gst_pad_push (speexenc->srcpad, buffer); -  } else { -    gst_buffer_unref (buffer); -  } +  return gst_pad_push (speexenc->srcpad, buffer); +  }  static GstCaps * @@ -890,18 +888,21 @@ gst_speexenc_sinkevent (GstPad * pad, GstEvent * event)    return res;  } +  static GstFlowReturn  gst_speexenc_chain (GstPad * pad, GstBuffer * buf)  {    GstSpeexEnc *speexenc; +  GstFlowReturn ret = GST_FLOW_OK; -  speexenc = GST_SPEEXENC (GST_PAD_PARENT (pad)); +  speexenc = GST_SPEEXENC (gst_pad_get_parent (pad));    if (!speexenc->setup) {      gst_buffer_unref (buf);      GST_ELEMENT_ERROR (speexenc, CORE, NEGOTIATION, (NULL),          ("encoder not initialized (input is not audio?)")); -    return GST_FLOW_UNEXPECTED; +    ret = GST_FLOW_UNEXPECTED; +    goto error;    }    if (!speexenc->header_sent) { @@ -939,8 +940,15 @@ gst_speexenc_chain (GstPad * pad, GstBuffer * buf)      gst_buffer_set_caps (buf2, caps);      /* push out buffers */ -    gst_speexenc_push_buffer (speexenc, buf1); -    gst_speexenc_push_buffer (speexenc, buf2); +    if (GST_FLOW_OK != (ret = gst_speexenc_push_buffer (speexenc, buf1))) { +      gst_buffer_unref (buf1); +      goto error; +    } + +    if (GST_FLOW_OK != (ret = gst_speexenc_push_buffer (speexenc, buf2))) { +      gst_buffer_unref (buf2); +      goto error; +    }      speex_bits_init (&speexenc->bits);      speex_bits_reset (&speexenc->bits); @@ -983,10 +991,14 @@ gst_speexenc_chain (GstPad * pad, GstBuffer * buf)        speex_bits_insert_terminator (&speexenc->bits);        outsize = speex_bits_nbytes (&speexenc->bits); -      gst_pad_alloc_buffer (speexenc->srcpad, +      ret = gst_pad_alloc_buffer (speexenc->srcpad,            GST_BUFFER_OFFSET_NONE, outsize, GST_PAD_CAPS (speexenc->srcpad),            &outbuf); +      if (GST_FLOW_OK != ret) { +        goto error; +      } +        written = speex_bits_write (&speexenc->bits,            (gchar *) GST_BUFFER_DATA (outbuf), outsize);        g_assert (written == outsize); @@ -1000,13 +1012,21 @@ gst_speexenc_chain (GstPad * pad, GstBuffer * buf)        GST_BUFFER_OFFSET_END (outbuf) =            speexenc->frameno * frame_size - speexenc->lookahead; -      gst_speexenc_push_buffer (speexenc, outbuf); +      if (GST_FLOW_OK != (ret = gst_speexenc_push_buffer (speexenc, outbuf))) { +        printf ("ret = %d\n", ret); +        // gst_buffer_unref(outbuf); +        //      goto error; +      }      }    } -  return GST_FLOW_OK; +error: + +  gst_object_unref (speexenc); +  return ret;  } +  static void  gst_speexenc_get_property (GObject * object, guint prop_id, GValue * value,      GParamSpec * pspec)  | 
