summaryrefslogtreecommitdiff
path: root/funcs/func_jitterbuffer.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-05-05 18:08:42 +0000
committerDavid Vossel <dvossel@digium.com>2011-05-05 18:08:42 +0000
commit00dc1556ab60944d6af9245543a2fcf11f60fa1f (patch)
treed5f763cd12bc001075a5fcf45262e6eab0a39a53 /funcs/func_jitterbuffer.c
parent87a8619e34d271c918869fa19629f2be6deb0c38 (diff)
Fixes reliability issues with func_jitterbuffer's usage in the new ConfBridge application.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_jitterbuffer.c')
-rw-r--r--funcs/func_jitterbuffer.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/funcs/func_jitterbuffer.c b/funcs/func_jitterbuffer.c
index e613e6a23..dd1de604a 100644
--- a/funcs/func_jitterbuffer.c
+++ b/funcs/func_jitterbuffer.c
@@ -203,6 +203,7 @@ static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_fram
struct jb_framedata *framedata = data;
struct timeval now_tv;
unsigned long now;
+ int putframe = 0; /* signifies if audio frame was placed into the buffer or not */
switch (event) {
case AST_FRAMEHOOK_EVENT_READ:
@@ -249,15 +250,31 @@ static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_fram
if (res == AST_JB_IMPL_OK) {
frame = &ast_null_frame;
}
+ putframe = 1;
}
if (frame->frametype == AST_FRAME_NULL) {
int res;
long next = framedata->jb_impl->next(framedata->jb_obj);
+ /* If now is earlier than the next expected output frame
+ * from the jitterbuffer we may choose to pass on retrieving
+ * a frame during this read iteration. The only exception
+ * to this rule is when an audio frame is placed into the buffer
+ * and the time for the next frame to come out of the buffer is
+ * at least within the timer_interval of the next output frame. By
+ * doing this we are able to feed off the timing of the input frames
+ * and only rely on our jitterbuffer timer when frames are dropped.
+ * During testing, this hybrid form of timing gave more reliable results. */
if (now < next) {
- return frame;
+ long int diff = next - now;
+ if (!putframe) {
+ return frame;
+ } else if (diff >= framedata->timer_interval) {
+ return frame;
+ }
}
+
res = framedata->jb_impl->get(framedata->jb_obj, &frame, now, framedata->timer_interval);
switch (res) {
case AST_JB_IMPL_OK: