From bf823bf2dce9f3933f025b12709fb0f3978754a5 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Tue, 5 Feb 2019 15:05:32 +0100 Subject: [PATCH] Android/openslES: prevent to run out of buffers if Enqueue() fails. --- src/audio/openslES/SDL_openslES.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index ceabf7a6899d5..f115483ee9b4e 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -549,19 +549,21 @@ openslES_PlayDevice(_THIS) SLresult result; LOGI("======openslES_PlayDevice( )======"); - /* Queue it up */ + /* Queue it up */ result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, audiodata->pmixbuff[audiodata->next_buffer], this->spec.size); - if (SL_RESULT_SUCCESS != result) { - /* just puk here */ - /* next ! */ - } audiodata->next_buffer++; if (audiodata->next_buffer >= NUM_BUFFERS) { audiodata->next_buffer = 0; } + /* If Enqueue fails, callback won't be called. + * Post the semphore, not to run out of buffer */ + if (SL_RESULT_SUCCESS != result) { + SDL_SemPost(audiodata->playsem); + } + return; }