Changeset 763


Ignore:
Timestamp:
Oct 11, 2006 4:03:41 PM (18 years ago)
Author:
bennylp
Message:

Changed pjsua_media.c to try different clock rates when opening sound device

File:
1 edited

Legend:

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

    r742 r763  
    4545 
    4646    /* Normalize configuration */ 
    47 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 
    48     pjsua_var.media_cfg.clock_rate = 44100; 
    49 #endif 
    5047 
    5148    if (pjsua_var.media_cfg.has_ioqueue && 
     
    973970    pjmedia_port *conf_port; 
    974971    const pjmedia_snd_dev_info *cap_info, *play_info; 
    975     pj_status_t status; 
     972    unsigned clock_rates[] = { 0, 22050, 44100, 48000, 11025, 32000, 8000}; 
     973    unsigned i; 
     974    pj_status_t status = -1; 
    976975 
    977976    /* Close existing sound port */ 
     
    982981    play_info = pjmedia_snd_get_dev_info(playback_dev); 
    983982 
    984     PJ_LOG(4,(THIS_FILE, "Opening %s sound playback device and " 
    985                          "%s sound capture device..", 
    986                          play_info->name, cap_info->name)); 
    987  
    988     /* Create the sound device. Sound port will start immediately. */ 
    989     status = pjmedia_snd_port_create(pjsua_var.pool, capture_dev, 
    990                                      playback_dev,  
    991                                      pjsua_var.media_cfg.clock_rate, 1, 
    992                                      pjsua_var.media_cfg.clock_rate/FPS, 
    993                                      16, 0, &pjsua_var.snd_port); 
     983    /* Set default clock rate */ 
     984    clock_rates[0] = pjsua_var.media_cfg.clock_rate; 
     985 
     986    /* Attempts to open the sound device with different clock rates */ 
     987    for (i=0; i<PJ_ARRAY_SIZE(clock_rates); ++i) { 
     988        char errmsg[PJ_ERR_MSG_SIZE]; 
     989 
     990        PJ_LOG(4,(THIS_FILE,  
     991                  "pjsua_set_snd_dev(): attempting to open devices " 
     992                  "@%d Hz", clock_rates[i])); 
     993 
     994        /* Create the sound device. Sound port will start immediately. */ 
     995        status = pjmedia_snd_port_create(pjsua_var.pool, capture_dev, 
     996                                         playback_dev,  
     997                                         clock_rates[i], 1, 
     998                                         clock_rates[i]/FPS, 
     999                                         16, 0, &pjsua_var.snd_port); 
     1000 
     1001        if (status == PJ_SUCCESS) 
     1002            break; 
     1003 
     1004        pj_strerror(status, errmsg, sizeof(errmsg)); 
     1005        PJ_LOG(4, ("..failed: %s", errmsg)); 
     1006    } 
     1007 
    9941008    if (status != PJ_SUCCESS) { 
    9951009        pjsua_perror(THIS_FILE, "Unable to open sound device", status); 
Note: See TracChangeset for help on using the changeset viewer.