From 8f7a3e43dcd3658428c056797baa7fdc4e1a4154 Mon Sep 17 00:00:00 2001 From: Brian West Date: Sat, 23 Jan 2010 18:35:05 +0000 Subject: [PATCH] fix some bypass media scenarios git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16480 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 1 + src/switch_core_session.c | 8 ++++++++ src/switch_ivr.c | 8 ++++++-- src/switch_ivr_bridge.c | 18 +++++++++++------- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 3a6c76e10c..8493fe675b 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -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 diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 0bf16bb69c..10f7d9e667 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -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; diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 498913eb22..e312645b95 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -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); } } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 6b61e6868d..45cf3dc6ff 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -30,7 +30,7 @@ */ #include -#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)); } } }