]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix some regression caused last week re: rtp and async timers on and off
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 9 Sep 2008 16:31:53 +0000 (16:31 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 9 Sep 2008 16:31:53 +0000 (16:31 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9491 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_channel.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_channel.c
src/switch_ivr.c
src/switch_ivr_bridge.c
src/switch_rtp.c

index b2485def1df9913fec7ce6d794e220e654755ca4..f466db617754ee97237b883463a882cc6270bb47 100644 (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);
index 3ce207f35aac198e9478373a6163857b749a80de..555ed742ec61900310c1dee5185061774fe25c6c 100644 (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);
                        }
index c364ff6ae7c914f49075f8355043906f5455fc3e..e4ca19c76aa30d0a8d0e7de521f744d948b32081 100644 (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;
                }
index 8ebcd71dd96d55dd111d504500d021c6c002bc90..e719fa261ff03fc5c2bab9049434b4c0d8ee433f 100644 (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);
                        }
                }
index fa4f0b8f13c8f9faca1b34ac55be143f050356ad..93c849de71c7628f3a8c523ebf8efc7467cfd2da 100644 (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);
index f30fccd311a823ee842ff7373556f6642167ba00..97d7d719e98ad0e8fc575cae41440a478f920615 100644 (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;