[gstreamermm] Gst::QueryAllocation: fixed methods using AllocationParams objects



commit c95f95920c18e1cf9ce500e370f565678699a292
Author: Marcin Kolny <marcin kolny flytronic pl>
Date:   Tue Nov 25 15:20:14 2014 +0100

    Gst::QueryAllocation: fixed methods using AllocationParams objects
    
        * gstreamer/src/query.ccg: accessing to a gobject was done incorrect -
          not by gobj() method, but by dereferencing this object.
          AllocationParams holds pointer, to a GstAllocationParams, and not to
          a object, that's why previous solution didn't work fine.
        * tests/test-query.cc: added test which proves this fix.

 gstreamer/src/query.ccg |    6 +++---
 tests/test-query.cc     |   12 ++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gstreamer/src/query.ccg b/gstreamer/src/query.ccg
index 2c0af66..23c23d0 100644
--- a/gstreamer/src/query.ccg
+++ b/gstreamer/src/query.ccg
@@ -581,7 +581,7 @@ void QueryAllocation::remove_nth_allocation_pool(guint index)
 
 void QueryAllocation::add_allocation_param(const Glib::RefPtr<Allocator>& allocator, const AllocationParams& 
params)
 {
-  gst_query_add_allocation_param(gobj(), allocator->gobj(), (const GstAllocationParams*)&params);
+  gst_query_add_allocation_param(gobj(), allocator->gobj(), params.gobj());
 }
 
 guint QueryAllocation::get_n_allocation_params() const
@@ -592,13 +592,13 @@ guint QueryAllocation::get_n_allocation_params() const
 void QueryAllocation::parse_nth_allocation_param(guint index, Glib::RefPtr<Allocator>& allocator, 
AllocationParams& params) const
 {
   GstAllocator* n_allocator;
-  gst_query_parse_nth_allocation_param(const_cast<GstQuery*>(gobj()), index, &n_allocator, 
(GstAllocationParams*)&params);
+  gst_query_parse_nth_allocation_param(const_cast<GstQuery*>(gobj()), index, &n_allocator, params.gobj());
   allocator = Glib::wrap(n_allocator, false);
 }
 
 void QueryAllocation::set_nth_allocation_param(guint index, const Glib::RefPtr<Allocator>& allocator, const 
AllocationParams& params)
 {
-  gst_query_set_nth_allocation_param(gobj(), index, allocator->gobj(), (const GstAllocationParams*)&params);
+  gst_query_set_nth_allocation_param(gobj(), index, allocator->gobj(), params.gobj());
 }
 
 void QueryAllocation::remove_nth_allocation_param(guint index)
diff --git a/tests/test-query.cc b/tests/test-query.cc
index b075159..63e9aa7 100644
--- a/tests/test-query.cc
+++ b/tests/test-query.cc
@@ -68,4 +68,16 @@ TEST(QueryTest, CheckRefCountsDuringQueryCapsCreation)
   ASSERT_EQ(3, caps->gobj()->mini_object.refcount); // - 1 (caps object) + 1 (filter object) + 1 (owned by 
query) = 3
 }
 
+TEST(QueryTest, CheckStoringAllocationParams)
+{
+  auto alloc_query = QueryAllocation::create(Caps::create_from_string("video/x-raw, format=RGB"), false);
+  RefPtr<Allocator> allocator = Allocator::get_default_allocator(), allocator2;
+  AllocationParams params, params2;
+  params.init(); params.set_align(10);
+  alloc_query->add_allocation_param(allocator, params);
+  alloc_query->parse_nth_allocation_param(0, allocator2, params2);
+  ASSERT_EQ(allocator, allocator2);
+  ASSERT_EQ(params.get_align(), params2.get_align());
+}
+
 


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