Android/openslES: check for non NULL variable, some intialization. use the previous naming
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c
index 397a301..bd0a287 100644
--- a/src/audio/openslES/SDL_openslES.c
+++ b/src/audio/openslES/SDL_openslES.c
@@ -56,12 +56,12 @@ static SLObjectItf outputMixObject = NULL;
/* static const SLEnvironmentalReverbSettings reverbSettings = SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR; */
/* buffer queue player interfaces */
-static SLObjectItf bqPlayerObject = NULL;
-static SLPlayItf bqPlayerItf;
-static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
-/*static SLEffectSendItf bqPlayerEffectSend; */
-static SLMuteSoloItf bqPlayerMuteSolo;
-static SLVolumeItf bqPlayerVolume;
+static SLObjectItf bqPlayerObject = NULL;
+static SLPlayItf bqPlayerPlay = NULL;
+static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue = NULL;
+/*static SLEffectSendItf bqPlayerEffectSend = NULL; */
+static SLMuteSoloItf bqPlayerMuteSolo = NULL;
+static SLVolumeItf bqPlayerVolume = NULL;
#if 0
/* recorder interfaces TODO */
@@ -353,7 +353,7 @@ openslES_CreatePCMPlayer(_THIS)
}
/* get the play interface */
- result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerItf);
+ result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
if (SL_RESULT_SUCCESS != result) {
LOGE("SL_IID_PLAY interface get failed");
goto failed;
@@ -418,7 +418,7 @@ openslES_CreatePCMPlayer(_THIS)
}
/* set the player's state to playing */
- result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PLAYING);
+ result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
if (SL_RESULT_SUCCESS != result) {
LOGE("Play set state failed");
goto failed;
@@ -440,9 +440,11 @@ openslES_DestroyPCMPlayer(_THIS)
SLresult result;
/* set the player's state to 'stopped' */
- result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_STOPPED);
- if (SL_RESULT_SUCCESS != result) {
- SDL_SetError("Stopped set state failed");
+ if (bqPlayerPlay != NULL) {
+ result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_STOPPED);
+ if (SL_RESULT_SUCCESS != result) {
+ SDL_SetError("Stopped set state failed");
+ }
}
/* destroy buffer queue audio player object, and invalidate all associated interfaces */
@@ -451,7 +453,7 @@ openslES_DestroyPCMPlayer(_THIS)
(*bqPlayerObject)->Destroy(bqPlayerObject);
bqPlayerObject = NULL;
- bqPlayerItf = NULL;
+ bqPlayerPlay = NULL;
bqPlayerBufferQueue = NULL;
/* bqPlayerEffectSend = NULL; */
bqPlayerMuteSolo = NULL;
@@ -603,7 +605,7 @@ void openslES_ResumeDevices()
SLresult result;
/* set the player's state to 'playing' */
- result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PLAYING);
+ result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
if (SL_RESULT_SUCCESS != result) {
SDL_SetError("Play set state failed");
}
@@ -614,7 +616,7 @@ void openslES_PauseDevices()
SLresult result;
/* set the player's state to 'paused' */
- result = (*bqPlayerItf)->SetPlayState(bqPlayerItf, SL_PLAYSTATE_PAUSED);
+ result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PAUSED);
if (SL_RESULT_SUCCESS != result) {
SDL_SetError("Playe set state failed");
}