1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
$NetBSD: patch-ba,v 1.2 2003/07/26 23:05:34 jmmv Exp $
--- src/audio/SDL_audio.c.orig 2002-10-05 18:50:56.000000000 +0200
+++ src/audio/SDL_audio.c
@@ -38,8 +38,15 @@ static char rcsid =
#include "SDL_audiomem.h"
#include "SDL_sysaudio.h"
+#include "SDL_name.h"
+#include "SDL_loadso.h"
+
/* Available audio drivers */
static AudioBootStrap *bootstrap[] = {
+ NULL, /* Optional 1: either arts, esd, nas */
+ NULL, /* Optional 2: either arts, esd, nas */
+ NULL, /* Optional 3: either arts, esd, nas */
+#define PLUGIN_COUNT 3
#ifdef OPENBSD_AUDIO_SUPPORT
&OPENBSD_AUDIO_bootstrap,
#endif
@@ -56,15 +63,6 @@ static AudioBootStrap *bootstrap[] = {
#ifdef DMEDIA_SUPPORT
&DMEDIA_bootstrap,
#endif
-#ifdef ARTSC_SUPPORT
- &ARTSC_bootstrap,
-#endif
-#ifdef ESD_SUPPORT
- &ESD_bootstrap,
-#endif
-#ifdef NAS_SUPPORT
- &NAS_bootstrap,
-#endif
#ifdef ENABLE_DIRECTX
&DSOUND_bootstrap,
#endif
@@ -252,16 +250,48 @@ static void SDL_UnlockAudio_Default(SDL_
SDL_mutexV(audio->mixer_lock);
}
+static int SDL_LoadAudioPlugins(void)
+{
+ int first = PLUGIN_COUNT;
+ char *envvar;
+ void *plugin;
+
+#define DO_LOAD(IDNAME, SONAME, BSNAME, PKGNAME) \
+ envvar = getenv("SDL_AUDIO_PLUGIN"); \
+ if (envvar == NULL || strcmp(envvar, IDNAME) == 0) { \
+ plugin = SDL_LoadObject(SONAME); \
+ if (plugin != NULL) { \
+ struct AudioBootStrap *bs; \
+ bs = SDL_LoadFunction(plugin, BSNAME); \
+ if (bs != NULL) { \
+ bootstrap[--first] = bs; \
+ } \
+ } else if (envvar != NULL && strcmp(envvar, IDNAME) == 0) { \
+ fprintf(stderr, "SDL (pkgsrc): SDL_AUDIO_PLUGIN is explicitly set to `" IDNAME "'.\n"); \
+ fprintf(stderr, "SDL (pkgsrc): Please install the " PKGNAME " package and retry.\n"); \
+ } \
+ }
+
+ DO_LOAD("arts", "libaudio_arts.so", "ARTSC_bootstrap", "audio/SDL-arts");
+ DO_LOAD("esound", "libaudio_esd.so", "ESD_bootstrap", "audio/SDL-esound");
+ DO_LOAD("nas", "libaudio_nas.so", "NAS_bootstrap", "audio/SDL-nas");
+#undef DO_LOAD
+
+ return first;
+}
+
int SDL_AudioInit(const char *driver_name)
{
SDL_AudioDevice *audio;
- int i = 0, idx;
+ int i = 0, idx, first;
/* Check to make sure we don't overwrite 'current_audio' */
if ( current_audio != NULL ) {
SDL_AudioQuit();
}
+ first = SDL_LoadAudioPlugins();
+
/* Select the proper audio driver */
audio = NULL;
idx = 0;
@@ -271,7 +301,7 @@ int SDL_AudioInit(const char *driver_nam
to use ESD, but don't start it if it's not already running.
This probably isn't the place to do this, but... Shh! :)
*/
- for ( i=0; bootstrap[i]; ++i ) {
+ for ( i=first; bootstrap[i]; ++i ) {
if ( strcmp(bootstrap[i]->name, "esd") == 0 ) {
const char *esd_no_spawn;
@@ -300,7 +330,7 @@ int SDL_AudioInit(const char *driver_nam
idx = atoi(strrchr(driver_name, ':')+1);
}
#endif
- for ( i=0; bootstrap[i]; ++i ) {
+ for ( i=first; bootstrap[i]; ++i ) {
if (strncmp(bootstrap[i]->name, driver_name,
strlen(bootstrap[i]->name)) == 0) {
if ( bootstrap[i]->available() ) {
@@ -310,7 +340,7 @@ int SDL_AudioInit(const char *driver_nam
}
}
} else {
- for ( i=0; bootstrap[i]; ++i ) {
+ for ( i=first; bootstrap[i]; ++i ) {
if ( bootstrap[i]->available() ) {
audio = bootstrap[i]->create(idx);
if ( audio != NULL ) {
|