Changeset 1378


Ignore:
Timestamp:
Jun 20, 2007 4:34:56 AM (12 years ago)
Author:
bennylp
Message:

Ticket #335: Detect timestamp jump to avoid excessive CPU usage in master clock (thanks ChenHuan?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/clock_thread.c

    r1266 r1378  
    2828 * Implementation of media clock with OS thread. 
    2929 */ 
    30  
     30#define MAX_JUMP    500 
    3131 
    3232struct pjmedia_clock 
     
    185185 
    186186    /* Calculate next tick */ 
     187    if (clock->next_tick.u64+MAX_JUMP < now.u64) { 
     188        /* Timestamp has made large jump, adjust next_tick */ 
     189        clock->next_tick.u64 = now.u64; 
     190    } 
    187191    clock->next_tick.u64 += clock->interval.u64; 
    188192 
     
    230234 
    231235        /* Calculate next tick */ 
     236        if (clock->next_tick.u64+MAX_JUMP < now.u64) { 
     237            /* Timestamp has made large jump, adjust next_tick */ 
     238            clock->next_tick.u64 = now.u64; 
     239        } 
    232240        clock->next_tick.u64 += clock->interval.u64; 
    233241 
Note: See TracChangeset for help on using the changeset viewer.