Changeset 3380


Ignore:
Timestamp:
Dec 2, 2010 6:12:19 AM (13 years ago)
Author:
nanang
Message:

Fix #1171, fixed issues in pjmedia_codec_mgr_set_default_param():

  • updated the releasing of the old pool to be done after the new codec param is copied
  • fixed the double dec_fmtp copy loop, one of them should be enc_fmtp copy loop instead
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/codec.c

    r3116 r3380  
    536536    unsigned i; 
    537537    pjmedia_codec_id codec_id; 
    538     pj_pool_t *pool; 
     538    pj_pool_t *pool, *old_pool = NULL; 
    539539    struct pjmedia_codec_desc *codec_desc = NULL; 
    540540    pjmedia_codec_default_param *p; 
     
    561561    } 
    562562 
    563     /* If codec param is previously set, release codec param pool */ 
     563    /* If codec param is previously set, reset the codec param but release 
     564     * the codec param pool later after the new param is set (ticket #1171). 
     565     */ 
    564566    if (codec_desc->param) { 
    565567        pj_assert(codec_desc->param->pool); 
    566         pj_pool_release(codec_desc->param->pool); 
     568        old_pool = codec_desc->param->pool; 
    567569        codec_desc->param = NULL; 
    568570    } 
     
    573575    if (NULL == param) { 
    574576        pj_mutex_unlock(mgr->mutex); 
     577        if (old_pool) 
     578            pj_pool_release(old_pool); 
    575579        return PJ_SUCCESS; 
    576580    } 
     
    591595                  &param->setting.dec_fmtp.param[i].val); 
    592596    } 
    593     for (i = 0; i < param->setting.dec_fmtp.cnt; ++i) { 
    594         pj_strdup(pool, &p->param->setting.dec_fmtp.param[i].name,  
    595                   &param->setting.dec_fmtp.param[i].name); 
    596         pj_strdup(pool, &p->param->setting.dec_fmtp.param[i].val,  
    597                   &param->setting.dec_fmtp.param[i].val); 
    598     } 
    599  
    600     pj_mutex_unlock(mgr->mutex); 
     597    for (i = 0; i < param->setting.enc_fmtp.cnt; ++i) { 
     598        pj_strdup(pool, &p->param->setting.enc_fmtp.param[i].name,  
     599                  &param->setting.enc_fmtp.param[i].name); 
     600        pj_strdup(pool, &p->param->setting.enc_fmtp.param[i].val,  
     601                  &param->setting.enc_fmtp.param[i].val); 
     602    } 
     603 
     604    pj_mutex_unlock(mgr->mutex); 
     605 
     606    if (old_pool) 
     607        pj_pool_release(old_pool); 
    601608 
    602609    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.