diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 78b3827aa9..21e80e28d5 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -811,6 +811,7 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void); \param value the value of the variable */ SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value); +SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event); /*! \brief Conditionally add a global variable to the core diff --git a/src/switch_channel.c b/src/switch_channel.c index 655dea39c0..827d7ea65b 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -3337,7 +3337,7 @@ static void do_execute_on(switch_channel_t *channel, const char *variable) char *app; app = switch_core_session_strdup(channel->session, variable); - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "EXEC %s\n", app); for(p = app; p && *p; p++) { if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) { *p++ = '\0'; @@ -3360,10 +3360,12 @@ static void do_execute_on(switch_channel_t *channel, const char *variable) SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix) { switch_event_header_t *hp; - switch_event_t *event; + switch_event_t *event, *cevent; int x = 0; - switch_channel_get_variables(channel, &event); + switch_core_get_variables(&event); + switch_channel_get_variables(channel, &cevent); + switch_event_merge(event, cevent); for (hp = event->headers; hp; hp = hp->next) { char *var = hp->name; @@ -3384,6 +3386,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *chan } switch_event_destroy(&event); + switch_event_destroy(&cevent); return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; } diff --git a/src/switch_core.c b/src/switch_core.c index 60e133c730..64ad73c685 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -307,6 +307,15 @@ SWITCH_DECLARE(const char *) switch_core_get_switchname(void) } +SWITCH_DECLARE(switch_status_t) switch_core_get_variables(switch_event_t **event) +{ + switch_status_t status; + switch_thread_rwlock_rdlock(runtime.global_var_rwlock); + status = switch_event_dup(event, runtime.global_vars); + switch_thread_rwlock_unlock(runtime.global_var_rwlock); + return status; +} + SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname) { char *val; diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 7a20f87b5c..2d80d93573 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -358,8 +358,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) } #endif - if (read_frame_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { - + if (read_frame_count == DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { switch_channel_execute_on(chan_a, SWITCH_CHANNEL_EXECUTE_ON_PRE_BRIDGE_VARIABLE); if (!inner_bridge) { @@ -373,8 +372,9 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_session_execute_application_async(session_a, exec_app, exec_data); exec_app = exec_data = NULL; } + } - + if (read_frame_count >= DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { if ((bypass_media_after_bridge || switch_channel_test_flag(chan_b, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED) && switch_channel_test_flag(chan_b, CF_ANSWERED)) { switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);