[0.11] gst-plugins-base: audioencoder: turn assert into a real error

Wim Taymans wtay at kemper.freedesktop.org
Mon Jan 2 06:42:59 PST 2012


Module: gst-plugins-base
Branch: 0.11
Commit: e9eaf17eae5a6649acf867668285dd65e9627422
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=e9eaf17eae5a6649acf867668285dd65e9627422

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Mon Jan  2 15:39:58 2012 +0100

audioencoder: turn assert into a real error

Post a real error instead of just asserting. Fixes a unit test.

---

 gst-libs/gst/audio/gstaudioencoder.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c
index bdce4ca..d4c387a 100644
--- a/gst-libs/gst/audio/gstaudioencoder.c
+++ b/gst-libs/gst/audio/gstaudioencoder.c
@@ -489,12 +489,14 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
   priv = enc->priv;
   ctx = &enc->priv->ctx;
 
-  /* subclass should know what it is producing by now */
-  g_return_val_if_fail (gst_pad_has_current_caps (enc->srcpad), GST_FLOW_ERROR);
   /* subclass should not hand us no data */
   g_return_val_if_fail (buf == NULL || gst_buffer_get_size (buf) > 0,
       GST_FLOW_ERROR);
 
+  /* subclass should know what it is producing by now */
+  if (!gst_pad_has_current_caps (enc->srcpad))
+    goto no_caps;
+
   GST_AUDIO_ENCODER_STREAM_LOCK (enc);
 
   GST_LOG_OBJECT (enc,
@@ -693,6 +695,11 @@ exit:
   return ret;
 
   /* ERRORS */
+no_caps:
+  {
+    GST_ELEMENT_ERROR (enc, STREAM, ENCODE, ("no caps set"), (NULL));
+    return GST_FLOW_ERROR;
+  }
 overflow:
   {
     GST_ELEMENT_ERROR (enc, STREAM, ENCODE,



More information about the gstreamer-commits mailing list