Changeset 2789


Ignore:
Timestamp:
Jun 24, 2009 3:20:39 PM (15 years ago)
Author:
nanang
Message:

Ticket #782: backported changes from ticket #781

Location:
pjproject/branches/1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.0

  • pjproject/branches/1.0/pjmedia/src/pjmedia/conference.c

    r2394 r2789  
    887887    PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 
    888888 
     889    pj_mutex_lock(conf->mutex); 
     890 
    889891    /* Port must be valid. */ 
    890     PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL); 
     892    conf_port = conf->ports[slot]; 
     893    if (conf_port == NULL) { 
     894        pj_mutex_unlock(conf->mutex); 
     895        return PJ_EINVAL; 
     896    } 
    891897 
    892898    conf_port = conf->ports[slot]; 
     
    897903    if (rx != PJMEDIA_PORT_NO_CHANGE) 
    898904        conf_port->rx_setting = rx; 
     905 
     906    pj_mutex_unlock(conf->mutex); 
    899907 
    900908    return PJ_SUCCESS; 
     
    918926                     sink_slot<conf->max_ports, PJ_EINVAL); 
    919927 
    920     /* Ports must be valid. */ 
    921     PJ_ASSERT_RETURN(conf->ports[src_slot] != NULL, PJ_EINVAL); 
    922     PJ_ASSERT_RETURN(conf->ports[sink_slot] != NULL, PJ_EINVAL); 
    923  
    924928    /* For now, level MUST be zero. */ 
    925929    PJ_ASSERT_RETURN(level == 0, PJ_EINVAL); 
     
    927931    pj_mutex_lock(conf->mutex); 
    928932 
     933    /* Ports must be valid. */ 
    929934    src_port = conf->ports[src_slot]; 
    930935    dst_port = conf->ports[sink_slot]; 
     936    if (!src_port || !dst_port) { 
     937        pj_mutex_unlock(conf->mutex); 
     938        return PJ_EINVAL; 
     939    } 
    931940 
    932941    /* Check if connection has been made */ 
     
    980989                     sink_slot<conf->max_ports, PJ_EINVAL); 
    981990 
     991    pj_mutex_lock(conf->mutex); 
     992 
    982993    /* Ports must be valid. */ 
    983     PJ_ASSERT_RETURN(conf->ports[src_slot] != NULL, PJ_EINVAL); 
    984     PJ_ASSERT_RETURN(conf->ports[sink_slot] != NULL, PJ_EINVAL); 
    985  
    986     pj_mutex_lock(conf->mutex); 
    987  
    988994    src_port = conf->ports[src_slot]; 
    989995    dst_port = conf->ports[sink_slot]; 
     996    if (!src_port || !dst_port) { 
     997        pj_mutex_unlock(conf->mutex); 
     998        return PJ_EINVAL; 
     999    } 
    9901000 
    9911001    /* Check if connection has been made */ 
     
    10581068    PJ_ASSERT_RETURN(conf && port < conf->max_ports, PJ_EINVAL); 
    10591069 
    1060     /* Port must be valid. */ 
    1061     PJ_ASSERT_RETURN(conf->ports[port] != NULL, PJ_EINVAL); 
    1062  
    10631070    /* Suspend the sound devices. 
    10641071     * Don't want to remove port while port is being accessed by sound 
     
    10681075    pj_mutex_lock(conf->mutex); 
    10691076 
     1077    /* Port must be valid. */ 
    10701078    conf_port = conf->ports[port]; 
     1079    if (conf_port == NULL) { 
     1080        pj_mutex_unlock(conf->mutex); 
     1081        return PJ_EINVAL; 
     1082    } 
     1083 
    10711084    conf_port->tx_setting = PJMEDIA_PORT_DISABLE; 
    10721085    conf_port->rx_setting = PJMEDIA_PORT_DISABLE; 
     
    11371150    PJ_ASSERT_RETURN(conf && p_count && ports, PJ_EINVAL); 
    11381151 
     1152    /* Lock mutex */ 
     1153    pj_mutex_lock(conf->mutex); 
     1154 
    11391155    for (i=0; i<conf->max_ports && count<*p_count; ++i) { 
    11401156        if (!conf->ports[i]) 
     
    11441160    } 
    11451161 
     1162    /* Unlock mutex */ 
     1163    pj_mutex_unlock(conf->mutex); 
     1164 
    11461165    *p_count = count; 
    11471166    return PJ_SUCCESS; 
     
    11601179    PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 
    11611180 
     1181    /* Lock mutex */ 
     1182    pj_mutex_lock(conf->mutex); 
     1183 
    11621184    /* Port must be valid. */ 
    1163     PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL); 
    1164  
    11651185    conf_port = conf->ports[slot]; 
     1186    if (conf_port == NULL) { 
     1187        pj_mutex_unlock(conf->mutex); 
     1188        return PJ_EINVAL; 
     1189    } 
    11661190 
    11671191    info->slot = slot; 
     
    11781202    info->rx_adj_level = conf_port->rx_adj_level - NORMAL_LEVEL; 
    11791203 
     1204    /* Unlock mutex */ 
     1205    pj_mutex_unlock(conf->mutex); 
     1206 
    11801207    return PJ_SUCCESS; 
    11811208} 
     
    11901217    PJ_ASSERT_RETURN(conf && size && info, PJ_EINVAL); 
    11911218 
     1219    /* Lock mutex */ 
     1220    pj_mutex_lock(conf->mutex); 
     1221 
    11921222    for (i=0; i<conf->max_ports && count<*size; ++i) { 
    11931223        if (!conf->ports[i]) 
     
    11971227        ++count; 
    11981228    } 
     1229 
     1230    /* Unlock mutex */ 
     1231    pj_mutex_unlock(conf->mutex); 
    11991232 
    12001233    *size = count; 
     
    12161249    PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 
    12171250 
     1251    /* Lock mutex */ 
     1252    pj_mutex_lock(conf->mutex); 
     1253 
    12181254    /* Port must be valid. */ 
    1219     PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL); 
    1220  
    12211255    conf_port = conf->ports[slot]; 
     1256    if (conf_port == NULL) { 
     1257        pj_mutex_unlock(conf->mutex); 
     1258        return PJ_EINVAL; 
     1259    } 
    12221260 
    12231261    if (tx_level != NULL) { 
     
    12271265    if (rx_level != NULL)  
    12281266        *rx_level = conf_port->rx_level; 
     1267 
     1268    /* Unlock mutex */ 
     1269    pj_mutex_unlock(conf->mutex); 
    12291270 
    12301271    return PJ_SUCCESS; 
     
    12441285    PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 
    12451286 
    1246     /* Port must be valid. */ 
    1247     PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL); 
    1248  
    12491287    /* Value must be from -128 to +127 */ 
    12501288    /* Disabled, you can put more than +127, at your own risk:  
     
    12531291    PJ_ASSERT_RETURN(adj_level >= -128, PJ_EINVAL); 
    12541292 
     1293    /* Lock mutex */ 
     1294    pj_mutex_lock(conf->mutex); 
     1295 
     1296    /* Port must be valid. */ 
    12551297    conf_port = conf->ports[slot]; 
     1298    if (conf_port == NULL) { 
     1299        pj_mutex_unlock(conf->mutex); 
     1300        return PJ_EINVAL; 
     1301    } 
    12561302 
    12571303    /* Set normalized adjustment level. */ 
    12581304    conf_port->rx_adj_level = adj_level + NORMAL_LEVEL; 
     1305 
     1306    /* Unlock mutex */ 
     1307    pj_mutex_unlock(conf->mutex); 
    12591308 
    12601309    return PJ_SUCCESS; 
     
    12741323    PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 
    12751324 
    1276     /* Port must be valid. */ 
    1277     PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL); 
    1278  
    12791325    /* Value must be from -128 to +127 */ 
    12801326    /* Disabled, you can put more than +127,, at your own risk: 
     
    12831329    PJ_ASSERT_RETURN(adj_level >= -128, PJ_EINVAL); 
    12841330 
     1331    /* Lock mutex */ 
     1332    pj_mutex_lock(conf->mutex); 
     1333 
     1334    /* Port must be valid. */ 
    12851335    conf_port = conf->ports[slot]; 
     1336    if (conf_port == NULL) { 
     1337        pj_mutex_unlock(conf->mutex); 
     1338        return PJ_EINVAL; 
     1339    } 
    12861340 
    12871341    /* Set normalized adjustment level. */ 
    12881342    conf_port->tx_adj_level = adj_level + NORMAL_LEVEL; 
     1343 
     1344    /* Unlock mutex */ 
     1345    pj_mutex_unlock(conf->mutex); 
    12891346 
    12901347    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.