equalizer: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Mon, 15 Feb 2021 16:27:51 +0000 (17:27 +0100)
committerStéphane Cerveau <scerveau@collabora.com>
Mon, 29 Mar 2021 10:45:22 +0000 (12:45 +0200)
Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>

gst/equalizer/gstiirequalizer.c
gst/equalizer/gstiirequalizer.h
gst/equalizer/gstiirequalizer10bands.c
gst/equalizer/gstiirequalizer3bands.c
gst/equalizer/gstiirequalizernbands.c
gst/equalizer/gstiirequalizerplugin.c [new file with mode: 0644]
gst/equalizer/meson.build

index e78d779..5ebd9d2 100644 (file)
@@ -893,29 +893,12 @@ gst_iir_equalizer_setup (GstAudioFilter * audio, const GstAudioInfo * info)
   return TRUE;
 }
 
-
-static gboolean
-plugin_init (GstPlugin * plugin)
+void
+equalizer_element_init (GstPlugin * plugin)
 {
-  GST_DEBUG_CATEGORY_INIT (equalizer_debug, "equalizer", 0, "equalizer");
-
-  if (!(gst_element_register (plugin, "equalizer-nbands", GST_RANK_NONE,
-              GST_TYPE_IIR_EQUALIZER_NBANDS)))
-    return FALSE;
-
-  if (!(gst_element_register (plugin, "equalizer-3bands", GST_RANK_NONE,
-              GST_TYPE_IIR_EQUALIZER_3BANDS)))
-    return FALSE;
-
-  if (!(gst_element_register (plugin, "equalizer-10bands", GST_RANK_NONE,
-              GST_TYPE_IIR_EQUALIZER_10BANDS)))
-    return FALSE;
-
-  return TRUE;
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    GST_DEBUG_CATEGORY_INIT (equalizer_debug, "equalizer", 0, "equalizer");
+    g_once_init_leave (&res, TRUE);
+  }
 }
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    equalizer,
-    "GStreamer audio equalizers",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 3ba70ee..6d8a214 100644 (file)
 
 #include <gst/audio/gstaudiofilter.h>
 
+void equalizer_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (equalizer_nbands);
+GST_ELEMENT_REGISTER_DECLARE (equalizer_3bands);
+GST_ELEMENT_REGISTER_DECLARE (equalizer_10bands);
+
 typedef struct _GstIirEqualizer GstIirEqualizer;
 typedef struct _GstIirEqualizerClass GstIirEqualizerClass;
 typedef struct _GstIirEqualizerBand GstIirEqualizerBand;
index d8492f6..97c60c6 100644 (file)
@@ -65,6 +65,9 @@ GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
 #define gst_iir_equalizer_10bands_parent_class parent_class
 G_DEFINE_TYPE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands,
     GST_TYPE_IIR_EQUALIZER);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (equalizer_10bands, "equalizer-10bands",
+    GST_RANK_NONE, GST_TYPE_IIR_EQUALIZER_10BANDS,
+    equalizer_element_init (plugin));
 
 /* equalizer implementation */
 
index 67ab2c4..3ea1667 100644 (file)
@@ -56,6 +56,9 @@ GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
 #define gst_iir_equalizer_3bands_parent_class parent_class
 G_DEFINE_TYPE (GstIirEqualizer3Bands, gst_iir_equalizer_3bands,
     GST_TYPE_IIR_EQUALIZER);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (equalizer_3bands, "equalizer-3bands",
+    GST_RANK_NONE, GST_TYPE_IIR_EQUALIZER_3BANDS,
+    equalizer_element_init (plugin));
 
 /* equalizer implementation */
 
index da7ea33..2f9f9a4 100644 (file)
@@ -99,7 +99,9 @@ GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
 #define gst_iir_equalizer_nbands_parent_class parent_class
 G_DEFINE_TYPE (GstIirEqualizerNBands, gst_iir_equalizer_nbands,
     GST_TYPE_IIR_EQUALIZER);
-
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (equalizer_nbands, "equalizer-nbands",
+    GST_RANK_NONE, GST_TYPE_IIR_EQUALIZER_NBANDS,
+    equalizer_element_init (plugin));
 /* equalizer implementation */
 
 static void
diff --git a/gst/equalizer/gstiirequalizerplugin.c b/gst/equalizer/gstiirequalizerplugin.c
new file mode 100644 (file)
index 0000000..74af309
--- /dev/null
@@ -0,0 +1,45 @@
+/* GStreamer
+ * Copyright (C) <2004> Benjamin Otte <otte@gnome.org>
+ *               <2007> Stefan Kost <ensonic@users.sf.net>
+ *               <2007> Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstiirequalizer.h"
+
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  gboolean ret = FALSE;
+
+  ret |= GST_ELEMENT_REGISTER (equalizer_nbands, plugin);
+  ret |= GST_ELEMENT_REGISTER (equalizer_3bands, plugin);
+  ret |= GST_ELEMENT_REGISTER (equalizer_10bands, plugin);
+
+  return ret;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    equalizer,
+    "GStreamer audio equalizers",
+    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 73fc857..ef796f8 100644 (file)
@@ -1,8 +1,10 @@
 eq_sources = [
   'gstiirequalizer.c',
+  'gstiirequalizerplugin.c',
   'gstiirequalizernbands.c',
   'gstiirequalizer3bands.c',
   'gstiirequalizer10bands.c',
+  'gstiirequalizerplugin.c',
 ]
 
 gstequalizer = library('gstequalizer',