summaryrefslogtreecommitdiff
path: root/jitterbuf.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-05-19 01:24:09 +0000
committerMark Spencer <markster@digium.com>2005-05-19 01:24:09 +0000
commit53d655cf0af46985576959ddc42f95f014e44dc8 (patch)
tree713fc32b1c867d1d214ad6fe3d2688862add7989 /jitterbuf.c
parent364e179b78206439202f85f993407cda6ddcbd88 (diff)
Yet another set of jitter buffer changes (this time some scheduling improvements) (bug #4319)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'jitterbuf.c')
-rwxr-xr-xjitterbuf.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/jitterbuf.c b/jitterbuf.c
index 9611048e0..da017c128 100755
--- a/jitterbuf.c
+++ b/jitterbuf.c
@@ -300,10 +300,12 @@ static void history_get(jitterbuf *jb)
jb->info.jitter = jitter;
}
-static void queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
+/* returns 1 if frame was inserted into head of queue, 0 otherwise */
+static int queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
{
jb_frame *frame;
jb_frame *p;
+ int head = 0;
long resync_ts = ts - jb->info.resync_offset;
frame = jb->free;
@@ -315,7 +317,7 @@ static void queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
if (!frame) {
jb_err("cannot allocate frame\n");
- return;
+ return 0;
}
jb->info.frames_cur++;
@@ -334,6 +336,7 @@ static void queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
jb->frames = frame;
frame->next = frame;
frame->prev = frame;
+ head = 1;
} else if (resync_ts < jb->frames->ts) {
frame->next = jb->frames;
frame->prev = jb->frames->prev;
@@ -345,6 +348,7 @@ static void queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
jb->info.frames_ooo++;
jb->frames = frame;
+ head = 1;
} else {
p = jb->frames;
@@ -360,6 +364,7 @@ static void queue_put(jitterbuf *jb, void *data, int type, long ms, long ts)
frame->next->prev = frame;
frame->prev->next = frame;
}
+ return head;
}
static long queue_next(jitterbuf *jb)
@@ -502,8 +507,10 @@ int jb_put(jitterbuf *jb, void *data, int type, long ms, long ts, long now)
return JB_DROP;
}
- queue_put(jb,data,type,ms,ts);
-
+ /* if put into head of queue, caller needs to reschedule */
+ if (queue_put(jb,data,type,ms,ts)) {
+ return JB_SCHED;
+ }
return JB_OK;
}