diff options
author | Chris Robinson <[email protected]> | 2019-05-26 21:28:51 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-05-26 21:28:51 -0700 |
commit | f57fedec7f8878230fb77be1d91d7c056f7e6de4 (patch) | |
tree | b10f6bf16db0f2e792b64f74388ec9ffde47791a /Alc | |
parent | f6f220025bd9674a33d896258b315c006cfd78f1 (diff) |
Get rid of the COUNTOF macro
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 17 | ||||
-rw-r--r-- | Alc/backends/opensl.cpp | 21 |
2 files changed, 17 insertions, 21 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 8a340b18..eb6269ec 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -1151,11 +1151,11 @@ static void alc_initconfig(void) continue; size_t len{next ? static_cast<size_t>(next-str) : strlen(str)}; - for(size_t n{0u};n < countof(gEffectList);n++) + for(const EffectList &effectitem : gEffectList) { - if(len == strlen(gEffectList[n].name) && - strncmp(gEffectList[n].name, str, len) == 0) - DisabledEffects[gEffectList[n].type] = AL_TRUE; + if(len == strlen(effectitem.name) && + strncmp(effectitem.name, str, len) == 0) + DisabledEffects[effectitem.type] = AL_TRUE; } } while(next++); } @@ -1280,14 +1280,13 @@ static ALboolean DecomposeDevFormat(ALenum format, DevFmtChannels *chans, DevFmt { AL_FORMAT_71CHN16, DevFmtX71, DevFmtShort }, { AL_FORMAT_71CHN32, DevFmtX71, DevFmtFloat }, }; - ALuint i; - for(i = 0;i < COUNTOF(list);i++) + for(const auto &item : list) { - if(list[i].format == format) + if(item.format == format) { - *chans = list[i].channels; - *type = list[i].type; + *chans = item.channels; + *type = item.type; return AL_TRUE; } } diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp index 2072f99c..1cf309f7 100644 --- a/Alc/backends/opensl.cpp +++ b/Alc/backends/opensl.cpp @@ -27,6 +27,7 @@ #include <jni.h> #include <new> +#include <array> #include <thread> #include <functional> @@ -352,8 +353,6 @@ ALCboolean OpenSLPlayback::reset() SLDataLocator_OutputMix loc_outmix; SLDataSource audioSrc; SLDataSink audioSnk; - SLInterfaceID ids[2]; - SLboolean reqs[2]; SLresult result; if(mBufferQueueObj) @@ -437,6 +436,9 @@ ALCboolean OpenSLPlayback::reset() mFrameSize = mDevice->frameSizeFromFmt(); + const std::array<SLInterfaceID,2> ids{{ SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION }}; + const std::array<SLboolean,2> reqs{{ SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE }}; + loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; loc_bufq.numBuffers = mDevice->BufferSize / mDevice->UpdateSize; @@ -472,13 +474,8 @@ ALCboolean OpenSLPlayback::reset() audioSnk.pFormat = nullptr; - ids[0] = SL_IID_ANDROIDSIMPLEBUFFERQUEUE; - reqs[0] = SL_BOOLEAN_TRUE; - ids[1] = SL_IID_ANDROIDCONFIGURATION; - reqs[1] = SL_BOOLEAN_FALSE; - - result = VCALL(mEngine,CreateAudioPlayer)(&mBufferQueueObj, &audioSrc, &audioSnk, COUNTOF(ids), - ids, reqs); + result = VCALL(mEngine,CreateAudioPlayer)(&mBufferQueueObj, &audioSrc, &audioSnk, ids.size(), + ids.data(), reqs.data()); PRINTERR(result, "engine->CreateAudioPlayer"); if(SL_RESULT_SUCCESS == result) { @@ -704,8 +701,8 @@ ALCenum OpenSLCapture::open(const ALCchar* name) } if(SL_RESULT_SUCCESS == result) { - const SLInterfaceID ids[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION }; - const SLboolean reqs[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE }; + const std::array<SLInterfaceID,2> ids{{ SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION }}; + const std::array<SLboolean,2> reqs{{ SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE }}; SLDataLocator_IODevice loc_dev{}; loc_dev.locatorType = SL_DATALOCATOR_IODEVICE; @@ -747,7 +744,7 @@ ALCenum OpenSLCapture::open(const ALCchar* name) audioSnk.pFormat = &format_pcm; result = VCALL(mEngine,CreateAudioRecorder)(&mRecordObj, &audioSrc, &audioSnk, - COUNTOF(ids), ids, reqs); + ids.size(), ids.data(), reqs.data()); PRINTERR(result, "engine->CreateAudioRecorder"); } if(SL_RESULT_SUCCESS == result) |