Changeset 5673 for pjproject


Ignore:
Timestamp:
Oct 16, 2017 3:49:22 AM (7 years ago)
Author:
ming
Message:

Re #2045 (misc): Prevent iLBC codec to be initialized more than once

Thanks to Kal Conley for the patch.

File:
1 edited

Legend:

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

    r5187 r5673  
    178178    PJ_ASSERT_RETURN(mode==0 || mode==20 || mode==30, PJ_EINVAL); 
    179179 
     180    if (ilbc_factory.endpt != NULL) { 
     181        /* Already initialized. */ 
     182        return PJ_SUCCESS; 
     183    } 
     184 
    180185    /* Create iLBC codec factory. */ 
    181186    ilbc_factory.base.op = &ilbc_factory_op; 
     
    189194 
    190195    if (mode == 20) { 
    191         ilbc_factory.bps = 15200;        
     196        ilbc_factory.bps = 15200; 
    192197    } else { 
    193198        ilbc_factory.bps = 13333; 
     
    196201    /* Get the codec manager. */ 
    197202    codec_mgr = pjmedia_endpt_get_codec_mgr(endpt); 
    198     if (!codec_mgr) 
     203    if (!codec_mgr) { 
     204        ilbc_factory.endpt = NULL; 
    199205        return PJ_EINVALIDOP; 
     206    } 
    200207 
    201208    /* Register codec factory to endpoint. */ 
    202209    status = pjmedia_codec_mgr_register_factory(codec_mgr,  
    203210                                                &ilbc_factory.base); 
    204     if (status != PJ_SUCCESS) 
     211    if (status != PJ_SUCCESS) { 
     212        ilbc_factory.endpt = NULL; 
    205213        return status; 
    206  
     214    } 
    207215 
    208216    /* Done. */ 
     
    221229    pj_status_t status; 
    222230 
     231    if (ilbc_factory.endpt == NULL) { 
     232        /* Not registered. */ 
     233        return PJ_SUCCESS; 
     234    } 
    223235 
    224236    /* Get the codec manager. */ 
Note: See TracChangeset for help on using the changeset viewer.