From 105a9eab72acf4d61613f5e7fb0c064dd54c4a25 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 17 Dec 2013 09:01:21 +0000 Subject: Fixed #1717: Destroy media subsystem after all pollings/busy_sleep() are done, but leave deallocating media transport (via pjsua_media_channel_deinit()) before the pollings to allow clean TURN destroy. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4694 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_core.c | 14 +++++++++++--- pjsip/src/pjsua-lib/pjsua_media.c | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index bc0cc406..8b0f0e62 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -1504,6 +1504,14 @@ PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags) pjsua_call_hangup_all(); } + /* Deinit media channel of all calls (see #1717) */ + for (i=0; i<(int)pjsua_var.ua_cfg.max_calls; ++i) { + /* TODO: check if we're not allowed to send to network in the + * "flags", and if so do not do TURN allocation... + */ + pjsua_media_channel_deinit(i); + } + /* Set all accounts to offline */ for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { if (!pjsua_var.acc[i].valid) @@ -1515,9 +1523,6 @@ PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags) /* Terminate all presence subscriptions. */ pjsua_pres_shutdown(flags); - /* Destroy media (to shutdown media transports etc) */ - pjsua_media_subsys_destroy(flags); - /* Wait for sometime until all publish client sessions are done * (ticket #364) */ @@ -1621,6 +1626,9 @@ PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags) PJ_LOG(4,(THIS_FILE, "Destroying...")); + /* Destroy media (to shutdown media endpoint, etc) */ + pjsua_media_subsys_destroy(flags); + /* Must destroy endpoint first before destroying pools in * buddies or accounts, since shutting down transaction layer * may emit events which trigger some buddy or account callbacks diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index acaa0e1f..ce7722c9 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -179,7 +179,7 @@ pj_status_t pjsua_media_subsys_start(void) */ pj_status_t pjsua_media_subsys_destroy(unsigned flags) { - unsigned i; + PJ_UNUSED_ARG(flags); PJ_LOG(4,(THIS_FILE, "Shutting down media..")); pj_log_push_indent(); @@ -191,6 +191,8 @@ pj_status_t pjsua_media_subsys_destroy(unsigned flags) pjsua_aud_subsys_destroy(); } +#if 0 + // This part has been moved out to pjsua_destroy() (see also #1717). /* Close media transports */ for (i=0; i