Changeset 2679


Ignore:
Timestamp:
May 6, 2009 7:08:43 PM (11 years ago)
Author:
bennylp
Message:

Ticket #824: Race condition in sound auto-close feature may cause sound device to not be opened

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r2597 r2679  
    523523    PJ_UNUSED_ARG(th); 
    524524 
    525     PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds",  
    526               pjsua_var.media_cfg.snd_auto_close_time)); 
    527  
    528     entry->id = PJ_FALSE; 
    529  
    530     close_snd_dev(); 
     525    PJSUA_LOCK(); 
     526    if (entry->id) { 
     527        PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds",  
     528                  pjsua_var.media_cfg.snd_auto_close_time)); 
     529 
     530        entry->id = PJ_FALSE; 
     531 
     532        close_snd_dev(); 
     533    } 
     534    PJSUA_UNLOCK(); 
    531535} 
    532536 
     
    16671671{ 
    16681672    /* If sound device idle timer is active, cancel it first. */ 
     1673    PJSUA_LOCK(); 
    16691674    if (pjsua_var.snd_idle_timer.id) { 
    16701675        pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.snd_idle_timer); 
    16711676        pjsua_var.snd_idle_timer.id = PJ_FALSE; 
    16721677    } 
     1678    PJSUA_UNLOCK(); 
    16731679 
    16741680 
Note: See TracChangeset for help on using the changeset viewer.