diff --git a/main/jitterbuf.c b/main/jitterbuf.c index 834be8781..867b6948b 100644 --- a/main/jitterbuf.c +++ b/main/jitterbuf.c @@ -510,27 +510,33 @@ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type t jb_dbg2("jb_put(%x,%x,%ld,%ld,%ld)\n", jb, data, ms, ts, now); - jb->info.frames_in++; + numts = 0; + if (jb->frames) + numts = jb->frames->prev->ts - jb->frames->ts; - if (jb->frames && jb->dropem) + if (numts >= jb->info.conf.max_jitterbuf) { + if (!jb->dropem) { + ast_debug(1, "Attempting to exceed Jitterbuf max %ld timeslots\n", + jb->info.conf.max_jitterbuf); + jb->dropem = 1; + } + jb->info.frames_dropped++; return JB_DROP; - jb->dropem = 0; + } else { + jb->dropem = 0; + } if (type == JB_TYPE_VOICE) { /* presently, I'm only adding VOICE frames to history and drift calculations; mostly because with the * IAX integrations, I'm sending retransmitted control frames with their awkward timestamps through */ - if (history_put(jb,ts,now,ms)) + if (history_put(jb,ts,now,ms)) { + jb->info.frames_dropped++; return JB_DROP; + } } - numts = 0; - if (jb->frames) - numts = jb->frames->prev->ts - jb->frames->ts; - if (numts >= jb->info.conf.max_jitterbuf) { - ast_debug(1, "Attempting to exceed Jitterbuf max %ld timeslots\n", - jb->info.conf.max_jitterbuf); - jb->dropem = 1; - return JB_DROP; - } + + jb->info.frames_in++; + /* if put into head of queue, caller needs to reschedule */ if (queue_put(jb,data,type,ms,ts)) { return JB_SCHED;