summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-05-06 19:08:43 +0000
committerBenny Prijono <bennylp@teluu.com>2009-05-06 19:08:43 +0000
commit48a361b0be23b7520be87434bc73225c367de9d3 (patch)
tree90b476273cc9f31ece7c4d05578aa527b401b5f7
parenteb2a9500da9ff360d64eb05a91c7bfb749de7662 (diff)
Ticket #824: Race condition in sound auto-close feature may cause sound device to not be opened
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2679 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 5d81fb0b..8d9643b3 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -522,12 +522,16 @@ static void close_snd_timer_cb( pj_timer_heap_t *th,
{
PJ_UNUSED_ARG(th);
- PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds",
- pjsua_var.media_cfg.snd_auto_close_time));
+ PJSUA_LOCK();
+ if (entry->id) {
+ PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds",
+ pjsua_var.media_cfg.snd_auto_close_time));
- entry->id = PJ_FALSE;
+ entry->id = PJ_FALSE;
- close_snd_dev();
+ close_snd_dev();
+ }
+ PJSUA_UNLOCK();
}
@@ -1666,10 +1670,12 @@ PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id source,
pjsua_conf_port_id sink)
{
/* If sound device idle timer is active, cancel it first. */
+ PJSUA_LOCK();
if (pjsua_var.snd_idle_timer.id) {
pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.snd_idle_timer);
pjsua_var.snd_idle_timer.id = PJ_FALSE;
}
+ PJSUA_UNLOCK();
/* For audio switchboard (i.e. APS-Direct):