summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2009-06-12 11:15:08 +0000
committerNanang Izzuddin <nanang@teluu.com>2009-06-12 11:15:08 +0000
commit68caf8c9c8cba8263e1ac0001e361c2fd5f21edf (patch)
treea0ae6bcbd4371434824c868b70bcdd711108aa44 /pjsip
parent54de99b9126223856df223ac0b27df66a5a5960a (diff)
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
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c28
1 files changed, 27 insertions, 1 deletions
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;