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
This commit is contained in:
Mark Spencer
2005-05-19 01:24:09 +00:00
parent 364e179b78
commit 53d655cf0a
3 changed files with 22 additions and 8 deletions

View File

@@ -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;
}