From 31a780a06115563cbf7426134072bae9e4fa0111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 16 Feb 2021 16:34:48 +0100 Subject: [PATCH] oss4: allow per feature registration 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: --- sys/oss4/gstoss4audioplugin.c | 47 +++++++++++++++++++++++++++++++++++ sys/oss4/meson.build | 2 +- sys/oss4/oss4-audio.c | 40 ++++++++++------------------- sys/oss4/oss4-audio.h | 2 ++ sys/oss4/oss4-sink.c | 2 ++ sys/oss4/oss4-sink.h | 1 + sys/oss4/oss4-source.c | 2 ++ sys/oss4/oss4-source.h | 1 + 8 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 sys/oss4/gstoss4audioplugin.c diff --git a/sys/oss4/gstoss4audioplugin.c b/sys/oss4/gstoss4audioplugin.c new file mode 100644 index 0000000000..b5c00e4b0c --- /dev/null +++ b/sys/oss4/gstoss4audioplugin.c @@ -0,0 +1,47 @@ +/* GStreamer OSS4 audio plugin + * Copyright (C) 2007-2008 Tim-Philipp Müller + * + * 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) diff --git a/sys/oss4/meson.build b/sys/oss4/meson.build index 85fc1c2eba..414350d825 100644 --- a/sys/oss4/meson.build +++ b/sys/oss4/meson.build @@ -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], diff --git a/sys/oss4/oss4-audio.c b/sys/oss4/oss4-audio.c index 44d2f6db9f..8c3eb62dbb 100644 --- a/sys/oss4/oss4-audio.c +++ b/sys/oss4/oss4-audio.c @@ -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) diff --git a/sys/oss4/oss4-audio.h b/sys/oss4/oss4-audio.h index 54128c0d84..44d3da677c 100644 --- a/sys/oss4/oss4-audio.h +++ b/sys/oss4/oss4-audio.h @@ -23,6 +23,8 @@ #include #include +G_GNUC_INTERNAL void oss4_element_init (GstPlugin * plugin); + /* This is the minimum version we require */ #define GST_MIN_OSS4_VERSION 0x040003 diff --git a/sys/oss4/oss4-sink.c b/sys/oss4/oss4-sink.c index 177d4dc224..65331051e6 100644 --- a/sys/oss4/oss4-sink.c +++ b/sys/oss4/oss4-sink.c @@ -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) diff --git a/sys/oss4/oss4-sink.h b/sys/oss4/oss4-sink.h index 04645fe7f3..61955e8c9d 100644 --- a/sys/oss4/oss4-sink.h +++ b/sys/oss4/oss4-sink.h @@ -54,6 +54,7 @@ struct _GstOss4SinkClass { }; GType gst_oss4_sink_get_type (void); +GST_ELEMENT_REGISTER_DECLARE (oss4sink); G_END_DECLS diff --git a/sys/oss4/oss4-source.c b/sys/oss4/oss4-source.c index 92a620ad43..4b994a0700 100644 --- a/sys/oss4/oss4-source.c +++ b/sys/oss4/oss4-source.c @@ -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); diff --git a/sys/oss4/oss4-source.h b/sys/oss4/oss4-source.h index 91d8f13690..3a975249fd 100644 --- a/sys/oss4/oss4-source.h +++ b/sys/oss4/oss4-source.h @@ -52,6 +52,7 @@ struct _GstOss4SourceClass { }; GType gst_oss4_source_get_type (void); +GST_ELEMENT_REGISTER_DECLARE (oss4src); G_END_DECLS