Changeset 3905 for pjproject/trunk
- Timestamp:
- Dec 9, 2011 5:15:39 AM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/event.h
r3901 r3905 332 332 * 333 333 * @param mgr The event manager. 334 * @param pool Pool to allocate memory from.335 334 * @param cb The callback function to receive the event. 336 335 * @param user_data The user data to be associated with the callback … … 341 340 */ 342 341 PJ_DECL(pj_status_t) pjmedia_event_subscribe(pjmedia_event_mgr *mgr, 343 pj_pool_t *pool,344 342 pjmedia_event_cb *cb, 345 343 void *user_data, -
pjproject/trunk/pjmedia/src/pjmedia/event.c
r3899 r3905 50 50 struct pjmedia_event_mgr 51 51 { 52 pj_pool_t *pool; 52 53 pj_thread_t *thread; /**< worker thread. */ 53 54 pj_bool_t is_quitting; … … 57 58 event_queue *pub_ev_queue; /**< publish() event queue. */ 58 59 esub esub_list; /**< list of subscribers. */ 60 esub free_esub_list; /**< list of subscribers. */ 59 61 esub *th_next_sub, /**< worker thread's next sub. */ 60 62 *pub_next_sub; /**< publish() next sub. */ … … 155 157 156 158 mgr = PJ_POOL_ZALLOC_T(pool, pjmedia_event_mgr); 159 mgr->pool = pj_pool_create(pool->factory, "evt mgr", 500, 500, NULL); 157 160 pj_list_init(&mgr->esub_list); 161 pj_list_init(&mgr->free_esub_list); 158 162 159 163 if (!(options & PJMEDIA_EVENT_MGR_NO_THREAD)) { 160 status = pj_sem_create(pool, "ev_sem", 0, MAX_EVENTS + 1, &mgr->sem); 164 status = pj_sem_create(mgr->pool, "ev_sem", 0, MAX_EVENTS + 1, 165 &mgr->sem); 161 166 if (status != PJ_SUCCESS) 162 167 return status; 163 168 164 status = pj_thread_create(pool, "ev_thread", &event_worker_thread, 169 status = pj_thread_create(mgr->pool, "ev_thread", 170 &event_worker_thread, 165 171 mgr, 0, 0, &mgr->thread); 166 172 if (status != PJ_SUCCESS) { … … 170 176 } 171 177 172 status = pj_mutex_create_recursive( pool, "ev_mutex", &mgr->mutex);178 status = pj_mutex_create_recursive(mgr->pool, "ev_mutex", &mgr->mutex); 173 179 if (status != PJ_SUCCESS) { 174 180 pjmedia_event_mgr_destroy(mgr); … … 197 203 PJ_DEF(void) pjmedia_event_mgr_destroy(pjmedia_event_mgr *mgr) 198 204 { 199 esub *sub;200 201 205 if (!mgr) mgr = pjmedia_event_mgr_instance(); 202 206 PJ_ASSERT_ON_FAIL(mgr != NULL, return); … … 218 222 } 219 223 220 sub = mgr->esub_list.next; 221 while (sub != &mgr->esub_list) { 222 esub *next = sub->next; 223 pj_list_erase(sub); 224 sub = next; 225 } 224 if (mgr->pool) 225 pj_pool_release(mgr->pool); 226 226 227 227 if (event_manager_instance == mgr) … … 242 242 243 243 PJ_DEF(pj_status_t) pjmedia_event_subscribe( pjmedia_event_mgr *mgr, 244 pj_pool_t *pool,245 244 pjmedia_event_cb *cb, 246 245 void *user_data, … … 249 248 esub *sub; 250 249 251 PJ_ASSERT_RETURN( pool &&cb, PJ_EINVAL);250 PJ_ASSERT_RETURN(cb, PJ_EINVAL); 252 251 253 252 if (!mgr) mgr = pjmedia_event_mgr_instance(); … … 271 270 } 272 271 273 sub = PJ_POOL_ZALLOC_T(pool, esub); 272 if (mgr->free_esub_list.next != &mgr->free_esub_list) { 273 sub = mgr->free_esub_list.next; 274 pj_list_erase(sub); 275 } else 276 sub = PJ_POOL_ZALLOC_T(mgr->pool, esub); 274 277 sub->cb = cb; 275 278 sub->user_data = user_data; … … 310 313 mgr->pub_next_sub = sub->next; 311 314 pj_list_erase(sub); 315 pj_list_push_back(&mgr->free_esub_list, sub); 312 316 if (user_data && epub) 313 317 break; -
pjproject/trunk/pjmedia/src/pjmedia/vid_port.c
r3893 r3905 268 268 269 269 /* Subscribe to device's events */ 270 pjmedia_event_subscribe(NULL, vp->pool,&vidstream_event_cb,270 pjmedia_event_subscribe(NULL, &vidstream_event_cb, 271 271 vp, vp->strm); 272 272 … … 411 411 412 412 /* Subscribe to client port's events */ 413 pjmedia_event_subscribe(NULL, vp->pool,&client_port_event_cb, vp,413 pjmedia_event_subscribe(NULL, &client_port_event_cb, vp, 414 414 vp->client_port); 415 415 -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
r3901 r3905 1362 1362 1363 1363 /* Subscribe to codec events */ 1364 pjmedia_event_subscribe(NULL, pool,&stream_event_cb, stream,1364 pjmedia_event_subscribe(NULL, &stream_event_cb, stream, 1365 1365 stream->codec); 1366 1366 -
pjproject/trunk/pjmedia/src/test/vid_codec_test.c
r3901 r3905 321 321 322 322 /* Subscribe to codec events */ 323 pjmedia_event_subscribe(NULL, pool,&codec_on_event, &codec_port_data,323 pjmedia_event_subscribe(NULL, &codec_on_event, &codec_port_data, 324 324 codec); 325 325 } -
pjproject/trunk/pjmedia/src/test/vid_dev_test.c
r3893 r3905 161 161 162 162 /* Set event handler */ 163 pjmedia_event_subscribe(NULL, pool,&vid_event_cb, NULL, renderer);163 pjmedia_event_subscribe(NULL, &vid_event_cb, NULL, renderer); 164 164 165 165 /* Connect capture to renderer */ -
pjproject/trunk/pjmedia/src/test/vid_port_test.c
r3893 r3905 118 118 119 119 /* Set event handler */ 120 pjmedia_event_subscribe(NULL, pool,&vid_event_cb, NULL, renderer);120 pjmedia_event_subscribe(NULL, &vid_event_cb, NULL, renderer); 121 121 122 122 /* Connect capture to renderer */ -
pjproject/trunk/pjsip-apps/src/samples/aviplay.c
r3893 r3905 402 402 403 403 /* subscribe events */ 404 pjmedia_event_subscribe(NULL, pool,&avi_event_cb, &avi_port,404 pjmedia_event_subscribe(NULL, &avi_event_cb, &avi_port, 405 405 renderer); 406 406 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
r3901 r3905 830 830 #if ENABLE_EVENT 831 831 /* Register to video events */ 832 pjmedia_event_subscribe(NULL, w->pool,&call_media_on_event,832 pjmedia_event_subscribe(NULL, &call_media_on_event, 833 833 call_med, w->vp_rend); 834 834 #endif … … 900 900 w = &pjsua_var.win[wid]; 901 901 #if ENABLE_EVENT 902 pjmedia_event_subscribe(NULL, w->pool,&call_media_on_event,902 pjmedia_event_subscribe(NULL, &call_media_on_event, 903 903 call_med, w->vp_cap); 904 904 #endif … … 1909 1909 1910 1910 #if ENABLE_EVENT 1911 pjmedia_event_subscribe(NULL, new_w->pool,&call_media_on_event,1911 pjmedia_event_subscribe(NULL, &call_media_on_event, 1912 1912 call_med, new_w->vp_cap); 1913 1913 #endif … … 1951 1951 #if ENABLE_EVENT 1952 1952 /* Resubscribe */ 1953 pjmedia_event_subscribe(NULL, w->pool,&call_media_on_event,1953 pjmedia_event_subscribe(NULL, &call_media_on_event, 1954 1954 call_med, w->vp_cap); 1955 1955 #endif
Note: See TracChangeset
for help on using the changeset viewer.