diff --git a/ext/openal/gstopenal.c b/ext/openal/gstopenal.c index 44bffb6f8d..d266892134 100644 --- a/ext/openal/gstopenal.c +++ b/ext/openal/gstopenal.c @@ -26,32 +26,19 @@ #include "config.h" #endif -#include "gstopenalsink.h" -#include "gstopenalsrc.h" +#include "gstopenalelements.h" #include -GST_DEBUG_CATEGORY (openal_debug); static gboolean plugin_init (GstPlugin * plugin) { - if (!gst_element_register (plugin, "openalsink", GST_RANK_SECONDARY, - GST_TYPE_OPENAL_SINK)) - return FALSE; + gboolean ret = FALSE; - if (!gst_element_register (plugin, "openalsrc", GST_RANK_SECONDARY, - GST_TYPE_OPENAL_SRC)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (openalsink, plugin); + ret |= GST_ELEMENT_REGISTER (openalsrc, 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"); -#endif - - GST_DEBUG_CATEGORY_INIT (openal_debug, "openal", 0, "openal plugins"); return TRUE; } diff --git a/ext/openal/gstopenalelement.c b/ext/openal/gstopenalelement.c new file mode 100644 index 0000000000..3f85f8d297 --- /dev/null +++ b/ext/openal/gstopenalelement.c @@ -0,0 +1,51 @@ +/* + * GStreamer openal plugin + * + * Copyright (C) 2005 Wim Taymans + * Copyright (C) 2006 Tim-Philipp Müller + * Copyright (C) 2009-2010 Chris Robinson + * Copyright (C) 2013 Juan Manuel Borges Caño + * + * 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 "gstopenalelements.h" +#include "gstopenalsink.h" +#include "gstopenalsrc.h" + +#include + +GST_DEBUG_CATEGORY (openal_debug); + +void +openal_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { +#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"); +#endif + GST_DEBUG_CATEGORY_INIT (openal_debug, "openal", 0, "openal plugins"); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/openal/gstopenalelements.h b/ext/openal/gstopenalelements.h new file mode 100644 index 0000000000..8b2d89d0e3 --- /dev/null +++ b/ext/openal/gstopenalelements.h @@ -0,0 +1,35 @@ +/* GStreamer + * Copyright (C) <2020> The Gstreamer Contributors. + * + * 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. + */ + + +#ifndef __GST_OPENAL_ELEMENTS_H__ +#define __GST_OPENAL_ELEMENTS_H__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +void openal_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (openalsink); +GST_ELEMENT_REGISTER_DECLARE (openalsrc); + +#endif /* __GST_OPENAL_ELEMENTS_H__ */ diff --git a/ext/openal/gstopenalsink.c b/ext/openal/gstopenalsink.c index eb9b9bace8..871e6715f1 100644 --- a/ext/openal/gstopenalsink.c +++ b/ext/openal/gstopenalsink.c @@ -61,6 +61,7 @@ GST_DEBUG_CATEGORY_EXTERN (openal_debug); #define GST_CAT_DEFAULT openal_debug +#include "gstopenalelements.h" #include "gstopenalsink.h" static void gst_openal_sink_dispose (GObject * object); @@ -159,6 +160,8 @@ checkALError (const char *fname, unsigned int fline) #define checkALError() checkALError(__FILE__, __LINE__) G_DEFINE_TYPE (GstOpenALSink, gst_openal_sink, GST_TYPE_AUDIO_SINK); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (openalsink, "openalsink", + GST_RANK_SECONDARY, GST_TYPE_OPENAL_SINK, openal_element_init (plugin)); static void gst_openal_sink_dispose (GObject * object) diff --git a/ext/openal/gstopenalsrc.c b/ext/openal/gstopenalsrc.c index 4f1e26e77d..602fb9388f 100644 --- a/ext/openal/gstopenalsrc.c +++ b/ext/openal/gstopenalsrc.c @@ -81,6 +81,7 @@ GST_DEBUG_CATEGORY_EXTERN (openal_debug); #define GST_CAT_DEFAULT openal_debug +#include "gstopenalelements.h" #include "gstopenalsrc.h" static void gst_openal_src_dispose (GObject * object); @@ -140,6 +141,8 @@ static GstStaticPadTemplate openalsrc_factory = GST_STATIC_PAD_TEMPLATE ("src", ); G_DEFINE_TYPE (GstOpenalSrc, gst_openal_src, GST_TYPE_AUDIO_SRC); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (openalsrc, "openalsrc", + GST_RANK_SECONDARY, GST_TYPE_OPENAL_SRC, openal_element_init (plugin)); static void gst_openal_src_dispose (GObject * object) diff --git a/ext/openal/meson.build b/ext/openal/meson.build index 68679bddd5..2f07cfb7bf 100644 --- a/ext/openal/meson.build +++ b/ext/openal/meson.build @@ -2,7 +2,7 @@ openal_dep = dependency('openal', method: 'pkg-config', version: '>= 1.14', requ if openal_dep.found() gstopenal = library('gstopenal', - 'gstopenal.c', 'gstopenalsink.c', 'gstopenalsrc.c', + 'gstopenal.c', 'gstopenalelement.c', 'gstopenalsink.c', 'gstopenalsrc.c', c_args: gst_plugins_bad_args, include_directories: [configinc, libsinc], dependencies: [gstaudio_dep, openal_dep],