From 580f545e26372744354ca34a8a4afaacbf00febf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 1 May 2008 16:41:46 +0000 Subject: [PATCH] tewaks git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8232 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_ivr.h | 4 ++-- .../applications/mod_commands/mod_commands.c | 2 +- .../applications/mod_dptools/mod_dptools.c | 2 +- src/mod/endpoints/mod_sofia/sofia_glue.c | 19 ++++++++++++++++--- src/switch_core_io.c | 5 ++++- src/switch_core_rwlock.c | 9 ++++----- src/switch_ivr.c | 10 +++++----- src/switch_ivr_bridge.c | 8 ++++++-- 8 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 1c5ac2bda8..104a49c5ea 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -466,7 +466,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi \param message optional message \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message); +SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message, switch_bool_t moh); /*! \brief Signal the session with a protocol specific unhold message. @@ -481,7 +481,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold_uuid(const char *uuid); \param message optional message \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message); +SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh); /*! \brief Signal the session with a protocol specific unhold message. diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index c1811ca612..e453fbc691 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1171,7 +1171,7 @@ SWITCH_STANDARD_API(uuid_hold_function) if (!strcasecmp(argv[0], "off")) { status = switch_ivr_unhold_uuid(argv[1]); } else { - status = switch_ivr_hold_uuid(argv[0], argv[1]); + status = switch_ivr_hold_uuid(argv[0], argv[1], 1); } } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index b99522a4c4..2574191275 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1897,7 +1897,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, #define HOLD_SYNTAX "[]" SWITCH_STANDARD_APP(hold_function) { - switch_ivr_hold_uuid(switch_core_session_get_uuid(session), data); + switch_ivr_hold_uuid(switch_core_session_get_uuid(session), data, 1); } #define UNHOLD_SYNTAX "" diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 1af6e8ab01..1acd1f26b7 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1829,7 +1829,13 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * } if (stream && strcasecmp(stream, "silence")) { - switch_ivr_broadcast(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), stream, SMF_ECHO_ALEG | SMF_LOOP); + if (!strcasecmp(stream, "indicate_hold")) { + switch_channel_set_flag(tech_pvt->channel, CF_SUSPEND); + switch_channel_set_flag(tech_pvt->channel, CF_HOLD); + switch_ivr_hold_uuid(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), NULL, 0); + } else { + switch_ivr_broadcast(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), stream, SMF_ECHO_ALEG | SMF_LOOP); + } } } } else { @@ -1843,8 +1849,15 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * if ((uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (b_session = switch_core_session_locate(uuid))) { switch_channel_t *b_channel = switch_core_session_get_channel(b_session); - switch_channel_stop_broadcast(b_channel); - switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000); + + if (switch_channel_test_flag(tech_pvt->channel, CF_HOLD)) { + switch_ivr_unhold(b_session); + switch_channel_clear_flag(tech_pvt->channel, CF_SUSPEND); + switch_channel_clear_flag(tech_pvt->channel, CF_HOLD); + } else { + switch_channel_stop_broadcast(b_channel); + switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000); + } switch_core_session_rwunlock(b_session); } diff --git a/src/switch_core_io.c b/src/switch_core_io.c index ff402bc967..c4dcf776ab 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -120,7 +120,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi if (switch_channel_test_flag(session->channel, CF_HOLD)) { status = SWITCH_STATUS_BREAK; - goto done; + goto even_more_done; } if (session->endpoint_interface->io_routines->read_frame) { @@ -459,6 +459,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi switch_thread_rwlock_unlock(session->bug_rwlock); } } + + even_more_done: + return status; } diff --git a/src/switch_core_rwlock.c b/src/switch_core_rwlock.c index 0bec5c935a..ae94e82f28 100644 --- a/src/switch_core_rwlock.c +++ b/src/switch_core_rwlock.c @@ -35,7 +35,6 @@ #include #include "private/switch_core_pvt.h" - SWITCH_DECLARE(switch_status_t) switch_core_session_signal_lock(switch_core_session_t *session) { return switch_mutex_lock(session->signal_mutex); @@ -58,12 +57,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio if (switch_test_flag(session, SSF_DESTROYED)) { status = SWITCH_STATUS_FALSE; #ifdef SWITCH_DEBUG_RWLOCKS - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "%s Read lock FAIL\n", switch_channel_get_name(session->channel)); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock FAIL\n", switch_channel_get_name(session->channel)); #endif } else { status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock); #ifdef SWITCH_DEBUG_RWLOCKS - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "%s Read lock AQUIRED\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock AQUIRED\n", switch_channel_get_name(session->channel)); #endif } @@ -76,7 +75,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, const char *file, const char *func, int line) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "%s Write lock AQUIRED\n", switch_channel_get_name(session->channel)); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Write lock AQUIRED\n", switch_channel_get_name(session->channel)); #else SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session) { @@ -87,7 +86,7 @@ SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *sessi #ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t *session, const char *file, const char *func, int line) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_ERROR, "%s Read/Write lock CLEARED\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read/Write lock CLEARED\n", switch_channel_get_name(session->channel)); #else SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 5274c46202..4601bb114b 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -741,7 +741,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess return status; } -SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message) +SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh) { switch_core_session_message_t msg = { 0 }; switch_channel_t *channel = switch_core_session_get_channel(session); @@ -756,8 +756,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, switch_channel_set_flag(channel, CF_SUSPEND); switch_core_session_receive_message(session, &msg); - - if ((stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) { + + if (moh && (stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) { if ((other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { switch_ivr_broadcast(other_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP); } @@ -767,12 +767,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message) +SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message, switch_bool_t moh) { switch_core_session_t *session; if ((session = switch_core_session_locate(uuid))) { - switch_ivr_hold(session, message); + switch_ivr_hold(session, message, moh); switch_core_session_rwunlock(session); } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 9b56a3b657..948e544be1 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -161,8 +161,12 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) } if (!nosuspend && (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND))) { - status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id); - + if (switch_channel_test_flag(chan_a, CF_SUSPEND)) { + status = SWITCH_STATUS_SUCCESS; + } else { + status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id); + } + if (!SWITCH_READ_ACCEPTABLE(status)) { goto end_of_bridge_loop; }