daemon/codec.c (in master) contains the following code for silence detection.
#define __silence_detect_type(type) \
static void __silence_detect_ ## type(struct codec_ssrc_handler *ch, AVFrame *frame, type thres) { \
type *s = (void *) frame->data[0]; \
struct silence_event *last = t_queue_peek_tail(&ch->silence_events); \
\
if (last && last->end) /* last event finished? */ \
last = NULL; \
\
for (unsigned int i = 0; i < frame->nb_samples; i++) { \
if (s[i] <= thres && s[1] >= -thres) { \
/* silence */ \
if (!last) { \
/* new event */ \
last = g_new0(__typeof(*last), 1); \
last->start = frame->pts + i; \
t_queue_push_tail(&ch->silence_events, last); \
} \
} \
else { \
/* not silence */ \
if (last && !last->end) { \
/* close off event */ \
last->end = frame->pts + i; \
last = NULL; \
} \
} \
} \
}
There may be some reason for it but I'm guessing that
if (s[i] <= thres && s[1] >= -thres) { sh
should be
if (s[i] <= thres && s[i] >= -thres) {
If so, happy to help if you would like me to submit a PR.
daemon/codec.c (in master) contains the following code for silence detection.
There may be some reason for it but I'm guessing that
should be
If so, happy to help if you would like me to submit a PR.