[gstreamermm] Gst::Buffer: fixed copy method
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::Buffer: fixed copy method
- Date: Thu, 30 Oct 2014 10:57:44 +0000 (UTC)
commit e0dc1e083f0867d7afd08b79e2ffcb899f8080b9
Author: Marcin Kolny <marcin kolny flytronic pl>
Date: Thu Oct 30 11:51:39 2014 +0100
Gst::Buffer: fixed copy method
* gstreamer/src/buffer.ccg: copy method should take ownership of new
buffer, and shouldn't increase refcount.
* gstreamer/src/miniobject.hg: added missing <map> header.
* tests/test-buffer.cc: added test which checks refcout after copying
buffer.
gstreamer/src/buffer.ccg | 2 +-
gstreamer/src/miniobject.hg | 2 ++
tests/test-buffer.cc | 10 +++++++++-
3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gstreamer/src/buffer.ccg b/gstreamer/src/buffer.ccg
index 4f93d05..dec627c 100644
--- a/gstreamer/src/buffer.ccg
+++ b/gstreamer/src/buffer.ccg
@@ -27,7 +27,7 @@ namespace Gst
Glib::RefPtr<Gst::Buffer> Buffer::copy() const
{
- return Glib::wrap(gst_buffer_copy(gobj()), true);
+ return Glib::wrap(gst_buffer_copy(gobj()), false);
}
Glib::RefPtr<Gst::Buffer> Buffer::create(guint size)
diff --git a/gstreamer/src/miniobject.hg b/gstreamer/src/miniobject.hg
index ef059f3..785d63e 100644
--- a/gstreamer/src/miniobject.hg
+++ b/gstreamer/src/miniobject.hg
@@ -21,6 +21,8 @@
#include <glibmm/value.h>
#include <sigc++/sigc++.h>
+#include <map>
+
_DEFS(gstreamermm,gst)
namespace Gst
diff --git a/tests/test-buffer.cc b/tests/test-buffer.cc
index 2b7f034..ded6227 100644
--- a/tests/test-buffer.cc
+++ b/tests/test-buffer.cc
@@ -83,10 +83,18 @@ TEST(BufferTest, ShouldResetMemoryPointerButAllowIncreaseRefcount)
ASSERT_EQ(1, mem2->gobj()->mini_object.refcount);
}
-TEST(BufferTest, CheckBufferRefcountAfterCopying)
+TEST(BufferTest, CheckBufferRefcountAfterCopyingRegion)
{
Glib::RefPtr<Buffer> buf = Buffer::create(10);
auto b = buf->copy_region(BUFFER_COPY_MEMORY, 0, 10);
ASSERT_EQ(1, b->gobj()->mini_object.refcount);
ASSERT_EQ(1, buf->gobj()->mini_object.refcount);
}
+
+TEST(BufferTest, CheckBufferRefcountAfterCopying)
+{
+ Glib::RefPtr<Buffer> buf = Buffer::create(10);
+ auto b = buf->copy();
+ ASSERT_EQ(1, b->gobj()->mini_object.refcount);
+ ASSERT_EQ(1, buf->gobj()->mini_object.refcount);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]