fix some regression caused last week re: rtp and async timers on and off

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9491 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-09-09 16:31:53 +00:00
parent c8b8672a3e
commit 0da29822ca
6 changed files with 44 additions and 25 deletions

View File

@ -77,7 +77,11 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_running_state(switch_c
SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel);
SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state);
SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to);
SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel,
switch_channel_flag_t want_flag,
switch_bool_t pres,
uint32_t to,
switch_channel_t *super_channel);
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
const char *file, const char *func, int line, switch_channel_state_t state);

View File

@ -2133,7 +2133,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
switch_channel_clear_flag(tech_pvt->channel, CF_HOLD);
} else {
switch_channel_stop_broadcast(b_channel);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
}
switch_core_session_rwunlock(b_session);
}

View File

@ -650,7 +650,11 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw
}
}
SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to)
SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel,
switch_channel_flag_t want_flag,
switch_bool_t pres,
uint32_t to,
switch_channel_t *super_channel)
{
if (to) {
@ -669,6 +673,15 @@ SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *c
}
switch_yield(1000);
if (super_channel && !switch_channel_ready(super_channel)) {
return SWITCH_STATUS_FALSE;
}
if (!switch_channel_ready(channel)) {
return SWITCH_STATUS_FALSE;
}
if (to && !--to) {
return SWITCH_STATUS_TIMEOUT;
}

View File

@ -368,7 +368,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
if ((b_session = switch_core_session_locate(b_uuid))) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
switch_ivr_broadcast(b_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000, NULL);
switch_core_session_rwunlock(b_session);
}
} else {
@ -393,7 +393,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
if ((b_session = switch_core_session_locate(b_uuid))) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
switch_channel_stop_broadcast(b_channel);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
switch_core_session_rwunlock(b_session);
}
}
@ -863,7 +863,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session
if ((other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (b_session = switch_core_session_locate(other_uuid))) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
switch_channel_stop_broadcast(b_channel);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
switch_core_session_rwunlock(b_session);
}
@ -907,7 +907,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
status = SWITCH_STATUS_SUCCESS;
switch_core_session_receive_message(session, &msg);
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000);
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if ((flags & SMF_REBRIDGE)
@ -916,7 +916,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
other_channel = switch_core_session_get_channel(other_session);
switch_assert(other_channel != NULL);
switch_core_session_receive_message(other_session, &msg);
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000);
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
switch_channel_clear_state_handler(other_channel, NULL);
switch_core_session_rwunlock(other_session);
@ -934,8 +934,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
} else {
switch_ivr_uuid_bridge(uuid, other_uuid);
}
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000);
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000);
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
}
}
@ -980,8 +980,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
} else {
switch_ivr_signal_bridge(session, other_session);
}
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000);
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000);
switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
switch_core_session_rwunlock(other_session);
}
}

View File

@ -129,7 +129,13 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
switch_channel_set_flag(chan_a, CF_BRIDGED);
switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 1000000);
switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
if (!switch_channel_test_flag(chan_b, CF_BRIDGED)) {
switch_channel_hangup(chan_b, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end_of_bridge_loop;
}
for (;;) {
switch_channel_state_t b_state;
@ -782,7 +788,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data");
switch_core_session_execute_application(peer_session, app, data);
}
switch_channel_set_private(peer_channel, "_bridge_", b_leg);
switch_channel_set_state(peer_channel, CS_EXCHANGE_MEDIA);
audio_bridge_thread(NULL, (void *) a_leg);

View File

@ -802,18 +802,15 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
timer_name = NULL;
}
if (!switch_strlen_zero(timer_name)) {
rtp_session->timer_name = switch_core_strdup(pool, timer_name);
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
}
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && switch_strlen_zero(timer_name)) {
timer_name = "soft";
}
if (!switch_strlen_zero(timer_name)) {
rtp_session->timer_name = switch_core_strdup(pool, timer_name);
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Starting timer [%s] %d bytes per %dms\n", timer_name, samples_per_interval, ms_per_packet);
@ -822,6 +819,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error starting timer [%s], async RTP disabled\n", timer_name);
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
}
} else {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
}
rtp_session->ready = 1;
@ -1243,10 +1243,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
goto end;
}
if (bytes == 1) {
continue;
}
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
const char *tx_host;
const char *old_host;