From 1f9817319745434134b97a96728821482a53782b Mon Sep 17 00:00:00 2001 From: Vittorio Alfieri Date: Sun, 27 Dec 2020 01:08:51 +0100 Subject: [PATCH] Avoided a memory allocation error of SDL EnginePlayer on Android version when loading more than 32 audio samples at same time. --- JGE/src/android/JSfx.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/JGE/src/android/JSfx.cpp b/JGE/src/android/JSfx.cpp index fc6aa2e54..52c295f09 100644 --- a/JGE/src/android/JSfx.cpp +++ b/JGE/src/android/JSfx.cpp @@ -184,7 +184,13 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName) const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; result = (*engineEngine)->CreateAudioPlayer(engineEngine, &music->playerObject, &audioSrc, &audioSnk, 2, ids, req); DebugTrace("result " << result); - + + if(result == SL_RESULT_MEMORY_FAILURE){ + delete music; + mCurrentMusic = NULL; + return NULL; + } + // realize the player result = (*music->playerObject)->Realize(music->playerObject, SL_BOOLEAN_FALSE); DebugTrace("result " << result); @@ -303,6 +309,12 @@ JSample *JSoundSystem::LoadSample(const char *fileName) 1, ids, req); DebugTrace("result " << result); + if(result == SL_RESULT_MEMORY_FAILURE){ + delete sample; + mCurrentSample = NULL; + return NULL; + } + // realize the player result = (*sample->playerObject)->Realize(sample->playerObject, SL_BOOLEAN_FALSE); DebugTrace("result " << result);