[Subplugin] Remove dlsym subplugin loader
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 19 Mar 2019 02:36:38 +0000 (11:36 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Thu, 21 Mar 2019 08:23:43 +0000 (17:23 +0900)
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 <myungjoo.ham@samsung.com>
gst/nnstreamer/nnstreamer_subplugin.c
gst/nnstreamer/nnstreamer_subplugin.h

index bcf322a..04c09ee 100644 (file)
@@ -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;
 
index 059ecf8..c3119b0 100644 (file)
  * 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