]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix some bypass media scenarios
authorBrian West <brian@freeswitch.org>
Sat, 23 Jan 2010 18:35:05 +0000 (18:35 +0000)
committerBrian West <brian@freeswitch.org>
Sat, 23 Jan 2010 18:35:05 +0000 (18:35 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16480 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_core.h
src/switch_core_session.c
src/switch_ivr.c
src/switch_ivr_bridge.c

index 3a6c76e10c55ed8fbfba8004f22a0ed38429194c..8493fe675b9f22f95b740730309f349a294b77f0 100644 (file)
@@ -2071,6 +2071,7 @@ SWITCH_DECLARE(void) switch_cache_db_detach(void);
 SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
 SWITCH_DECLARE(void) switch_cache_db_flush_handles(void);
 SWITCH_DECLARE(const char *) switch_core_banner(void);
+SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session);
 
 SWITCH_END_EXTERN_C
 #endif
index 0bf16bb69c056af68bf11867353a2b21646d7e08..10f7d9e6676c7ae96410acd514bf5312f79302c0 100644 (file)
@@ -1141,6 +1141,14 @@ SWITCH_DECLARE(void) switch_core_session_disable_heartbeat(switch_core_session_t
        
 }
 
+SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session)
+{
+       if (switch_thread_self() == session->thread_id) {
+               return SWITCH_TRUE;
+       }
+       return SWITCH_FALSE;
+}
+
 static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj)
 {
        switch_core_session_t *session = obj;
index 498913eb220f859f6122e4931f7c3dcdd7d9ae4b..e312645b952effe2ddae52cdd78884f943cb4227 100644 (file)
@@ -1286,7 +1286,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
                        if (other_channel) {
                                switch_channel_wait_for_state(other_channel, channel, CS_PARK);
                        }
-                       switch_channel_wait_for_state_timeout(channel, CS_PARK, 5000000);
+                       if (switch_core_session_in_thread(session)) {
+                               switch_yield(100000);
+                       }
                        
                        switch_channel_clear_flag(channel, CF_NOT_READY);
 
@@ -1300,7 +1302,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
                                        switch_ivr_signal_bridge(session, other_session);
                                }
                                switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
-                               switch_channel_wait_for_state(channel, other_channel, CS_HIBERNATE);
+                               if (switch_core_session_in_thread(session)) {
+                                       switch_yield(100000);
+                               }
                                switch_core_session_rwunlock(other_session);
                        }
                }
index 6b61e6868d2d0320db9834a44ff3c8eccee92f0f..45cf3dc6ffcc1969d35886cdf182a340c22105ba 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 #include <switch.h>
-#define DEFAULT_LEAD_FRAMES 5
+#define DEFAULT_LEAD_FRAMES 10
 
 static const switch_state_handler_table_t audio_bridge_peer_state_handlers;
 static void cleanup_proxy_mode_a(switch_core_session_t *session);
@@ -839,18 +839,22 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session)
             switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
                        
             if (switch_channel_up(other_channel)) {
+
                                if (switch_true(switch_channel_get_variable(other_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
                                        switch_ivr_park_session(other_session);
                                } else if ((var = switch_channel_get_variable(other_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
                                        transfer_after_bridge(other_session, var);
                                }
-                               
-                               if (switch_channel_test_flag(other_channel, CF_BRIDGE_ORIGINATOR) && 
-                                       switch_channel_test_flag(channel, CF_ANSWERED) &&
-                                       switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
-                                       switch_channel_hangup(other_channel, switch_channel_get_cause(channel));        
+
+                               if (switch_channel_test_flag(other_channel, CF_BRIDGE_ORIGINATOR)) {
+                                       if (switch_channel_test_flag(channel, CF_ANSWERED) &&
+                                               switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
+                                               switch_channel_hangup(other_channel, switch_channel_get_cause(channel));        
+                                       } else {
+                                               switch_channel_set_state(other_channel, CS_EXECUTE);
+                                       }
                                } else {
-                                       switch_channel_set_state(other_channel, CS_EXECUTE);
+                                       switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
                                }
             }
         }