From 9cf44f3a5ee7cba9fc378447780499d41c4de671 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 6 Jul 2011 16:45:25 -0500 Subject: [PATCH] fix campon to play music even on first run and cancel faster --- src/include/switch_channel.h | 1 + .../applications/mod_dptools/mod_dptools.c | 34 ++++++++++++------- src/switch_channel.c | 6 ++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 53117de6a7..1f3bd8fd2f 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -125,6 +125,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(_In_ switch_channel SWITCH_DECLARE(switch_call_cause_t) switch_channel_cause_q850(switch_call_cause_t cause); SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause_q850(switch_channel_t *channel); +SWITCH_DECLARE(switch_call_cause_t *) switch_channel_get_cause_ptr(switch_channel_t *channel); /*! \brief return a cause string for a given cause diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 49312a708a..5916bc8435 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -2517,6 +2517,7 @@ static void *SWITCH_THREAD_FUNC camp_music_thread(switch_thread_t *thread, void switch_core_session_rwunlock(session); stake->running = 0; + return NULL; } @@ -2538,6 +2539,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) switch_threadattr_t *thd_attr = NULL; char *camp_data = NULL; switch_status_t status; + int camp_loops = 0; if (zstr(data)) { return; @@ -2607,7 +2609,6 @@ SWITCH_STANDARD_APP(audio_bridge_function) do { fail = 0; - status = switch_ivr_originate(NULL, &peer_session, &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL); if (!switch_channel_ready(caller_channel)) { fail = 1; @@ -2635,22 +2636,29 @@ SWITCH_STANDARD_APP(audio_bridge_function) thread_started = 1; } + if (camp_loops++) { + if (--campon_retries <= 0 || stake.do_xfer) { + camping = 0; + stake.do_xfer = 1; + break; + } - if (--campon_retries <= 0 || stake.do_xfer) { - camping = 0; - stake.do_xfer = 1; - break; - } - - if (fail) { - int64_t wait = campon_sleep * 1000000; - - while (stake.running && wait > 0 && switch_channel_ready(caller_channel)) { - switch_yield(100000); - wait -= 100000; + if (fail) { + int64_t wait = campon_sleep * 1000000; + + while (stake.running && wait > 0 && switch_channel_ready(caller_channel)) { + switch_yield(100000); + wait -= 100000; + } } } } + + status = switch_ivr_originate(NULL, &peer_session, + &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE, + switch_channel_get_cause_ptr(caller_channel)); + + } while (camping && switch_channel_ready(caller_channel)); if (thread) { diff --git a/src/switch_channel.c b/src/switch_channel.c index 0d25d4d4cc..d8abf7706e 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -181,6 +181,12 @@ SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *c } +SWITCH_DECLARE(switch_call_cause_t *) switch_channel_get_cause_ptr(switch_channel_t *channel) +{ + return &channel->hangup_cause; +} + + struct switch_callstate_table { const char *name; switch_channel_callstate_t callstate;