Changeset 2581
- Timestamp:
- Apr 7, 2009 11:08:21 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/conf_switch.c
r2506 r2581 474 474 PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 475 475 476 pj_mutex_lock(conf->mutex); 477 476 478 /* Port must be valid. */ 477 PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL);478 479 479 conf_port = conf->ports[slot]; 480 if (conf_port == NULL) { 481 pj_mutex_unlock(conf->mutex); 482 return PJ_EINVAL; 483 } 480 484 481 485 if (tx != PJMEDIA_PORT_NO_CHANGE) … … 484 488 if (rx != PJMEDIA_PORT_NO_CHANGE) 485 489 conf_port->rx_setting = rx; 490 491 pj_mutex_unlock(conf->mutex); 486 492 487 493 return PJ_SUCCESS; … … 505 511 sink_slot<conf->max_ports, PJ_EINVAL); 506 512 507 /* Ports must be valid. */508 PJ_ASSERT_RETURN(conf->ports[src_slot] != NULL, PJ_EINVAL);509 PJ_ASSERT_RETURN(conf->ports[sink_slot] != NULL, PJ_EINVAL);510 511 513 /* For now, level MUST be zero. */ 512 514 PJ_ASSERT_RETURN(level == 0, PJ_EINVAL); … … 514 516 pj_mutex_lock(conf->mutex); 515 517 518 /* Ports must be valid. */ 516 519 src_port = conf->ports[src_slot]; 517 520 dst_port = conf->ports[sink_slot]; 521 if (!src_port || !dst_port) { 522 pj_mutex_unlock(conf->mutex); 523 return PJ_EINVAL; 524 } 518 525 519 526 /* Format must match. */ … … 603 610 sink_slot<conf->max_ports, PJ_EINVAL); 604 611 612 pj_mutex_lock(conf->mutex); 613 605 614 /* Ports must be valid. */ 606 PJ_ASSERT_RETURN(conf->ports[src_slot] != NULL, PJ_EINVAL);607 PJ_ASSERT_RETURN(conf->ports[sink_slot] != NULL, PJ_EINVAL);608 609 pj_mutex_lock(conf->mutex);610 611 615 src_port = conf->ports[src_slot]; 612 616 dst_port = conf->ports[sink_slot]; 617 if (!src_port || !dst_port) { 618 pj_mutex_unlock(conf->mutex); 619 return PJ_EINVAL; 620 } 613 621 614 622 /* Check if connection has been made */ … … 686 694 PJ_ASSERT_RETURN(conf && port < conf->max_ports, PJ_EINVAL); 687 695 688 /* Port must be valid. */689 PJ_ASSERT_RETURN(conf->ports[port] != NULL, PJ_EINVAL);690 691 696 /* Suspend the sound devices. 692 697 * Don't want to remove port while port is being accessed by sound … … 696 701 pj_mutex_lock(conf->mutex); 697 702 703 /* Port must be valid. */ 698 704 conf_port = conf->ports[port]; 705 if (conf_port == NULL) { 706 pj_mutex_unlock(conf->mutex); 707 return PJ_EINVAL; 708 } 709 699 710 conf_port->tx_setting = PJMEDIA_PORT_DISABLE; 700 711 conf_port->rx_setting = PJMEDIA_PORT_DISABLE; … … 773 784 PJ_ASSERT_RETURN(conf && p_count && ports, PJ_EINVAL); 774 785 786 /* Lock mutex */ 787 pj_mutex_lock(conf->mutex); 788 775 789 for (i=0; i<conf->max_ports && count<*p_count; ++i) { 776 790 if (!conf->ports[i]) … … 780 794 } 781 795 796 /* Unlock mutex */ 797 pj_mutex_unlock(conf->mutex); 798 782 799 *p_count = count; 783 800 return PJ_SUCCESS; … … 796 813 PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 797 814 815 /* Lock mutex */ 816 pj_mutex_lock(conf->mutex); 817 798 818 /* Port must be valid. */ 799 PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL);800 801 819 conf_port = conf->ports[slot]; 820 if (conf_port == NULL) { 821 pj_mutex_unlock(conf->mutex); 822 return PJ_EINVAL; 823 } 802 824 803 825 pj_bzero(info, sizeof(pjmedia_conf_port_info)); … … 818 840 info->rx_adj_level = conf_port->rx_adj_level - NORMAL_LEVEL; 819 841 842 /* Unlock mutex */ 843 pj_mutex_unlock(conf->mutex); 844 820 845 return PJ_SUCCESS; 821 846 } … … 830 855 PJ_ASSERT_RETURN(conf && size && info, PJ_EINVAL); 831 856 857 /* Lock mutex */ 858 pj_mutex_lock(conf->mutex); 859 832 860 for (i=0; i<conf->max_ports && count<*size; ++i) { 833 861 if (!conf->ports[i]) … … 837 865 ++count; 838 866 } 867 868 /* Unlock mutex */ 869 pj_mutex_unlock(conf->mutex); 839 870 840 871 *size = count; … … 856 887 PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 857 888 889 /* Lock mutex */ 890 pj_mutex_lock(conf->mutex); 891 858 892 /* Port must be valid. */ 859 PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL);860 861 893 conf_port = conf->ports[slot]; 894 if (conf_port == NULL) { 895 pj_mutex_unlock(conf->mutex); 896 return PJ_EINVAL; 897 } 862 898 863 899 if (tx_level != NULL) { … … 867 903 if (rx_level != NULL) 868 904 *rx_level = conf_port->rx_level; 905 906 /* Unlock mutex */ 907 pj_mutex_unlock(conf->mutex); 869 908 870 909 return PJ_SUCCESS; … … 883 922 /* Check arguments */ 884 923 PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 885 886 /* Port must be valid. */887 PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL);888 924 889 925 /* Value must be from -128 to +127 */ … … 893 929 PJ_ASSERT_RETURN(adj_level >= -128, PJ_EINVAL); 894 930 931 /* Lock mutex */ 932 pj_mutex_lock(conf->mutex); 933 934 /* Port must be valid. */ 895 935 conf_port = conf->ports[slot]; 936 if (conf_port == NULL) { 937 pj_mutex_unlock(conf->mutex); 938 return PJ_EINVAL; 939 } 896 940 897 941 /* Level adjustment is applicable only for ports that work with raw PCM. */ … … 902 946 conf_port->rx_adj_level = adj_level + NORMAL_LEVEL; 903 947 948 /* Unlock mutex */ 949 pj_mutex_unlock(conf->mutex); 950 904 951 return PJ_SUCCESS; 905 952 } … … 917 964 /* Check arguments */ 918 965 PJ_ASSERT_RETURN(conf && slot<conf->max_ports, PJ_EINVAL); 919 920 /* Port must be valid. */921 PJ_ASSERT_RETURN(conf->ports[slot] != NULL, PJ_EINVAL);922 966 923 967 /* Value must be from -128 to +127 */ … … 927 971 PJ_ASSERT_RETURN(adj_level >= -128, PJ_EINVAL); 928 972 973 /* Lock mutex */ 974 pj_mutex_lock(conf->mutex); 975 976 /* Port must be valid. */ 929 977 conf_port = conf->ports[slot]; 978 if (conf_port == NULL) { 979 pj_mutex_unlock(conf->mutex); 980 return PJ_EINVAL; 981 } 930 982 931 983 /* Level adjustment is applicable only for ports that work with raw PCM. */ … … 935 987 /* Set normalized adjustment level. */ 936 988 conf_port->tx_adj_level = adj_level + NORMAL_LEVEL; 989 990 /* Unlock mutex */ 991 pj_mutex_unlock(conf->mutex); 937 992 938 993 return PJ_SUCCESS; … … 1126 1181 unsigned ci, i; 1127 1182 1128 /* Must lock mutex */1183 /* Lock mutex */ 1129 1184 pj_mutex_lock(conf->mutex); 1130 1185 … … 1370 1425 { 1371 1426 pjmedia_conf *conf = (pjmedia_conf*) this_port->port_data.pdata; 1372 struct conf_port *cport = conf->ports[this_port->port_data.ldata];1427 struct conf_port *cport; 1373 1428 unsigned j; 1374 1429 pj_int32_t level = 0; 1430 1431 /* Lock mutex */ 1432 pj_mutex_lock(conf->mutex); 1433 1434 /* Get conf port of this port */ 1435 cport = conf->ports[this_port->port_data.ldata]; 1436 if (cport == NULL) { 1437 /* Unlock mutex */ 1438 pj_mutex_unlock(conf->mutex); 1439 return PJ_SUCCESS; 1440 } 1375 1441 1376 1442 pj_add_timestamp32(&cport->ts_rx, cport->info->samples_per_frame); … … 1379 1445 if (cport->rx_setting == PJMEDIA_PORT_DISABLE) { 1380 1446 cport->rx_level = 0; 1447 /* Unlock mutex */ 1448 pj_mutex_unlock(conf->mutex); 1381 1449 return PJ_SUCCESS; 1382 1450 } … … 1385 1453 if (cport->listener_cnt == 0) { 1386 1454 cport->rx_level = 0; 1455 /* Unlock mutex */ 1456 pj_mutex_unlock(conf->mutex); 1387 1457 return PJ_SUCCESS; 1388 1458 } … … 1461 1531 } 1462 1532 1533 /* Unlock mutex */ 1534 pj_mutex_unlock(conf->mutex); 1535 1463 1536 return PJ_SUCCESS; 1464 1537 }
Note: See TracChangeset
for help on using the changeset viewer.