@@ -426,28 +426,29 @@ static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device)
426426
427427static bool OPENSLES_CreatePCMPlayer (SDL_AudioDevice * device )
428428{
429- /* If we want to add floating point audio support (requires API level 21)
430- it can be done as described here:
431- https://developer.android.com/ndk/guides/audio/opensl/android-extensions.html#floating-point
432- */
429+ /* according to https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android,
430+ Android's OpenSL ES only supports Uint8 and _littleendian_ Sint16.
431+ (and float32, with an extension we use, below.) */
433432 if (SDL_GetAndroidSDKVersion () >= 21 ) {
434433 const SDL_AudioFormat * closefmts = SDL_ClosestAudioFormats (device -> spec .format );
435434 SDL_AudioFormat test_format ;
436435 while ((test_format = * (closefmts ++ )) != 0 ) {
437- if (SDL_AUDIO_ISSIGNED (test_format )) {
436+ switch (test_format ) {
437+ case SDL_AUDIO_U8 :
438+ case SDL_AUDIO_S16LE :
439+ case SDL_AUDIO_F32 :
438440 break ;
439- }
440441 }
441442
442443 if (!test_format ) {
443444 // Didn't find a compatible format :
444- LOGI ("No compatible audio format, using signed 16-bit audio" );
445- test_format = SDL_AUDIO_S16 ;
445+ LOGI ("No compatible audio format, using signed 16-bit LE audio" );
446+ test_format = SDL_AUDIO_S16LE ;
446447 }
447448 device -> spec .format = test_format ;
448449 } else {
449450 // Just go with signed 16-bit audio as it's the most compatible
450- device -> spec .format = SDL_AUDIO_S16 ;
451+ device -> spec .format = SDL_AUDIO_S16LE ;
451452 }
452453
453454 // Update the fragment size as size in bytes
0 commit comments