tAdded --enable-plugins configure option to control whether to build plugins or to statically link them in; separated LDFLAGS for each plugin so that (e.g.) the ESD plugin does not get linked against SDL. - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 93a4266fc985b6405024b7b0677c440993e3833c
(DIR) parent 459af9c28bbad3621b0605d3a0cafd83ddabbde9
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Mon, 13 May 2002 15:37:40 +0000
Added --enable-plugins configure option to control whether to build plugins
or to statically link them in; separated LDFLAGS for each plugin so that
(e.g.) the ESD plugin does not get linked against SDL.
Diffstat:
M src/sound.c | 38 ++++++++++++++++++++++++++-----
1 file changed, 32 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/src/sound.c b/src/sound.c
t@@ -25,7 +25,14 @@
#endif
#include <glib.h>
+
+#ifdef PLUGINS
#include <dlfcn.h>
+#else
+#include "plugins/sound_sdl.h"
+#include "plugins/sound_esd.h"
+#include "plugins/sound_winmm.h"
+#endif
#include "sound.h"
t@@ -33,25 +40,42 @@ static SoundDriver *driver = NULL;
typedef SoundDriver *(*InitFunc)(void);
void *soundmodule = NULL;
+static void AddPlugin(InitFunc ifunc)
+{
+ driver = (*ifunc)();
+ if (driver) {
+ g_print("%s sound plugin init OK\n", driver->name);
+ }
+}
+
void SoundInit(void)
{
+#ifdef PLUGINS
InitFunc ifunc;
- soundmodule = dlopen("sound.so", RTLD_NOW);
+ soundmodule = dlopen("libsound_esd.so", RTLD_NOW);
if (!soundmodule) {
/* FIXME: using dlerror() here causes a segfault later in the program */
g_print("dlopen failed\n");
return;
}
- ifunc = dlsym(soundmodule, "init");
+ ifunc = dlsym(soundmodule, "sound_esd_init");
if (ifunc) {
- driver = (*ifunc)();
- if (driver) {
- g_print("%s sound plugin init OK\n", driver->name);
- }
+ AddPlugin(ifunc);
} else {
g_print("dlsym failed: %s\n", dlerror());
}
+#else
+#ifdef HAVE_ESD
+ AddPlugin(sound_esd_init);
+#endif
+#ifdef HAVE_SDL_MIXER
+ AddPlugin(sound_sdl_init);
+#endif
+#ifdef HAVE_WINMM
+ AddPlugin(sound_winmm_init);
+#endif
+#endif
}
void SoundOpen(gchar *drivername)
t@@ -66,9 +90,11 @@ void SoundClose(void)
if (driver && driver->close) {
driver->close();
}
+#ifdef PLUGINS
if (soundmodule) {
dlclose(soundmodule);
}
+#endif
}
void SoundPlay(const gchar *snd)