Changeset 1855


Ignore:
Timestamp:
Mar 11, 2008 1:15:43 PM (16 years ago)
Author:
bennylp
Message:

More ticket #495: bug in snd_clock_rate causing unability to open sound device on WinCE

Location:
pjproject/trunk/pjsip/src/pjsua-lib
Files:
2 edited

Legend:

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

    r1823 r1855  
    163163 
    164164    cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE; 
    165     cfg->snd_clock_rate = PJSUA_DEFAULT_CLOCK_RATE; 
     165    cfg->snd_clock_rate = 0; 
    166166    cfg->audio_frame_ptime = PJSUA_DEFAULT_AUDIO_FRAME_PTIME; 
    167167    cfg->max_media_ports = PJSUA_MAX_CONF_PORTS; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r1823 r1855  
    5353 
    5454    /* Normalize configuration */ 
     55    if (pjsua_var.media_cfg.snd_clock_rate == 0) { 
     56        pjsua_var.media_cfg.snd_clock_rate = pjsua_var.media_cfg.clock_rate; 
     57    } 
    5558 
    5659    if (pjsua_var.media_cfg.has_ioqueue && 
     
    185188                                 opt, &pjsua_var.mconf); 
    186189    if (status != PJ_SUCCESS) { 
    187         pjsua_perror(THIS_FILE,  
    188                      "Media stack initialization has returned error",  
     190        pjsua_perror(THIS_FILE, "Error creating conference bridge",  
    189191                     status); 
    190192        return status; 
     
    17901792        clock_rates[0] = pjsua_var.media_cfg.clock_rate; 
    17911793 
     1794    /* Get the port0 of the conference bridge. */ 
     1795    conf_port = pjmedia_conf_get_master_port(pjsua_var.mconf); 
     1796    pj_assert(conf_port != NULL); 
     1797 
    17921798    /* Attempts to open the sound device with different clock rates */ 
    17931799    for (i=0; i<PJ_ARRAY_SIZE(clock_rates); ++i) { 
     
    18091815        if (status == PJ_SUCCESS) { 
    18101816            selected_clock_rate = clock_rates[i]; 
    1811             break; 
     1817 
     1818            /* If there's mismatch between sound port and conference's port, 
     1819             * create a resample port to bridge them. 
     1820             */ 
     1821            if (selected_clock_rate != pjsua_var.media_cfg.clock_rate) { 
     1822                pjmedia_port *resample_port; 
     1823                unsigned resample_opt = 0; 
     1824 
     1825                if (pjsua_var.media_cfg.quality >= 3 && 
     1826                    pjsua_var.media_cfg.quality <= 4) 
     1827                { 
     1828                    resample_opt |= PJMEDIA_CONF_SMALL_FILTER; 
     1829                } 
     1830                else if (pjsua_var.media_cfg.quality < 3) { 
     1831                    resample_opt |= PJMEDIA_CONF_USE_LINEAR; 
     1832                } 
     1833                 
     1834                status = pjmedia_resample_port_create(pjsua_var.pool,  
     1835                                                      conf_port, 
     1836                                                      selected_clock_rate, 
     1837                                                      resample_opt,  
     1838                                                      &resample_port); 
     1839                if (status != PJ_SUCCESS) { 
     1840                    pj_strerror(status, errmsg, sizeof(errmsg)); 
     1841                    PJ_LOG(4, (THIS_FILE,  
     1842                               "Error creating resample port, trying next " 
     1843                               "clock rate",  
     1844                               errmsg)); 
     1845                    pjmedia_snd_port_destroy(pjsua_var.snd_port); 
     1846                    pjsua_var.snd_port = NULL; 
     1847                    continue; 
     1848                } else { 
     1849                    conf_port = resample_port; 
     1850                    break; 
     1851                } 
     1852 
     1853            } else { 
     1854                break; 
     1855            } 
    18121856        } 
    18131857 
     
    18201864        return status; 
    18211865    } 
    1822  
    1823     /* Get the port0 of the conference bridge. */ 
    1824     conf_port = pjmedia_conf_get_master_port(pjsua_var.mconf); 
    1825     pj_assert(conf_port != NULL); 
    18261866 
    18271867    /* Set AEC */ 
     
    18291869                             pjsua_var.media_cfg.ec_tail_len,  
    18301870                             pjsua_var.media_cfg.ec_options); 
    1831  
    1832     /* If there's mismatch between sound port and conference's port, 
    1833      * create a resample port to bridge them. 
    1834      */ 
    1835     if (selected_clock_rate != pjsua_var.media_cfg.clock_rate) { 
    1836         pjmedia_port *resample_port; 
    1837         unsigned resample_opt = 0; 
    1838  
    1839         if (pjsua_var.media_cfg.quality >= 3 && 
    1840             pjsua_var.media_cfg.quality <= 4) 
    1841         { 
    1842             resample_opt |= PJMEDIA_CONF_SMALL_FILTER; 
    1843         } 
    1844         else if (pjsua_var.media_cfg.quality < 3) { 
    1845             resample_opt |= PJMEDIA_CONF_USE_LINEAR; 
    1846         } 
    1847          
    1848         status = pjmedia_resample_port_create(pjsua_var.pool, conf_port,  
    1849                                               selected_clock_rate,  
    1850                                               resample_opt, &resample_port); 
    1851         if (status != PJ_SUCCESS) { 
    1852             pjsua_perror("Error creating resample port", THIS_FILE, status); 
    1853             return status; 
    1854         } 
    1855  
    1856         conf_port = resample_port; 
    1857     } 
    18581871 
    18591872    /* Connect sound port to the bridge */        
Note: See TracChangeset for help on using the changeset viewer.