src/audio/alsa/SDL_alsa_audio.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1664 cd3db072ba8a
child 1702 a7ad7081b977
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -48,11 +48,11 @@
     1.4  #define DEFAULT_DEVICE	"default"
     1.5  
     1.6  /* Audio driver functions */
     1.7 -static int ALSA_OpenAudio (_THIS, SDL_AudioSpec * spec);
     1.8 -static void ALSA_WaitAudio (_THIS);
     1.9 -static void ALSA_PlayAudio (_THIS);
    1.10 -static Uint8 *ALSA_GetAudioBuf (_THIS);
    1.11 -static void ALSA_CloseAudio (_THIS);
    1.12 +static int ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec);
    1.13 +static void ALSA_WaitAudio(_THIS);
    1.14 +static void ALSA_PlayAudio(_THIS);
    1.15 +static Uint8 *ALSA_GetAudioBuf(_THIS);
    1.16 +static void ALSA_CloseAudio(_THIS);
    1.17  
    1.18  #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
    1.19  
    1.20 @@ -62,83 +62,81 @@
    1.21  
    1.22  static int (*SDL_snd_pcm_open) (snd_pcm_t ** pcm, const char *name,
    1.23                                  snd_pcm_stream_t stream, int mode);
    1.24 -static int (*SDL_NAME (snd_pcm_open)) (snd_pcm_t ** pcm, const char *name,
    1.25 -                                       snd_pcm_stream_t stream, int mode);
    1.26 -static int (*SDL_NAME (snd_pcm_close)) (snd_pcm_t * pcm);
    1.27 -static snd_pcm_sframes_t (*SDL_NAME (snd_pcm_writei)) (snd_pcm_t * pcm,
    1.28 -                                                       const void *buffer,
    1.29 -                                                       snd_pcm_uframes_t
    1.30 -                                                       size);
    1.31 -static int (*SDL_NAME (snd_pcm_resume)) (snd_pcm_t * pcm);
    1.32 -static int (*SDL_NAME (snd_pcm_prepare)) (snd_pcm_t * pcm);
    1.33 -static int (*SDL_NAME (snd_pcm_drain)) (snd_pcm_t * pcm);
    1.34 -static const char *(*SDL_NAME (snd_strerror)) (int errnum);
    1.35 -static size_t (*SDL_NAME (snd_pcm_hw_params_sizeof)) (void);
    1.36 -static size_t (*SDL_NAME (snd_pcm_sw_params_sizeof)) (void);
    1.37 -static int (*SDL_NAME (snd_pcm_hw_params_any)) (snd_pcm_t * pcm,
    1.38 -                                                snd_pcm_hw_params_t * params);
    1.39 -static int (*SDL_NAME (snd_pcm_hw_params_set_access)) (snd_pcm_t * pcm,
    1.40 -                                                       snd_pcm_hw_params_t *
    1.41 -                                                       params,
    1.42 -                                                       snd_pcm_access_t
    1.43 -                                                       access);
    1.44 -static int (*SDL_NAME (snd_pcm_hw_params_set_format)) (snd_pcm_t * pcm,
    1.45 -                                                       snd_pcm_hw_params_t *
    1.46 -                                                       params,
    1.47 -                                                       snd_pcm_format_t val);
    1.48 -static int (*SDL_NAME (snd_pcm_hw_params_set_channels)) (snd_pcm_t * pcm,
    1.49 -                                                         snd_pcm_hw_params_t *
    1.50 -                                                         params,
    1.51 -                                                         unsigned int val);
    1.52 -static int (*SDL_NAME (snd_pcm_hw_params_get_channels)) (const
    1.53 -                                                         snd_pcm_hw_params_t *
    1.54 -                                                         params);
    1.55 +static int (*SDL_NAME(snd_pcm_open)) (snd_pcm_t ** pcm, const char *name,
    1.56 +                                      snd_pcm_stream_t stream, int mode);
    1.57 +static int (*SDL_NAME(snd_pcm_close)) (snd_pcm_t * pcm);
    1.58 +static snd_pcm_sframes_t(*SDL_NAME(snd_pcm_writei)) (snd_pcm_t * pcm,
    1.59 +                                                     const void *buffer,
    1.60 +                                                     snd_pcm_uframes_t size);
    1.61 +static int (*SDL_NAME(snd_pcm_resume)) (snd_pcm_t * pcm);
    1.62 +static int (*SDL_NAME(snd_pcm_prepare)) (snd_pcm_t * pcm);
    1.63 +static int (*SDL_NAME(snd_pcm_drain)) (snd_pcm_t * pcm);
    1.64 +static const char *(*SDL_NAME(snd_strerror)) (int errnum);
    1.65 +static size_t(*SDL_NAME(snd_pcm_hw_params_sizeof)) (void);
    1.66 +static size_t(*SDL_NAME(snd_pcm_sw_params_sizeof)) (void);
    1.67 +static int (*SDL_NAME(snd_pcm_hw_params_any)) (snd_pcm_t * pcm,
    1.68 +                                               snd_pcm_hw_params_t * params);
    1.69 +static int (*SDL_NAME(snd_pcm_hw_params_set_access)) (snd_pcm_t * pcm,
    1.70 +                                                      snd_pcm_hw_params_t *
    1.71 +                                                      params,
    1.72 +                                                      snd_pcm_access_t
    1.73 +                                                      access);
    1.74 +static int (*SDL_NAME(snd_pcm_hw_params_set_format)) (snd_pcm_t * pcm,
    1.75 +                                                      snd_pcm_hw_params_t *
    1.76 +                                                      params,
    1.77 +                                                      snd_pcm_format_t val);
    1.78 +static int (*SDL_NAME(snd_pcm_hw_params_set_channels)) (snd_pcm_t * pcm,
    1.79 +                                                        snd_pcm_hw_params_t *
    1.80 +                                                        params,
    1.81 +                                                        unsigned int val);
    1.82 +static int (*SDL_NAME(snd_pcm_hw_params_get_channels)) (const
    1.83 +                                                        snd_pcm_hw_params_t *
    1.84 +                                                        params);
    1.85  static unsigned int
    1.86 -    (*SDL_NAME (snd_pcm_hw_params_set_rate_near)) (snd_pcm_t *
    1.87 -                                                   pcm,
    1.88 -                                                   snd_pcm_hw_params_t
    1.89 -                                                   * params,
    1.90 -                                                   unsigned
    1.91 -                                                   int val, int *dir);
    1.92 +    (*SDL_NAME(snd_pcm_hw_params_set_rate_near)) (snd_pcm_t *
    1.93 +                                                  pcm,
    1.94 +                                                  snd_pcm_hw_params_t
    1.95 +                                                  * params,
    1.96 +                                                  unsigned int val, int *dir);
    1.97  static snd_pcm_uframes_t
    1.98 -    (*SDL_NAME (snd_pcm_hw_params_set_period_size_near)) (snd_pcm_t * pcm,
    1.99 -                                                          snd_pcm_hw_params_t
   1.100 -                                                          * params,
   1.101 -                                                          snd_pcm_uframes_t
   1.102 -                                                          val, int *dir);
   1.103 +    (*SDL_NAME(snd_pcm_hw_params_set_period_size_near)) (snd_pcm_t * pcm,
   1.104 +                                                         snd_pcm_hw_params_t
   1.105 +                                                         * params,
   1.106 +                                                         snd_pcm_uframes_t
   1.107 +                                                         val, int *dir);
   1.108  static snd_pcm_sframes_t
   1.109 -    (*SDL_NAME (snd_pcm_hw_params_get_period_size)) (const
   1.110 +    (*SDL_NAME(snd_pcm_hw_params_get_period_size)) (const
   1.111 +                                                    snd_pcm_hw_params_t
   1.112 +                                                    * params);
   1.113 +static unsigned int
   1.114 +    (*SDL_NAME(snd_pcm_hw_params_set_periods_near)) (snd_pcm_t * pcm,
   1.115                                                       snd_pcm_hw_params_t
   1.116 -                                                     * params);
   1.117 -static unsigned int
   1.118 -    (*SDL_NAME (snd_pcm_hw_params_set_periods_near)) (snd_pcm_t * pcm,
   1.119 -                                                      snd_pcm_hw_params_t
   1.120 -                                                      * params,
   1.121 -                                                      unsigned int val,
   1.122 -                                                      int *dir);
   1.123 -static int (*SDL_NAME (snd_pcm_hw_params_get_periods)) (snd_pcm_hw_params_t *
   1.124 -                                                        params);
   1.125 -static int (*SDL_NAME (snd_pcm_hw_params)) (snd_pcm_t * pcm,
   1.126 -                                            snd_pcm_hw_params_t * params);
   1.127 +                                                     * params,
   1.128 +                                                     unsigned int val,
   1.129 +                                                     int *dir);
   1.130 +static int (*SDL_NAME(snd_pcm_hw_params_get_periods)) (snd_pcm_hw_params_t *
   1.131 +                                                       params);
   1.132 +static int (*SDL_NAME(snd_pcm_hw_params)) (snd_pcm_t * pcm,
   1.133 +                                           snd_pcm_hw_params_t * params);
   1.134  /*
   1.135  */
   1.136 -static int (*SDL_NAME (snd_pcm_sw_params_current)) (snd_pcm_t * pcm,
   1.137 -                                                    snd_pcm_sw_params_t *
   1.138 -                                                    swparams);
   1.139 -static int (*SDL_NAME (snd_pcm_sw_params_set_start_threshold)) (snd_pcm_t *
   1.140 -                                                                pcm,
   1.141 -                                                                snd_pcm_sw_params_t
   1.142 -                                                                * params,
   1.143 -                                                                snd_pcm_uframes_t
   1.144 -                                                                val);
   1.145 -static int (*SDL_NAME (snd_pcm_sw_params_set_avail_min)) (snd_pcm_t * pcm,
   1.146 -                                                          snd_pcm_sw_params_t
   1.147 -                                                          * params,
   1.148 -                                                          snd_pcm_uframes_t
   1.149 -                                                          val);
   1.150 -static int (*SDL_NAME (snd_pcm_sw_params)) (snd_pcm_t * pcm,
   1.151 -                                            snd_pcm_sw_params_t * params);
   1.152 -static int (*SDL_NAME (snd_pcm_nonblock)) (snd_pcm_t * pcm, int nonblock);
   1.153 +static int (*SDL_NAME(snd_pcm_sw_params_current)) (snd_pcm_t * pcm,
   1.154 +                                                   snd_pcm_sw_params_t *
   1.155 +                                                   swparams);
   1.156 +static int (*SDL_NAME(snd_pcm_sw_params_set_start_threshold)) (snd_pcm_t *
   1.157 +                                                               pcm,
   1.158 +                                                               snd_pcm_sw_params_t
   1.159 +                                                               * params,
   1.160 +                                                               snd_pcm_uframes_t
   1.161 +                                                               val);
   1.162 +static int (*SDL_NAME(snd_pcm_sw_params_set_avail_min)) (snd_pcm_t * pcm,
   1.163 +                                                         snd_pcm_sw_params_t
   1.164 +                                                         * params,
   1.165 +                                                         snd_pcm_uframes_t
   1.166 +                                                         val);
   1.167 +static int (*SDL_NAME(snd_pcm_sw_params)) (snd_pcm_t * pcm,
   1.168 +                                           snd_pcm_sw_params_t * params);
   1.169 +static int (*SDL_NAME(snd_pcm_nonblock)) (snd_pcm_t * pcm, int nonblock);
   1.170  #define snd_pcm_hw_params_sizeof SDL_NAME(snd_pcm_hw_params_sizeof)
   1.171  #define snd_pcm_sw_params_sizeof SDL_NAME(snd_pcm_sw_params_sizeof)
   1.172  
   1.173 @@ -149,81 +147,81 @@
   1.174      void **func;
   1.175  } alsa_functions[] = {
   1.176      {
   1.177 -    "snd_pcm_open", (void **) (char *) &SDL_NAME (snd_pcm_open)}, {
   1.178 -    "snd_pcm_close", (void **) (char *) &SDL_NAME (snd_pcm_close)}, {
   1.179 -    "snd_pcm_writei", (void **) (char *) &SDL_NAME (snd_pcm_writei)}, {
   1.180 -    "snd_pcm_resume", (void **) (char *) &SDL_NAME (snd_pcm_resume)}, {
   1.181 -    "snd_pcm_prepare", (void **) (char *) &SDL_NAME (snd_pcm_prepare)}, {
   1.182 -    "snd_pcm_drain", (void **) (char *) &SDL_NAME (snd_pcm_drain)}, {
   1.183 -    "snd_strerror", (void **) (char *) &SDL_NAME (snd_strerror)}, {
   1.184 +    "snd_pcm_open", (void **) (char *) &SDL_NAME(snd_pcm_open)}, {
   1.185 +    "snd_pcm_close", (void **) (char *) &SDL_NAME(snd_pcm_close)}, {
   1.186 +    "snd_pcm_writei", (void **) (char *) &SDL_NAME(snd_pcm_writei)}, {
   1.187 +    "snd_pcm_resume", (void **) (char *) &SDL_NAME(snd_pcm_resume)}, {
   1.188 +    "snd_pcm_prepare", (void **) (char *) &SDL_NAME(snd_pcm_prepare)}, {
   1.189 +    "snd_pcm_drain", (void **) (char *) &SDL_NAME(snd_pcm_drain)}, {
   1.190 +    "snd_strerror", (void **) (char *) &SDL_NAME(snd_strerror)}, {
   1.191      "snd_pcm_hw_params_sizeof",
   1.192 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_sizeof)}, {
   1.193 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_sizeof)}, {
   1.194      "snd_pcm_sw_params_sizeof",
   1.195 -            (void **) (char *) &SDL_NAME (snd_pcm_sw_params_sizeof)}, {
   1.196 +            (void **) (char *) &SDL_NAME(snd_pcm_sw_params_sizeof)}, {
   1.197      "snd_pcm_hw_params_any",
   1.198 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_any)}, {
   1.199 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_any)}, {
   1.200      "snd_pcm_hw_params_set_access",
   1.201 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_access)}, {
   1.202 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_access)}, {
   1.203      "snd_pcm_hw_params_set_format",
   1.204 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_format)}, {
   1.205 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_format)}, {
   1.206      "snd_pcm_hw_params_set_channels",
   1.207 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_channels)}, {
   1.208 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_channels)}, {
   1.209      "snd_pcm_hw_params_get_channels",
   1.210 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_get_channels)}, {
   1.211 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_channels)}, {
   1.212      "snd_pcm_hw_params_set_rate_near",
   1.213 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_rate_near)}, {
   1.214 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_rate_near)}, {
   1.215          "snd_pcm_hw_params_set_period_size_near", (void **) (char *)
   1.216 -    &SDL_NAME (snd_pcm_hw_params_set_period_size_near)}, {
   1.217 +    &SDL_NAME(snd_pcm_hw_params_set_period_size_near)}, {
   1.218      "snd_pcm_hw_params_get_period_size",
   1.219 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_get_period_size)},
   1.220 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_period_size)},
   1.221      {
   1.222          "snd_pcm_hw_params_set_periods_near", (void **) (char *)
   1.223 -    &SDL_NAME (snd_pcm_hw_params_set_periods_near)}, {
   1.224 +    &SDL_NAME(snd_pcm_hw_params_set_periods_near)}, {
   1.225      "snd_pcm_hw_params_get_periods",
   1.226 -            (void **) (char *) &SDL_NAME (snd_pcm_hw_params_get_periods)}, {
   1.227 -    "snd_pcm_hw_params", (void **) (char *) &SDL_NAME (snd_pcm_hw_params)}, {
   1.228 +            (void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_periods)}, {
   1.229 +    "snd_pcm_hw_params", (void **) (char *) &SDL_NAME(snd_pcm_hw_params)}, {
   1.230      "snd_pcm_sw_params_current",
   1.231 -            (void **) (char *) &SDL_NAME (snd_pcm_sw_params_current)}, {
   1.232 +            (void **) (char *) &SDL_NAME(snd_pcm_sw_params_current)}, {
   1.233          "snd_pcm_sw_params_set_start_threshold", (void **) (char *)
   1.234 -    &SDL_NAME (snd_pcm_sw_params_set_start_threshold)}, {
   1.235 +    &SDL_NAME(snd_pcm_sw_params_set_start_threshold)}, {
   1.236      "snd_pcm_sw_params_set_avail_min",
   1.237 -            (void **) (char *) &SDL_NAME (snd_pcm_sw_params_set_avail_min)}, {
   1.238 -    "snd_pcm_sw_params", (void **) (char *) &SDL_NAME (snd_pcm_sw_params)}, {
   1.239 -"snd_pcm_nonblock", (void **) (char *) &SDL_NAME (snd_pcm_nonblock)},};
   1.240 +            (void **) (char *) &SDL_NAME(snd_pcm_sw_params_set_avail_min)}, {
   1.241 +    "snd_pcm_sw_params", (void **) (char *) &SDL_NAME(snd_pcm_sw_params)}, {
   1.242 +"snd_pcm_nonblock", (void **) (char *) &SDL_NAME(snd_pcm_nonblock)},};
   1.243  
   1.244  static void
   1.245 -UnloadALSALibrary (void)
   1.246 +UnloadALSALibrary(void)
   1.247  {
   1.248      if (alsa_loaded) {
   1.249  /*		SDL_UnloadObject(alsa_handle);*/
   1.250 -        dlclose (alsa_handle);
   1.251 +        dlclose(alsa_handle);
   1.252          alsa_handle = NULL;
   1.253          alsa_loaded = 0;
   1.254      }
   1.255  }
   1.256  
   1.257  static int
   1.258 -LoadALSALibrary (void)
   1.259 +LoadALSALibrary(void)
   1.260  {
   1.261      int i, retval = -1;
   1.262  
   1.263  /*	alsa_handle = SDL_LoadObject(alsa_library);*/
   1.264 -    alsa_handle = dlopen (alsa_library, RTLD_NOW);
   1.265 +    alsa_handle = dlopen(alsa_library, RTLD_NOW);
   1.266      if (alsa_handle) {
   1.267          alsa_loaded = 1;
   1.268          retval = 0;
   1.269 -        for (i = 0; i < SDL_arraysize (alsa_functions); i++) {
   1.270 +        for (i = 0; i < SDL_arraysize(alsa_functions); i++) {
   1.271  /*			*alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name);*/
   1.272  #if HAVE_DLVSYM
   1.273              *alsa_functions[i].func =
   1.274 -                dlvsym (alsa_handle, alsa_functions[i].name, "ALSA_0.9");
   1.275 +                dlvsym(alsa_handle, alsa_functions[i].name, "ALSA_0.9");
   1.276              if (!*alsa_functions[i].func)
   1.277  #endif
   1.278                  *alsa_functions[i].func =
   1.279 -                    dlsym (alsa_handle, alsa_functions[i].name);
   1.280 +                    dlsym(alsa_handle, alsa_functions[i].name);
   1.281              if (!*alsa_functions[i].func) {
   1.282                  retval = -1;
   1.283 -                UnloadALSALibrary ();
   1.284 +                UnloadALSALibrary();
   1.285                  break;
   1.286              }
   1.287          }
   1.288 @@ -234,13 +232,13 @@
   1.289  #else
   1.290  
   1.291  static void
   1.292 -UnloadALSALibrary (void)
   1.293 +UnloadALSALibrary(void)
   1.294  {
   1.295      return;
   1.296  }
   1.297  
   1.298  static int
   1.299 -LoadALSALibrary (void)
   1.300 +LoadALSALibrary(void)
   1.301  {
   1.302      return 0;
   1.303  }
   1.304 @@ -248,11 +246,11 @@
   1.305  #endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
   1.306  
   1.307  static const char *
   1.308 -get_audio_device (int channels)
   1.309 +get_audio_device(int channels)
   1.310  {
   1.311      const char *device;
   1.312  
   1.313 -    device = SDL_getenv ("AUDIODEV");   /* Is there a standard variable name? */
   1.314 +    device = SDL_getenv("AUDIODEV");    /* Is there a standard variable name? */
   1.315      if (device == NULL) {
   1.316          if (channels == 6)
   1.317              device = "surround51";
   1.318 @@ -267,56 +265,56 @@
   1.319  /* Audio driver bootstrap functions */
   1.320  
   1.321  static int
   1.322 -Audio_Available (void)
   1.323 +Audio_Available(void)
   1.324  {
   1.325      int available;
   1.326      int status;
   1.327      snd_pcm_t *handle;
   1.328  
   1.329      available = 0;
   1.330 -    if (LoadALSALibrary () < 0) {
   1.331 +    if (LoadALSALibrary() < 0) {
   1.332          return available;
   1.333      }
   1.334      status =
   1.335 -        SDL_NAME (snd_pcm_open) (&handle, get_audio_device (2),
   1.336 -                                 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
   1.337 +        SDL_NAME(snd_pcm_open) (&handle, get_audio_device(2),
   1.338 +                                SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
   1.339      if (status >= 0) {
   1.340          available = 1;
   1.341 -        SDL_NAME (snd_pcm_close) (handle);
   1.342 +        SDL_NAME(snd_pcm_close) (handle);
   1.343      }
   1.344 -    UnloadALSALibrary ();
   1.345 +    UnloadALSALibrary();
   1.346      return (available);
   1.347  }
   1.348  
   1.349  static void
   1.350 -Audio_DeleteDevice (SDL_AudioDevice * device)
   1.351 +Audio_DeleteDevice(SDL_AudioDevice * device)
   1.352  {
   1.353 -    SDL_free (device->hidden);
   1.354 -    SDL_free (device);
   1.355 -    UnloadALSALibrary ();
   1.356 +    SDL_free(device->hidden);
   1.357 +    SDL_free(device);
   1.358 +    UnloadALSALibrary();
   1.359  }
   1.360  
   1.361  static SDL_AudioDevice *
   1.362 -Audio_CreateDevice (int devindex)
   1.363 +Audio_CreateDevice(int devindex)
   1.364  {
   1.365      SDL_AudioDevice *this;
   1.366  
   1.367      /* Initialize all variables that we clean on shutdown */
   1.368 -    LoadALSALibrary ();
   1.369 -    this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice));
   1.370 +    LoadALSALibrary();
   1.371 +    this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
   1.372      if (this) {
   1.373 -        SDL_memset (this, 0, (sizeof *this));
   1.374 +        SDL_memset(this, 0, (sizeof *this));
   1.375          this->hidden = (struct SDL_PrivateAudioData *)
   1.376 -            SDL_malloc ((sizeof *this->hidden));
   1.377 +            SDL_malloc((sizeof *this->hidden));
   1.378      }
   1.379      if ((this == NULL) || (this->hidden == NULL)) {
   1.380 -        SDL_OutOfMemory ();
   1.381 +        SDL_OutOfMemory();
   1.382          if (this) {
   1.383 -            SDL_free (this);
   1.384 +            SDL_free(this);
   1.385          }
   1.386          return (0);
   1.387      }
   1.388 -    SDL_memset (this->hidden, 0, (sizeof *this->hidden));
   1.389 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   1.390  
   1.391      /* Set the function pointers */
   1.392      this->OpenAudio = ALSA_OpenAudio;
   1.393 @@ -337,7 +335,7 @@
   1.394  
   1.395  /* This function waits until it is possible to write a full sound buffer */
   1.396  static void
   1.397 -ALSA_WaitAudio (_THIS)
   1.398 +ALSA_WaitAudio(_THIS)
   1.399  {
   1.400      /* Check to see if the thread-parent process is still alive */
   1.401      {
   1.402 @@ -346,7 +344,7 @@
   1.403             that use a different process id for each thread.
   1.404           */
   1.405          if (parent && (((++cnt) % 10) == 0)) {  /* Check every 10 loops */
   1.406 -            if (kill (parent, 0) < 0) {
   1.407 +            if (kill(parent, 0) < 0) {
   1.408                  this->enabled = 0;
   1.409              }
   1.410          }
   1.411 @@ -354,7 +352,7 @@
   1.412  }
   1.413  
   1.414  static void
   1.415 -ALSA_PlayAudio (_THIS)
   1.416 +ALSA_PlayAudio(_THIS)
   1.417  {
   1.418      int status;
   1.419      int sample_len;
   1.420 @@ -364,21 +362,21 @@
   1.421      sample_buf = (signed short *) mixbuf;
   1.422      while (sample_len > 0) {
   1.423          status =
   1.424 -            SDL_NAME (snd_pcm_writei) (pcm_handle, sample_buf, sample_len);
   1.425 +            SDL_NAME(snd_pcm_writei) (pcm_handle, sample_buf, sample_len);
   1.426          if (status < 0) {
   1.427              if (status == -EAGAIN) {
   1.428 -                SDL_Delay (1);
   1.429 +                SDL_Delay(1);
   1.430                  continue;
   1.431              }
   1.432              if (status == -ESTRPIPE) {
   1.433                  do {
   1.434 -                    SDL_Delay (1);
   1.435 -                    status = SDL_NAME (snd_pcm_resume) (pcm_handle);
   1.436 +                    SDL_Delay(1);
   1.437 +                    status = SDL_NAME(snd_pcm_resume) (pcm_handle);
   1.438                  }
   1.439                  while (status == -EAGAIN);
   1.440              }
   1.441              if (status < 0) {
   1.442 -                status = SDL_NAME (snd_pcm_prepare) (pcm_handle);
   1.443 +                status = SDL_NAME(snd_pcm_prepare) (pcm_handle);
   1.444              }
   1.445              if (status < 0) {
   1.446                  /* Hmm, not much we can do - abort */
   1.447 @@ -393,27 +391,27 @@
   1.448  }
   1.449  
   1.450  static Uint8 *
   1.451 -ALSA_GetAudioBuf (_THIS)
   1.452 +ALSA_GetAudioBuf(_THIS)
   1.453  {
   1.454      return (mixbuf);
   1.455  }
   1.456  
   1.457  static void
   1.458 -ALSA_CloseAudio (_THIS)
   1.459 +ALSA_CloseAudio(_THIS)
   1.460  {
   1.461      if (mixbuf != NULL) {
   1.462 -        SDL_FreeAudioMem (mixbuf);
   1.463 +        SDL_FreeAudioMem(mixbuf);
   1.464          mixbuf = NULL;
   1.465      }
   1.466      if (pcm_handle) {
   1.467 -        SDL_NAME (snd_pcm_drain) (pcm_handle);
   1.468 -        SDL_NAME (snd_pcm_close) (pcm_handle);
   1.469 +        SDL_NAME(snd_pcm_drain) (pcm_handle);
   1.470 +        SDL_NAME(snd_pcm_close) (pcm_handle);
   1.471          pcm_handle = NULL;
   1.472      }
   1.473  }
   1.474  
   1.475  static int
   1.476 -ALSA_OpenAudio (_THIS, SDL_AudioSpec * spec)
   1.477 +ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec)
   1.478  {
   1.479      int status;
   1.480      snd_pcm_hw_params_t *hwparams;
   1.481 @@ -425,40 +423,40 @@
   1.482      /* Open the audio device */
   1.483      /* Name of device should depend on # channels in spec */
   1.484      status =
   1.485 -        SDL_NAME (snd_pcm_open) (&pcm_handle,
   1.486 -                                 get_audio_device (spec->channels),
   1.487 -                                 SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
   1.488 +        SDL_NAME(snd_pcm_open) (&pcm_handle,
   1.489 +                                get_audio_device(spec->channels),
   1.490 +                                SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
   1.491  
   1.492      if (status < 0) {
   1.493 -        SDL_SetError ("Couldn't open audio device: %s",
   1.494 -                      SDL_NAME (snd_strerror) (status));
   1.495 +        SDL_SetError("Couldn't open audio device: %s",
   1.496 +                     SDL_NAME(snd_strerror) (status));
   1.497          return (-1);
   1.498      }
   1.499  
   1.500      /* Figure out what the hardware is capable of */
   1.501 -    snd_pcm_hw_params_alloca (&hwparams);
   1.502 -    status = SDL_NAME (snd_pcm_hw_params_any) (pcm_handle, hwparams);
   1.503 +    snd_pcm_hw_params_alloca(&hwparams);
   1.504 +    status = SDL_NAME(snd_pcm_hw_params_any) (pcm_handle, hwparams);
   1.505      if (status < 0) {
   1.506 -        SDL_SetError ("Couldn't get hardware config: %s",
   1.507 -                      SDL_NAME (snd_strerror) (status));
   1.508 -        ALSA_CloseAudio (this);
   1.509 +        SDL_SetError("Couldn't get hardware config: %s",
   1.510 +                     SDL_NAME(snd_strerror) (status));
   1.511 +        ALSA_CloseAudio(this);
   1.512          return (-1);
   1.513      }
   1.514  
   1.515      /* SDL only uses interleaved sample output */
   1.516      status =
   1.517 -        SDL_NAME (snd_pcm_hw_params_set_access) (pcm_handle, hwparams,
   1.518 -                                                 SND_PCM_ACCESS_RW_INTERLEAVED);
   1.519 +        SDL_NAME(snd_pcm_hw_params_set_access) (pcm_handle, hwparams,
   1.520 +                                                SND_PCM_ACCESS_RW_INTERLEAVED);
   1.521      if (status < 0) {
   1.522 -        SDL_SetError ("Couldn't set interleaved access: %s",
   1.523 -                      SDL_NAME (snd_strerror) (status));
   1.524 -        ALSA_CloseAudio (this);
   1.525 +        SDL_SetError("Couldn't set interleaved access: %s",
   1.526 +                     SDL_NAME(snd_strerror) (status));
   1.527 +        ALSA_CloseAudio(this);
   1.528          return (-1);
   1.529      }
   1.530  
   1.531      /* Try for a closest match on audio format */
   1.532      status = -1;
   1.533 -    for (test_format = SDL_FirstAudioFormat (spec->format);
   1.534 +    for (test_format = SDL_FirstAudioFormat(spec->format);
   1.535           test_format && (status < 0);) {
   1.536          switch (test_format) {
   1.537          case AUDIO_U8:
   1.538 @@ -485,29 +483,29 @@
   1.539          }
   1.540          if (format != 0) {
   1.541              status =
   1.542 -                SDL_NAME (snd_pcm_hw_params_set_format) (pcm_handle,
   1.543 -                                                         hwparams, format);
   1.544 +                SDL_NAME(snd_pcm_hw_params_set_format) (pcm_handle,
   1.545 +                                                        hwparams, format);
   1.546          }
   1.547          if (status < 0) {
   1.548 -            test_format = SDL_NextAudioFormat ();
   1.549 +            test_format = SDL_NextAudioFormat();
   1.550          }
   1.551      }
   1.552      if (status < 0) {
   1.553 -        SDL_SetError ("Couldn't find any hardware audio formats");
   1.554 -        ALSA_CloseAudio (this);
   1.555 +        SDL_SetError("Couldn't find any hardware audio formats");
   1.556 +        ALSA_CloseAudio(this);
   1.557          return (-1);
   1.558      }
   1.559      spec->format = test_format;
   1.560  
   1.561      /* Set the number of channels */
   1.562      status =
   1.563 -        SDL_NAME (snd_pcm_hw_params_set_channels) (pcm_handle, hwparams,
   1.564 -                                                   spec->channels);
   1.565 +        SDL_NAME(snd_pcm_hw_params_set_channels) (pcm_handle, hwparams,
   1.566 +                                                  spec->channels);
   1.567      if (status < 0) {
   1.568 -        status = SDL_NAME (snd_pcm_hw_params_get_channels) (hwparams);
   1.569 +        status = SDL_NAME(snd_pcm_hw_params_get_channels) (hwparams);
   1.570          if ((status <= 0) || (status > 2)) {
   1.571 -            SDL_SetError ("Couldn't set audio channels");
   1.572 -            ALSA_CloseAudio (this);
   1.573 +            SDL_SetError("Couldn't set audio channels");
   1.574 +            ALSA_CloseAudio(this);
   1.575              return (-1);
   1.576          }
   1.577          spec->channels = status;
   1.578 @@ -515,12 +513,12 @@
   1.579  
   1.580      /* Set the audio rate */
   1.581      status =
   1.582 -        SDL_NAME (snd_pcm_hw_params_set_rate_near) (pcm_handle, hwparams,
   1.583 -                                                    spec->freq, NULL);
   1.584 +        SDL_NAME(snd_pcm_hw_params_set_rate_near) (pcm_handle, hwparams,
   1.585 +                                                   spec->freq, NULL);
   1.586      if (status < 0) {
   1.587 -        SDL_SetError ("Couldn't set audio frequency: %s",
   1.588 -                      SDL_NAME (snd_strerror) (status));
   1.589 -        ALSA_CloseAudio (this);
   1.590 +        SDL_SetError("Couldn't set audio frequency: %s",
   1.591 +                     SDL_NAME(snd_strerror) (status));
   1.592 +        ALSA_CloseAudio(this);
   1.593          return (-1);
   1.594      }
   1.595      spec->freq = status;
   1.596 @@ -528,19 +526,19 @@
   1.597      /* Set the buffer size, in samples */
   1.598      frames = spec->samples;
   1.599      frames =
   1.600 -        SDL_NAME (snd_pcm_hw_params_set_period_size_near) (pcm_handle,
   1.601 -                                                           hwparams, frames,
   1.602 -                                                           NULL);
   1.603 +        SDL_NAME(snd_pcm_hw_params_set_period_size_near) (pcm_handle,
   1.604 +                                                          hwparams, frames,
   1.605 +                                                          NULL);
   1.606      spec->samples = frames;
   1.607 -    SDL_NAME (snd_pcm_hw_params_set_periods_near) (pcm_handle, hwparams, 2,
   1.608 -                                                   NULL);
   1.609 +    SDL_NAME(snd_pcm_hw_params_set_periods_near) (pcm_handle, hwparams, 2,
   1.610 +                                                  NULL);
   1.611  
   1.612      /* "set" the hardware with the desired parameters */
   1.613 -    status = SDL_NAME (snd_pcm_hw_params) (pcm_handle, hwparams);
   1.614 +    status = SDL_NAME(snd_pcm_hw_params) (pcm_handle, hwparams);
   1.615      if (status < 0) {
   1.616 -        SDL_SetError ("Couldn't set hardware audio parameters: %s",
   1.617 -                      SDL_NAME (snd_strerror) (status));
   1.618 -        ALSA_CloseAudio (this);
   1.619 +        SDL_SetError("Couldn't set hardware audio parameters: %s",
   1.620 +                     SDL_NAME(snd_strerror) (status));
   1.621 +        ALSA_CloseAudio(this);
   1.622          return (-1);
   1.623      }
   1.624  
   1.625 @@ -555,57 +553,57 @@
   1.626  */
   1.627  
   1.628      /* Set the software parameters */
   1.629 -    snd_pcm_sw_params_alloca (&swparams);
   1.630 -    status = SDL_NAME (snd_pcm_sw_params_current) (pcm_handle, swparams);
   1.631 +    snd_pcm_sw_params_alloca(&swparams);
   1.632 +    status = SDL_NAME(snd_pcm_sw_params_current) (pcm_handle, swparams);
   1.633      if (status < 0) {
   1.634 -        SDL_SetError ("Couldn't get software config: %s",
   1.635 -                      SDL_NAME (snd_strerror) (status));
   1.636 -        ALSA_CloseAudio (this);
   1.637 +        SDL_SetError("Couldn't get software config: %s",
   1.638 +                     SDL_NAME(snd_strerror) (status));
   1.639 +        ALSA_CloseAudio(this);
   1.640          return (-1);
   1.641      }
   1.642      status =
   1.643 -        SDL_NAME (snd_pcm_sw_params_set_start_threshold) (pcm_handle,
   1.644 -                                                          swparams, 0);
   1.645 +        SDL_NAME(snd_pcm_sw_params_set_start_threshold) (pcm_handle,
   1.646 +                                                         swparams, 0);
   1.647      if (status < 0) {
   1.648 -        SDL_SetError ("Couldn't set start threshold: %s",
   1.649 -                      SDL_NAME (snd_strerror) (status));
   1.650 -        ALSA_CloseAudio (this);
   1.651 +        SDL_SetError("Couldn't set start threshold: %s",
   1.652 +                     SDL_NAME(snd_strerror) (status));
   1.653 +        ALSA_CloseAudio(this);
   1.654          return (-1);
   1.655      }
   1.656      status =
   1.657 -        SDL_NAME (snd_pcm_sw_params_set_avail_min) (pcm_handle, swparams,
   1.658 -                                                    frames);
   1.659 +        SDL_NAME(snd_pcm_sw_params_set_avail_min) (pcm_handle, swparams,
   1.660 +                                                   frames);
   1.661      if (status < 0) {
   1.662 -        SDL_SetError ("Couldn't set avail min: %s",
   1.663 -                      SDL_NAME (snd_strerror) (status));
   1.664 -        ALSA_CloseAudio (this);
   1.665 +        SDL_SetError("Couldn't set avail min: %s",
   1.666 +                     SDL_NAME(snd_strerror) (status));
   1.667 +        ALSA_CloseAudio(this);
   1.668          return (-1);
   1.669      }
   1.670 -    status = SDL_NAME (snd_pcm_sw_params) (pcm_handle, swparams);
   1.671 +    status = SDL_NAME(snd_pcm_sw_params) (pcm_handle, swparams);
   1.672      if (status < 0) {
   1.673 -        SDL_SetError ("Couldn't set software audio parameters: %s",
   1.674 -                      SDL_NAME (snd_strerror) (status));
   1.675 -        ALSA_CloseAudio (this);
   1.676 +        SDL_SetError("Couldn't set software audio parameters: %s",
   1.677 +                     SDL_NAME(snd_strerror) (status));
   1.678 +        ALSA_CloseAudio(this);
   1.679          return (-1);
   1.680      }
   1.681  
   1.682      /* Calculate the final parameters for this audio specification */
   1.683 -    SDL_CalculateAudioSpec (spec);
   1.684 +    SDL_CalculateAudioSpec(spec);
   1.685  
   1.686      /* Allocate mixing buffer */
   1.687      mixlen = spec->size;
   1.688 -    mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen);
   1.689 +    mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen);
   1.690      if (mixbuf == NULL) {
   1.691 -        ALSA_CloseAudio (this);
   1.692 +        ALSA_CloseAudio(this);
   1.693          return (-1);
   1.694      }
   1.695 -    SDL_memset (mixbuf, spec->silence, spec->size);
   1.696 +    SDL_memset(mixbuf, spec->silence, spec->size);
   1.697  
   1.698      /* Get the parent process id (we're the parent of the audio thread) */
   1.699 -    parent = getpid ();
   1.700 +    parent = getpid();
   1.701  
   1.702      /* Switch to blocking mode for playback */
   1.703 -    SDL_NAME (snd_pcm_nonblock) (pcm_handle, 0);
   1.704 +    SDL_NAME(snd_pcm_nonblock) (pcm_handle, 0);
   1.705  
   1.706      /* We're ready to rock and roll. :-) */
   1.707      return (0);