[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Convert audio subsystem to use dynamically-loaded plugins.
From: |
Christopher Brannon |
Subject: |
[PATCH] Convert audio subsystem to use dynamically-loaded plugins. |
Date: |
Sun, 12 Dec 2010 15:12:35 +0000 |
Now, each of Speech Dispatcher's audio backends is represented by a
separate dynamically-loaded library, one per backend. We use libltdl,
which portably handles dynamic loading. On platforms which do not
support dynamic loading, libltdl will cause audio plugins to be
statically linked into executables.
Much of the credit for this patch goes to Andrei Kholodnyi.
---
configure.ac | 32 +++++++++---------
src/modules/Makefile.am | 13 ++++++-
src/modules/audio/Makefile.am | 41 +++++++++++++++++-----
src/modules/audio/alsa.c | 2 +
src/modules/audio/libao.c | 3 +-
src/modules/audio/nas.c | 4 ++-
src/modules/audio/oss.c | 2 +
src/modules/audio/pulse.c | 2 +
src/modules/audio/spd_audio.c | 59 +++++++++++++++++++++++++++-----
src/modules/audio/spd_audio.h | 2 +
src/modules/audio/spd_audio_plugin.h | 2 +
src/modules/audio/static_plugins.c.in | 54 ------------------------------
src/modules/module_main.c | 3 ++
13 files changed, 125 insertions(+), 94 deletions(-)
delete mode 100644 src/modules/audio/static_plugins.c.in
diff --git a/configure.ac b/configure.ac
index 5bd1056..825a558 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,10 @@ AC_CHECK_FUNCS([dup2 gethostbyname gettimeofday memmove
memset mkdir])
AC_CHECK_FUNCS([select socket strcasecmp strchr strcspn strdup])
AC_CHECK_FUNCS([strerror strncasecmp strndup strstr strtol])
+# Check for ltdl.
+AC_CHECK_LIB([ltdl], [lt_dlopen], [], [
+ AC_MSG_ERROR(libltdl3-dev is required for plugin loading)])
+
# Extra libraries for sockets and espeak added by Willie Walker
# based upon how SunStudio libraries work. Also
# conditionally set other compiler/linker flags.
@@ -199,8 +203,7 @@ AS_IF([test $with_pico != "no"],
[AC_MSG_FAILURE([SVOX pico is not available])])])])
AM_CONDITIONAL([pico_support], [test $with_pico = "yes"])
-# clear static audio plugins list
-STATIC_AUDIO_PLUGINS_LIST=""
+AUDIO_DLOPEN_MODULES='-dlopen force'
# clear default audio method
default_audio_method=""
@@ -216,7 +219,7 @@ AS_IF([test $with_pulse != "no"],
[with_pulse=yes
AS_IF([test -z "$default_audio_method"],
[default_audio_method=pulse])
- STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST pulse"],
+ AUDIO_DLOPEN_MODULES="$AUDIO_DLOPEN_MODULES -dlopen
audio/spd_pulse.la"],
[AS_IF([test $with_pulse = "yes"],
[AC_MSG_FAILURE([pulseaudio is not available])])])])
AM_CONDITIONAL([pulse_support], [test $with_pulse = "yes"])
@@ -233,7 +236,7 @@ AS_IF([test $with_alsa != "no"],
[with_alsa=yes
AS_IF([test -z "$default_audio_method"],
[default_audio_method=alsa])
- STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST alsa"],
+ AUDIO_DLOPEN_MODULES="$AUDIO_DLOPEN_MODULES -dlopen
audio/spd_alsa.la"],
[AS_IF([test $with_alsa = "yes"],
[AC_MSG_FAILURE([ALSA is not available])])])])
AM_CONDITIONAL([alsa_support], [test $with_alsa = "yes"])
@@ -250,7 +253,7 @@ AS_IF([test $with_libao != "no"],
[with_libao=yes
AS_IF([test -z "$default_audio_method"],
[default_audio_method=libao])
- STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST libao"],
+ AUDIO_DLOPEN_MODULES="$AUDIO_DLOPEN_MODULES -dlopen
audio/spd_libao.la"],
[AS_IF([test $with_libao = yes],
[AC_MSG_FAILURE([libao is not available])])])])
AM_CONDITIONAL([libao_support], [test $with_libao = "yes"])
@@ -267,7 +270,7 @@ AS_IF([test $with_oss != "no"],
[with_oss=yes
AS_IF([test -z "$default_audio_method"],
[default_audio_method=oss])
- STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST oss"],
+ AUDIO_DLOPEN_MODULES="$AUDIO_DLOPEN_MODULES -dlopen
audio/spd_oss.la"],
[AS_IF([test $with_oss = "yes"],
[AC_MSG_FAILURE([oss is not available])])])])
AM_CONDITIONAL([oss_support], [test $with_oss = "yes"])
@@ -282,7 +285,7 @@ AS_IF([test $with_nas != "no"],
[with_nas=yes
AS_IF([test -z "$default_audio_method"],
[default_audio_method=nas])
- STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST nas";
+ AUDIO_DLOPEN_MODULES="$AUDIO_DLOPEN_MODULES -dlopen
audio/spd_nas.la";
NAS_LIBS="-L/usr/X11R6/lib -lXau -laudio"],
[AS_IF([test $with_nas = "yes"],
[AC_MSG_FAILURE([nas is not available])])],
@@ -298,14 +301,8 @@ AC_ARG_WITH([default-audio-method],
AC_MSG_NOTICE([Default audio method is $default_audio_method])
AC_SUBST([default_audio_method])
-for name in $STATIC_AUDIO_PLUGINS_LIST; do
- STATIC_AUDIO_PLUGINS_GET="$STATIC_AUDIO_PLUGINS_GET${name}_plugin_get,";
- STATIC_AUDIO_PLUGINS_EXTERN="${STATIC_AUDIO_PLUGINS_EXTERN} extern
spd_audio_plugin_t const * ${name}_plugin_get (void); "
-done
-
-# used in src/audio/static_plugins.c.in
-AC_SUBST([STATIC_AUDIO_PLUGINS_EXTERN])
-AC_SUBST([STATIC_AUDIO_PLUGINS_GET])
+# We'll build these modules:
+AC_SUBST(AUDIO_DLOPEN_MODULES)
# current, age and revision values for shared libraries.
LIB_SDAUDIO_CURRENT=2 # Current main version (increment on every API change --
incompatible AND extensions)
@@ -356,6 +353,10 @@ AC_SUBST([modulebindir])
spdlibdir='${libdir}/speech-dispatcher'
AC_SUBST([spdlibdir])
+# Path for audio libraries and plugins:
+audiodir="$spdlibdir"
+AC_SUBST([audiodir])
+
# Path for speech-dispatcher include files:
spdincludedir=${includedir}/speech-dispatcher
AC_SUBST([spdincludedir])
@@ -380,7 +381,6 @@ AC_CONFIG_FILES([Makefile
src/common/Makefile
src/modules/Makefile
src/modules/audio/Makefile
- src/modules/audio/static_plugins.c
src/server/Makefile
src/tests/Makefile])
AC_OUTPUT
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index 4359b3a..cf1a76b 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -15,7 +15,8 @@ modulebin_PROGRAMS = sd_dummy sd_generic sd_festival sd_cicero
sd_dummy_SOURCES = dummy.c $(common_SOURCES) module_utils_addvoice.c
sd_dummy_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
-sd_dummy_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio -lpthread \
+sd_dummy_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ -lpthread \
$(SNDFILE_LIBS) $(DOTCONF_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS)
dist_snddata_DATA = dummy-message.wav
@@ -23,16 +24,19 @@ sd_festival_SOURCES = festival.c festival_client.c
festival_client.h \
$(common_SOURCES)
sd_festival_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_festival_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
-lpthread $(DOTCONF_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS)
$(EXTRA_SOCKET_LIBS)
sd_generic_SOURCES = generic.c $(common_SOURCES) module_utils_addvoice.c
sd_generic_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_generic_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
-lpthread $(DOTCONF_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS)
sd_cicero_SOURCES = cicero.c $(common_SOURCES)
sd_cicero_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_cicero_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
-lpthread $(DOTCONF_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS)
if flite_support
@@ -40,6 +44,7 @@ modulebin_PROGRAMS += sd_flite
sd_flite_SOURCES = flite.c $(common_SOURCES)
sd_flite_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_flite_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
$(flite_kal) $(flite_basic) -lpthread $(DOTCONF_LIBS) $(GLIB_LIBS) \
$(GTHREAD_LIBS)
endif
@@ -49,6 +54,7 @@ modulebin_PROGRAMS += sd_ibmtts
sd_ibmtts_SOURCES = ibmtts.c $(common_SOURCES) module_utils_addvoice.c
sd_ibmtts_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_ibmtts_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
-lm -lpthread -libmeci $(SNDFILE_LIBS) $(DOTCONF_LIBS) \
$(GLIB_LIBS) $(GTHREAD_LIBS)
endif
@@ -58,6 +64,7 @@ modulebin_PROGRAMS += sd_espeak
sd_espeak_SOURCES = espeak.c $(common_SOURCES)
sd_espeak_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_espeak_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
-lespeak $(SNDFILE_LIBS) $(EXTRA_ESPEAK_LIBS) $(DOTCONF_LIBS) \
$(GLIB_LIBS) $(GTHREAD_LIBS)
endif
@@ -67,6 +74,7 @@ modulebin_PROGRAMS += sd_ivona
sd_ivona_SOURCES = ivona.c ivona_client.c ivona_client.h $(common_SOURCES)
sd_ivona_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
sd_ivona_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ \
-ldumbtts -lpthread $(SNDFILE_LIBS) $(DOTCONF_LIBS) $(GLIB_LIBS) \
$(GTHREAD_LIBS)
endif
@@ -75,6 +83,7 @@ if pico_support
modulebin_PROGRAMS += sd_pico
sd_pico_SOURCES = pico.c $(common_SOURCES)
sd_pico_LDFLAGS = $(RPATH) '$(spdlibdir)' $(lib_audio)
-sd_pico_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio -lttspico \
+sd_pico_LDADD = $(top_builddir)/src/common/libcommon.la -lsdaudio \
+ @AUDIO_DLOPEN_MODULES@ -lttspico \
$(DOTCONF_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS)
endif
diff --git a/src/modules/audio/Makefile.am b/src/modules/audio/Makefile.am
index 5c1d450..093f462 100644
--- a/src/modules/audio/Makefile.am
+++ b/src/modules/audio/Makefile.am
@@ -5,30 +5,51 @@ inc_local = -I$(top_srcdir)/include/
spdinclude_HEADERS = spd_audio_plugin.h
spdlib_LTLIBRARIES = libsdaudio.la
-libsdaudio_la_CPPFLAGS = $(ALSA_CFLAGS) $(LIBAO_CFLAGS) $(PULSE_CFLAGS) \
- $(GLIB_CFLAGS) $(inc_local)
+libsdaudio_la_SOURCES = spd_audio.c spd_audio.h spd_audio_plugin.h
+libsdaudio_la_CPPFLAGS = $(GLIB_CFLAGS) $(inc_local) \
+ -DPLUGIN_DIR="\"$(audiodir)\""
libsdaudio_la_LDFLAGS = -version-info \
$(LIB_SDAUDIO_CURRENT):$(LIB_SDAUDIO_REVISION):$(LIB_SDAUDIO_AGE)
-libsdaudio_la_LIBADD = $(GLIB_LIBS) -lpthread \
- $(ALSA_LIBS) $(LIBAO_LIBS) $(NAS_LIBS) $(PULSE_LIBS)
-libsdaudio_la_SOURCES = spd_audio.c spd_audio.h static_plugins.c
+libsdaudio_la_LIBADD = $(GLIB_LIBS) -lpthread
+
+audio_LTLIBRARIES =
if alsa_support
-libsdaudio_la_SOURCES += alsa.c
+audio_LTLIBRARIES += spd_alsa.la
+spd_alsa_la_SOURCES = alsa.c spd_audio_plugin.h
+spd_alsa_la_CPPFLAGS = $(GLIB_CFLAGS) $(inc_local) $(ALSA_CFLAGS)
+spd_alsa_la_LIBADD = $(ALSA_LIBS) $(GLIB_LIBS)
+spd_alsa_la_LDFLAGS = -module -avoid-version
endif
if libao_support
-libsdaudio_la_SOURCES += libao.c
+audio_LTLIBRARIES += spd_libao.la
+spd_libao_la_SOURCES = libao.c spd_audio_plugin.h
+spd_libao_la_CPPFLAGS = $(GLIB_CFLAGS) $(inc_local) $(LIBAO_CFLAGS)
+spd_libao_la_LIBADD = $(LIBAO_LIBS) $(GLIB_LIBS)
+spd_libao_la_LDFLAGS = -module -avoid-version
endif
if nas_support
-libsdaudio_la_SOURCES += nas.c
+audio_LTLIBRARIES += spd_nas.la
+spd_nas_la_SOURCES = nas.c spd_audio_plugin.h
+spd_nas_la_CPPFLAGS = $(GLIB_CFLAGS) $(inc_local)
+spd_nas_la_LIBADD = $(NAS_LIBS) $(GLIB_LIBS)
+spd_nas_la_LDFLAGS = -module -avoid-version
endif
if oss_support
-libsdaudio_la_SOURCES += oss.c
+audio_LTLIBRARIES += spd_oss.la
+spd_oss_la_SOURCES = oss.c spd_audio_plugin.h
+spd_oss_la_CPPFLAGS = $(GLIB_CFLAGS) $(inc_local)
+spd_oss_la_LIBADD = $(GLIB_LIBS)
+spd_oss_la_LDFLAGS = -module -avoid-version
endif
if pulse_support
-libsdaudio_la_SOURCES += pulse.c
+audio_LTLIBRARIES += spd_pulse.la
+spd_pulse_la_SOURCES = pulse.c spd_audio_plugin.h
+spd_pulse_la_CPPFLAGS = $(GLIB_CFLAGS) $(inc_local) $(PULSE_CFLAGS)
+spd_pulse_la_LIBADD = $(PULSE_LIBS) $(GLIB_LIBS)
+spd_pulse_la_LDFLAGS = -module -avoid-version
endif
diff --git a/src/modules/audio/alsa.c b/src/modules/audio/alsa.c
index 9fbfc7f..e609018 100644
--- a/src/modules/audio/alsa.c
+++ b/src/modules/audio/alsa.c
@@ -37,6 +37,7 @@
#include <alsa/asoundlib.h>
+#define SPD_AUDIO_PLUGIN_ENTRY spd_alsa_LTX_spd_audio_plugin_get
#include "spd_audio_plugin.h"
typedef struct {
@@ -835,5 +836,6 @@ static spd_audio_plugin_t alsa_functions = {
};
spd_audio_plugin_t * alsa_plugin_get (void) {return &alsa_functions;}
+spd_audio_plugin_t * SPD_AUDIO_PLUGIN_ENTRY (void) __attribute__ ((weak,
alias("alsa_plugin_get")));
#undef MSG
#undef ERR
diff --git a/src/modules/audio/libao.c b/src/modules/audio/libao.c
index 79b3e16..211eaf2 100644
--- a/src/modules/audio/libao.c
+++ b/src/modules/audio/libao.c
@@ -31,6 +31,7 @@
#include <glib.h>
#include <ao/ao.h>
+#define SPD_AUDIO_PLUGIN_ENTRY spd_libao_LTX_spd_audio_plugin_get
#include "spd_audio_plugin.h"
/* send a packet of XXX bytes to the sound device */
@@ -241,6 +242,6 @@ static spd_audio_plugin_t libao_functions =
libao_get_playcmd
};
spd_audio_plugin_t * libao_plugin_get (void) {return &libao_functions;}
-
+spd_audio_plugin_t * SPD_AUDIO_PLUGIN_ENTRY (void) __attribute__ ((weak,
alias("libao_plugin_get")));
#undef MSG
#undef ERR
diff --git a/src/modules/audio/nas.c b/src/modules/audio/nas.c
index 3d8d6e3..98dd7b9 100644
--- a/src/modules/audio/nas.c
+++ b/src/modules/audio/nas.c
@@ -33,6 +33,7 @@
#include <pthread.h>
+#define SPD_AUDIO_PLUGIN_ENTRY spd_nas_LTX_spd_audio_plugin_get
#include "spd_audio_plugin.h"
typedef struct {
@@ -254,4 +255,5 @@ static spd_audio_plugin_t nas_functions = {
nas_get_playcmd
};
-spd_audio_plugin_t * nas_plugin_get (void) {return &nas_functions;}
\ No newline at end of file
+spd_audio_plugin_t * nas_plugin_get (void) {return &nas_functions;}
+spd_audio_plugin_t * SPD_AUDIO_PLUGIN_ENTRY (void) __attribute__ ((weak,
alias("nas_plugin_get")));
diff --git a/src/modules/audio/oss.c b/src/modules/audio/oss.c
index e6466f9..bd94a1d 100644
--- a/src/modules/audio/oss.c
+++ b/src/modules/audio/oss.c
@@ -41,6 +41,7 @@
#include <sys/soundcard.h>
+#define SPD_AUDIO_PLUGIN_ENTRY spd_oss_LTX_spd_audio_plugin_get
#include "spd_audio_plugin.h"
typedef struct {
@@ -501,5 +502,6 @@ static spd_audio_plugin_t oss_functions = {
oss_get_playcmd
};
spd_audio_plugin_t * oss_plugin_get (void) {return &oss_functions;}
+spd_audio_plugin_t * SPD_AUDIO_PLUGIN_ENTRY (void) __attribute__ ((weak,
alias("oss_plugin_get")));
#undef MSG
#undef ERR
diff --git a/src/modules/audio/pulse.c b/src/modules/audio/pulse.c
index 4145965..2e20284 100644
--- a/src/modules/audio/pulse.c
+++ b/src/modules/audio/pulse.c
@@ -43,6 +43,7 @@
#include <pulse/simple.h>
#include <pulse/error.h>
+#define SPD_AUDIO_PLUGIN_ENTRY spd_pulse_LTX_spd_audio_plugin_get
#include "spd_audio_plugin.h"
/* Switch this on to debug, see output log location in MSG() */
@@ -294,3 +295,4 @@ static spd_audio_plugin_t pulse_functions = {
};
spd_audio_plugin_t * pulse_plugin_get (void) {return &pulse_functions;}
+spd_audio_plugin_t * SPD_AUDIO_PLUGIN_ENTRY (void) __attribute__ ((weak,
alias("pulse_plugin_get")));
diff --git a/src/modules/audio/spd_audio.c b/src/modules/audio/spd_audio.c
index 55dd0f0..fc30762 100644
--- a/src/modules/audio/spd_audio.c
+++ b/src/modules/audio/spd_audio.c
@@ -48,9 +48,10 @@
#include <pthread.h>
#include <glib.h>
+#include <ltdl.h>
static int spd_audio_log_level;
-extern spd_audio_plugin_t * spd_audio_static_plugin_get (char * name);
+static lt_dlhandle lt_h;
/* Open the audio device.
@@ -72,20 +73,51 @@ AudioID*
spd_audio_open(char *name, void **pars, char **error)
{
AudioID *id;
- struct spd_audio_plugin *function;
spd_audio_plugin_t const *p;
+ spd_audio_plugin_t * (*fn) (void);
+ gchar * libname;
+ int ret;
+
+ /* now check whether dynamic plugin is available */
+ ret = lt_dlinit();
+ if (ret != 0) {
+ *error = (char*) g_strdup_printf("lt_dlinit() failed");
+ return (AudioID *)NULL;
+ }
+
+ret = lt_dlsetsearchpath(PLUGIN_DIR);
+ if (ret != 0) {
+ *error = (char*) g_strdup_printf("lt_dlsetsearchpath() failed");
+ return (AudioID *)NULL;
+ }
+
+ libname = g_strdup_printf(SPD_AUDIO_LIB_PREFIX"%s",name);
+ lt_h = lt_dlopenext (libname);
+ g_free(libname);
+ if (NULL == lt_h) {
+ *error = (char*) g_strdup_printf("Cannot open plugin %s. error: %s",
+ name, lt_dlerror());
+ return (AudioID *)NULL;
+ }
- /* check whether static plugin is available */
- p = spd_audio_static_plugin_get (name);
+ fn = lt_dlsym (lt_h, SPD_AUDIO_PLUGIN_ENTRY_STR);
+ if (NULL == fn) {
+ *error = (char*) g_strdup_printf("Cannot find symbol %s",
+ SPD_AUDIO_PLUGIN_ENTRY_STR);
+ return (AudioID *)NULL;
+ }
+
+ p = fn();
if (p == NULL || p->name == NULL) {
- *error = (char*)g_strdup_printf("Unknown plugin %s ", name);
- return (AudioID *)NULL;
+ *error = (char*) g_strdup_printf("plugin %s not found",
+ name);
+ return (AudioID *)NULL;
}
id = p->open (pars);
if (id == NULL) {
- *error = (char*) g_strdup_printf("Couldn't open %s plugin", name);
- return (AudioID *)NULL;
+ *error = (char*) g_strdup_printf("Couldn't open %s plugin", name);
+ return (AudioID *)NULL;
}
id->function = p;
@@ -205,9 +237,16 @@ spd_audio_close(AudioID *id)
{
int ret = 0;
if (id && id->function->close){
- return (id->function->close(id));
+ ret = (id->function->close(id));
+ }
+
+ if (NULL != lt_h){
+ lt_dlclose (lt_h);
+ lt_h = NULL;
+ lt_dlexit ();
}
- return -1;
+
+ return ret;
}
/* Set volume for playing tracks on the device id
diff --git a/src/modules/audio/spd_audio.h b/src/modules/audio/spd_audio.h
index 90aa95f..7aa5b77 100644
--- a/src/modules/audio/spd_audio.h
+++ b/src/modules/audio/spd_audio.h
@@ -27,6 +27,8 @@
#include "spd_audio_plugin.h"
+#define SPD_AUDIO_LIB_PREFIX "spd_"
+
AudioID* spd_audio_open(char *name, void **pars, char **error);
int spd_audio_play(AudioID *id, AudioTrack track, AudioFormat format);
diff --git a/src/modules/audio/spd_audio_plugin.h
b/src/modules/audio/spd_audio_plugin.h
index 6fae68a..45d5d47 100644
--- a/src/modules/audio/spd_audio_plugin.h
+++ b/src/modules/audio/spd_audio_plugin.h
@@ -23,6 +23,8 @@
#ifndef __SPD_AUDIO_PLUGIN_H
#define __SPD_AUDIO_PLUGIN_H
+#define SPD_AUDIO_PLUGIN_ENTRY_STR "spd_audio_plugin_get"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/modules/audio/static_plugins.c.in
b/src/modules/audio/static_plugins.c.in
deleted file mode 100644
index 055f4d1..0000000
--- a/src/modules/audio/static_plugins.c.in
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * static_plugins.c -- spd audio library static plugins
- *
- * Copyright (C) 2010 Andrei Kholodnyi
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1, or (at your option) any later
- * version.
- *
- * This software 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include "spd_audio_plugin.h"
-
- at STATIC_AUDIO_PLUGINS_EXTERN@
-
-static spd_audio_plugin_t const * (* spd_audio_static_plugins[]) (void) =
-{
- @STATIC_AUDIO_PLUGINS_GET@
- 0
-};
-
-spd_audio_plugin_t const * spd_audio_static_plugin_get (char * name)
-{
- int i;
- spd_audio_plugin_t const * plugin;
-
- for (i=0; spd_audio_static_plugins[i]; i++)
- {
- plugin = spd_audio_static_plugins[i]();
- if (plugin != NULL && 0 == strcmp(plugin->name, name))
- {
- return plugin;
- }
- }
-
- return (spd_audio_plugin_t *)NULL;
-}
diff --git a/src/modules/module_main.c b/src/modules/module_main.c
index b014702..baca7b3 100644
--- a/src/modules/module_main.c
+++ b/src/modules/module_main.c
@@ -31,6 +31,7 @@
#include <pthread.h>
#include <glib.h>
#include <dotconf.h>
+#include <ltdl.h>
#include <spd_utils.h>
#include "module_utils.h"
@@ -79,6 +80,8 @@ main(int argc, char *argv[])
g_thread_init(NULL);
+ /* Initialize ltdl's list of preloaded audio backends. */
+ LTDL_SET_PRELOADED_SYMBOLS();
module_num_dc_options = 0;
module_audio_id = 0;
--
1.7.3.3
- [PATCH] Convert audio subsystem to use dynamically-loaded plugins.,
Christopher Brannon <=