SDL: OpenSLES: CloseDevice() is called at higher level, if OpenDevice() fails

From 8ac0fb52cb13e5856aa7f4a3fd0598d3ec58283f Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Thu, 29 Apr 2021 09:29:02 +0200
Subject: [PATCH] OpenSLES: CloseDevice() is called at higher level, if
 OpenDevice() fails - explicit initialization of static variables

---
 src/audio/openslES/SDL_openslES.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c
index d271724db..ae0f6a62a 100644
--- a/src/audio/openslES/SDL_openslES.c
+++ b/src/audio/openslES/SDL_openslES.c
@@ -75,24 +75,24 @@
 #define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT)
 
 /* engine interfaces */
-static SLObjectItf engineObject;
-static SLEngineItf engineEngine;
+static SLObjectItf engineObject = NULL;
+static SLEngineItf engineEngine = NULL;
 
 /* output mix interfaces */
-static SLObjectItf outputMixObject;
+static SLObjectItf outputMixObject = NULL;
 
 /* buffer queue player interfaces */
-static SLObjectItf bqPlayerObject;
+static SLObjectItf bqPlayerObject = NULL;
 static SLPlayItf bqPlayerPlay = NULL;
-static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
+static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue = NULL;
 #if 0
 static SLVolumeItf bqPlayerVolume;
 #endif
 
 /* recorder interfaces */
-static SLObjectItf recorderObject;
-static SLRecordItf recorderRecord;
-static SLAndroidSimpleBufferQueueItf recorderBufferQueue;
+static SLObjectItf recorderObject = NULL;
+static SLRecordItf recorderRecord = NULL;
+static SLAndroidSimpleBufferQueueItf recorderBufferQueue = NULL;
 
 #if 0
 static const char *sldevaudiorecorderstr = "SLES Audio Recorder";
@@ -355,8 +355,6 @@ openslES_CreatePCMRecorder(_THIS)
 
 failed:
 
-    openslES_DestroyPCMRecorder(this);
-
     return SDL_SetError("Open device failed!");
 }
 
@@ -581,8 +579,6 @@ openslES_CreatePCMPlayer(_THIS)
 
 failed:
 
-    openslES_DestroyPCMPlayer(this);
-
     return SDL_SetError("Open device failed!");
 }