From 00cf6705198a09361de5409cb99005cf8821adc3 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Tue, 19 Mar 2019 11:36:38 +0900 Subject: [PATCH] [Subplugin] Remove dlsym subplugin loader We no longer need dlsym subplugin loader, which make it incompatible with statically built subplugins. Subplugins have been calling register_subplugin in its init functions; thus removing dlsym routines is ok. Fixes #1130 Signed-off-by: MyungJoo Ham --- gst/nnstreamer/nnstreamer_subplugin.c | 42 +++-------------------------------- gst/nnstreamer/nnstreamer_subplugin.h | 17 ++------------ 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/gst/nnstreamer/nnstreamer_subplugin.c b/gst/nnstreamer/nnstreamer_subplugin.c index bcf322a..04c09ee 100644 --- a/gst/nnstreamer/nnstreamer_subplugin.c +++ b/gst/nnstreamer/nnstreamer_subplugin.c @@ -73,8 +73,6 @@ get_subplugin (subpluginType type, const char *name) if (data == NULL) { /* Search and register if found with the conf */ const gchar *fullpath = nnsconf_get_fullpath (name, type); - char *dlsym_error; - nnstreamer_subplugin_data *nsdata; if (fullpath == NULL) goto error; /* No Such Thing !!! */ @@ -91,48 +89,14 @@ get_subplugin (subpluginType type, const char *name) /* If a subplugin's constructor has called register_subplugin, skip the rest */ data = g_hash_table_lookup (table, name); - if (data != NULL) - goto registered; - - nsdata = (nnstreamer_subplugin_data *) - dlsym (handle, "nnstreamer_subplugin"); - dlsym_error = dlerror (); - - if (NULL == nsdata) { - GST_ERROR ("nnstreamer_subplugin does not exists in %s (%s)", name, - fullpath); - goto error_handle; - } - if (dlsym_error) { - GST_ERROR ("Loading nnstreamer_subplugin in %s (%s) incurs: %s", name, - fullpath, dlsym_error); - goto error_handle; - } - - if (nsdata->checker != NNS_SUBPLUGIN_CHECKER) { - GST_ERROR ("nnstreamer_subplugin of %s (%s) is broken (first bytes)", - name, fullpath); - goto error_handle; - } - - if (nsdata->type != type) { - GST_ERROR ("nnstreamer_subplugin of %s (%s) is broken (type mismatch)", - name, fullpath); - goto error_handle; - } - - if (g_strcmp0 (nsdata->name, name)) { - GST_ERROR ("nnstreamer_subplugin of %s (%s) is broken (name mismatch)", + if (data == NULL) { + GST_ERROR + ("nnstreamer_subplugin of %s (%s) is broken. It does not call register_subplugin with its init function.", name, fullpath); goto error_handle; } - - g_assert (TRUE == register_subplugin (type, name, nsdata->data)); - g_assert ((data = g_hash_table_lookup (table, name)) != NULL); - data->handle = handle; } -registered: G_UNLOCK (splock); return data->data; diff --git a/gst/nnstreamer/nnstreamer_subplugin.h b/gst/nnstreamer/nnstreamer_subplugin.h index 059ecf8..c3119b0 100644 --- a/gst/nnstreamer/nnstreamer_subplugin.h +++ b/gst/nnstreamer/nnstreamer_subplugin.h @@ -26,10 +26,8 @@ * This fils it to be packaged as "devel" package for NN developers. (subplugin writers) * * @note Any independent subplugin (existing as an independent .so) - * should have an exported variable "nnstreamer_subplugin", - * whose type is nnstreamer_subplugin_data. - * A built-in subplugin (existing in libnnstreamer.so) does not - * need this. + * should call register_subplugin () (or its wrapper) with the + * subplugin's constructor function. */ #ifndef __GST_NNSTREAMER_SUBPLUGIN_H__ #define __GST_NNSTREAMER_SUBPLUGIN_H__ @@ -47,17 +45,6 @@ typedef enum { #define NNS_SUBPLUGIN_CHECKER (0xdeadbeef) /** - * @brief Any independent shared object subplugin must export this as - * "nnstreamer_subplugin" - */ -typedef struct { - uint32_t checker; /**< This MUST be 0xdeadbeef (NNS_SUBPLUGIN_CHECKER) */ - subpluginType type; /**< The subplugin type */ - const char *name; /**< The name of subplugin. The resulting .so file should be ${prefix}${name}.so */ - void *data; /**< Subplugin specific data (usually funcptr callbacks), forwarded to subplugin's corresponding handler */ -} nnstreamer_subplugin_data; - -/** * @brief Retrieve the resigered data with the subplugin name. * @param[in] type Subplugin Type * @param[in] name Subplugin Name. The filename should be libnnstreamer_${type}_${name}.so -- 2.7.4