nvcodec: Clean up pointless return values around plugin init
authorSeungha Yang <seungha.yang@navercorp.com>
Thu, 25 Jul 2019 07:45:21 +0000 (16:45 +0900)
committerSebastian Dröge <slomo@coaxion.net>
Thu, 25 Jul 2019 08:47:50 +0000 (08:47 +0000)
Any plugin which returned FALSE from plugin_init will be blacklisted
so the plugin will be unusable even if an user install required runtime
dependency next time. So that's the reason why nvcodec returns TRUE always.

This commit is to remove possible misreading code.

sys/nvcodec/gstnvdec.c
sys/nvcodec/gstnvdec.h
sys/nvcodec/gstnvenc.c
sys/nvcodec/gstnvenc.h
sys/nvcodec/plugin.c

index f82652f..60834af 100644 (file)
@@ -1122,7 +1122,7 @@ typedef struct
   cudaVideoChromaFormat format;
 } GstNvdecChromaMap;
 
-static gboolean
+static void
 gst_nvdec_register (GstPlugin * plugin, GType type, cudaVideoCodec codec_type,
     const gchar * codec, const gchar * sink_caps_string, guint rank,
     gint device_count)
@@ -1274,8 +1274,6 @@ gst_nvdec_register (GstPlugin * plugin, GType type, cudaVideoCodec codec_type,
     gst_clear_caps (&sink_templ);
     gst_clear_caps (&src_templ);
   }
-
-  return TRUE;
 }
 
 typedef struct
@@ -1316,13 +1314,12 @@ const GstNvCodecMap codec_map[] = {
   {cudaVideoCodec_VP9, "vp9", "video/x-vp9"}
 };
 
-gboolean
+void
 gst_nvdec_plugin_init (GstPlugin * plugin)
 {
   gint i;
   CUresult cuda_ret;
   gint dev_count = 0;
-  gboolean ret = TRUE;
 
   GST_DEBUG_CATEGORY_INIT (gst_nvdec_debug_category, "nvdec", 0,
       "Debug category for the nvdec element");
@@ -1346,26 +1343,24 @@ gst_nvdec_plugin_init (GstPlugin * plugin)
           codec_map[i].codec_name, 0, GST_RANK_PRIMARY, sink_templ, src_templ);
     }
 
-    return TRUE;
+    return;
   }
 
   cuda_ret = CuInit (0);
   if (cuda_ret != CUDA_SUCCESS) {
     GST_ERROR ("Failed to initialize CUDA API");
-    return TRUE;
+    return;
   }
 
   cuda_ret = CuDeviceGetCount (&dev_count);
   if (cuda_ret != CUDA_SUCCESS || dev_count == 0) {
     GST_ERROR ("No CUDA devices detected");
-    return TRUE;
+    return;
   }
 
   for (i = 0; i < G_N_ELEMENTS (codec_map); i++) {
-    ret &= gst_nvdec_register (plugin, GST_TYPE_NVDEC, codec_map[i].codec,
+    gst_nvdec_register (plugin, GST_TYPE_NVDEC, codec_map[i].codec,
         codec_map[i].codec_name, codec_map[i].sink_caps_string,
         GST_RANK_PRIMARY, dev_count);
   }
-
-  return ret;
 }
index 8578c7c..727448c 100644 (file)
@@ -87,7 +87,7 @@ struct _GstNvDecClass
 
 GType gst_nvdec_get_type (void);
 
-gboolean gst_nvdec_plugin_init (GstPlugin * plugin);
+void gst_nvdec_plugin_init (GstPlugin * plugin);
 
 G_END_DECLS
 
index fe17dd6..d580d27 100644 (file)
@@ -635,7 +635,7 @@ gst_nv_enc_get_supported_codec_profiles (gpointer enc, GUID codec_id)
   return ret;
 }
 
-static gboolean
+static void
 gst_nv_enc_register (GstPlugin * plugin, GType type, GUID codec_id,
     const gchar * codec, guint rank, gint device_count)
 {
@@ -780,22 +780,18 @@ gst_nv_enc_register (GstPlugin * plugin, GType type, GUID codec_id,
     gst_clear_caps (&sink_templ);
     gst_clear_caps (&src_templ);
   }
-
-  return TRUE;
 }
 
 
-gboolean
+void
 gst_nvenc_plugin_init (GstPlugin * plugin)
 {
-  gboolean ret = TRUE;
-
   GST_DEBUG_CATEGORY_INIT (gst_nvenc_debug, "nvenc", 0, "Nvidia NVENC encoder");
 
   nvenc_api.version = NV_ENCODE_API_FUNCTION_LIST_VER;
   if (!load_nvenc_library ()) {
     GST_INFO ("Failed to load nvenc library");
-    return TRUE;
+    return;
   }
 
   if (nvEncodeAPICreateInstance (&nvenc_api) != NV_ENC_SUCCESS) {
@@ -809,23 +805,19 @@ gst_nvenc_plugin_init (GstPlugin * plugin)
     cuda_ret = CuInit (0);
     if (cuda_ret != CUDA_SUCCESS) {
       GST_ERROR ("Failed to initialize CUDA API");
-      return TRUE;
+      return;
     }
 
     cuda_ret = CuDeviceGetCount (&dev_count);
     if (cuda_ret != CUDA_SUCCESS || dev_count == 0) {
       GST_ERROR ("No CUDA devices detected");
-      return TRUE;
+      return;
     }
 
-    ret &=
-        gst_nv_enc_register (plugin, GST_TYPE_NV_H264_ENC,
+    gst_nv_enc_register (plugin, GST_TYPE_NV_H264_ENC,
         NV_ENC_CODEC_H264_GUID, "h264", GST_RANK_PRIMARY * 2, dev_count);
-    ret &=
-        gst_nv_enc_register (plugin, GST_TYPE_NV_H265_ENC,
+    gst_nv_enc_register (plugin, GST_TYPE_NV_H265_ENC,
         NV_ENC_CODEC_HEVC_GUID, "h265", GST_RANK_PRIMARY * 2, dev_count);
 
   }
-
-  return ret;
 }
index 07e0920..39a0409 100644 (file)
@@ -48,7 +48,7 @@ GValue *                gst_nv_enc_get_supported_codec_profiles (gpointer enc,
                                                                  GUID codec_id);
 
 
-gboolean                gst_nvenc_plugin_init (GstPlugin * plugin);
+void                    gst_nvenc_plugin_init (GstPlugin * plugin);
 
 
 #endif /* __GST_NVENC_H_INCLUDED__ */
index 3dc27af..385df55 100644 (file)
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  gboolean ret = TRUE;
-
   if (!gst_cuda_load_library ())
     return TRUE;
 
 #if HAVE_NVCODEC_GST_GL
   /* FIXME: make nvdec usable without OpenGL dependency */
   if (gst_cuvid_load_library ()) {
-    ret &= gst_nvdec_plugin_init (plugin);
+    gst_nvdec_plugin_init (plugin);
   }
 #endif
 
-  ret &= gst_nvenc_plugin_init (plugin);
+  gst_nvenc_plugin_init (plugin);
 
   return TRUE;
 }