Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:smarty12:multimedia
nnstreamer
nnstreamer-fix-glib-2.68.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File nnstreamer-fix-glib-2.68.patch of Package nnstreamer
From 85c7fe1ad940a60f91a40c8a502042fb12461124 Mon Sep 17 00:00:00 2001 From: Julien Vuillaumier <julien.vuillaumier@nxp.com> Date: Wed, 3 Nov 2021 14:46:09 +0100 Subject: [PATCH] [Build] Add g_memdup2() support for glib >= 2.68 Update to fix build with glib version 2.68 and later Legacy function: gpointer g_memdup ( gconstpointer mem, guint byte_size ) is deprecated since version 2.68 and replaced by: gpointer g_memdup2 ( gconstpointer mem, gsize byte_size ) Difference is byte_size argument type changed from guint to gsize. Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com> --- ext/nnstreamer/extra/nnstreamer_grpc_flatbuf.cc | 3 ++- ext/nnstreamer/extra/nnstreamer_grpc_protobuf.cc | 3 ++- ext/nnstreamer/extra/nnstreamer_protobuf.cc | 4 ++-- .../tensor_converter/tensor_converter_python3.cc | 5 +++-- gst/nnstreamer/include/nnstreamer_util.h | 9 +++++++++ meson.build | 3 +++ tests/gstreamer_join/unittest_join.cc | 5 +++-- tests/nnstreamer_converter/unittest_converter.cc | 8 +++++--- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ext/nnstreamer/extra/nnstreamer_grpc_flatbuf.cc b/ext/nnstreamer/extra/nnstreamer_grpc_flatbuf.cc index 793291513..844b83e7e 100644 --- a/ext/nnstreamer/extra/nnstreamer_grpc_flatbuf.cc +++ b/ext/nnstreamer/extra/nnstreamer_grpc_flatbuf.cc @@ -16,6 +16,7 @@ #include <nnstreamer_log.h> #include <nnstreamer_plugin_api.h> +#include <nnstreamer_util.h> #include <thread> @@ -119,7 +120,7 @@ ServiceImplFlatbuf::_get_buffer_from_tensors (Message<Tensors> &msg, const Tensor * tensor = tensors->tensor ()->Get (i); const void * data = tensor->data ()->data (); gsize size = VectorLength (tensor->data ()); - gpointer new_data = g_memdup (data, size); + gpointer new_data = _g_memdup (data, size); memory = gst_memory_new_wrapped ((GstMemoryFlags) 0, new_data, size, 0, size, new_data, g_free); diff --git a/ext/nnstreamer/extra/nnstreamer_grpc_protobuf.cc b/ext/nnstreamer/extra/nnstreamer_grpc_protobuf.cc index 333e1a958..119a025b2 100644 --- a/ext/nnstreamer/extra/nnstreamer_grpc_protobuf.cc +++ b/ext/nnstreamer/extra/nnstreamer_grpc_protobuf.cc @@ -16,6 +16,7 @@ #include <nnstreamer_log.h> #include <nnstreamer_plugin_api.h> +#include <nnstreamer_util.h> #include <thread> @@ -113,7 +114,7 @@ ServiceImplProtobuf::_get_buffer_from_tensors (Tensors &tensors, const Tensor * tensor = &tensors.tensor (i); const void * data = tensor->data ().c_str (); gsize size = tensor->data ().length (); - gpointer new_data = g_memdup (data, size); + gpointer new_data = _g_memdup (data, size); memory = gst_memory_new_wrapped ((GstMemoryFlags) 0, new_data, size, 0, size, new_data, g_free); diff --git a/ext/nnstreamer/extra/nnstreamer_protobuf.cc b/ext/nnstreamer/extra/nnstreamer_protobuf.cc index 1e1f92bab..93ab75eab 100644 --- a/ext/nnstreamer/extra/nnstreamer_protobuf.cc +++ b/ext/nnstreamer/extra/nnstreamer_protobuf.cc @@ -125,7 +125,7 @@ gst_tensor_converter_protobuf (GstBuffer *in_buf, GstTensorsConfig *config, void GstMemory *in_mem, *out_mem; GstMapInfo in_info; GstBuffer *out_buf; - guint mem_size; + gsize mem_size; gpointer mem_data; UNUSED (priv_data); @@ -160,7 +160,7 @@ gst_tensor_converter_protobuf (GstBuffer *in_buf, GstTensorsConfig *config, void config->info.info[i].dimension[j] = tensor->dimension (j); } mem_size = tensor->data ().length (); - mem_data = g_memdup (tensor->data ().c_str (), mem_size); + mem_data = _g_memdup (tensor->data ().c_str (), mem_size); out_mem = gst_memory_new_wrapped ((GstMemoryFlags) 0, mem_data, mem_size, 0, mem_size, NULL, NULL); diff --git a/ext/nnstreamer/tensor_converter/tensor_converter_python3.cc b/ext/nnstreamer/tensor_converter/tensor_converter_python3.cc index 6a9e8eac2..c7407d33a 100644 --- a/ext/nnstreamer/tensor_converter/tensor_converter_python3.cc +++ b/ext/nnstreamer/tensor_converter/tensor_converter_python3.cc @@ -140,7 +140,8 @@ PYConverterCore::convert (GstBuffer *in_buf, GstTensorsConfig *config) GstBuffer *out_buf = NULL; PyObject *tensors_info = NULL, *output = NULL, *pyValue = NULL; gint rate_n, rate_d; - guint i, num, mem_size; + guint i, num; + gsize mem_size; gpointer mem_data; if (nullptr == in_buf) @@ -196,7 +197,7 @@ PYConverterCore::convert (GstBuffer *in_buf, GstTensorsConfig *config) = (PyArrayObject *)PyList_GetItem (output, (Py_ssize_t)i); mem_size = PyArray_SIZE (output_array); - mem_data = g_memdup ((guint8 *) PyArray_DATA (output_array), mem_size); + mem_data = _g_memdup ((guint8 *) PyArray_DATA (output_array), mem_size); out_mem = gst_memory_new_wrapped ((GstMemoryFlags) 0, mem_data, mem_size, 0, mem_size, mem_data, g_free); diff --git a/gst/nnstreamer/include/nnstreamer_util.h b/gst/nnstreamer/include/nnstreamer_util.h index de53c2c5b..4a2c4adeb 100644 --- a/gst/nnstreamer/include/nnstreamer_util.h +++ b/gst/nnstreamer/include/nnstreamer_util.h @@ -22,4 +22,13 @@ #define UNUSED(expr) do { (void)(expr); } while (0) #endif +/** + * @brief g_memdup() function replaced by g_memdup2() in glib version >= 2.68 + */ +#if GLIB_USE_G_MEMDUP2 +#define _g_memdup(data, size) g_memdup2 (data, size) +#else +#define _g_memdup(data, size) g_memdup (data, size) +#endif + #endif /* __NNSTREAMER_UTIL_H__ */ diff --git a/meson.build b/meson.build index 48a2024b5..856632d1e 100644 --- a/meson.build +++ b/meson.build @@ -128,6 +128,9 @@ add_project_arguments('-DNNSTREAMER_CONF_FILE="' + join_paths(nnstreamer_inidir, # Dependencies glib_dep = dependency('glib-2.0') +if glib_dep.version().version_compare('>= 2.68.0') + add_project_arguments('-DGLIB_USE_G_MEMDUP2', language: ['c', 'cpp']) +endif gobject_dep = dependency('gobject-2.0') gmodule_dep = dependency('gmodule-2.0') gio_dep = dependency('gio-2.0') diff --git a/tests/gstreamer_join/unittest_join.cc b/tests/gstreamer_join/unittest_join.cc index 8a551b96a..41a65ff72 100644 --- a/tests/gstreamer_join/unittest_join.cc +++ b/tests/gstreamer_join/unittest_join.cc @@ -12,6 +12,7 @@ #include <glib/gstdio.h> #include <gst/app/gstappsrc.h> #include <gst/gst.h> +#include <nnstreamer_util.h> #include <unittest_util.h> static int data_received; @@ -92,10 +93,10 @@ TEST (join, normal0) g_signal_connect (sink_handle, "new-data", (GCallback)new_data_cb, (gpointer)&idx); - buf_0 = gst_buffer_new_wrapped (g_memdup (test_frames[0], 192), 192); + buf_0 = gst_buffer_new_wrapped (_g_memdup (test_frames[0], 192), 192); buf_3 = gst_buffer_copy (buf_0); - buf_1 = gst_buffer_new_wrapped (g_memdup (test_frames[1], 192), 192); + buf_1 = gst_buffer_new_wrapped (_g_memdup (test_frames[1], 192), 192); buf_4 = gst_buffer_copy (buf_1); data_received = 0; diff --git a/tests/nnstreamer_converter/unittest_converter.cc b/tests/nnstreamer_converter/unittest_converter.cc index 63ab972ac..629f53942 100644 --- a/tests/nnstreamer_converter/unittest_converter.cc +++ b/tests/nnstreamer_converter/unittest_converter.cc @@ -16,6 +16,8 @@ #include <flatbuffers/flexbuffers.h> #include <gst/app/gstappsrc.h> #include <nnstreamer_plugin_api_converter.h> +#include <nnstreamer_util.h> + #define TEST_TIMEOUT_MS (10000U) @@ -66,7 +68,7 @@ tensor_converter_custom_cb (GstBuffer *in_buf, } flexbuffers::Blob tensor_data = tensor[3].AsBlob (); mem_size = tensor_data.size (); - mem_data = g_memdup (tensor_data.data (), mem_size); + mem_data = _g_memdup (tensor_data.data (), mem_size); out_mem = gst_memory_new_wrapped ((GstMemoryFlags) 0, mem_data, mem_size, 0, mem_size, mem_data, g_free); @@ -395,8 +397,8 @@ TEST (tensorConverterPython, dynamicDimension) data_received = (guint *) g_malloc0 (sizeof (guint)); g_signal_connect (sink_handle, "new-data", (GCallback)new_data_cb, data_received); - buf_0 = gst_buffer_new_wrapped (g_memdup (_test_frames1, 96), 96); - buf_1 = gst_buffer_new_wrapped (g_memdup (_test_frames2, 192), 192); + buf_0 = gst_buffer_new_wrapped (_g_memdup (_test_frames1, 96), 96); + buf_1 = gst_buffer_new_wrapped (_g_memdup (_test_frames2, 192), 192); buf_2 = gst_buffer_copy (buf_0); EXPECT_EQ (setPipelineStateSync (pipeline, GST_STATE_PLAYING, TEST_TIMEOUT_MS), 0);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor