summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-04-30 10:22:05 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-04-30 10:22:05 +0000
commit95374ad3ca67da51882df1bf3fa79f42bd363102 (patch)
treefc15c48c981ca65957d69c4e6afc07e3da041a27
parent6eeb8e13a1c3ad1aa951258033949c4593f29a06 (diff)
Re #969: Fixed bug division by zero in JB progressive discard code, caused by possibility of uninitialized burst level after JB switches status INITIALIZING -> PROCESSING (thanks Janos Tolgyesi and Tamàs Solymosi for the report and investigation).
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3154 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjmedia/src/pjmedia/jbuf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pjmedia/src/pjmedia/jbuf.c b/pjmedia/src/pjmedia/jbuf.c
index dd530e99..f7ba2c95 100644
--- a/pjmedia/src/pjmedia/jbuf.c
+++ b/pjmedia/src/pjmedia/jbuf.c
@@ -648,6 +648,10 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
*/
if (++jb->jb_init_cycle_cnt >= INIT_CYCLE && oper == JB_OP_GET) {
jb->jb_status = JB_STATUS_PROCESSING;
+ /* To make sure the burst calculation will be done right after
+ * this, adjust burst level if it exceeds max burst level.
+ */
+ jb->jb_level = PJ_MIN(jb->jb_level, jb->jb_max_burst);
} else {
jb->jb_level = 0;
return;
@@ -660,7 +664,7 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
* the GET op may be idle, in this case, we better skip the jitter
* calculation.
*/
- if (oper == JB_OP_GET && jb->jb_level < jb->jb_max_burst)
+ if (oper == JB_OP_GET && jb->jb_level <= jb->jb_max_burst)
jbuf_calculate_jitter(jb);
jb->jb_level = 0;