Skip to content

Commit 982c63a

Browse files
committed
Mixer: use MP_LIKELY macro instead of locally brewed one
1 parent 449dbea commit 982c63a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

shared-module/audiomixer/Mixer.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ static inline uint32_t pack8(uint32_t val) {
140140
return ((val & 0xff000000) >> 16) | ((val & 0xff00) >> 8);
141141
}
142142

143-
#define LIKELY(x) (__builtin_expect(!!(x), 1))
144-
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
145143
static void mix_one_voice(audiomixer_mixer_obj_t* self,
146144
audiomixer_mixervoice_obj_t* voice, bool voices_active,
147145
uint32_t* word_buffer, uint32_t length) {
@@ -172,8 +170,8 @@ static void mix_one_voice(audiomixer_mixer_obj_t* self,
172170

173171
// First active voice gets copied over verbatim.
174172
if (!voices_active) {
175-
if (LIKELY(self->bits_per_sample == 16)) {
176-
if (LIKELY(self->samples_signed)) {
173+
if (MP_LIKELY(self->bits_per_sample == 16)) {
174+
if (MP_LIKELY(self->samples_signed)) {
177175
for (uint32_t i = 0; i<n; i++) {
178176
uint32_t v = src[i];
179177
word_buffer[i] = mult16signed(v, level);
@@ -190,16 +188,16 @@ static void mix_one_voice(audiomixer_mixer_obj_t* self,
190188
uint16_t *hsrc = (uint16_t*)src;
191189
for (uint32_t i = 0; i<n*2; i++) {
192190
uint32_t word = unpack8(hsrc[i]);
193-
if (LIKELY(!self->samples_signed)) {
191+
if (MP_LIKELY(!self->samples_signed)) {
194192
word = tosigned16(word);
195193
}
196194
word = mult16signed(word, level);
197195
hword_buffer[i] = pack8(word);
198196
}
199197
}
200198
} else {
201-
if (LIKELY(self->bits_per_sample == 16)) {
202-
if (LIKELY(self->samples_signed)) {
199+
if (MP_LIKELY(self->bits_per_sample == 16)) {
200+
if (MP_LIKELY(self->samples_signed)) {
203201
for (uint32_t i = 0; i<n; i++) {
204202
uint32_t word = src[i];
205203
word_buffer[i] = add16signed(mult16signed(word, level), word_buffer[i]);
@@ -216,7 +214,7 @@ static void mix_one_voice(audiomixer_mixer_obj_t* self,
216214
uint16_t *hsrc = (uint16_t*)src;
217215
for (uint32_t i = 0; i<n*2; i++) {
218216
uint32_t word = unpack8(hsrc[i]);
219-
if (LIKELY(!self->samples_signed)) {
217+
if (MP_LIKELY(!self->samples_signed)) {
220218
word = tosigned16(word);
221219
}
222220
word = mult16signed(word, level);

0 commit comments

Comments
 (0)