oss4: allow per feature registration
authorStéphane Cerveau <scerveau@collabora.com>
Tue, 16 Feb 2021 15:34:48 +0000 (16:34 +0100)
committerStéphane Cerveau <scerveau@collabora.com>
Mon, 29 Mar 2021 10:45:23 +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>

sys/oss4/gstoss4audioplugin.c [new file with mode: 0644]
sys/oss4/meson.build
sys/oss4/oss4-audio.c
sys/oss4/oss4-audio.h
sys/oss4/oss4-sink.c
sys/oss4/oss4-sink.h
sys/oss4/oss4-source.c
sys/oss4/oss4-source.h

diff --git a/sys/oss4/gstoss4audioplugin.c b/sys/oss4/gstoss4audioplugin.c
new file mode 100644 (file)
index 0000000..b5c00e4
--- /dev/null
@@ -0,0 +1,47 @@
+/* GStreamer OSS4 audio plugin
+ * Copyright (C) 2007-2008 Tim-Philipp Müller <tim centricular net>
+ *
+ * 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.
+ */
+
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "oss4-sink.h"
+#include "oss4-source.h"
+
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  gboolean ret = FALSE;
+
+  ret |= GST_ELEMENT_REGISTER (oss4sink, plugin);
+  ret |= GST_ELEMENT_REGISTER (oss4src, plugin);
+
+  return ret;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    oss4,
+    "Open Sound System (OSS) version 4 support for GStreamer",
+    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 85fc1c2..414350d 100644 (file)
@@ -18,7 +18,7 @@ if have_oss4
   message('Required headers found, building Open Sound System 4 plugin.')
 
   plugins += [library('gstoss4',
-    'oss4-audio.c', 'oss4-property-probe.c', 'oss4-sink.c', 'oss4-source.c',
+    'gstoss4audioplugin.c', 'oss4-audio.c', 'oss4-property-probe.c', 'oss4-sink.c', 'oss4-source.c',
     c_args : gst_plugins_good_args,
     include_directories : [configinc, libsinc],
     dependencies : [gstaudio_dep, gstbase_dep],
index 44d2f6d..8c3eb62 100644 (file)
@@ -746,36 +746,22 @@ gst_oss4_audio_find_device (GstObject * oss)
   return ret;
 }
 
-static gboolean
-plugin_init (GstPlugin * plugin)
+void
+oss4_element_init (GstPlugin * plugin)
 {
-  gint rank;
-
-  GST_DEBUG_CATEGORY_INIT (oss4sink_debug, "oss4sink", 0, "OSS4 audio sink");
-  GST_DEBUG_CATEGORY_INIT (oss4src_debug, "oss4src", 0, "OSS4 audio src");
-  GST_DEBUG_CATEGORY_INIT (oss4mixer_debug, "oss4mixer", 0, "OSS4 mixer");
-  GST_DEBUG_CATEGORY_INIT (oss4_debug, "oss4", 0, "OSS4 plugin");
+  static gsize res = FALSE;
+  if (g_once_init_enter (&res)) {
+    GST_DEBUG_CATEGORY_INIT (oss4sink_debug, "oss4sink", 0, "OSS4 audio sink");
+    GST_DEBUG_CATEGORY_INIT (oss4src_debug, "oss4src", 0, "OSS4 audio src");
+    GST_DEBUG_CATEGORY_INIT (oss4mixer_debug, "oss4mixer", 0, "OSS4 mixer");
+    GST_DEBUG_CATEGORY_INIT (oss4_debug, "oss4", 0, "OSS4 plugin");
 
 #ifdef ENABLE_NLS
-  GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
-      LOCALEDIR);
-  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
+        LOCALEDIR);
+    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 #endif
-
-  /* we want a higher rank than the legacy OSS elements have now */
-  rank = GST_RANK_SECONDARY + 1;
-
-  if (!gst_element_register (plugin, "oss4sink", rank, GST_TYPE_OSS4_SINK) ||
-      !gst_element_register (plugin, "oss4src", rank, GST_TYPE_OSS4_SOURCE)) {
-    return FALSE;
+    g_once_init_leave (&res, TRUE);
   }
-
-  return TRUE;
 }
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    oss4,
-    "Open Sound System (OSS) version 4 support for GStreamer",
-    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index 54128c0..44d3da6 100644 (file)
@@ -23,6 +23,8 @@
 #include <gst/gst.h>
 #include <gst/audio/audio.h>
 
+G_GNUC_INTERNAL void oss4_element_init (GstPlugin * plugin);
+
 /* This is the minimum version we require */
 #define GST_MIN_OSS4_VERSION  0x040003
 
index 177d4dc..6533105 100644 (file)
@@ -104,6 +104,8 @@ enum
 #define gst_oss4_sink_parent_class parent_class
 G_DEFINE_TYPE_WITH_CODE (GstOss4Sink, gst_oss4_sink,
     GST_TYPE_AUDIO_SINK, G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL));
+GST_ELEMENT_REGISTER_DEFINE (oss4sink, "oss4sink", GST_RANK_SECONDARY + 1,
+    GST_TYPE_OSS4_SINK);
 
 static void
 gst_oss4_sink_dispose (GObject * object)
index 04645fe..61955e8 100644 (file)
@@ -54,6 +54,7 @@ struct _GstOss4SinkClass {
 };
 
 GType  gst_oss4_sink_get_type (void);
+GST_ELEMENT_REGISTER_DECLARE (oss4sink);
 
 G_END_DECLS
 
index 92a620a..4b994a0 100644 (file)
@@ -73,6 +73,8 @@ enum
 
 #define gst_oss4_source_parent_class parent_class
 G_DEFINE_TYPE (GstOss4Source, gst_oss4_source, GST_TYPE_AUDIO_SRC);
+GST_ELEMENT_REGISTER_DEFINE (oss4src, "oss4src", GST_RANK_SECONDARY + 1,
+    GST_TYPE_OSS4_SOURCE);
 
 static void gst_oss4_source_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
index 91d8f13..3a97524 100644 (file)
@@ -52,6 +52,7 @@ struct _GstOss4SourceClass {
 };
 
 GType  gst_oss4_source_get_type (void);
+GST_ELEMENT_REGISTER_DECLARE (oss4src);
 
 G_END_DECLS