audio/aaudio, audio/openslES: fix -Wdeclaration-after-statement errors Fixes https://github.com/libsdl-org/SDL/issues/5950
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c
index 1d1553b..5f31866 100644
--- a/src/audio/aaudio/SDL_aaudio.c
+++ b/src/audio/aaudio/SDL_aaudio.c
@@ -437,14 +437,17 @@ void aaudio_ResumeDevices(void)
*/
SDL_bool aaudio_DetectBrokenPlayState( void )
{
+ struct SDL_PrivateAudioData *private;
+ int64_t framePosition, timeNanoseconds;
+ aaudio_result_t res;
+
if ( !audioDevice || !audioDevice->hidden ) {
return SDL_FALSE;
}
- struct SDL_PrivateAudioData *private = audioDevice->hidden;
+ private = audioDevice->hidden;
- int64_t framePosition, timeNanoseconds;
- aaudio_result_t res = ctx.AAudioStream_getTimestamp( private->stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds );
+ res = ctx.AAudioStream_getTimestamp( private->stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds );
if ( res == AAUDIO_ERROR_INVALID_STATE ) {
aaudio_stream_state_t currentState = ctx.AAudioStream_getState( private->stream );
/* AAudioStream_getTimestamp() will also return AAUDIO_ERROR_INVALID_STATE while the stream is still initially starting. But we only care if it silently went invalid while playing. */
diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c
index 39d64b2..474de3b 100644
--- a/src/audio/openslES/SDL_openslES.c
+++ b/src/audio/openslES/SDL_openslES.c
@@ -131,6 +131,8 @@ static void openslES_DestroyEngine(void)
static int
openslES_CreateEngine(void)
{
+ const SLInterfaceID ids[1] = { SL_IID_VOLUME };
+ const SLboolean req[1] = { SL_BOOLEAN_FALSE };
SLresult result;
LOGI("openSLES_CreateEngine()");
@@ -160,8 +162,6 @@ openslES_CreateEngine(void)
LOGI("EngineGetInterface OK");
/* create output mix */
- const SLInterfaceID ids[1] = { SL_IID_VOLUME };
- const SLboolean req[1] = { SL_BOOLEAN_FALSE };
result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
if (SL_RESULT_SUCCESS != result) {
LOGE("CreateOutputMix failed: %d", result);
@@ -229,6 +229,12 @@ openslES_CreatePCMRecorder(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
SLDataFormat_PCM format_pcm;
+ SLDataLocator_AndroidSimpleBufferQueue loc_bufq;
+ SLDataSink audioSnk;
+ SLDataLocator_IODevice loc_dev;
+ SLDataSource audioSrc;
+ const SLInterfaceID ids[1] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
+ const SLboolean req[1] = { SL_BOOLEAN_TRUE };
SLresult result;
int i;
@@ -250,11 +256,16 @@ openslES_CreatePCMRecorder(_THIS)
this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples);
/* configure audio source */
- SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT, SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
- SLDataSource audioSrc = {&loc_dev, NULL};
+ loc_dev.locatorType = SL_DATALOCATOR_IODEVICE;
+ loc_dev.deviceType = SL_IODEVICE_AUDIOINPUT;
+ loc_dev.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT;
+ loc_dev.device = NULL;
+ audioSrc.pLocator = &loc_dev;
+ audioSrc.pFormat = NULL;
/* configure audio sink */
- SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, NUM_BUFFERS };
+ loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
+ loc_bufq.numBuffers = NUM_BUFFERS;
format_pcm.formatType = SL_DATAFORMAT_PCM;
format_pcm.numChannels = this->spec.channels;
@@ -264,17 +275,11 @@ openslES_CreatePCMRecorder(_THIS)
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
- SLDataSink audioSnk = { &loc_bufq, &format_pcm };
+ audioSnk.pLocator = &loc_bufq;
+ audioSnk.pFormat = &format_pcm;
/* create audio recorder */
/* (requires the RECORD_AUDIO permission) */
- const SLInterfaceID ids[1] = {
- SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- };
- const SLboolean req[1] = {
- SL_BOOLEAN_TRUE,
- };
-
result = (*engineEngine)->CreateAudioRecorder(engineEngine, &recorderObject, &audioSrc, &audioSnk, 1, ids, req);
if (SL_RESULT_SUCCESS != result) {
LOGE("CreateAudioRecorder failed: %d", result);
@@ -354,7 +359,6 @@ openslES_CreatePCMRecorder(_THIS)
return 0;
failed:
-
return SDL_SetError("Open device failed!");
}
@@ -384,7 +388,6 @@ openslES_DestroyPCMPlayer(_THIS)
/* destroy buffer queue audio player object, and invalidate all associated interfaces */
if (bqPlayerObject != NULL) {
-
(*bqPlayerObject)->Destroy(bqPlayerObject);
bqPlayerObject = NULL;
@@ -406,8 +409,14 @@ static int
openslES_CreatePCMPlayer(_THIS)
{
struct SDL_PrivateAudioData *audiodata = this->hidden;
+ SLDataLocator_AndroidSimpleBufferQueue loc_bufq;
SLDataFormat_PCM format_pcm;
SLAndroidDataFormat_PCM_EX format_pcm_ex;
+ SLDataSource audioSrc;
+ SLDataSink audioSnk;
+ SLDataLocator_OutputMix loc_outmix;
+ const SLInterfaceID ids[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_VOLUME };
+ const SLboolean req[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE };
SLresult result;
int i;
@@ -442,7 +451,8 @@ openslES_CreatePCMPlayer(_THIS)
this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples);
/* configure audio source */
- SLDataLocator_AndroidSimpleBufferQueue loc_bufq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, NUM_BUFFERS };
+ loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
+ loc_bufq.numBuffers = NUM_BUFFERS;
format_pcm.formatType = SL_DATAFORMAT_PCM;
format_pcm.numChannels = this->spec.channels;
@@ -501,23 +511,16 @@ openslES_CreatePCMPlayer(_THIS)
format_pcm_ex.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
}
- SLDataSource audioSrc = { &loc_bufq, SDL_AUDIO_ISFLOAT(this->spec.format) ? (void*)&format_pcm_ex : (void*)&format_pcm };
+ audioSrc.pLocator = &loc_bufq;
+ audioSrc.pFormat = SDL_AUDIO_ISFLOAT(this->spec.format) ? (void*)&format_pcm_ex : (void*)&format_pcm;
/* configure audio sink */
- SLDataLocator_OutputMix loc_outmix = { SL_DATALOCATOR_OUTPUTMIX, outputMixObject };
- SLDataSink audioSnk = { &loc_outmix, NULL };
+ loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
+ loc_outmix.outputMix = outputMixObject;
+ audioSnk.pLocator = &loc_outmix;
+ audioSnk.pFormat = NULL;
/* create audio player */
- const SLInterfaceID ids[2] = {
- SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- SL_IID_VOLUME
- };
-
- const SLboolean req[2] = {
- SL_BOOLEAN_TRUE,
- SL_BOOLEAN_FALSE,
- };
-
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, &audioSrc, &audioSnk, 2, ids, req);
if (SL_RESULT_SUCCESS != result) {
LOGE("CreateAudioPlayer failed: %d", result);
@@ -590,7 +593,6 @@ openslES_CreatePCMPlayer(_THIS)
return 0;
failed:
-
return -1;
}