Ticket #505: ticket505.3.patch

File ticket505.3.patch, 1.5 KB (added by nanang, 14 years ago)

Shrink only one frame at one time

  • pjmedia/src/pjmedia/jbuf.c

     
    8282/* Enabling this would log the jitter buffer state about once per  
    8383 * second. 
    8484 */ 
    85 #if 1 
    86 #  define TRACE__(args)     PJ_LOG(4,args) 
     85#if 0 
     86#  define TRACE__(args)     PJ_LOG(5,args) 
    8787#else 
    8888#  define TRACE__(args) 
    8989#endif 
     
    395395        /* Level is decreasing */ 
    396396        if (jb->jb_level < jb->jb_prefetch) { 
    397397 
    398             static const int stable_history_limit = 100; 
     398            enum { STABLE_HISTORY_LIMIT = 100 }; 
    399399             
    400400            jb->jb_stable_hist++; 
    401401             
    402402            /* Only update the prefetch if 'stable' condition is reached  
    403403             * (not just short time impulse) 
    404404             */ 
    405             if (jb->jb_stable_hist > (int)stable_history_limit) { 
     405            if (jb->jb_stable_hist > STABLE_HISTORY_LIMIT) { 
    406406                diff = (jb->jb_prefetch - jb->jb_max_hist_level) / 3; 
    407407 
    408408                if (diff < 1) 
     
    444444    /* These code is used for shortening the delay in the jitter buffer. */ 
    445445    diff = jb_framelist_size(&jb->jb_framelist) - jb->jb_prefetch; 
    446446    if (diff > SAFE_SHRINKING_DIFF) { 
    447          
    448         /* Drop some frames so jitter buffer size should be == jb_prefetch */ 
     447        /* Shrink slowly */ 
     448        diff = 1; 
     449 
     450        /* Drop frame(s)! */ 
    449451        jb_framelist_remove_head(&jb->jb_framelist, diff); 
    450452 
    451453        TRACE__((jb->name.ptr,  
    452                  "JB shrinking %d frames, size=%d", diff, 
     454                 "JB shrinking %d frame(s), size=%d", diff, 
    453455                 jb_framelist_size(&jb->jb_framelist))); 
    454456    } 
    455457