Changeset 3986 for pjproject/branches/1.x/pjmedia/src/pjmedia/endpoint.c
- Timestamp:
- Mar 22, 2012 11:29:20 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjmedia/src/pjmedia/endpoint.c
r3957 r3986 24 24 #include <pj/assert.h> 25 25 #include <pj/ioqueue.h> 26 #include <pj/lock.h> 26 27 #include <pj/log.h> 27 28 #include <pj/os.h> … … 57 58 58 59 60 /* List of media endpoint exit callback. */ 61 typedef struct exit_cb 62 { 63 PJ_DECL_LIST_MEMBER (struct exit_cb); 64 pjmedia_endpt_exit_callback func; 65 } exit_cb; 66 67 59 68 /** Concrete declaration of media endpoint. */ 60 69 struct pjmedia_endpt … … 86 95 /** Is telephone-event enable */ 87 96 pj_bool_t has_telephone_event; 97 98 /** List of exit callback. */ 99 exit_cb exit_cb_list; 88 100 }; 89 101 … … 129 141 goto on_error; 130 142 143 /* Initialize exit callback list. */ 144 pj_list_init(&endpt->exit_cb_list); 145 131 146 /* Create ioqueue if none is specified. */ 132 147 if (endpt->ioqueue == NULL) { … … 189 204 PJ_DEF(pj_status_t) pjmedia_endpt_destroy (pjmedia_endpt *endpt) 190 205 { 206 exit_cb *ecb; 191 207 unsigned i; 192 208 … … 202 218 endpt->thread[i] = NULL; 203 219 } 220 } 221 222 /* Call all registered exit callbacks */ 223 ecb = endpt->exit_cb_list.next; 224 while (ecb != &endpt->exit_cb_list) { 225 (*ecb->func)(endpt); 226 ecb = ecb->next; 204 227 } 205 228 … … 629 652 return PJ_SUCCESS; 630 653 } 654 655 PJ_DEF(pj_status_t) pjmedia_endpt_atexit( pjmedia_endpt *endpt, 656 pjmedia_endpt_exit_callback func) 657 { 658 exit_cb *new_cb; 659 660 PJ_ASSERT_RETURN(endpt && func, PJ_EINVAL); 661 662 if (endpt->quit_flag) 663 return PJ_EINVALIDOP; 664 665 new_cb = PJ_POOL_ZALLOC_T(endpt->pool, exit_cb); 666 new_cb->func = func; 667 668 pj_enter_critical_section(); 669 pj_list_push_back(&endpt->exit_cb_list, new_cb); 670 pj_leave_critical_section(); 671 672 return PJ_SUCCESS; 673 }
Note: See TracChangeset
for help on using the changeset viewer.