Android/openslES: prevent to run out of buffers if Enqueue() fails.
authorSylvain Becker <sylvain.becker@gmail.com>
Tue, 05 Feb 2019 15:05:32 +0100
changeset 125966654faf2160e
parent 12595 4ecb6ce33406
child 12597 b5ea5997cbf9
Android/openslES: prevent to run out of buffers if Enqueue() fails.
src/audio/openslES/SDL_openslES.c
     1.1 --- a/src/audio/openslES/SDL_openslES.c	Mon Feb 04 23:35:18 2019 -0500
     1.2 +++ b/src/audio/openslES/SDL_openslES.c	Tue Feb 05 15:05:32 2019 +0100
     1.3 @@ -549,19 +549,21 @@
     1.4      SLresult result;
     1.5  
     1.6      LOGI("======openslES_PlayDevice( )======");
     1.7 +
     1.8      /* Queue it up */
     1.9 -
    1.10      result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, audiodata->pmixbuff[audiodata->next_buffer], this->spec.size);
    1.11 -    if (SL_RESULT_SUCCESS != result) {
    1.12 -        /* just puk here */
    1.13 -        /* next ! */
    1.14 -    }
    1.15  
    1.16      audiodata->next_buffer++;
    1.17      if (audiodata->next_buffer >= NUM_BUFFERS) {
    1.18          audiodata->next_buffer = 0;
    1.19      }
    1.20  
    1.21 +    /* If Enqueue fails, callback won't be called.
    1.22 +     * Post the semphore, not to run out of buffer */
    1.23 +    if (SL_RESULT_SUCCESS != result) {
    1.24 +        SDL_SemPost(audiodata->playsem);
    1.25 +    }
    1.26 +
    1.27      return;
    1.28  }
    1.29