static int clock_thread(void *arg)
{
pj_timestamp now;
pjmedia_clock *clock = (pjmedia_clock*) arg;
/* Set thread priority to maximum unless not wanted. */
if ((clock->options & PJMEDIA_CLOCK_NO_HIGHEST_PRIO) == 0) {
int max = pj_thread_get_prio_max(pj_thread_this());
if (max > 0)
pj_thread_set_prio(pj_thread_this(), max);
}
/* Get the first tick */
pj_get_timestamp(&clock->next_tick);
clock->next_tick.u64 += clock->interval.u64;
printf("pjmedia_clock_size=%u pj_timestamp=%u\n",sizeof(pjmedia_clock),sizeof(now));
while (!clock->quitting) {
pj_get_timestamp(&now);
/* Wait for the next tick to happen */
if (now.u64 < clock->next_tick.u64) {
unsigned msec;
msec = pj_elapsed_msec(&now, &clock->next_tick);
pj_thread_sleep(msec);
}
/* Skip if not running */
if (!clock->running) {
/* Calculate next tick */
clock_calc_next_tick(clock, &now);
continue;
}
pj_lock_acquire(clock->lock);
/* Call callback, if any */
if (clock->cb)
(*clock->cb)(&clock->timestamp, clock->user_data);
/* Best effort way to detect if we've been destroyed in the callback */
if (clock->quitting) {
pj_lock_release(clock->lock);
break;
}
/* Increment timestamp */
clock->timestamp.u64 += clock->timestamp_inc;
/* Calculate next tick */
clock_calc_next_tick(clock, &now);
pj_lock_release(clock->lock);
}
return 0;
}
Если я правильно понимаю, тут реализация выпонения callbacks по clock