src/audio/alsa/SDL_alsa_audio.c
changeset 10561 35fee69e84df
parent 10560 5d9ad1fd5acd
child 10582 0e1dd7514610
equal deleted inserted replaced
10560:5d9ad1fd5acd 10561:35fee69e84df
    89   (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
    89   (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
    90 static int (*ALSA_snd_pcm_reset)(snd_pcm_t *);
    90 static int (*ALSA_snd_pcm_reset)(snd_pcm_t *);
    91 static int (*ALSA_snd_device_name_hint) (int, const char *, void ***);
    91 static int (*ALSA_snd_device_name_hint) (int, const char *, void ***);
    92 static char* (*ALSA_snd_device_name_get_hint) (const void *, const char *);
    92 static char* (*ALSA_snd_device_name_get_hint) (const void *, const char *);
    93 static int (*ALSA_snd_device_name_free_hint) (void **);
    93 static int (*ALSA_snd_device_name_free_hint) (void **);
       
    94 #ifdef SND_CHMAP_API_VERSION
    94 static snd_pcm_chmap_t* (*ALSA_snd_pcm_get_chmap) (snd_pcm_t *);
    95 static snd_pcm_chmap_t* (*ALSA_snd_pcm_get_chmap) (snd_pcm_t *);
    95 static int (*ALSA_snd_pcm_chmap_print) (const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
    96 static int (*ALSA_snd_pcm_chmap_print) (const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
       
    97 #endif
    96 
    98 
    97 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
    99 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
    98 #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
   100 #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
    99 #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof
   101 #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof
   100 
   102 
   155     SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min);
   157     SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min);
   156     SDL_ALSA_SYM(snd_pcm_reset);
   158     SDL_ALSA_SYM(snd_pcm_reset);
   157     SDL_ALSA_SYM(snd_device_name_hint);
   159     SDL_ALSA_SYM(snd_device_name_hint);
   158     SDL_ALSA_SYM(snd_device_name_get_hint);
   160     SDL_ALSA_SYM(snd_device_name_get_hint);
   159     SDL_ALSA_SYM(snd_device_name_free_hint);
   161     SDL_ALSA_SYM(snd_device_name_free_hint);
       
   162 #ifdef SND_CHMAP_API_VERSION
   160     SDL_ALSA_SYM(snd_pcm_get_chmap);
   163     SDL_ALSA_SYM(snd_pcm_get_chmap);
   161     SDL_ALSA_SYM(snd_pcm_chmap_print);
   164     SDL_ALSA_SYM(snd_pcm_chmap_print);
       
   165 #endif
   162 
   166 
   163     return 0;
   167     return 0;
   164 }
   168 }
   165 
   169 
   166 #undef SDL_ALSA_SYM
   170 #undef SDL_ALSA_SYM
   557     snd_pcm_sw_params_t *swparams = NULL;
   561     snd_pcm_sw_params_t *swparams = NULL;
   558     snd_pcm_format_t format = 0;
   562     snd_pcm_format_t format = 0;
   559     SDL_AudioFormat test_format = 0;
   563     SDL_AudioFormat test_format = 0;
   560     unsigned int rate = 0;
   564     unsigned int rate = 0;
   561     unsigned int channels = 0;
   565     unsigned int channels = 0;
       
   566 #ifdef SND_CHMAP_API_VERSION
   562     snd_pcm_chmap_t *chmap;
   567     snd_pcm_chmap_t *chmap;
   563     char chmap_str[64];
   568     char chmap_str[64];
       
   569 #endif
   564 
   570 
   565     /* Initialize all variables that we clean on shutdown */
   571     /* Initialize all variables that we clean on shutdown */
   566     this->hidden = (struct SDL_PrivateAudioData *)
   572     this->hidden = (struct SDL_PrivateAudioData *)
   567         SDL_malloc((sizeof *this->hidden));
   573         SDL_malloc((sizeof *this->hidden));
   568     if (this->hidden == NULL) {
   574     if (this->hidden == NULL) {
   655 
   661 
   656     /* Validate number of channels and determine if swizzling is necessary
   662     /* Validate number of channels and determine if swizzling is necessary
   657      * Assume original swizzling, until proven otherwise.
   663      * Assume original swizzling, until proven otherwise.
   658      */
   664      */
   659     this->hidden->swizzle_func = swizzle_alsa_channels;
   665     this->hidden->swizzle_func = swizzle_alsa_channels;
       
   666 #ifdef SND_CHMAP_API_VERSION
   660     chmap = ALSA_snd_pcm_get_chmap(pcm_handle);
   667     chmap = ALSA_snd_pcm_get_chmap(pcm_handle);
   661     if (chmap) {
   668     if (chmap) {
   662         ALSA_snd_pcm_chmap_print(chmap, sizeof(chmap_str), chmap_str);
   669         ALSA_snd_pcm_chmap_print(chmap, sizeof(chmap_str), chmap_str);
   663         if (SDL_strcmp("FL FR FC LFE RL RR", chmap_str) == 0 ||
   670         if (SDL_strcmp("FL FR FC LFE RL RR", chmap_str) == 0 ||
   664             SDL_strcmp("FL FR FC LFE SL SR", chmap_str) == 0) {
   671             SDL_strcmp("FL FR FC LFE SL SR", chmap_str) == 0) {
   665             this->hidden->swizzle_func = no_swizzle;
   672             this->hidden->swizzle_func = no_swizzle;
   666         }
   673         }
   667         free(chmap);
   674         free(chmap);
   668     }
   675     }
       
   676 #endif /* SND_CHMAP_API_VERSION */
   669 
   677 
   670     /* Set the number of channels */
   678     /* Set the number of channels */
   671     status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams,
   679     status = ALSA_snd_pcm_hw_params_set_channels(pcm_handle, hwparams,
   672                                                  this->spec.channels);
   680                                                  this->spec.channels);
   673     channels = this->spec.channels;
   681     channels = this->spec.channels;