Ticket #1059: 1059.diff

File 1059.diff, 2.8 KB (added by nanang, 12 years ago)

Added polling for master port (of null audio device) into pjsua_handle_events().

  • pjsip/include/pjsua-lib/pjsua_internal.h

     
    323323    pjmedia_snd_port    *snd_port;  /**< Sound port.                    */ 
    324324    pj_timer_entry       snd_idle_timer;/**< Sound device idle timer.   */ 
    325325    pjmedia_master_port *null_snd;  /**< Master port for null sound.    */ 
     326    pj_bool_t            poll_null_snd; /**< Should poll master port?   */ 
    326327    pjmedia_port        *null_port; /**< Null port.                     */ 
    327328 
    328329 
  • pjsip/src/pjsua-lib/pjsua_media.c

     
    27212721/* Close existing sound device */ 
    27222722static void close_snd_dev(void) 
    27232723{ 
     2724    /* Stop polling master port (for null audio device) */ 
     2725    pjsua_var.poll_null_snd = PJ_FALSE; 
     2726 
    27242727    /* Close sound device */ 
    27252728    if (pjsua_var.snd_port) { 
    27262729        pjmedia_aud_dev_info cap_info, play_info; 
     
    28462849PJ_DEF(pj_status_t) pjsua_set_null_snd_dev(void) 
    28472850{ 
    28482851    pjmedia_port *conf_port; 
     2852    unsigned master_port_opt = 0; 
    28492853    pj_status_t status; 
    28502854 
    28512855    /* Close existing sound device */ 
     
    28612865    conf_port = pjmedia_conf_get_master_port(pjsua_var.mconf); 
    28622866    pj_assert(conf_port != NULL); 
    28632867 
     2868    /* Ticket #1059: master port should avoid thread creation when media 
     2869     * subsystem is configured with zero thread. 
     2870     * 
     2871     * Exception applies for Symbian platforms, as it can still achieve 
     2872     * asynchronous timer using Active Object (instead of thread). 
     2873     */ 
     2874#if !defined(PJ_SYMBIAN) || PJ_SYMBIAN == 0 
     2875    if (pjsua_var.media_cfg.thread_cnt == 0) { 
     2876        master_port_opt |= PJMEDIA_CLOCK_NO_ASYNC; 
     2877        pjsua_var.poll_null_snd = PJ_TRUE; 
     2878    } 
     2879#endif 
     2880 
    28642881    /* Create master port, connecting port0 of the conference bridge to 
    28652882     * a null port. 
    28662883     */ 
    28672884    status = pjmedia_master_port_create(pjsua_var.snd_pool, pjsua_var.null_port, 
    2868                                         conf_port, 0, &pjsua_var.null_snd); 
     2885                                        conf_port, master_port_opt, 
     2886                                        &pjsua_var.null_snd); 
    28692887    if (status != PJ_SUCCESS) { 
    28702888        pjsua_perror(THIS_FILE, "Unable to create null sound device", 
    28712889                     status); 
  • pjsip/src/pjsua-lib/pjsua_core.c

     
    14571457    pj_time_val tv; 
    14581458    pj_status_t status; 
    14591459 
     1460    /* Poll master port (for null audio device) */ 
     1461    if (pjsua_var.poll_null_snd) { 
     1462        while (pjmedia_master_port_wait(pjsua_var.null_snd, PJ_FALSE, NULL)); 
     1463    } 
     1464 
    14601465    tv.sec = 0; 
    14611466    tv.msec = msec_timeout; 
    14621467    pj_time_val_normalize(&tv);