[gstreamermm: 145/167] fixed Buffer::create_writeable method



commit 6a4173ad30873e464c602cdb6b92b3322e14c345
Author: Marcin Kolny [loganek] <marcin kolny gmail com>
Date:   Wed Aug 7 00:14:35 2013 +0200

    fixed Buffer::create_writeable method

 gstreamer/src/buffer.ccg |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/gstreamer/src/buffer.ccg b/gstreamer/src/buffer.ccg
index cce27e2..c3a8b7d 100644
--- a/gstreamer/src/buffer.ccg
+++ b/gstreamer/src/buffer.ccg
@@ -32,7 +32,15 @@ Glib::RefPtr<Gst::Buffer> Buffer::copy() const
 
 Glib::RefPtr<Gst::Buffer> Buffer::create_writable()
 {
-  return Glib::wrap(gst_buffer_make_writable(gobj()), true);
+  if(is_writable())  // caller has the only one reference to the buffer
+  {                 // since there is no other ref to the buffer, nobody else can do a ref in the meantime
+    return Glib::wrap(gst_buffer_make_writable(gobj()), true); // take copy so original object is left to 
the current owner (and hopefully will be released soon)
+  }
+  else
+  {
+    reference(); // gst_buffer_make_writable(buf) will unref the old buffer, but our caller is still holding 
RefPtr to it
+    return Glib::wrap(gst_buffer_make_writable(gobj()));
+  }
 }
 
 Glib::RefPtr<Gst::Buffer> Buffer::create(guint size)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]