t"Real" plugin support via. gmodule (still very very experimental). - 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 ed2c06e2d0e4bce066bf8fff4788b014509665fd
(DIR) parent 137f2f5d8c2ca095c2db249b5c82d44f9d3089f4
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Mon, 13 May 2002 15:35:20 +0000
"Real" plugin support via. gmodule (still very very experimental).
Diffstat:
M src/sound.c | 38 +++++++++++++++++++++----------
1 file changed, 26 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/src/sound.c b/src/sound.c
t@@ -24,23 +24,34 @@
#include <config.h>
#endif
-#include "sound_esd.h"
-#include "sound_sdl.h"
-#include "sound_winmm.h"
+#include <glib.h>
+#include <gmodule.h>
+
+#include "sound.h"
static SoundDriver *driver = NULL;
+typedef SoundDriver *(*InitFunc)(void);
+GModule *soundmodule = NULL;
void SoundInit(void)
{
-#ifdef HAVE_SDL_MIXER
- driver = SoundInit_SDL();
-#endif
-//#ifdef HAVE_ESD
-// driver = SoundInit_ESD();
-//#endif
-#ifdef HAVE_WINMM
- driver = SoundInit_WinMM();
-#endif
+ InitFunc ifunc;
+ gchar *err;
+
+ soundmodule = g_module_open("sound.so", G_MODULE_BIND_LAZY);
+ if (!soundmodule) {
+ g_print("g_module_open failed: %s\n", g_module_error());
+ return;
+ }
+ if (g_module_symbol(soundmodule, "init", (gpointer *)&ifunc)) {
+ g_print("module symbol = %p\n", ifunc);
+ driver = (*ifunc)();
+ if (driver) {
+ g_print("Plugin %s init OK\n", driver->name);
+ }
+ } else {
+ g_print("g_module_symbol failed: %s\n", g_module_error());
+ }
}
void SoundOpen(gchar *drivername)
t@@ -55,6 +66,9 @@ void SoundClose(void)
if (driver && driver->close) {
driver->close();
}
+ if (soundmodule) {
+ g_module_close(soundmodule);
+ }
}
void SoundPlay(const gchar *snd)