- Timestamp:
- Oct 20, 2007 11:58:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/clock_thread.c
r1378 r1509 28 28 * Implementation of media clock with OS thread. 29 29 */ 30 #define MAX_JUMP 50031 30 32 31 struct pjmedia_clock … … 38 37 unsigned samples_per_frame; 39 38 unsigned options; 39 pj_uint64_t max_jump; 40 40 pjmedia_clock_callback *cb; 41 41 void *user_data; … … 49 49 static int clock_thread(void *arg); 50 50 51 #define MAX_JUMP_MSEC 500 51 52 52 53 /* … … 77 78 clock->next_tick.u64 = 0; 78 79 clock->timestamp.u64 = 0; 80 clock->max_jump = MAX_JUMP_MSEC * clock->freq.u64 / 1000; 79 81 clock->samples_per_frame = samples_per_frame; 80 82 clock->options = options; … … 143 145 144 146 147 /* Calculate next tick */ 148 PJ_INLINE(void) clock_calc_next_tick(pjmedia_clock *clock, 149 pj_timestamp *now) 150 { 151 if (clock->next_tick.u64+clock->max_jump < now->u64) { 152 /* Timestamp has made large jump, adjust next_tick */ 153 clock->next_tick.u64 = now->u64; 154 } 155 clock->next_tick.u64 += clock->interval.u64; 156 157 } 158 145 159 /* 146 160 * Poll the clock. … … 185 199 186 200 /* 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 } 191 clock->next_tick.u64 += clock->interval.u64; 201 clock_calc_next_tick(clock, &now); 192 202 193 203 /* Done */ … … 221 231 222 232 /* Skip if not running */ 223 if (!clock->running) 233 if (!clock->running) { 234 /* Calculate next tick */ 235 clock_calc_next_tick(clock, &now); 224 236 continue; 237 } 225 238 226 239 pj_lock_acquire(clock->lock); … … 234 247 235 248 /* 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 } 240 clock->next_tick.u64 += clock->interval.u64; 249 clock_calc_next_tick(clock, &now); 241 250 242 251 pj_lock_release(clock->lock);
Note: See TracChangeset
for help on using the changeset viewer.