src/audio/openslES/SDL_openslES.c
changeset 12766 a85ea89b0561
parent 12754 aec84759c57e
child 12767 8b07df58da32
     1.1 --- a/src/audio/openslES/SDL_openslES.c	Fri Jun 07 09:00:26 2019 -0700
     1.2 +++ b/src/audio/openslES/SDL_openslES.c	Fri Jun 07 15:09:15 2019 -0700
     1.3 @@ -290,19 +290,41 @@
     1.4  #define SL_SPEAKER_TOP_BACK_CENTER       ((SLuint32) 0x00010000)
     1.5  #define SL_SPEAKER_TOP_BACK_RIGHT        ((SLuint32) 0x00020000)
     1.6  */
     1.7 +#define SL_ANDROID_SPEAKER_QUAD (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT)
     1.8 +#define SL_ANDROID_SPEAKER_5DOT1 (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_FRONT_CENTER  | SL_SPEAKER_LOW_FREQUENCY| SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT)
     1.9 +#define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT)
    1.10  
    1.11 -    if (this->spec.channels == 1) {
    1.12 -        format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
    1.13 -    } else if (this->spec.channels == 2) {
    1.14 +    switch (this->spec.channels)
    1.15 +    {
    1.16 +    case 1:
    1.17 +        format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
    1.18 +        break;
    1.19 +    case 2:
    1.20          format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
    1.21 -    } else if (this->spec.channels == 3) {
    1.22 +        break;
    1.23 +    case 3:
    1.24          format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_FRONT_CENTER;
    1.25 -    } else if (this->spec.channels == 4) {
    1.26 -        format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
    1.27 -              SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT;
    1.28 -    } else {
    1.29 -        format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
    1.30 -              SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT | SL_SPEAKER_FRONT_CENTER;
    1.31 +        break;
    1.32 +    case 4:
    1.33 +        format_pcm.channelMask = SL_ANDROID_SPEAKER_QUAD;
    1.34 +        break;
    1.35 +    case 5:
    1.36 +        format_pcm.channelMask = SL_ANDROID_SPEAKER_QUAD | SL_SPEAKER_FRONT_CENTER;
    1.37 +        break;
    1.38 +    case 6:
    1.39 +        format_pcm.channelMask = SL_ANDROID_SPEAKER_5DOT1;
    1.40 +        break;
    1.41 +    case 7:
    1.42 +        format_pcm.channelMask = SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_BACK_CENTER;
    1.43 +        break;
    1.44 +    case 8:
    1.45 +        format_pcm.channelMask = SL_ANDROID_SPEAKER_7DOT1;
    1.46 +        break;
    1.47 +    default:
    1.48 +        /* Unknown number of channels, fall back to stereo */
    1.49 +        this->spec.channels = 2;
    1.50 +        format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
    1.51 +        break;
    1.52      }
    1.53  
    1.54      SLDataSource audioSrc = { &loc_bufq, &format_pcm };