From 03f11e7a0f2fc09dcd65eef5e2c46e79cb282290 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthony.minessale@gmail.com>
Date: Mon, 14 Apr 2008 17:12:42 +0000
Subject: [PATCH] vars to execute app before bridge (FSCORE-114)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8108 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 src/switch_ivr_bridge.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c
index 1e172d0ca2..c0436d98c0 100644
--- a/src/switch_ivr_bridge.c
+++ b/src/switch_ivr_bridge.c
@@ -689,20 +689,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
 			switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
 			switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
 
-			if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_app"))) {
-				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_data");
-				if ((application_interface = switch_loadable_module_get_application_interface(app))) {
-					switch_core_session_exec(session, application_interface, data);
-				}
-			}
-			
-			if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_app"))) {
-				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data");
-				if ((application_interface = switch_loadable_module_get_application_interface(app))) {
-					switch_core_session_exec(peer_session, application_interface, data);
-				}
-			}
-
 			if (!(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
 				if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS) {
 					switch_channel_state_t w_state = switch_channel_get_state(caller_channel);
@@ -752,6 +738,20 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
 			switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(session));
 			switch_channel_set_variable(peer_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(session));
 			
+			if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_app"))) {
+				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_data");
+				if ((application_interface = switch_loadable_module_get_application_interface(app))) {
+					switch_core_session_exec(session, application_interface, data);
+				}
+			}
+			
+			if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_app"))) {
+				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data");
+				if ((application_interface = switch_loadable_module_get_application_interface(app))) {
+					switch_core_session_exec(peer_session, application_interface, data);
+				}
+			}
+
 			switch_channel_set_private(peer_channel, "_bridge_", b_leg);
 			switch_channel_set_state(peer_channel, CS_LOOPBACK);
 			audio_bridge_thread(NULL, (void *) a_leg);