switch_channel_set_flag(other_channel, CF_RESET);
switch_channel_set_flag(other_channel, CF_REDIRECT);
+
+ if (!switch_core_session_in_thread(session)) {
+ switch_channel_set_state(channel, CS_PARK);
+ }
switch_channel_set_state(other_channel, CS_PARK);
if (switch_core_session_in_thread(session)) {
switch_yield(100000);
switch_core_session_receive_message(session, &msg);
- if (!switch_core_session_in_thread(session)) {
- switch_channel_set_state(channel, CS_PARK);
- switch_channel_wait_for_state(channel, channel, CS_PARK);
- switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
- switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
- switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
- }
-
if (other_channel) {
+ if (!switch_core_session_in_thread(session)) {
+ switch_channel_wait_for_state(channel, channel, CS_PARK);
+ switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+ switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+ switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
+ }
+
if (swap) {
switch_ivr_signal_bridge(other_session, session);
} else {