From 68caf8c9c8cba8263e1ac0001e361c2fd5f21edf Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 12 Jun 2009 11:15:08 +0000 Subject: Ticket #882: Added check of active call count before auto-close sound device. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2758 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_media.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'pjsip/src') diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 958756f9..5496df9f 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -495,13 +495,39 @@ on_error: /* Check if sound device is idle. */ static void check_snd_dev_idle() { + unsigned call_cnt; + + /* Get the call count, we shouldn't close the sound device when there is + * any calls active. + */ + call_cnt = pjsua_call_get_count(); + + /* When this function is called from pjsua_media_channel_deinit() upon + * disconnecting call, actually the call count hasn't been updated/ + * decreased. So we put additional check here, if there is only one + * call and it's in DISCONNECTED state, there is actually no active + * call. + */ + if (call_cnt == 1) { + pjsua_call_id call_id; + pj_status_t status; + + status = pjsua_enum_calls(&call_id, &call_cnt); + if (status == PJ_SUCCESS && call_cnt > 0 && + !pjsua_call_is_active(call_id)) + { + call_cnt = 0; + } + } /* Activate sound device auto-close timer if sound device is idle. - * It is idle when there is no port connection in the bridge. + * It is idle when there is no port connection in the bridge and + * there is no active call. */ if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL) && pjsua_var.snd_idle_timer.id == PJ_FALSE && pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0 && + call_cnt == 0 && pjsua_var.media_cfg.snd_auto_close_time >= 0) { pj_time_val delay; -- cgit v1.2.3