Changeset 3840 for pjproject/trunk
- Timestamp:
- Oct 24, 2011 8:49:42 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/clock_thread.c
r3664 r3840 110 110 struct pjmedia_clock 111 111 { 112 pj_pool_t *pool; 112 113 pj_timestamp freq; 113 114 pj_timestamp interval; … … 165 166 p_clock, PJ_EINVAL); 166 167 168 pool = pj_pool_create(pool->factory, "clock%p", 512, 512, NULL); 169 167 170 clock = PJ_POOL_ALLOC_T(pool, pjmedia_clock); 171 clock->pool = pool; 168 172 169 173 status = pj_get_timestamp_freq(&clock->freq); … … 191 195 return status; 192 196 197 *p_clock = clock; 198 199 return PJ_SUCCESS; 200 } 201 202 203 /* 204 * Start the clock. 205 */ 206 PJ_DEF(pj_status_t) pjmedia_clock_start(pjmedia_clock *clock) 207 { 208 pj_timestamp now; 209 pj_status_t status; 210 211 PJ_ASSERT_RETURN(clock != NULL, PJ_EINVAL); 212 213 if (clock->running) 214 return PJ_SUCCESS; 215 216 status = pj_get_timestamp(&now); 217 if (status != PJ_SUCCESS) 218 return status; 219 220 clock->next_tick.u64 = now.u64 + clock->interval.u64; 221 clock->running = PJ_TRUE; 222 clock->quitting = PJ_FALSE; 223 193 224 if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0) { 194 status = pj_thread_create( pool, "clock", &clock_thread, clock,225 status = pj_thread_create(clock->pool, "clock", &clock_thread, clock, 195 226 0, 0, &clock->thread); 196 227 if (status != PJ_SUCCESS) { … … 200 231 } 201 232 202 203 *p_clock = clock; 204 205 return PJ_SUCCESS; 206 } 207 208 209 /* 210 * Start the clock. 211 */ 212 PJ_DEF(pj_status_t) pjmedia_clock_start(pjmedia_clock *clock) 213 { 214 pj_timestamp now; 215 pj_status_t status; 216 233 return PJ_SUCCESS; 234 } 235 236 237 /* 238 * Stop the clock. 239 */ 240 PJ_DEF(pj_status_t) pjmedia_clock_stop(pjmedia_clock *clock) 241 { 217 242 PJ_ASSERT_RETURN(clock != NULL, PJ_EINVAL); 218 243 219 if (clock->running)220 return PJ_SUCCESS;221 222 status = pj_get_timestamp(&now);223 if (status != PJ_SUCCESS)224 return status;225 226 pj_lock_acquire(clock->lock);227 clock->next_tick.u64 = now.u64 + clock->interval.u64;228 clock->running = PJ_TRUE;229 pj_lock_release(clock->lock);230 231 return status;232 }233 234 235 /*236 * Stop the clock.237 */238 PJ_DEF(pj_status_t) pjmedia_clock_stop(pjmedia_clock *clock)239 {240 PJ_ASSERT_RETURN(clock != NULL, PJ_EINVAL);241 242 244 clock->running = PJ_FALSE; 245 clock->quitting = PJ_TRUE; 246 247 if (clock->thread) { 248 pj_thread_join(clock->thread); 249 clock->thread = NULL; 250 } 243 251 244 252 return PJ_SUCCESS; … … 401 409 } 402 410 403 return PJ_SUCCESS; 404 } 405 406 411 if (clock->pool) { 412 pj_pool_t *pool = clock->pool; 413 clock->pool = NULL; 414 pj_pool_release(pool); 415 } 416 return PJ_SUCCESS; 417 } 418 419
Note: See TracChangeset
for help on using the changeset viewer.