46
49
static int selected_plugin = -1;
48
51
/**********************************************************************
49
Returns a static, NULL-terminated list of all sound plugins
52
Returns a static string vector of all sound plugins
50
53
available on the system. This function is unfortunately similar to
51
54
audio_get_all_plugin_names().
52
55
***********************************************************************/
53
const char **get_soundplugin_list(void)
56
const struct strvec *get_soundplugin_list(void)
55
static const char* plugin_list[MAX_NUM_PLUGINS + 1];
58
for (i = 0; i < num_plugins_used; i++) {
59
plugin_list[i] = plugins[i].name;
58
static struct strvec *plugin_list = NULL;
60
if (NULL == plugin_list) {
63
plugin_list = strvec_new();
64
strvec_reserve(plugin_list, num_plugins_used);
65
for (i = 0; i < num_plugins_used; i++) {
66
strvec_set(plugin_list, i, plugins[i].name);
61
assert(i <= MAX_NUM_PLUGINS);
62
plugin_list[i] = NULL;
64
70
return plugin_list;
67
73
/**********************************************************************
68
Returns a static list of soundsets available on the system by
74
Returns a static string vector of soundsets available on the system by
69
75
searching all data directories for files matching SNDSPEC_SUFFIX.
70
76
The list is NULL-terminated.
71
77
***********************************************************************/
72
const char **get_soundset_list(void)
78
const struct strvec *get_soundset_list(void)
74
static const char **audio_list = NULL;
77
/* Note: this means you must restart the client after installing a new
79
audio_list = (const char **)datafilelist(SNDSPEC_SUFFIX);
80
static struct strvec *audio_list = NULL;
82
if (NULL == audio_list) {
85
audio_list = strvec_new();
86
list = datafilelist(SNDSPEC_SUFFIX);
87
for (file = list; NULL != *file; file++) {
88
strvec_append(audio_list, *file);
124
136
if (!plugins[i].init()) {
125
freelog(LOG_ERROR, _("Plugin %s found but can't be initialized."), name);
137
freelog(LOG_ERROR, "Plugin %s found, but can't be initialized.", name);
174
freelog(LOG_ERROR, _("Couldn't find soundset \"%s\" trying \"%s\"."),
186
freelog(LOG_ERROR, "Couldn't find soundset \"%s\", trying \"%s\".",
175
187
soundset_name, soundset_default);
176
188
return soundspec_fullname(soundset_default);
189
201
if (strcmp(prefered_plugin_name, "none") == 0) {
190
202
/* We explicitly choose none plugin, silently skip the code below */
191
freelog(LOG_VERBOSE, "Proceeding with sound support disabled");
203
freelog(LOG_VERBOSE, "Proceeding with sound support disabled.");
195
207
if (num_plugins_used == 1) {
196
208
/* We only have the dummy plugin, skip the code but issue an advertise */
197
209
freelog(LOG_NORMAL, _("No real audio plugin present."));
198
freelog(LOG_NORMAL, _("Proceeding with sound support disabled"));
210
freelog(LOG_NORMAL, _("Proceeding with sound support disabled."));
199
211
freelog(LOG_NORMAL, _("For sound support, install SDL_mixer"));
200
212
freelog(LOG_NORMAL, "http://www.libsdl.org/projects/SDL_mixer/index.html");
204
216
if (!spec_name) {
205
freelog(LOG_FATAL, _("No sound spec-file given!"));
217
freelog(LOG_FATAL, "No sound spec-file given!");
206
218
exit(EXIT_FAILURE);
208
220
freelog(LOG_VERBOSE, "Initializing sound using %s...", spec_name);
209
221
filename = soundspec_fullname(spec_name);
211
freelog(LOG_ERROR, _("Cannot find sound spec-file \"%s\"."), spec_name);
223
freelog(LOG_ERROR, "Cannot find sound spec-file \"%s\".", spec_name);
212
224
freelog(LOG_NORMAL, _("To get sound you need to download a sound set!"));
213
225
freelog(LOG_NORMAL, _("Get sound sets from <%s>."),
214
226
"ftp://ftp.freeciv.org/freeciv/contrib/audio/soundsets");
215
freelog(LOG_NORMAL, _("Proceeding with sound support disabled"));
227
freelog(LOG_NORMAL, _("Proceeding with sound support disabled."));
245
257
if (prefered_plugin_name[0] != '\0') {
246
258
if (!audio_select_plugin(prefered_plugin_name))
247
freelog(LOG_NORMAL, _("Proceeding with sound support disabled"));
259
freelog(LOG_NORMAL, _("Proceeding with sound support disabled."));
252
264
if (audio_select_plugin("sdl")) return;
255
_("No real audio subsystem managed to initialize!"));
257
_("Perhaps there is some misconfiguration or bad permissions"));
258
freelog(LOG_NORMAL, _("Proceeding with sound support disabled"));
266
freelog(LOG_NORMAL, _("No real audio subsystem managed to initialize!"));
268
_("Perhaps there is some misconfiguration or bad permissions."));
269
freelog(LOG_NORMAL, _("Proceeding with sound support disabled."));
261
272
/**************************************************************************
278
289
fullpath = datafilename(soundfile);
280
freelog(LOG_ERROR, _("Cannot find audio file %s"), soundfile);
291
freelog(LOG_ERROR, "Cannot find audio file %s", soundfile);