Attempt to clean up PulseAudio dynamic loading support.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 17 Jan 2010 06:43:28 +0000
changeset 3673c9d5bd1b4e18
parent 3672 878d8adf2fde
child 3674 7b597182d06b
Attempt to clean up PulseAudio dynamic loading support.
src/audio/pulseaudio/SDL_pulseaudio.c
     1.1 --- a/src/audio/pulseaudio/SDL_pulseaudio.c	Sun Jan 17 06:14:04 2010 +0000
     1.2 +++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Sun Jan 17 06:43:28 2010 +0000
     1.3 @@ -45,19 +45,11 @@
     1.4  #include "../SDL_audiomem.h"
     1.5  #include "../SDL_audio_c.h"
     1.6  #include "SDL_pulseaudio.h"
     1.7 -
     1.8 -#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
     1.9 -#include "SDL_name.h"
    1.10  #include "SDL_loadso.h"
    1.11 -#else
    1.12 -#define SDL_NAME(X)	X
    1.13 -#endif
    1.14  
    1.15  /* The tag name used by pulse audio */
    1.16  #define PULSEAUDIO_DRIVER_NAME         "pulseaudio"
    1.17  
    1.18 -#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
    1.19 -
    1.20  #if (PA_API_VERSION < 12)
    1.21  /** Return non-zero if the passed state is one of the connected states */
    1.22  static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
    1.23 @@ -75,157 +67,159 @@
    1.24  }
    1.25  #endif /* pulseaudio <= 0.9.10 */
    1.26  
    1.27 -static const char *pulse_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
    1.28 -static void *pulse_handle = NULL;
    1.29  
    1.30 -/* !!! FIXME: I hate this SDL_NAME clutter...it makes everything so messy! */
    1.31 -static pa_simple *(*SDL_NAME(pa_simple_new)) (const char *server,
    1.32 -                                              const char *name,
    1.33 -                                              pa_stream_direction_t dir,
    1.34 -                                              const char *dev,
    1.35 -                                              const char *stream_name,
    1.36 -                                              const pa_sample_spec * ss,
    1.37 -                                              const pa_channel_map * map,
    1.38 -                                              const pa_buffer_attr * attr,
    1.39 -                                              int *error);
    1.40 -static void (*SDL_NAME(pa_simple_free)) (pa_simple * s);
    1.41 -static pa_channel_map *(*SDL_NAME(pa_channel_map_init_auto)) (pa_channel_map *
    1.42 -                                                              m,
    1.43 -                                                              unsigned
    1.44 -                                                              channels,
    1.45 -                                                              pa_channel_map_def_t
    1.46 -                                                              def);
    1.47 -static const char *(*SDL_NAME(pa_strerror)) (int error);
    1.48 -static pa_mainloop * (*SDL_NAME(pa_mainloop_new))(void);
    1.49 -static pa_mainloop_api * (*SDL_NAME(pa_mainloop_get_api))(pa_mainloop *m);
    1.50 -static int (*SDL_NAME(pa_mainloop_iterate))(pa_mainloop *m, int block, int *retval);
    1.51 -static void (*SDL_NAME(pa_mainloop_free))(pa_mainloop *m);
    1.52 +static pa_simple *(*PULSEAUDIO_pa_simple_new) (const char *, const char *,
    1.53 +    pa_stream_direction_t, const char *, const char *, const pa_sample_spec *,
    1.54 +    const pa_channel_map *, const pa_buffer_attr *, int *);
    1.55 +static void (*PULSEAUDIO_pa_simple_free) (pa_simple *);
    1.56 +static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto) (
    1.57 +    pa_channel_map *, unsigned, pa_channel_map_def_t);
    1.58 +static const char * (*PULSEAUDIO_pa_strerror) (int);
    1.59 +static pa_mainloop * (*PULSEAUDIO_pa_mainloop_new) (void);
    1.60 +static pa_mainloop_api * (*PULSEAUDIO_pa_mainloop_get_api) (pa_mainloop *);
    1.61 +static int (*PULSEAUDIO_pa_mainloop_iterate) (pa_mainloop *, int, int *);
    1.62 +static void (*PULSEAUDIO_pa_mainloop_free) (pa_mainloop *);
    1.63 +
    1.64 +static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state) (
    1.65 +    pa_operation *);
    1.66 +static void (*PULSEAUDIO_pa_operation_cancel) (pa_operation *);
    1.67 +static void (*PULSEAUDIO_pa_operation_unref) (pa_operation *);
    1.68  
    1.69 -static pa_operation_state_t (*SDL_NAME(pa_operation_get_state))(pa_operation *o);
    1.70 -static void (*SDL_NAME(pa_operation_cancel))(pa_operation *o);
    1.71 -static void (*SDL_NAME(pa_operation_unref))(pa_operation *o);
    1.72 -
    1.73 -static pa_context * (*SDL_NAME(pa_context_new))(
    1.74 -    pa_mainloop_api *m, const char *name);
    1.75 -static int (*SDL_NAME(pa_context_connect))(
    1.76 -    pa_context *c, const char *server,
    1.77 -    pa_context_flags_t flags, const pa_spawn_api *api);
    1.78 -static pa_context_state_t (*SDL_NAME(pa_context_get_state))(pa_context *c);
    1.79 -static void (*SDL_NAME(pa_context_disconnect))(pa_context *c);
    1.80 -static void (*SDL_NAME(pa_context_unref))(pa_context *c);
    1.81 +static pa_context * (*PULSEAUDIO_pa_context_new) (pa_mainloop_api *,
    1.82 +    const char *);
    1.83 +static int (*PULSEAUDIO_pa_context_connect) (pa_context *, const char *,
    1.84 +    pa_context_flags_t, const pa_spawn_api *);
    1.85 +static pa_context_state_t (*PULSEAUDIO_pa_context_get_state) (pa_context *);
    1.86 +static void (*PULSEAUDIO_pa_context_disconnect) (pa_context *);
    1.87 +static void (*PULSEAUDIO_pa_context_unref) (pa_context *);
    1.88  
    1.89 -static pa_stream * (*SDL_NAME(pa_stream_new))(pa_context *c,
    1.90 -    const char *name, const pa_sample_spec *ss, const pa_channel_map *map);
    1.91 -static int (*SDL_NAME(pa_stream_connect_playback))(pa_stream *s, const char *dev,
    1.92 -    const pa_buffer_attr *attr, pa_stream_flags_t flags,
    1.93 -    pa_cvolume *volume, pa_stream *sync_stream);
    1.94 -static pa_stream_state_t (*SDL_NAME(pa_stream_get_state))(pa_stream *s);
    1.95 -static size_t (*SDL_NAME(pa_stream_writable_size))(pa_stream *s);
    1.96 -static int (*SDL_NAME(pa_stream_write))(pa_stream *s, const void *data, size_t nbytes,
    1.97 -    pa_free_cb_t free_cb, int64_t offset, pa_seek_mode_t seek);
    1.98 -static pa_operation * (*SDL_NAME(pa_stream_drain))(pa_stream *s,
    1.99 -    pa_stream_success_cb_t cb, void *userdata);
   1.100 -static int (*SDL_NAME(pa_stream_disconnect))(pa_stream *s);
   1.101 -static void (*SDL_NAME(pa_stream_unref))(pa_stream *s);
   1.102 +static pa_stream * (*PULSEAUDIO_pa_stream_new) (pa_context *, const char *,
   1.103 +    const pa_sample_spec *, const pa_channel_map *);
   1.104 +static int (*PULSEAUDIO_pa_stream_connect_playback) (pa_stream *, const char *,
   1.105 +    const pa_buffer_attr *, pa_stream_flags_t, pa_cvolume *, pa_stream *);
   1.106 +static pa_stream_state_t (*PULSEAUDIO_pa_stream_get_state) (pa_stream *);
   1.107 +static size_t (*PULSEAUDIO_pa_stream_writable_size) (pa_stream *);
   1.108 +static int (*PULSEAUDIO_pa_stream_write) (pa_stream *, const void *, size_t,
   1.109 +    pa_free_cb_t, int64_t, pa_seek_mode_t);
   1.110 +static pa_operation * (*PULSEAUDIO_pa_stream_drain) (pa_stream *,
   1.111 +    pa_stream_success_cb_t, void *);
   1.112 +static int (*PULSEAUDIO_pa_stream_disconnect) (pa_stream *);
   1.113 +static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *);
   1.114 +
   1.115 +static int load_pulseaudio_syms(void);
   1.116  
   1.117  
   1.118 -#define SDL_PULSEAUDIO_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
   1.119 -static struct
   1.120 +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
   1.121 +
   1.122 +static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
   1.123 +static void *pulseaudio_handle = NULL;
   1.124 +
   1.125 +static int
   1.126 +load_pulseaudio_sym(const char *fn, void **addr)
   1.127  {
   1.128 -    const char *name;
   1.129 -    void **func;
   1.130 -} pulse_functions[] = {
   1.131 -/* *INDENT-OFF* */
   1.132 -    SDL_PULSEAUDIO_SYM(pa_simple_new),
   1.133 -    SDL_PULSEAUDIO_SYM(pa_simple_free),
   1.134 -    SDL_PULSEAUDIO_SYM(pa_mainloop_new),
   1.135 -    SDL_PULSEAUDIO_SYM(pa_mainloop_get_api),
   1.136 -    SDL_PULSEAUDIO_SYM(pa_mainloop_iterate),
   1.137 -    SDL_PULSEAUDIO_SYM(pa_mainloop_free),
   1.138 -    SDL_PULSEAUDIO_SYM(pa_operation_get_state),
   1.139 -    SDL_PULSEAUDIO_SYM(pa_operation_cancel),
   1.140 -    SDL_PULSEAUDIO_SYM(pa_operation_unref),
   1.141 -    SDL_PULSEAUDIO_SYM(pa_context_new),
   1.142 -    SDL_PULSEAUDIO_SYM(pa_context_connect),
   1.143 -    SDL_PULSEAUDIO_SYM(pa_context_get_state),
   1.144 -    SDL_PULSEAUDIO_SYM(pa_context_disconnect),
   1.145 -    SDL_PULSEAUDIO_SYM(pa_context_unref),
   1.146 -    SDL_PULSEAUDIO_SYM(pa_stream_new),
   1.147 -    SDL_PULSEAUDIO_SYM(pa_stream_connect_playback),
   1.148 -    SDL_PULSEAUDIO_SYM(pa_stream_get_state),
   1.149 -    SDL_PULSEAUDIO_SYM(pa_stream_writable_size),
   1.150 -    SDL_PULSEAUDIO_SYM(pa_stream_write),
   1.151 -    SDL_PULSEAUDIO_SYM(pa_stream_drain),
   1.152 -    SDL_PULSEAUDIO_SYM(pa_stream_disconnect),
   1.153 -    SDL_PULSEAUDIO_SYM(pa_stream_unref),
   1.154 -    SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto),
   1.155 -    SDL_PULSEAUDIO_SYM(pa_strerror),
   1.156 -/* *INDENT-ON* */
   1.157 -};
   1.158 +    *addr = SDL_LoadFunction(pulseaudio_handle, fn);
   1.159 +    if (*addr == NULL) {
   1.160 +        /* Don't call SDL_SetError(): SDL_LoadFunction already did. */
   1.161 +        return 0;
   1.162 +    }
   1.163  
   1.164 -#undef SDL_PULSEAUDIO_SYM
   1.165 +    return 1;
   1.166 +}
   1.167 +
   1.168 +/* cast funcs to char* first, to please GCC's strict aliasing rules. */
   1.169 +#define SDL_PULSEAUDIO_SYM(x) \
   1.170 +    if (!load_pulseaudio_sym(#x, (void **) (char *) &PULSEAUDIO_##x)) return -1
   1.171  
   1.172  static void
   1.173 -UnloadPulseLibrary()
   1.174 +UnloadPulseAudioLibrary(void)
   1.175  {
   1.176 -    if (pulse_handle != NULL) {
   1.177 -        SDL_UnloadObject(pulse_handle);
   1.178 -        pulse_handle = NULL;
   1.179 +    if (pulseaudio_handle != NULL) {
   1.180 +		SDL_UnloadObject(pulseaudio_handle);
   1.181 +        pulseaudio_handle = NULL;
   1.182      }
   1.183  }
   1.184  
   1.185  static int
   1.186 -LoadPulseLibrary(void)
   1.187 +LoadPulseAudioLibrary(void)
   1.188  {
   1.189 -    int i, retval = -1;
   1.190 -
   1.191 -    if (pulse_handle == NULL) {
   1.192 -        pulse_handle = SDL_LoadObject(pulse_library);
   1.193 -        if (pulse_handle != NULL) {
   1.194 -            retval = 0;
   1.195 -            for (i = 0; i < SDL_arraysize(pulse_functions); ++i) {
   1.196 -                *pulse_functions[i].func =
   1.197 -                    SDL_LoadFunction(pulse_handle, pulse_functions[i].name);
   1.198 -                if (!*pulse_functions[i].func) {
   1.199 -                    retval = -1;
   1.200 -                    UnloadPulseLibrary();
   1.201 -                    break;
   1.202 -                }
   1.203 +    int retval = 0;
   1.204 +    if (pulseaudio_handle == NULL) {
   1.205 +        pulseaudio_handle = SDL_LoadObject(pulseaudio_library);
   1.206 +        if (pulseaudio_handle == NULL) {
   1.207 +            retval = -1;
   1.208 +            /* Don't call SDL_SetError(): SDL_LoadObject already did. */
   1.209 +        } else {
   1.210 +            retval = load_pulseaudio_syms();
   1.211 +            if (retval < 0) {
   1.212 +                UnloadPulseAudioLibrary();
   1.213              }
   1.214          }
   1.215      }
   1.216 -
   1.217      return retval;
   1.218  }
   1.219  
   1.220  #else
   1.221  
   1.222 +#define SDL_PULSEAUDIO_SYM(x) PULSEAUDIO_##x = x
   1.223 +
   1.224  static void
   1.225 -UnloadPulseLibrary()
   1.226 +UnloadPulseAudioLibrary(void)
   1.227  {
   1.228 -    return;
   1.229  }
   1.230  
   1.231  static int
   1.232 -LoadPulseLibrary(void)
   1.233 +LoadPulseAudioLibrary(void)
   1.234  {
   1.235 +    load_pulseaudio_syms();
   1.236      return 0;
   1.237  }
   1.238  
   1.239  #endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
   1.240  
   1.241 +
   1.242 +static int
   1.243 +load_pulseaudio_syms(void)
   1.244 +{
   1.245 +    SDL_PULSEAUDIO_SYM(pa_simple_new);
   1.246 +    SDL_PULSEAUDIO_SYM(pa_simple_free);
   1.247 +    SDL_PULSEAUDIO_SYM(pa_mainloop_new);
   1.248 +    SDL_PULSEAUDIO_SYM(pa_mainloop_get_api);
   1.249 +    SDL_PULSEAUDIO_SYM(pa_mainloop_iterate);
   1.250 +    SDL_PULSEAUDIO_SYM(pa_mainloop_free);
   1.251 +    SDL_PULSEAUDIO_SYM(pa_operation_get_state);
   1.252 +    SDL_PULSEAUDIO_SYM(pa_operation_cancel);
   1.253 +    SDL_PULSEAUDIO_SYM(pa_operation_unref);
   1.254 +    SDL_PULSEAUDIO_SYM(pa_context_new);
   1.255 +    SDL_PULSEAUDIO_SYM(pa_context_connect);
   1.256 +    SDL_PULSEAUDIO_SYM(pa_context_get_state);
   1.257 +    SDL_PULSEAUDIO_SYM(pa_context_disconnect);
   1.258 +    SDL_PULSEAUDIO_SYM(pa_context_unref);
   1.259 +    SDL_PULSEAUDIO_SYM(pa_stream_new);
   1.260 +    SDL_PULSEAUDIO_SYM(pa_stream_connect_playback);
   1.261 +    SDL_PULSEAUDIO_SYM(pa_stream_get_state);
   1.262 +    SDL_PULSEAUDIO_SYM(pa_stream_writable_size);
   1.263 +    SDL_PULSEAUDIO_SYM(pa_stream_write);
   1.264 +    SDL_PULSEAUDIO_SYM(pa_stream_drain);
   1.265 +    SDL_PULSEAUDIO_SYM(pa_stream_disconnect);
   1.266 +    SDL_PULSEAUDIO_SYM(pa_stream_unref);
   1.267 +    SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto);
   1.268 +    SDL_PULSEAUDIO_SYM(pa_strerror);
   1.269 +    return 0;
   1.270 +}
   1.271 +
   1.272 +
   1.273  /* This function waits until it is possible to write a full sound buffer */
   1.274  static void
   1.275  PULSEAUDIO_WaitDevice(_THIS)
   1.276  {
   1.277      while(1) {
   1.278 -        if (SDL_NAME(pa_context_get_state)(this->hidden->context) != PA_CONTEXT_READY ||
   1.279 -            SDL_NAME(pa_stream_get_state)(this->hidden->stream) != PA_STREAM_READY ||
   1.280 -            SDL_NAME(pa_mainloop_iterate)(this->hidden->mainloop, 1, NULL) < 0) {
   1.281 +        if (PULSEAUDIO_pa_context_get_state(this->hidden->context) != PA_CONTEXT_READY ||
   1.282 +            PULSEAUDIO_pa_stream_get_state(this->hidden->stream) != PA_STREAM_READY ||
   1.283 +            PULSEAUDIO_pa_mainloop_iterate(this->hidden->mainloop, 1, NULL) < 0) {
   1.284              this->enabled = 0;
   1.285              return;
   1.286          }
   1.287 -        if (SDL_NAME(pa_stream_writable_size)(this->hidden->stream) >= this->hidden->mixlen) {
   1.288 +        if (PULSEAUDIO_pa_stream_writable_size(this->hidden->stream) >= this->hidden->mixlen) {
   1.289              return;
   1.290          }
   1.291      }
   1.292 @@ -235,7 +229,7 @@
   1.293  PULSEAUDIO_PlayDevice(_THIS)
   1.294  {
   1.295      /* Write the audio data */
   1.296 -    if (SDL_NAME(pa_stream_write) (this->hidden->stream, this->hidden->mixbuf,
   1.297 +    if (PULSEAUDIO_pa_stream_write(this->hidden->stream, this->hidden->mixbuf,
   1.298                                     this->hidden->mixlen, NULL, 0LL,
   1.299                                     PA_SEEK_RELATIVE) < 0) {
   1.300          this->enabled = 0;
   1.301 @@ -253,21 +247,21 @@
   1.302  {
   1.303      pa_operation *o;
   1.304  
   1.305 -    o = SDL_NAME(pa_stream_drain)(this->hidden->stream, stream_drain_complete, NULL);
   1.306 +    o = PULSEAUDIO_pa_stream_drain(this->hidden->stream, stream_drain_complete, NULL);
   1.307      if (!o) {
   1.308          return;
   1.309      }
   1.310  
   1.311 -    while (SDL_NAME(pa_operation_get_state)(o) != PA_OPERATION_DONE) {
   1.312 -        if (SDL_NAME(pa_context_get_state)(this->hidden->context) != PA_CONTEXT_READY ||
   1.313 -            SDL_NAME(pa_stream_get_state)(this->hidden->stream) != PA_STREAM_READY ||
   1.314 -            SDL_NAME(pa_mainloop_iterate)(this->hidden->mainloop, 1, NULL) < 0) {
   1.315 -            SDL_NAME(pa_operation_cancel)(o);
   1.316 +    while (PULSEAUDIO_pa_operation_get_state(o) != PA_OPERATION_DONE) {
   1.317 +        if (PULSEAUDIO_pa_context_get_state(this->hidden->context) != PA_CONTEXT_READY ||
   1.318 +            PULSEAUDIO_pa_stream_get_state(this->hidden->stream) != PA_STREAM_READY ||
   1.319 +            PULSEAUDIO_pa_mainloop_iterate(this->hidden->mainloop, 1, NULL) < 0) {
   1.320 +            PULSEAUDIO_pa_operation_cancel(o);
   1.321              break;
   1.322          }
   1.323      }
   1.324  
   1.325 -    SDL_NAME(pa_operation_unref)(o);
   1.326 +    PULSEAUDIO_pa_operation_unref(o);
   1.327  }
   1.328  
   1.329  
   1.330 @@ -288,17 +282,17 @@
   1.331              this->hidden->mixbuf = NULL;
   1.332          }
   1.333          if (this->hidden->stream) {
   1.334 -            SDL_NAME(pa_stream_disconnect)(this->hidden->stream);
   1.335 -            SDL_NAME(pa_stream_unref)(this->hidden->stream);
   1.336 +            PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
   1.337 +            PULSEAUDIO_pa_stream_unref(this->hidden->stream);
   1.338              this->hidden->stream = NULL;
   1.339          }
   1.340          if (this->hidden->context != NULL) {
   1.341 -            SDL_NAME(pa_context_disconnect)(this->hidden->context);
   1.342 -            SDL_NAME(pa_context_unref)(this->hidden->context);
   1.343 +            PULSEAUDIO_pa_context_disconnect(this->hidden->context);
   1.344 +            PULSEAUDIO_pa_context_unref(this->hidden->context);
   1.345              this->hidden->context = NULL;
   1.346          }
   1.347          if (this->hidden->mainloop != NULL) {
   1.348 -            SDL_NAME(pa_mainloop_free)(this->hidden->mainloop);
   1.349 +            PULSEAUDIO_pa_mainloop_free(this->hidden->mainloop);
   1.350              this->hidden->mainloop = NULL;
   1.351          }
   1.352          SDL_free(this->hidden);
   1.353 @@ -427,37 +421,37 @@
   1.354  
   1.355      /* The SDL ALSA output hints us that we use Windows' channel mapping */
   1.356      /* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */
   1.357 -    SDL_NAME(pa_channel_map_init_auto) (&pacmap, this->spec.channels,
   1.358 +    PULSEAUDIO_pa_channel_map_init_auto(&pacmap, this->spec.channels,
   1.359                                          PA_CHANNEL_MAP_WAVEEX);
   1.360  
   1.361      /* Set up a new main loop */
   1.362 -    if (!(this->hidden->mainloop = SDL_NAME(pa_mainloop_new)())) {
   1.363 +    if (!(this->hidden->mainloop = PULSEAUDIO_pa_mainloop_new())) {
   1.364          PULSEAUDIO_CloseDevice(this);
   1.365          SDL_SetError("pa_mainloop_new() failed");
   1.366          return 0;
   1.367      }
   1.368  
   1.369 -    this->hidden->mainloop_api = SDL_NAME(pa_mainloop_get_api)(this->hidden->mainloop);
   1.370 -    if (!(this->hidden->context = SDL_NAME(pa_context_new)(this->hidden->mainloop_api, get_progname()))) {
   1.371 +    this->hidden->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(this->hidden->mainloop);
   1.372 +    if (!(this->hidden->context = PULSEAUDIO_pa_context_new(this->hidden->mainloop_api, get_progname()))) {
   1.373          PULSEAUDIO_CloseDevice(this);
   1.374          SDL_SetError("pa_context_new() failed");
   1.375          return 0;
   1.376      }
   1.377  
   1.378      /* Connect to the PulseAudio server */
   1.379 -    if (SDL_NAME(pa_context_connect)(this->hidden->context, NULL, 0, NULL) < 0) {
   1.380 +    if (PULSEAUDIO_pa_context_connect(this->hidden->context, NULL, 0, NULL) < 0) {
   1.381          PULSEAUDIO_CloseDevice(this);
   1.382          SDL_SetError("Could not setup connection to PulseAudio");
   1.383          return 0;
   1.384      }
   1.385  
   1.386      do {
   1.387 -        if (SDL_NAME(pa_mainloop_iterate)(this->hidden->mainloop, 1, NULL) < 0) {
   1.388 +        if (PULSEAUDIO_pa_mainloop_iterate(this->hidden->mainloop, 1, NULL) < 0) {
   1.389              PULSEAUDIO_CloseDevice(this);
   1.390              SDL_SetError("pa_mainloop_iterate() failed");
   1.391              return 0;
   1.392          }
   1.393 -        state = SDL_NAME(pa_context_get_state)(this->hidden->context);
   1.394 +        state = PULSEAUDIO_pa_context_get_state(this->hidden->context);
   1.395          if (!PA_CONTEXT_IS_GOOD(state)) {
   1.396              PULSEAUDIO_CloseDevice(this);
   1.397              SDL_SetError("Could not connect to PulseAudio");
   1.398 @@ -465,7 +459,7 @@
   1.399          }
   1.400      } while (state != PA_CONTEXT_READY);
   1.401  
   1.402 -    this->hidden->stream = SDL_NAME(pa_stream_new)(
   1.403 +    this->hidden->stream = PULSEAUDIO_pa_stream_new(
   1.404          this->hidden->context,
   1.405          "Simple DirectMedia Layer", /* stream description */
   1.406          &paspec,    /* sample format spec */
   1.407 @@ -478,7 +472,7 @@
   1.408          return 0;
   1.409      }
   1.410  
   1.411 -    if (SDL_NAME(pa_stream_connect_playback)(this->hidden->stream, NULL, &paattr, flags,
   1.412 +    if (PULSEAUDIO_pa_stream_connect_playback(this->hidden->stream, NULL, &paattr, flags,
   1.413              NULL, NULL) < 0) {
   1.414          PULSEAUDIO_CloseDevice(this);
   1.415          SDL_SetError("Could not connect PulseAudio stream");
   1.416 @@ -486,12 +480,12 @@
   1.417      }
   1.418  
   1.419      do {
   1.420 -        if (SDL_NAME(pa_mainloop_iterate)(this->hidden->mainloop, 1, NULL) < 0) {
   1.421 +        if (PULSEAUDIO_pa_mainloop_iterate(this->hidden->mainloop, 1, NULL) < 0) {
   1.422              PULSEAUDIO_CloseDevice(this);
   1.423              SDL_SetError("pa_mainloop_iterate() failed");
   1.424              return 0;
   1.425          }
   1.426 -        state = SDL_NAME(pa_stream_get_state)(this->hidden->stream);
   1.427 +        state = PULSEAUDIO_pa_stream_get_state(this->hidden->stream);
   1.428          if (!PA_STREAM_IS_GOOD(state)) {
   1.429              PULSEAUDIO_CloseDevice(this);
   1.430              SDL_SetError("Could not create to PulseAudio stream");
   1.431 @@ -507,14 +501,14 @@
   1.432  static void
   1.433  PULSEAUDIO_Deinitialize(void)
   1.434  {
   1.435 -    UnloadPulseLibrary();
   1.436 +    UnloadPulseAudioLibrary();
   1.437  }
   1.438  
   1.439  
   1.440  static int
   1.441  PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
   1.442  {
   1.443 -    if (LoadPulseLibrary() < 0) {
   1.444 +    if (LoadPulseAudioLibrary() < 0) {
   1.445          return 0;
   1.446      }
   1.447