Android/openslES: check for non NULL variable, some intialization.
authorSylvain Becker <sylvain.becker@gmail.com>
Mon, 14 Jan 2019 14:36:13 +0100
changeset 12543621d0ce55072
parent 12542 c86d239a58f0
child 12544 ea4097dfa68d
Android/openslES: check for non NULL variable, some intialization.
use the previous naming
src/audio/openslES/SDL_openslES.c
     1.1 --- a/src/audio/openslES/SDL_openslES.c	Mon Jan 14 14:31:06 2019 +0100
     1.2 +++ b/src/audio/openslES/SDL_openslES.c	Mon Jan 14 14:36:13 2019 +0100
     1.3 @@ -56,12 +56,12 @@
     1.4  /* static const SLEnvironmentalReverbSettings reverbSettings = SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR; */
     1.5  
     1.6  /* buffer queue player interfaces */
     1.7 -static SLObjectItf                   bqPlayerObject = NULL;
     1.8 -static SLPlayItf                     bqPlayerItf;
     1.9 -static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
    1.10 -/*static SLEffectSendItf          bqPlayerEffectSend; */
    1.11 -static SLMuteSoloItf                 bqPlayerMuteSolo;
    1.12 -static SLVolumeItf                   bqPlayerVolume;
    1.13 +static SLObjectItf                   bqPlayerObject      = NULL;
    1.14 +static SLPlayItf                     bqPlayerPlay        = NULL;
    1.15 +static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue = NULL;
    1.16 +/*static SLEffectSendItf          bqPlayerEffectSend = NULL; */
    1.17 +static SLMuteSoloItf                 bqPlayerMuteSolo    = NULL;
    1.18 +static SLVolumeItf                   bqPlayerVolume      = NULL;
    1.19  
    1.20  #if 0
    1.21  /* recorder interfaces TODO */
    1.22 @@ -353,7 +353,7 @@
    1.23      }
    1.24  
    1.25      /* get the play interface */
    1.26 -    result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerItf);
    1.27 +    result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
    1.28      if (SL_RESULT_SUCCESS != result) {
    1.29          LOGE("SL_IID_PLAY interface get failed");
    1.30          goto failed;
    1.31 @@ -418,7 +418,7 @@
    1.32      }
    1.33  
    1.34      /* set the player's state to playing */
    1.35 -    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PLAYING);
    1.36 +    result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
    1.37      if (SL_RESULT_SUCCESS != result) {
    1.38          LOGE("Play set state failed");
    1.39          goto failed;
    1.40 @@ -440,9 +440,11 @@
    1.41      SLresult result;
    1.42  
    1.43      /* set the player's state to 'stopped' */
    1.44 -    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_STOPPED);
    1.45 -    if (SL_RESULT_SUCCESS != result) {
    1.46 -        SDL_SetError("Stopped set state failed");
    1.47 +    if (bqPlayerPlay != NULL) {
    1.48 +        result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_STOPPED);
    1.49 +        if (SL_RESULT_SUCCESS != result) {
    1.50 +            SDL_SetError("Stopped set state failed");
    1.51 +        }
    1.52      }
    1.53  
    1.54      /* destroy buffer queue audio player object, and invalidate all associated interfaces */
    1.55 @@ -451,7 +453,7 @@
    1.56          (*bqPlayerObject)->Destroy(bqPlayerObject);
    1.57  
    1.58          bqPlayerObject = NULL;
    1.59 -        bqPlayerItf = NULL;
    1.60 +        bqPlayerPlay = NULL;
    1.61          bqPlayerBufferQueue = NULL;
    1.62          /* bqPlayerEffectSend = NULL; */
    1.63          bqPlayerMuteSolo = NULL;
    1.64 @@ -603,7 +605,7 @@
    1.65      SLresult result;
    1.66  
    1.67      /* set the player's state to 'playing' */
    1.68 -    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PLAYING);
    1.69 +    result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
    1.70      if (SL_RESULT_SUCCESS != result) {
    1.71          SDL_SetError("Play set state failed");
    1.72      }
    1.73 @@ -614,7 +616,7 @@
    1.74      SLresult result;
    1.75  
    1.76      /* set the player's state to 'paused' */
    1.77 -    result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PAUSED);
    1.78 +    result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PAUSED);
    1.79      if (SL_RESULT_SUCCESS != result) {
    1.80          SDL_SetError("Playe set state failed");
    1.81      }