~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to client/audio.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100223220902-s3spqi1x4e190y0t
[ Karl Goetz ]
* Remove civserver files in /etc/ggzd/ (Closes: 523772, 517787)
* Adding ${misc:Depends} to all binary packages (lintian warnings)

[ Clint Adams ]
* New upstream version.
  - Drop data_dsc_use_bindir.diff (binary pathnames have changed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <stdlib.h>
21
21
#include <string.h>
22
22
 
 
23
/* utility */
23
24
#include "capability.h"
24
25
#include "fcintl.h"
25
26
#include "log.h"
26
27
#include "mem.h"
27
28
#include "registry.h"
28
29
#include "shared.h"
 
30
#include "string_vector.h"
29
31
#include "support.h"
30
32
 
 
33
/* client */
31
34
#include "audio_none.h"
32
35
#ifdef AUDIO_SDL
33
36
#include "audio_sdl.h"
46
49
static int selected_plugin = -1;
47
50
 
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)
54
57
{
55
 
  static const char* plugin_list[MAX_NUM_PLUGINS + 1];
56
 
  int i;
57
 
  
58
 
  for (i = 0; i < num_plugins_used; i++) {
59
 
    plugin_list[i] = plugins[i].name;
 
58
  static struct strvec *plugin_list = NULL;
 
59
 
 
60
  if (NULL == plugin_list) {
 
61
    int i;
 
62
 
 
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);
 
67
    }
60
68
  }
61
 
  assert(i <= MAX_NUM_PLUGINS);
62
 
  plugin_list[i] = NULL;
63
69
 
64
70
  return plugin_list;
65
71
}
66
72
 
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)
73
79
{
74
 
  static const char **audio_list = NULL;
75
 
 
76
 
  if (!audio_list) {
77
 
    /* Note: this means you must restart the client after installing a new
78
 
       soundset. */
79
 
    audio_list = (const char **)datafilelist(SNDSPEC_SUFFIX);
 
80
  static struct strvec *audio_list = NULL;
 
81
 
 
82
  if (NULL == audio_list) {
 
83
    char **list, **file;
 
84
 
 
85
    audio_list = strvec_new();
 
86
    list = datafilelist(SNDSPEC_SUFFIX);
 
87
    for (file = list; NULL != *file; file++) {
 
88
      strvec_append(audio_list, *file);
 
89
      free(*file);
 
90
    }
 
91
    free(list);
80
92
  }
81
93
 
82
94
  return audio_list;
122
134
  }
123
135
 
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);
126
138
    return FALSE;
127
139
  }
128
140
 
171
183
    return NULL;
172
184
  }
173
185
 
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);
177
189
}
188
200
 
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.");
192
204
    tagfile = NULL;
193
205
    return;
194
206
  }
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");
201
213
    tagfile = NULL;
202
214
    return;
203
215
  }
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);
207
219
  }
208
220
  freelog(LOG_VERBOSE, "Initializing sound using %s...", spec_name);
209
221
  filename = soundspec_fullname(spec_name);
210
222
  if (!filename) {
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."));
216
228
    tagfile = NULL;
217
229
    return;
218
230
  }
244
256
 
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."));
248
260
    return;
249
261
  }
250
262
 
251
263
#ifdef AUDIO_SDL
252
264
  if (audio_select_plugin("sdl")) return; 
253
265
#endif
254
 
  freelog(LOG_NORMAL,
255
 
    _("No real audio subsystem managed to initialize!"));
256
 
  freelog(LOG_NORMAL,
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!"));
 
267
  freelog(LOG_NORMAL,
 
268
          _("Perhaps there is some misconfiguration or bad permissions."));
 
269
  freelog(LOG_NORMAL, _("Proceeding with sound support disabled."));
259
270
}
260
271
 
261
272
/**************************************************************************
277
288
    } else {
278
289
      fullpath = datafilename(soundfile);
279
290
      if (!fullpath) {
280
 
        freelog(LOG_ERROR, _("Cannot find audio file %s"), soundfile);
 
291
        freelog(LOG_ERROR, "Cannot find audio file %s", soundfile);
281
292
      }
282
293
    }
283
294
  }