- Timestamp:
- Mar 1, 2013 3:46:45 AM (12 years ago)
- Location:
- pjproject/branches/1.x
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x
- Property svn:mergeinfo changed
/pjproject/trunk merged: 3840,3854-3855,4160
- Property svn:mergeinfo changed
-
pjproject/branches/1.x/pjlib/src/pj/os_core_win32.c
r3986 r4410 580 580 PJ_ASSERT_RETURN(p, PJ_EINVAL); 581 581 582 if (p == pj_thread_this()) 583 return PJ_ECANCELLED; 584 582 585 PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name)); 583 586 -
pjproject/branches/1.x/pjmedia/src/pjmedia/clock_thread.c
r3553 r4410 32 32 struct pjmedia_clock 33 33 { 34 pj_pool_t *pool; 34 35 pj_timestamp freq; 35 36 pj_timestamp interval; … … 71 72 72 73 clock = PJ_POOL_ALLOC_T(pool, pjmedia_clock); 73 74 74 clock->pool = pj_pool_create(pool->factory, "clock%p", 512, 512, NULL); 75 75 76 status = pj_get_timestamp_freq(&clock->freq); 76 77 if (status != PJ_SUCCESS) … … 95 96 return status; 96 97 97 if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0) {98 status = pj_thread_create(pool, "clock", &clock_thread, clock,99 0, 0, &clock->thread);100 if (status != PJ_SUCCESS) {101 pj_lock_destroy(clock->lock);102 return status;103 }104 }105 106 107 98 *p_clock = clock; 108 99 … … 128 119 return status; 129 120 130 pj_lock_acquire(clock->lock);131 121 clock->next_tick.u64 = now.u64 + clock->interval.u64; 132 122 clock->running = PJ_TRUE; 133 pj_lock_release(clock->lock); 134 135 return status; 123 clock->quitting = PJ_FALSE; 124 125 if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0 && !clock->thread) { 126 status = pj_thread_create(clock->pool, "clock", &clock_thread, clock, 127 0, 0, &clock->thread); 128 if (status != PJ_SUCCESS) { 129 clock->running = PJ_FALSE; 130 return status; 131 } 132 } 133 134 return PJ_SUCCESS; 136 135 } 137 136 … … 145 144 146 145 clock->running = PJ_FALSE; 146 clock->quitting = PJ_TRUE; 147 148 if (clock->thread) { 149 if (pj_thread_join(clock->thread) == PJ_SUCCESS) { 150 pj_thread_destroy(clock->thread); 151 clock->thread = NULL; 152 pj_pool_reset(clock->pool); 153 } else { 154 clock->quitting = PJ_FALSE; 155 } 156 } 147 157 148 158 return PJ_SUCCESS; … … 255 265 (*clock->cb)(&clock->timestamp, clock->user_data); 256 266 267 /* Best effort way to detect if we've been destroyed in the callback */ 268 if (clock->quitting) 269 break; 270 257 271 /* Increment timestamp */ 258 272 clock->timestamp.u64 += clock->timestamp_inc; … … 289 303 } 290 304 305 if (clock->pool) { 306 pj_pool_t *pool = clock->pool; 307 clock->pool = NULL; 308 pj_pool_release(pool); 309 } 291 310 return PJ_SUCCESS; 292 311 }
Note: See TracChangeset
for help on using the changeset viewer.