aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-03-01 11:35:39 -0800
committerChris Robinson <[email protected]>2023-03-01 11:35:39 -0800
commitfde74453a62a1ce4b5efaac0ec1835b9f5731e25 (patch)
treeed74db646800b78ca8651bb5291453927f48cd93 /alc
parentec9c421d312d6df701631877f6ce6256355101dc (diff)
Use macros for the likely/unlikely attributes
The syntax parser for GCC 8 (and earlier?) fails when these attributes are in certain places.
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp6
-rw-r--r--alc/alu.cpp12
-rw-r--r--alc/backends/jack.cpp4
-rw-r--r--alc/backends/opensl.cpp97
-rw-r--r--alc/backends/pipewire.cpp14
-rw-r--r--alc/backends/pulseaudio.cpp24
-rw-r--r--alc/effects/convolution.cpp4
7 files changed, 81 insertions, 80 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index fa230882..1a4a89ad 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2472,7 +2472,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
bool ResetDeviceParams(ALCdevice *device, const int *attrList)
{
/* If the device was disconnected, reset it since we're opened anew. */
- if(!device->Connected.load(std::memory_order_relaxed)) [[unlikely]]
+ if(!device->Connected.load(std::memory_order_relaxed)) UNLIKELY
{
/* Make sure disconnection is finished before continuing on. */
device->waitForMix();
@@ -2504,7 +2504,7 @@ bool ResetDeviceParams(ALCdevice *device, const int *attrList)
}
ALCenum err{UpdateDeviceParams(device, attrList)};
- if(err == ALC_NO_ERROR) [[likely]] return ALC_TRUE;
+ if(err == ALC_NO_ERROR) LIKELY return ALC_TRUE;
alcSetError(device, err);
return ALC_FALSE;
@@ -2556,7 +2556,7 @@ ContextRef GetContextRef(void)
*/
}
context = ALCcontext::sGlobalContext.load(std::memory_order_acquire);
- if(context) [[likely]] context->add_ref();
+ if(context) LIKELY context->add_ref();
ALCcontext::sGlobalContextLock.store(false, std::memory_order_release);
}
return ContextRef{context};
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 7af21245..a5230580 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -488,7 +488,7 @@ bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ContextBa
/* Otherwise, if it would be deleted send it off with a release event. */
RingBuffer *ring{context->mAsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
- if(evt_vec.first.len > 0) [[likely]]
+ if(evt_vec.first.len > 0) LIKELY
{
AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf),
AsyncEvent::ReleaseEffectState)};
@@ -1531,7 +1531,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
}
/* Distance-based air absorption and initial send decay. */
- if(Distance > props->RefDistance) [[likely]]
+ if(Distance > props->RefDistance) LIKELY
{
const float distance_base{(Distance-props->RefDistance) * props->RolloffFactor};
const float distance_meters{distance_base * context->mParams.MetersPerUnit};
@@ -1826,7 +1826,7 @@ void ProcessParamUpdates(ContextBase *ctx, const EffectSlotArray &slots,
ProcessVoiceChanges(ctx);
IncrementRef(ctx->mUpdateCount);
- if(!ctx->mHoldUpdates.load(std::memory_order_acquire)) [[likely]]
+ if(!ctx->mHoldUpdates.load(std::memory_order_acquire)) LIKELY
{
bool force{CalcContextParams(ctx)};
auto sorted_slots = const_cast<EffectSlot**>(slots.data() + slots.size());
@@ -1918,7 +1918,7 @@ void ProcessContexts(DeviceBase *device, const uint SamplesToDo)
* left that don't target any sorted slots, they can't
* contribute to the output, so leave them.
*/
- if(next_target == split_point) [[unlikely]]
+ if(next_target == split_point) UNLIKELY
break;
--next_target;
@@ -1961,7 +1961,7 @@ void ApplyDistanceComp(const al::span<FloatBufferLine> Samples, const size_t Sam
float *inout{al::assume_aligned<16>(chanbuffer.data())};
auto inout_end = inout + SamplesToDo;
- if(SamplesToDo >= base) [[likely]]
+ if(SamplesToDo >= base) LIKELY
{
auto delay_end = std::rotate(inout, inout_end - base, inout_end);
std::swap_ranges(inout, delay_end, distbuf);
@@ -2136,7 +2136,7 @@ void DeviceBase::renderSamples(void *outBuffer, const uint numSamples, const siz
{
const uint samplesToDo{renderSamples(todo)};
- if(outBuffer) [[likely]]
+ if(outBuffer) LIKELY
{
/* Finally, interleave and convert samples, writing to the device's
* output buffer.
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 95796862..791002ca 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -345,7 +345,7 @@ int JackPlayback::processRt(jack_nframes_t numframes) noexcept
out[numchans++] = static_cast<float*>(jack_port_get_buffer(port, numframes));
}
- if(mPlaying.load(std::memory_order_acquire)) [[likely]]
+ if(mPlaying.load(std::memory_order_acquire)) LIKELY
mDevice->renderSamples({out.data(), numchans}, static_cast<uint>(numframes));
else
{
@@ -369,7 +369,7 @@ int JackPlayback::process(jack_nframes_t numframes) noexcept
}
jack_nframes_t total{0};
- if(mPlaying.load(std::memory_order_acquire)) [[likely]]
+ if(mPlaying.load(std::memory_order_acquire)) LIKELY
{
auto data = mRing->getReadVector();
jack_nframes_t todo{minu(numframes, static_cast<uint>(data.first.len))};
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index f46438ce..f5b98fb8 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -113,7 +113,7 @@ constexpr SLuint32 GetByteOrderEndianness() noexcept
return SL_BYTEORDER_BIGENDIAN;
}
-const char *res_str(SLresult result) noexcept
+constexpr const char *res_str(SLresult result) noexcept
{
switch(result)
{
@@ -147,10 +147,11 @@ const char *res_str(SLresult result) noexcept
return "Unknown error code";
}
-#define PRINTERR(x, s) do { \
- if((x) != SL_RESULT_SUCCESS) [[unlikely]] \
- ERR("%s: %s\n", (s), res_str((x))); \
-} while(0)
+inline void PrintErr(SLresult res, const char *str)
+{
+ if(res != SL_RESULT_SUCCESS) UNLIKELY
+ ERR("%s: %s\n", str, res_str(res));
+}
struct OpenSLPlayback final : public BackendBase {
@@ -234,11 +235,11 @@ int OpenSLPlayback::mixerProc()
SLAndroidSimpleBufferQueueItf bufferQueue;
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
- PRINTERR(result, "bufferQueue->GetInterface SL_IID_ANDROIDSIMPLEBUFFERQUEUE");
+ PrintErr(result, "bufferQueue->GetInterface SL_IID_ANDROIDSIMPLEBUFFERQUEUE");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player);
- PRINTERR(result, "bufferQueue->GetInterface SL_IID_PLAY");
+ PrintErr(result, "bufferQueue->GetInterface SL_IID_PLAY");
}
const size_t frame_step{mDevice->channelsFromFmt()};
@@ -254,11 +255,11 @@ int OpenSLPlayback::mixerProc()
SLuint32 state{0};
result = VCALL(player,GetPlayState)(&state);
- PRINTERR(result, "player->GetPlayState");
+ PrintErr(result, "player->GetPlayState");
if(SL_RESULT_SUCCESS == result && state != SL_PLAYSTATE_PLAYING)
{
result = VCALL(player,SetPlayState)(SL_PLAYSTATE_PLAYING);
- PRINTERR(result, "player->SetPlayState");
+ PrintErr(result, "player->SetPlayState");
}
if(SL_RESULT_SUCCESS != result)
{
@@ -295,7 +296,7 @@ int OpenSLPlayback::mixerProc()
}
result = VCALL(bufferQueue,Enqueue)(data.first.buf, mDevice->UpdateSize*mFrameSize);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
if(SL_RESULT_SUCCESS != result)
{
mDevice->handleDisconnect("Failed to queue audio: 0x%08x", result);
@@ -324,26 +325,26 @@ void OpenSLPlayback::open(const char *name)
// create engine
SLresult result{slCreateEngine(&mEngineObj, 0, nullptr, 0, nullptr, nullptr)};
- PRINTERR(result, "slCreateEngine");
+ PrintErr(result, "slCreateEngine");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "engine->Realize");
+ PrintErr(result, "engine->Realize");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,GetInterface)(SL_IID_ENGINE, &mEngine);
- PRINTERR(result, "engine->GetInterface");
+ PrintErr(result, "engine->GetInterface");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngine,CreateOutputMix)(&mOutputMix, 0, nullptr, nullptr);
- PRINTERR(result, "engine->CreateOutputMix");
+ PrintErr(result, "engine->CreateOutputMix");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mOutputMix,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "outputMix->Realize");
+ PrintErr(result, "outputMix->Realize");
}
if(SL_RESULT_SUCCESS != result)
@@ -511,20 +512,20 @@ bool OpenSLPlayback::reset()
result = VCALL(mEngine,CreateAudioPlayer)(&mBufferQueueObj, &audioSrc, &audioSnk, ids.size(),
ids.data(), reqs.data());
- PRINTERR(result, "engine->CreateAudioPlayer");
+ PrintErr(result, "engine->CreateAudioPlayer");
}
if(SL_RESULT_SUCCESS == result)
{
/* Set the stream type to "media" (games, music, etc), if possible. */
SLAndroidConfigurationItf config;
result = VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDCONFIGURATION, &config);
- PRINTERR(result, "bufferQueue->GetInterface SL_IID_ANDROIDCONFIGURATION");
+ PrintErr(result, "bufferQueue->GetInterface SL_IID_ANDROIDCONFIGURATION");
if(SL_RESULT_SUCCESS == result)
{
SLint32 streamType = SL_ANDROID_STREAM_MEDIA;
result = VCALL(config,SetConfiguration)(SL_ANDROID_KEY_STREAM_TYPE, &streamType,
sizeof(streamType));
- PRINTERR(result, "config->SetConfiguration");
+ PrintErr(result, "config->SetConfiguration");
}
/* Clear any error since this was optional. */
@@ -533,7 +534,7 @@ bool OpenSLPlayback::reset()
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mBufferQueueObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "bufferQueue->Realize");
+ PrintErr(result, "bufferQueue->Realize");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -560,11 +561,11 @@ void OpenSLPlayback::start()
SLAndroidSimpleBufferQueueItf bufferQueue;
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
- PRINTERR(result, "bufferQueue->GetInterface");
+ PrintErr(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(&OpenSLPlayback::processC, this);
- PRINTERR(result, "bufferQueue->RegisterCallback");
+ PrintErr(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS != result)
throw al::backend_exception{al::backend_error::DeviceError,
@@ -590,25 +591,25 @@ void OpenSLPlayback::stop()
SLPlayItf player;
SLresult result{VCALL(mBufferQueueObj,GetInterface)(SL_IID_PLAY, &player)};
- PRINTERR(result, "bufferQueue->GetInterface");
+ PrintErr(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(player,SetPlayState)(SL_PLAYSTATE_STOPPED);
- PRINTERR(result, "player->SetPlayState");
+ PrintErr(result, "player->SetPlayState");
}
SLAndroidSimpleBufferQueueItf bufferQueue;
result = VCALL(mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bufferQueue);
- PRINTERR(result, "bufferQueue->GetInterface");
+ PrintErr(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL0(bufferQueue,Clear)();
- PRINTERR(result, "bufferQueue->Clear");
+ PrintErr(result, "bufferQueue->Clear");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(nullptr, nullptr);
- PRINTERR(result, "bufferQueue->RegisterCallback");
+ PrintErr(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -617,7 +618,7 @@ void OpenSLPlayback::stop()
std::this_thread::yield();
result = VCALL(bufferQueue,GetState)(&state);
} while(SL_RESULT_SUCCESS == result && state.count > 0);
- PRINTERR(result, "bufferQueue->GetState");
+ PrintErr(result, "bufferQueue->GetState");
mRing->reset();
}
@@ -694,16 +695,16 @@ void OpenSLCapture::open(const char* name)
name};
SLresult result{slCreateEngine(&mEngineObj, 0, nullptr, 0, nullptr, nullptr)};
- PRINTERR(result, "slCreateEngine");
+ PrintErr(result, "slCreateEngine");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "engine->Realize");
+ PrintErr(result, "engine->Realize");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mEngineObj,GetInterface)(SL_IID_ENGINE, &mEngine);
- PRINTERR(result, "engine->GetInterface");
+ PrintErr(result, "engine->GetInterface");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -778,7 +779,7 @@ void OpenSLCapture::open(const char* name)
result = VCALL(mEngine,CreateAudioRecorder)(&mRecordObj, &audioSrc, &audioSnk,
ids.size(), ids.data(), reqs.data());
}
- PRINTERR(result, "engine->CreateAudioRecorder");
+ PrintErr(result, "engine->CreateAudioRecorder");
}
}
if(SL_RESULT_SUCCESS == result)
@@ -786,13 +787,13 @@ void OpenSLCapture::open(const char* name)
/* Set the record preset to "generic", if possible. */
SLAndroidConfigurationItf config;
result = VCALL(mRecordObj,GetInterface)(SL_IID_ANDROIDCONFIGURATION, &config);
- PRINTERR(result, "recordObj->GetInterface SL_IID_ANDROIDCONFIGURATION");
+ PrintErr(result, "recordObj->GetInterface SL_IID_ANDROIDCONFIGURATION");
if(SL_RESULT_SUCCESS == result)
{
SLuint32 preset = SL_ANDROID_RECORDING_PRESET_GENERIC;
result = VCALL(config,SetConfiguration)(SL_ANDROID_KEY_RECORDING_PRESET, &preset,
sizeof(preset));
- PRINTERR(result, "config->SetConfiguration");
+ PrintErr(result, "config->SetConfiguration");
}
/* Clear any error since this was optional. */
@@ -801,19 +802,19 @@ void OpenSLCapture::open(const char* name)
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mRecordObj,Realize)(SL_BOOLEAN_FALSE);
- PRINTERR(result, "recordObj->Realize");
+ PrintErr(result, "recordObj->Realize");
}
SLAndroidSimpleBufferQueueItf bufferQueue;
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(mRecordObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bufferQueue);
- PRINTERR(result, "recordObj->GetInterface");
+ PrintErr(result, "recordObj->GetInterface");
}
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(bufferQueue,RegisterCallback)(&OpenSLCapture::processC, this);
- PRINTERR(result, "bufferQueue->RegisterCallback");
+ PrintErr(result, "bufferQueue->RegisterCallback");
}
if(SL_RESULT_SUCCESS == result)
{
@@ -826,12 +827,12 @@ void OpenSLCapture::open(const char* name)
for(size_t i{0u};i < data.first.len && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(data.first.buf + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
for(size_t i{0u};i < data.second.len && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(data.second.buf + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
}
@@ -857,12 +858,12 @@ void OpenSLCapture::start()
{
SLRecordItf record;
SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_RECORD, &record)};
- PRINTERR(result, "recordObj->GetInterface");
+ PrintErr(result, "recordObj->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(record,SetRecordState)(SL_RECORDSTATE_RECORDING);
- PRINTERR(result, "record->SetRecordState");
+ PrintErr(result, "record->SetRecordState");
}
if(SL_RESULT_SUCCESS != result)
throw al::backend_exception{al::backend_error::DeviceError,
@@ -873,12 +874,12 @@ void OpenSLCapture::stop()
{
SLRecordItf record;
SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_RECORD, &record)};
- PRINTERR(result, "recordObj->GetInterface");
+ PrintErr(result, "recordObj->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = VCALL(record,SetRecordState)(SL_RECORDSTATE_PAUSED);
- PRINTERR(result, "record->SetRecordState");
+ PrintErr(result, "record->SetRecordState");
}
}
@@ -916,12 +917,12 @@ void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
}
SLAndroidSimpleBufferQueueItf bufferQueue{};
- if(mDevice->Connected.load(std::memory_order_acquire)) [[likely]]
+ if(mDevice->Connected.load(std::memory_order_acquire)) LIKELY
{
const SLresult result{VCALL(mRecordObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue)};
- PRINTERR(result, "recordObj->GetInterface");
- if(SL_RESULT_SUCCESS != result) [[unlikely]]
+ PrintErr(result, "recordObj->GetInterface");
+ if(SL_RESULT_SUCCESS != result) UNLIKELY
{
mDevice->handleDisconnect("Failed to get capture buffer queue: 0x%08x", result);
bufferQueue = nullptr;
@@ -942,14 +943,14 @@ void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
SLresult result{SL_RESULT_SUCCESS};
auto wdata = mRing->getWriteVector();
- if(adv_count > wdata.second.len) [[likely]]
+ if(adv_count > wdata.second.len) LIKELY
{
auto len1 = std::min(wdata.first.len, adv_count-wdata.second.len);
auto buf1 = wdata.first.buf + chunk_size*(wdata.first.len-len1);
for(size_t i{0u};i < len1 && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(buf1 + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
}
if(wdata.second.len > 0)
@@ -959,7 +960,7 @@ void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
for(size_t i{0u};i < len2 && SL_RESULT_SUCCESS == result;i++)
{
result = VCALL(bufferQueue,Enqueue)(buf2 + chunk_size*i, chunk_size);
- PRINTERR(result, "bufferQueue->Enqueue");
+ PrintErr(result, "bufferQueue->Enqueue");
}
}
}
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 7bde4b78..c6569a74 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -477,7 +477,7 @@ struct EventManager {
*/
void waitForInit()
{
- if(!mInitDone.load(std::memory_order_acquire)) [[unlikely]]
+ if(!mInitDone.load(std::memory_order_acquire)) UNLIKELY
{
MainloopUniqueLock plock{mLoop};
plock.wait([this](){ return mInitDone.load(std::memory_order_acquire); });
@@ -862,7 +862,7 @@ void NodeProxy::infoCallback(const pw_node_info *info)
{
/* Can this actually change? */
const char *media_class{spa_dict_lookup(info->props, PW_KEY_MEDIA_CLASS)};
- if(!media_class) [[unlikely]] return;
+ if(!media_class) UNLIKELY return;
NodeType ntype{};
if(al::strcasecmp(media_class, AudioSinkClass) == 0)
@@ -919,7 +919,7 @@ void NodeProxy::paramCallback(int, uint32_t id, uint32_t, uint32_t, const spa_po
if(id == SPA_PARAM_EnumFormat)
{
DeviceNode *node{DeviceNode::Find(mId)};
- if(!node) [[unlikely]] return;
+ if(!node) UNLIKELY return;
if(const spa_pod_prop *prop{spa_pod_find_prop(param, nullptr, SPA_FORMAT_AUDIO_rate)})
node->parseSampleRate(&prop->value);
@@ -1344,7 +1344,7 @@ void PipeWirePlayback::ioChangedCallback(uint32_t id, void *area, uint32_t size)
void PipeWirePlayback::outputCallback()
{
pw_buffer *pw_buf{pw_stream_dequeue_buffer(mStream.get())};
- if(!pw_buf) [[unlikely]] return;
+ if(!pw_buf) UNLIKELY return;
const al::span<spa_data> datas{pw_buf->buffer->datas,
minu(mNumChannels, pw_buf->buffer->n_datas)};
@@ -1360,7 +1360,7 @@ void PipeWirePlayback::outputCallback()
uint length{mRateMatch ? mRateMatch->size : 0u};
#endif
/* If no length is specified, use the device's update size as a fallback. */
- if(!length) [[unlikely]] length = mDevice->UpdateSize;
+ if(!length) UNLIKELY length = mDevice->UpdateSize;
/* For planar formats, each datas[] seems to contain one channel, so store
* the pointers in an array. Limit the render length in case the available
@@ -1729,7 +1729,7 @@ ClockLatency PipeWirePlayback::getClockLatency()
*/
nanoseconds monoclock{seconds{tspec.tv_sec} + nanoseconds{tspec.tv_nsec}};
nanoseconds curtic{}, delay{};
- if(ptime.rate.denom < 1) [[unlikely]]
+ if(ptime.rate.denom < 1) UNLIKELY
{
/* If there's no stream rate, the stream hasn't had a chance to get
* going and return time info yet. Just use dummy values.
@@ -1827,7 +1827,7 @@ void PipeWireCapture::stateChangedCallback(pw_stream_state, pw_stream_state, con
void PipeWireCapture::inputCallback()
{
pw_buffer *pw_buf{pw_stream_dequeue_buffer(mStream.get())};
- if(!pw_buf) [[unlikely]] return;
+ if(!pw_buf) UNLIKELY return;
spa_data *bufdata{pw_buf->buffer->datas};
const uint offset{minu(bufdata->chunk->offset, bufdata->maxsize)};
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 9b7e2c08..4b0e316f 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -667,7 +667,7 @@ void PulsePlayback::streamWriteCallback(pa_stream *stream, size_t nbytes) noexce
pa_free_cb_t free_func{nullptr};
auto buflen = static_cast<size_t>(-1);
void *buf{};
- if(pa_stream_begin_write(stream, &buf, &buflen) || !buf) [[unlikely]]
+ if(pa_stream_begin_write(stream, &buf, &buflen) || !buf) UNLIKELY
{
buflen = nbytes;
buf = pa_xmalloc(buflen);
@@ -680,7 +680,7 @@ void PulsePlayback::streamWriteCallback(pa_stream *stream, size_t nbytes) noexce
mDevice->renderSamples(buf, static_cast<uint>(buflen/mFrameSize), mSpec.channels);
int ret{pa_stream_write(stream, buf, buflen, free_func, 0, PA_SEEK_RELATIVE)};
- if(ret != PA_OK) [[unlikely]]
+ if(ret != PA_OK) UNLIKELY
ERR("Failed to write to stream: %d, %s\n", ret, pa_strerror(ret));
} while(nbytes > 0);
}
@@ -1006,7 +1006,7 @@ ClockLatency PulsePlayback::getClockLatency()
err = pa_stream_get_latency(mStream, &latency, &neg);
}
- if(err != 0) [[unlikely]]
+ if(err != 0) UNLIKELY
{
/* If err = -PA_ERR_NODATA, it means we were called too soon after
* starting the stream and no timing info has been received from the
@@ -1017,7 +1017,7 @@ ClockLatency PulsePlayback::getClockLatency()
latency = mDevice->BufferSize - mDevice->UpdateSize;
neg = 0;
}
- else if(neg) [[unlikely]]
+ else if(neg) UNLIKELY
latency = 0;
ret.Latency = std::chrono::microseconds{latency};
@@ -1240,7 +1240,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
mLastReadable -= static_cast<uint>(dstbuf.size());
while(!dstbuf.empty())
{
- if(mHoleLength > 0) [[unlikely]]
+ if(mHoleLength > 0) UNLIKELY
{
const size_t rem{minz(dstbuf.size(), mHoleLength)};
std::fill_n(dstbuf.begin(), rem, mSilentVal);
@@ -1259,7 +1259,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
continue;
}
- if(!mDevice->Connected.load(std::memory_order_acquire)) [[unlikely]]
+ if(!mDevice->Connected.load(std::memory_order_acquire)) UNLIKELY
break;
MainloopUniqueLock plock{mMainloop};
@@ -1270,7 +1270,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
}
const pa_stream_state_t state{pa_stream_get_state(mStream)};
- if(!PA_STREAM_IS_GOOD(state)) [[unlikely]]
+ if(!PA_STREAM_IS_GOOD(state)) UNLIKELY
{
mDevice->handleDisconnect("Bad capture state: %u", state);
break;
@@ -1278,7 +1278,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
const void *capbuf;
size_t caplen;
- if(pa_stream_peek(mStream, &capbuf, &caplen) < 0) [[unlikely]]
+ if(pa_stream_peek(mStream, &capbuf, &caplen) < 0) UNLIKELY
{
mDevice->handleDisconnect("Failed retrieving capture samples: %s",
pa_strerror(pa_context_errno(mContext)));
@@ -1287,7 +1287,7 @@ void PulseCapture::captureSamples(al::byte *buffer, uint samples)
plock.unlock();
if(caplen == 0) break;
- if(!capbuf) [[unlikely]]
+ if(!capbuf) UNLIKELY
mHoleLength = caplen;
else
mCapBuffer = {static_cast<const al::byte*>(capbuf), caplen};
@@ -1305,7 +1305,7 @@ uint PulseCapture::availableSamples()
{
MainloopUniqueLock plock{mMainloop};
size_t got{pa_stream_readable_size(mStream)};
- if(static_cast<ssize_t>(got) < 0) [[unlikely]]
+ if(static_cast<ssize_t>(got) < 0) UNLIKELY
{
const char *err{pa_strerror(static_cast<int>(got))};
ERR("pa_stream_readable_size() failed: %s\n", err);
@@ -1342,13 +1342,13 @@ ClockLatency PulseCapture::getClockLatency()
err = pa_stream_get_latency(mStream, &latency, &neg);
}
- if(err != 0) [[unlikely]]
+ if(err != 0) UNLIKELY
{
ERR("Failed to get stream latency: 0x%x\n", err);
latency = 0;
neg = 0;
}
- else if(neg) [[unlikely]]
+ else if(neg) UNLIKELY
latency = 0;
ret.Latency = std::chrono::microseconds{latency};
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 92b70323..e526e009 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -420,7 +420,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot
{ SideRight, Deg2Rad( 90.0f), Deg2Rad(0.0f) }
};
- if(mNumConvolveSegs < 1) [[unlikely]]
+ if(mNumConvolveSegs < 1) UNLIKELY
return;
mMix = &ConvolutionState::NormalMix;
@@ -524,7 +524,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot
void ConvolutionState::process(const size_t samplesToDo,
const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- if(mNumConvolveSegs < 1) [[unlikely]]
+ if(mNumConvolveSegs < 1) UNLIKELY
return;
constexpr size_t m{ConvolveUpdateSize/2 + 1};