summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-06-25 13:09:24 +0000
committerBenny Prijono <bennylp@teluu.com>2009-06-25 13:09:24 +0000
commit1f0b3e9af6e86015483a048867539d34fee98030 (patch)
tree540f83f8fd1e0cd334ea5f9e1a0995fdcf08a7b3
parent6f42f3125f06806f23ed87a0bb8ba91cfdcf6854 (diff)
Ticket #898: Race condition in sound auto-close feature may cause sound device to not be opened
- backported changes from #824 git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.0@2813 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 8d2d8a8a..60174ac4 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -468,12 +468,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();
}
@@ -1605,10 +1609,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();
/* Create sound port if none is instantiated */
if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&