aboutsummaryrefslogtreecommitdiffstats
path: root/jitterbuf.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-19 01:24:09 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-19 01:24:09 +0000
commit160bd00f28f1a866ce0d62fad10d9115fc070c1d (patch)
tree713fc32b1c867d1d214ad6fe3d2688862add7989 /jitterbuf.c
parent4be4420d180e7487b8971de2eb9e2cc1a44b4722 (diff)
Yet another set of jitter buffer changes (this time some scheduling improvements) (bug #4319)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5722 f38db490-d61c-443f-a65b-d21fe96a405b
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;
}