@@ -426,28 +426,29 @@ static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device)
426
426
427
427
static bool OPENSLES_CreatePCMPlayer (SDL_AudioDevice * device )
428
428
{
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.) */
433
432
if (SDL_GetAndroidSDKVersion () >= 21 ) {
434
433
const SDL_AudioFormat * closefmts = SDL_ClosestAudioFormats (device -> spec .format );
435
434
SDL_AudioFormat test_format ;
436
435
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 :
438
440
break ;
439
- }
440
441
}
441
442
442
443
if (!test_format ) {
443
444
// 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 ;
446
447
}
447
448
device -> spec .format = test_format ;
448
449
} else {
449
450
// 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 ;
451
452
}
452
453
453
454
// Update the fragment size as size in bytes
0 commit comments