Use dlfnc instead of gmodule 59/306059/4
authorminje.ahn <minje.ahn@samsung.com>
Fri, 16 Feb 2024 02:05:13 +0000 (11:05 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Fri, 16 Feb 2024 08:26:55 +0000 (08:26 +0000)
Change-Id: Iac10a0cb3459e673b4cc4d7a06b150ac31491273
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
imgp/CMakeLists.txt
imgp/mm_util_imgp.c
packaging/libmm-utility.spec

index 2fb3f2552802b16a2a02d0575104a63f1d21a4ee..f8ad85744be91315264682874501a88701ba3974 100644 (file)
@@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES(${INC_DIR}
     ../jpeg/include
 )
 
-SET(dependents "dlog glib-2.0 gmodule-2.0")
+SET(dependents "dlog glib-2.0")
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${fw_name} REQUIRED ${dependents})
@@ -39,7 +39,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
 aux_source_directory(. SOURCES)
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} mmutil_common)
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} mmutil_common -ldl)
 SET_TARGET_PROPERTIES(${fw_name}
     PROPERTIES
     VERSION ${VERSION}
index 6970a389d5c426d8926fd2b149796e72d952eacc..af16cf9bf5471194b3de9d68863c4bde22125744 100644 (file)
@@ -19,8 +19,9 @@
  *
  */
 
-#include <gmodule.h>
 #include <limits.h>
+#include <dlfcn.h>
+#include <glib.h>
 #include "mm_util_private.h"
 #include "mm_util_imgp.h"
 #include "mm_util_imgp_internal.h"
@@ -194,10 +195,10 @@ static int __mm_set_imgp_info_s(imgp_info_s *_imgp_info_s, mm_util_color_format_
        return ret;
 }
 
-static void __mm_util_imgp_finalize(GModule *module, imgp_info_s *_imgp_info_s)
+static void __mm_util_imgp_finalize(void *module, imgp_info_s *_imgp_info_s)
 {
        if (module)
-               g_module_close(module);
+               dlclose(module);
 
        g_free(_imgp_info_s);
 }
@@ -283,21 +284,18 @@ unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_wid
        }
 }
 
-static IMGPInfoFunc __mm_util_initialize(GModule **module)
+static IMGPInfoFunc __mm_util_initialize(void **module)
 {
-       GModule *_module = NULL;
+       void *_module = NULL;
        IMGPInfoFunc _func = NULL;
 
-       _module = g_module_open(PATH_GSTCS_LIB, G_MODULE_BIND_LAZY);
+       _module = dlopen(PATH_GSTCS_LIB, RTLD_LAZY);
        mm_util_retvm_if(!module, NULL, "%s module open failed", PATH_GSTCS_LIB);
 
-       mm_util_debug("module: %p, g_module_name: %s", _module, g_module_name(_module));
-
-       g_module_symbol(_module, IMGP_FUNC_NAME, (gpointer *)&_func);
-
+       _func = dlsym(_module, IMGP_FUNC_NAME);
        if (!_func) {
-               mm_util_error("invalid function");
-               g_module_close(_module);
+               mm_util_error("dlsym failed: %s", dlerror());
+               dlclose(_module);
                return NULL;
        }
 
@@ -318,7 +316,7 @@ int mm_util_convert_colorspace(mm_util_image_h src, mm_util_color_format_e color
 {
        int ret = MM_UTIL_ERROR_NONE;
        IMGPInfoFunc _mm_util_imgp_func = NULL;
-       GModule *_module = NULL;
+       void *_module = NULL;
        unsigned char *output_buffer = NULL;
        mm_image_info_s *_src = (mm_image_info_s *)src;
        mm_util_image_h _convert_image = NULL;
@@ -389,7 +387,7 @@ int mm_util_resize_image(mm_util_image_h src, unsigned int width, unsigned int h
 {
        int ret = MM_UTIL_ERROR_NONE;
        IMGPInfoFunc _mm_util_imgp_func = NULL;
-       GModule *_module = NULL;
+       void *_module = NULL;
        unsigned char *output_buffer = NULL;
        mm_image_info_s *_src = (mm_image_info_s *)src;
        mm_util_image_h _resize_image = NULL;
@@ -468,7 +466,7 @@ int mm_util_rotate_image(mm_util_image_h src, mm_util_rotate_type_e angle, mm_ut
 {
        int ret = MM_UTIL_ERROR_NONE;
        IMGPInfoFunc _mm_util_imgp_func = NULL;
-       GModule *_module = NULL;
+       void *_module = NULL;
        unsigned char *output_buffer = NULL;
        unsigned int uint_w = 0;
        unsigned int uint_h = 0;
index acde0cb027693359f45f80f5355dc4b6e42f7e31..811f55105fbbb23466aff25122259c23a2bb1be7 100644 (file)
@@ -14,7 +14,6 @@ BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(gio-2.0)
-BuildRequires:  pkgconfig(gmodule-2.0)
 BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  libjpeg-turbo-devel
 BuildRequires:  pkgconfig(libtzplatform-config)