Changeset 2813 for pjproject


Ignore:
Timestamp:
Jun 25, 2009 1:09:24 PM (15 years ago)
Author:
bennylp
Message:

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

  • backported changes from #824
File:
1 edited

Legend:

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

    r2541 r2813  
    469469    PJ_UNUSED_ARG(th); 
    470470 
    471     PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds",  
    472               pjsua_var.media_cfg.snd_auto_close_time)); 
    473  
    474     entry->id = PJ_FALSE; 
    475  
    476     close_snd_dev(); 
     471    PJSUA_LOCK(); 
     472    if (entry->id) { 
     473        PJ_LOG(4,(THIS_FILE,"Closing sound device after idle for %d seconds",  
     474                  pjsua_var.media_cfg.snd_auto_close_time)); 
     475 
     476        entry->id = PJ_FALSE; 
     477 
     478        close_snd_dev(); 
     479    } 
     480    PJSUA_UNLOCK(); 
    477481} 
    478482 
     
    16061610{ 
    16071611    /* If sound device idle timer is active, cancel it first. */ 
     1612    PJSUA_LOCK(); 
    16081613    if (pjsua_var.snd_idle_timer.id) { 
    16091614        pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.snd_idle_timer); 
    16101615        pjsua_var.snd_idle_timer.id = PJ_FALSE; 
    16111616    } 
     1617    PJSUA_UNLOCK(); 
    16121618 
    16131619    /* Create sound port if none is instantiated */ 
Note: See TracChangeset for help on using the changeset viewer.