From 5bef8e17b3b0ffcfa59ad195787c956903b81978 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Thu, 22 Mar 2012 03:29:56 +0000 Subject: Re #1467: fix sound device (opened/closed) status check in check_snd_dev_idle(), especially when sound device is managed by app (no_snd = PJ_TRUE). Note that pjsua_media_subsys_destroy() always close the sound device first, so check_snd_dev_idle() in pjsua_destroy() sequence should have been just a no-operation. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3981 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_media.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 917dadcb..fb3936b6 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -278,6 +278,14 @@ static void check_snd_dev_idle() { unsigned call_cnt; + /* Check if the sound device auto-close feature is disabled. */ + if (pjsua_var.media_cfg.snd_auto_close_time < 0) + return; + + /* Check if the sound device is currently closed. */ + if (!pjsua_var.snd_is_on) + return; + /* Get the call count, we shouldn't close the sound device when there is * any calls active. */ @@ -304,15 +312,10 @@ static void check_snd_dev_idle() /* Activate sound device auto-close timer if sound device is idle. * It is idle when there is no port connection in the bridge and * there is no active call. - * - * Note: this block is now valid if no snd dev is used because of #1299 */ - if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL || - pjsua_var.no_snd) && - pjsua_var.snd_idle_timer.id == PJ_FALSE && - pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0 && + if (pjsua_var.snd_idle_timer.id == PJ_FALSE && call_cnt == 0 && - pjsua_var.media_cfg.snd_auto_close_time >= 0) + pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0) { pj_time_val delay; @@ -3837,6 +3840,8 @@ static pj_status_t open_snd_dev(pjmedia_snd_port_param *param) ++pjsua_var.aud_open_cnt; } + pjsua_var.snd_is_on = PJ_TRUE; + pj_log_pop_indent(); return PJ_SUCCESS; -- cgit v1.2.3