gst-plugins-bad: opus: Handle GstByteWriter return values

Sebastian Dröge slomo at kemper.freedesktop.org
Wed Apr 25 01:31:09 PDT 2012


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

Author: Edward Hervey <edward.hervey at collabora.co.uk>
Date:   Wed Apr  4 11:51:28 2012 +0200

opus: Handle GstByteWriter return values

---

 ext/opus/gstopusheader.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/ext/opus/gstopusheader.c b/ext/opus/gstopusheader.c
index 2de891d..8dc5d27 100644
--- a/ext/opus/gstopusheader.c
+++ b/ext/opus/gstopusheader.c
@@ -33,6 +33,7 @@ gst_opus_enc_create_id_buffer (gint nchannels, gint n_stereo_streams,
 {
   GstBuffer *buffer;
   GstByteWriter bw;
+  gboolean hdl = TRUE;
 
   g_return_val_if_fail (nchannels > 0 && nchannels < 256, NULL);
   g_return_val_if_fail (n_stereo_streams >= 0, NULL);
@@ -41,19 +42,22 @@ gst_opus_enc_create_id_buffer (gint nchannels, gint n_stereo_streams,
   gst_byte_writer_init (&bw);
 
   /* See http://wiki.xiph.org/OggOpus */
-  gst_byte_writer_put_data (&bw, (const guint8 *) "OpusHead", 8);
-  gst_byte_writer_put_uint8 (&bw, 0);   /* version number */
-  gst_byte_writer_put_uint8 (&bw, nchannels);
-  gst_byte_writer_put_uint16_le (&bw, 0);       /* pre-skip */
-  gst_byte_writer_put_uint32_le (&bw, sample_rate);
-  gst_byte_writer_put_uint16_le (&bw, 0);       /* output gain */
-  gst_byte_writer_put_uint8 (&bw, channel_mapping_family);
+  hdl &= gst_byte_writer_put_data (&bw, (const guint8 *) "OpusHead", 8);
+  hdl &= gst_byte_writer_put_uint8 (&bw, 0);    /* version number */
+  hdl &= gst_byte_writer_put_uint8 (&bw, nchannels);
+  hdl &= gst_byte_writer_put_uint16_le (&bw, 0);        /* pre-skip */
+  hdl &= gst_byte_writer_put_uint32_le (&bw, sample_rate);
+  hdl &= gst_byte_writer_put_uint16_le (&bw, 0);        /* output gain */
+  hdl &= gst_byte_writer_put_uint8 (&bw, channel_mapping_family);
   if (channel_mapping_family > 0) {
-    gst_byte_writer_put_uint8 (&bw, nchannels - n_stereo_streams);
-    gst_byte_writer_put_uint8 (&bw, n_stereo_streams);
-    gst_byte_writer_put_data (&bw, channel_mapping, nchannels);
+    hdl &= gst_byte_writer_put_uint8 (&bw, nchannels - n_stereo_streams);
+    hdl &= gst_byte_writer_put_uint8 (&bw, n_stereo_streams);
+    hdl &= gst_byte_writer_put_data (&bw, channel_mapping, nchannels);
   }
 
+  if (!hdl)
+    GST_WARNING ("Error creating header");
+
   buffer = gst_byte_writer_reset_and_get_buffer (&bw);
 
   GST_BUFFER_OFFSET (buffer) = 0;



More information about the gstreamer-commits mailing list