Skip to content

Commit 21ebec0

Browse files
authored
Rename overflow check function and constants
1 parent d88e257 commit 21ebec0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/plugins/janus_audiobridge.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,13 @@ void janus_audiobridge_destroy_session(janus_plugin_session *handle, int *error)
12761276
json_t *janus_audiobridge_query_session(janus_plugin_session *handle);
12771277

12781278
/* Audio mixing with overflow protection - tuned to 0.9 of MAX/MIN to prevent clipping */
1279-
#define SHRT_MAX_TUNED 29491
1280-
#define SHRT_MIN_TUNED -29491
1279+
#define JANUS_AUDIOBRIDGE_SHRT_MAX_TUNED 29491
1280+
#define JANUS_AUDIOBRIDGE_SHRT_MIN_TUNED -29491
12811281

12821282
/* Optimized inline function to clamp 16-bit audio samples */
1283-
static inline opus_int16 overflow_check(int sum) {
1284-
sum = sum > SHRT_MAX_TUNED ? SHRT_MAX_TUNED : sum;
1285-
sum = sum < SHRT_MIN_TUNED ? SHRT_MIN_TUNED : sum;
1283+
static inline opus_int16 janus_audiobridge_overflow_check(int32_t sum) {
1284+
sum = sum > JANUS_AUDIOBRIDGE_SHRT_MAX_TUNED ? JANUS_AUDIOBRIDGE_SHRT_MAX_TUNED : sum;
1285+
sum = sum < JANUS_AUDIOBRIDGE_SHRT_MIN_TUNED ? JANUS_AUDIOBRIDGE_SHRT_MIN_TUNED : sum;
12861286
return (opus_int16)sum;
12871287
}
12881288

@@ -8911,7 +8911,7 @@ static void *janus_audiobridge_mixer_thread(void *data) {
89118911
}
89128912
for(i=0; i<samples; i++)
89138913
/* FIXME Smoothen/Normalize instead of truncating? */
8914-
outBuffer[i] = overflow_check(sumBuffer[i]);
8914+
outBuffer[i] = janus_audiobridge_overflow_check(sumBuffer[i]);
89158915
/* Enqueue this mixed frame for encoding in the participant thread */
89168916
janus_audiobridge_rtp_relay_packet *mixedpkt = g_malloc(sizeof(janus_audiobridge_rtp_relay_packet));
89178917
mixedpkt->data = g_malloc(samples*2);

0 commit comments

Comments
 (0)