]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix campon to play music even on first run and cancel faster
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 6 Jul 2011 21:45:25 +0000 (16:45 -0500)
committerBrian West <brian@freeswitch.org>
Wed, 6 Jul 2011 21:45:36 +0000 (16:45 -0500)
src/include/switch_channel.h
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_channel.c

index 53117de6a7b020b848f043d80d7674787a3921ac..1f3bd8fd2f5ef8dd36763c1e7ff27df7ba018986 100644 (file)
@@ -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
index 49312a708a7ecf5bf26467fcdb3604662a7bfd5a..5916bc843586e19edcdc12e8dbcaff4b3509415c 100755 (executable)
@@ -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) {
index 0d25d4d4cc7b38c47229591bfd5e651c02277933..d8abf7706ea246e8acc2f41edc78a9e620bf8abf 100644 (file)
@@ -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;