src/audio/openslES/SDL_openslES.c
changeset 12767 8b07df58da32
parent 12766 a85ea89b0561
child 13041 6ea2f4ed7014
equal deleted inserted replaced
12766:a85ea89b0561 12767:8b07df58da32
    19   3. This notice may not be removed or altered from any source distribution.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    20 */
    21 #include "../../SDL_internal.h"
    21 #include "../../SDL_internal.h"
    22 
    22 
    23 #if SDL_AUDIO_DRIVER_OPENSLES
    23 #if SDL_AUDIO_DRIVER_OPENSLES
       
    24 
       
    25 /* For more discussion of low latency audio on Android, see this:
       
    26    https://googlesamples.github.io/android-audio-high-performance/guides/opensl_es.html
       
    27 */
    24 
    28 
    25 #include "SDL_audio.h"
    29 #include "SDL_audio.h"
    26 #include "../SDL_audio_c.h"
    30 #include "../SDL_audio_c.h"
    27 #include "SDL_openslES.h"
    31 #include "SDL_openslES.h"
    28 
    32 
   288 #define SL_SPEAKER_TOP_FRONT_RIGHT       ((SLuint32) 0x00004000)
   292 #define SL_SPEAKER_TOP_FRONT_RIGHT       ((SLuint32) 0x00004000)
   289 #define SL_SPEAKER_TOP_BACK_LEFT         ((SLuint32) 0x00008000)
   293 #define SL_SPEAKER_TOP_BACK_LEFT         ((SLuint32) 0x00008000)
   290 #define SL_SPEAKER_TOP_BACK_CENTER       ((SLuint32) 0x00010000)
   294 #define SL_SPEAKER_TOP_BACK_CENTER       ((SLuint32) 0x00010000)
   291 #define SL_SPEAKER_TOP_BACK_RIGHT        ((SLuint32) 0x00020000)
   295 #define SL_SPEAKER_TOP_BACK_RIGHT        ((SLuint32) 0x00020000)
   292 */
   296 */
   293 #define SL_ANDROID_SPEAKER_QUAD (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT)
   297 #define SL_ANDROID_SPEAKER_STEREO (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT)
   294 #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)
   298 #define SL_ANDROID_SPEAKER_QUAD (SL_ANDROID_SPEAKER_STEREO | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT)
       
   299 #define SL_ANDROID_SPEAKER_5DOT1 (SL_ANDROID_SPEAKER_QUAD | SL_SPEAKER_FRONT_CENTER  | SL_SPEAKER_LOW_FREQUENCY)
   295 #define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT)
   300 #define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT)
   296 
   301 
   297     switch (this->spec.channels)
   302     switch (this->spec.channels)
   298     {
   303     {
   299     case 1:
   304     case 1:
   300         format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
   305         format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
   301         break;
   306         break;
   302     case 2:
   307     case 2:
   303         format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
   308         format_pcm.channelMask = SL_ANDROID_SPEAKER_STEREO;
   304         break;
   309         break;
   305     case 3:
   310     case 3:
   306         format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_FRONT_CENTER;
   311         format_pcm.channelMask = SL_ANDROID_SPEAKER_STEREO | SL_SPEAKER_FRONT_CENTER;
   307         break;
   312         break;
   308     case 4:
   313     case 4:
   309         format_pcm.channelMask = SL_ANDROID_SPEAKER_QUAD;
   314         format_pcm.channelMask = SL_ANDROID_SPEAKER_QUAD;
   310         break;
   315         break;
   311     case 5:
   316     case 5: