]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix a bunch of stuff
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 11 Mar 2008 03:45:16 +0000 (03:45 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 11 Mar 2008 03:45:16 +0000 (03:45 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7854 d0543943-73ff-0310-b7d9-9358b9ac24b2

17 files changed:
src/include/switch_ivr.h
src/include/switch_platform.h
src/include/switch_types.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/applications/mod_enum/mod_enum.c
src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_channel.c
src/switch_core_state_machine.c
src/switch_ivr.c
src/switch_ivr_originate.c
src/switch_ivr_play_say.c
src/switch_rtp.c
src/switch_time.c

index 99bac572eb99c5a4155e4a8e34dd04c11b575966..a8e8f284caa058744f60fb4978117ae2e63c8956 100644 (file)
@@ -459,9 +459,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
 /*!
   \brief Signal the session with a protocol specific hold message.
   \param uuid the uuid of the session to hold
+  \param message optional message
   \return SWITCH_STATUS_SUCCESS if all is well
 */
-SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid);
+SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message);
 
 /*!
   \brief Signal the session with a protocol specific unhold message.
@@ -473,9 +474,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_unhold_uuid(const char *uuid);
 /*!
   \brief Signal the session with a protocol specific hold message.
   \param session the session to hold
+  \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);
+SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message);
 
 /*!
   \brief Signal the session with a protocol specific unhold message.
index 143857f5d82e939fcea624e8878030502d19f2cb..38f6c2877f08d2c39aa3cb7b624eec8d0b2810a6 100644 (file)
@@ -35,6 +35,7 @@
 #define SWITCH_PLATFORM_H
 
 SWITCH_BEGIN_EXTERN_C
+#define SWITCH_USE_CLOCK_FUNCS
 #ifdef __ICC
 #pragma warning (disable:810 869 981 279 1469 188)
 #endif
index 59dadead2c940287740f5a44ce026aaf32252f32..19e9461ebbd7768636b57244f96cd5495da24010 100644 (file)
@@ -504,7 +504,8 @@ typedef enum {
        SWITCH_MESSAGE_INDICATE_BROADCAST,
        SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT,
        SWITCH_MESSAGE_INDICATE_DEFLECT,
-       SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ
+       SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ,
+       SWITCH_MESSAGE_INDICATE_DISPLAY
 } switch_core_session_message_types_t;
 
 
index 7075d0629df3f1e8de1b1241bc566281da23b58c..4b5a5517b8c510cd9f90baecd26ed69e5d59d8d4 100644 (file)
@@ -1081,7 +1081,7 @@ SWITCH_STANDARD_API(sched_broadcast_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define HOLD_SYNTAX "<uuid>"
+#define HOLD_SYNTAX "<uuid> [<display>]"
 SWITCH_STANDARD_API(uuid_hold_function)
 {
        char *mycmd = NULL, *argv[4] = { 0 };
@@ -1102,7 +1102,49 @@ 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]);
+                       status = switch_ivr_hold_uuid(argv[0], argv[1]);
+               }
+       }
+
+       if (status == SWITCH_STATUS_SUCCESS) {
+               stream->write_function(stream, "+OK Success\n");
+       } else {
+               stream->write_function(stream, "-ERR Operation Failed\n");
+       }
+
+       switch_safe_free(mycmd);
+       return SWITCH_STATUS_SUCCESS;
+}
+
+
+#define DISPLAY_SYNTAX "<uuid> <display>"
+SWITCH_STANDARD_API(uuid_display_function)
+{
+       char *mycmd = NULL, *argv[2] = { 0 };
+       int argc = 0;
+       switch_status_t status = SWITCH_STATUS_FALSE;
+
+       if (session) {
+               return status;
+       }
+
+       if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
+               argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+       }
+
+       if (switch_strlen_zero(cmd) || argc < 2 || switch_strlen_zero(argv[0]) || switch_strlen_zero(argv[1])) {
+               stream->write_function(stream, "-USAGE: %s\n", HOLD_SYNTAX);
+       } else {
+               switch_core_session_message_t msg = { 0 };
+               switch_core_session_t *lsession = NULL;
+
+               msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
+               msg.string_arg = argv[1];
+               msg.from = __FILE__;
+
+               if ((lsession = switch_core_session_locate(argv[0]))) {
+                       status = switch_core_session_receive_message(lsession, &msg);
+                       switch_core_session_rwunlock(lsession);
                }
        }
 
@@ -2152,6 +2194,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "uuid_broadcast", "broadcast", uuid_broadcast_function, BROADCAST_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "hold", "hold (depricated)", uuid_hold_function, HOLD_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "media", "media (depricated)", uuid_media_function, MEDIA_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
index 2611ff79dee0a9d888a161d47570d10a2a4a6014..31ab5a21017ce5e330b377f33248bfff090c048a 100644 (file)
@@ -374,6 +374,17 @@ SWITCH_STANDARD_APP(redirect_function)
        switch_core_session_receive_message(session, &msg);
 }
 
+SWITCH_STANDARD_APP(display_function)
+{
+       switch_core_session_message_t msg = { 0 };
+
+       /* Tell the channel to redirect */
+       msg.from = __FILE__;
+       msg.string_arg = data;
+       msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
+       switch_core_session_receive_message(session, &msg);
+}
+
 SWITCH_STANDARD_APP(respond_function)
 {
        switch_core_session_message_t msg = { 0 };
@@ -1588,6 +1599,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
        SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
        SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
        SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
+       SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>", SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);
        SWITCH_ADD_APP(app_interface, "reject", "Send session reject (depricated)", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
index 6eb60c21186b1c6c618032669c3336a51bd7de99..86ab09d5c9c7b4139fe48a668b0126eb4c3e8c4c 100644 (file)
@@ -572,10 +572,6 @@ SWITCH_STANDARD_DIALPLAN(enum_dialplan_hunt)
                free_results(&results);
        }
 
-       if (extension) {
-               switch_channel_set_state(channel, CS_EXECUTE);
-       }
-
        return extension;
 
 }
index 805880c06f20d557ca185874239690f9abd40682..48fef5fe69b91285fdb04565c0ccd0e5b4a6c55d 100644 (file)
@@ -284,10 +284,6 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
 
        switch_config_close_file(&cfg);
 
-       if (extension) {
-               switch_channel_set_state(channel, CS_EXECUTE);
-       } 
-
        return extension;
 }
 
index 626a9124409f1d9618082af504994eafeff299ed..3f1f14288ed86a86ce06c1e761de40a20761bdb6 100644 (file)
@@ -138,11 +138,6 @@ SWITCH_STANDARD_DIALPLAN(directory_dialplan_hunt)
 
        switch_core_directory_close(&dh);
 
-
-       if (extension) {
-               switch_channel_set_state(channel, CS_EXECUTE);
-       }
-
        return extension;
 }
 
index 8b0d25ff2fa1c09471ca536f8730c78b158335b3..792cc7fd48173dbd23976213971efcaa5f98be52 100644 (file)
@@ -274,10 +274,6 @@ SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
        switch_xml_free(xml);
        xml = NULL;
 
-       if (extension) {
-               switch_channel_set_state(channel, CS_EXECUTE);
-       }
-
   done:
        switch_xml_free(xml);
        return extension;
index 505c63a08e00ab47548097ac7cc4aa3e7ccb4f53..a4dab15f8e730a1bbf4849e6079a4bfaf4f997f6 100644 (file)
@@ -100,12 +100,14 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
 
                if (sofia_glue_do_invite(session) != SWITCH_STATUS_SUCCESS) {
                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+                       assert( switch_channel_get_state(channel) != CS_INIT);
                        return SWITCH_STATUS_FALSE;
                }
        }
 
        /* Move Channel's State Machine to RING */
        switch_channel_set_state(channel, CS_RING);
+       assert( switch_channel_get_state(channel) != CS_INIT);
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -538,6 +540,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
                        tech_pvt->read_frame.flags = SFF_NONE;
 
                        status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
+                       
                        if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
                                if (status == SWITCH_STATUS_TIMEOUT) {
                                        switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
@@ -552,7 +555,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
                                switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
                                switch_channel_queue_dtmf(channel, &dtmf);
                        }
-
+                       
                        if (tech_pvt->read_frame.datalen > 0) {
                                size_t bytes = 0;
                                int frames = 1;
@@ -844,10 +847,25 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                }
                break;
 
+       case SWITCH_MESSAGE_INDICATE_DISPLAY:
+               {
+                       if (!switch_strlen_zero(msg->string_arg)) {
+                               char message[256] = "";
+                               snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
+                               nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
+                       }
+               }
+               break;
+
        case SWITCH_MESSAGE_INDICATE_HOLD:
                {
                        switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
                        sofia_glue_do_invite(session);
+                       if (!switch_strlen_zero(msg->string_arg)) {
+                               char message[256] = "";
+                               snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
+                               nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
+                       }
                }
                break;
                
index 82d581ff2a9056842f6646edb7b964dc4e54738a..defba010606bb25e304e44f7a5cab0e8d63d3720 100644 (file)
@@ -1083,20 +1083,20 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw
        }
        x = 0;
        /* Index Variables */
-       for (hi = channel->variables->headers; hi; hi = hi->next) {
-               char buf[1024];
-               char *vvar = NULL, *vval = NULL;
-
-               vvar = (char *) hi->name;
-               vval = (char *) hi->value;
-               x++;
-
-               switch_assert(vvar && vval);
-               switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
-               switch_event_add_header(event, SWITCH_STACK_BOTTOM, buf, "%s", vval);
-
+       if (channel->variables) {
+               for (hi = channel->variables->headers; hi; hi = hi->next) {
+                       char buf[1024];
+                       char *vvar = NULL, *vval = NULL;
+
+                       vvar = (char *) hi->name;
+                       vval = (char *) hi->value;
+                       x++;
+
+                       switch_assert(vvar && vval);
+                       switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
+                       switch_event_add_header(event, SWITCH_STACK_BOTTOM, buf, "%s", vval);
+               }
        }
-
        switch_mutex_unlock(channel->profile_mutex);
 }
 
index f7b82e8fcdc31acfa652a2f9ef39aac32b6f2ca4..143b0e580246d3769e6ab4c2ebaea29c670b351d 100644 (file)
@@ -93,6 +93,7 @@ static void switch_core_standard_on_ring(switch_core_session_t *session)
 
                                        if ((extension = dialplan_interface->hunt_function(session, dparg, NULL)) != 0) {
                                                switch_channel_set_caller_extension(session->channel, extension);
+                                               switch_channel_set_state(session->channel, CS_EXECUTE);
                                                goto end;
                                        }
                                }
@@ -112,12 +113,14 @@ static void switch_core_standard_on_ring(switch_core_session_t *session)
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No Route, Aborting\n");
                switch_channel_hangup(session->channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
        }
+
        
  end:
 
        if (expanded && dpstr && expanded != dpstr) {
                free(expanded);
        }
+
 }
 
 static void switch_core_standard_on_execute(switch_core_session_t *session)
@@ -294,7 +297,7 @@ void switch_core_state_machine_init(switch_memory_pool_t *pool)
 #define STATE_MACRO(__STATE, __STATE_STR)                                              do {    \
                midstate = state;                                                                                               \
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State %s\n", switch_channel_get_name(session->channel), __STATE_STR);     \
-               if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
+               if (!driver_state_handler->on_##__STATE || ( driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
                                                                                                        && midstate == switch_channel_get_state(session->channel))) { \
                        while (do_extra_handlers && (application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) { \
                                if (!application_state_handler || !application_state_handler->on_##__STATE \
@@ -325,6 +328,7 @@ void switch_core_state_machine_init(switch_memory_pool_t *pool)
                                switch_core_standard_on_##__STATE(session);                             \
                        }                                                                                                                       \
                }                                                                                                                               \
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State end %s %s %s\n", switch_channel_get_name(session->channel), __STATE_STR, switch_channel_state_name(midstate), switch_channel_state_name(switch_channel_get_state(session->channel))); \
        } while (silly)
 
 SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
@@ -430,9 +434,14 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
                                }
                                goto done;
                        case CS_INIT: /* Basic setup tasks */
-                               switch_core_session_signal_lock(session);
-                               STATE_MACRO(init, "INIT");
-                               switch_core_session_signal_unlock(session);
+                               assert(driver_state_handler->on_init);
+                               //switch_core_session_signal_lock(session);
+                               if (0) STATE_MACRO(init, "INIT");
+                               //switch_core_session_signal_unlock(session);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State INIT\n", switch_channel_get_name(session->channel));
+                               driver_state_handler->on_init(session);
+                               assert( switch_channel_get_state(session->channel) != CS_INIT);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) State INIT-END\n", switch_channel_get_name(session->channel));
                                break;
                        case CS_RING: /* Look for a dialplan and find something to do */
                                switch_core_session_signal_lock(session);
@@ -480,6 +489,8 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
                        if (endstate == CS_NEW) {
                                switch_yield(1000);
                        } else {
+                               assert( switch_channel_get_state(session->channel) != CS_INIT);
+                               assert( switch_channel_get_running_state(session->channel) != CS_INIT);
                                switch_thread_cond_wait(session->cond, session->mutex);
                        }
                }
index c2218b7cee91f86efe10c026327cfa8e48f74b53..658b54472684447d31a47e36c40fc2d384595d69 100644 (file)
@@ -678,7 +678,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)
+SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message)
 {
        switch_core_session_message_t msg = { 0 };
        switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -686,6 +686,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
        const char *other_uuid;
 
        msg.message_id = SWITCH_MESSAGE_INDICATE_HOLD;
+       msg.string_arg = message;
        msg.from = __FILE__;
 
        switch_channel_set_flag(channel, CF_HOLD);
@@ -693,7 +694,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session)
 
        switch_core_session_receive_message(session, &msg);
 
-
        if ((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);
@@ -704,12 +704,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)
+SWITCH_DECLARE(switch_status_t) switch_ivr_hold_uuid(const char *uuid, const char *message)
 {
        switch_core_session_t *session;
 
        if ((session = switch_core_session_locate(uuid))) {
-               switch_ivr_hold(session);
+               switch_ivr_hold(session, message);
                switch_core_session_rwunlock(session);
        }
 
index a5fc1678f365289b0602ecb13b0d3a0c7a76bd93..1a017b47eaed9e7ab698d716c7638adb10aba866 100644 (file)
@@ -34,7 +34,7 @@
 
 static const switch_state_handler_table_t originate_state_handlers;
 
-static switch_status_t originate_on_hold(switch_core_session_t *session)
+static switch_status_t originate_on_hold_transmit(switch_core_session_t *session)
 {
        switch_channel_t *channel = switch_core_session_get_channel(session);
        
@@ -42,7 +42,6 @@ static switch_status_t originate_on_hold(switch_core_session_t *session)
                switch_ivr_sleep(session, 10);
        }
        
-       /* clear this handler so it only works once (next time (a.k.a. Transfer) we will do the real ring and hold states) */
        switch_channel_clear_state_handler(channel, &originate_state_handlers);
 
        return SWITCH_STATUS_FALSE;
@@ -64,8 +63,8 @@ static const switch_state_handler_table_t originate_state_handlers = {
        /*.on_execute */ NULL,
        /*.on_hangup */ NULL,
        /*.on_loopback */ NULL,
-       /*.on_transmit */ NULL,
-       /*.on_hold */ originate_on_hold
+       /*.on_transmit */ originate_on_hold_transmit,
+       /*.on_hold */ originate_on_hold_transmit
 };
 
 typedef enum {
@@ -113,6 +112,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t * thread, voi
                        goto wbreak;
                }
 
+               switch_channel_set_state(channel, CS_TRANSMIT);
                switch_core_session_exec(collect->session, application_interface, app_data);
                
                if (switch_channel_get_state(channel) < CS_HANGUP) {
index 5ccb898681d78a4ee6c1286ddbe740911ba71717..5e213e9298375b858dac62a7554e472a11010493 100644 (file)
@@ -1057,8 +1057,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                        while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
                                switch_yield(10000);
                        }
+                       
                        tstatus = switch_core_session_read_frame(session, &read_frame, -1, 0);
-
+                       
                        if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
                                break;
                        }
index c0145fbbb507063571236b349f9d0ea1d5ebdc4c..902600e6d6242329e108191e79ed79d929f5bbed 100644 (file)
@@ -879,14 +879,12 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
        void *pop;
        switch_socket_t *sock;
 
-
-       switch_mutex_lock((*rtp_session)->flag_mutex);
-
        if (!rtp_session || !*rtp_session || !(*rtp_session)->ready) {
-               switch_mutex_unlock((*rtp_session)->flag_mutex);
                return;
        }
 
+       switch_mutex_lock((*rtp_session)->flag_mutex);
+
        READ_INC((*rtp_session));
        WRITE_INC((*rtp_session));
 
@@ -1122,7 +1120,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
 
                bytes = sizeof(rtp_msg_t);
                status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
-
+               
                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
                        switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
                        bytes = 0;
@@ -1293,7 +1291,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
 
                if (rtp_session->timer.interval) {
                        check = (uint8_t) (switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS);
-
+                       
                        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTO_CNG) &&
                                rtp_session->timer.samplecount >= (rtp_session->last_write_samplecount + (rtp_session->samples_per_interval * 50))) {
                                uint8_t data[10] = { 0 };
index 2774f7d0a77ae1ad8de11463fbdb4529af1b43c7..de4c8a11541bf7556672e33c5ef86f05ce29ea68 100644 (file)
@@ -58,7 +58,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(softtimer_shutdown);
 SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime);
 SWITCH_MODULE_DEFINITION(CORE_SOFTTIMER_MODULE, softtimer_load, softtimer_shutdown, softtimer_runtime);
 
-#define MAX_ELEMENTS 360
+#define MAX_ELEMENTS 3600
 #define IDLE_SPEED 100
 #define STEP_MS 1
 #define STEP_MIC 1000
@@ -202,7 +202,7 @@ static switch_status_t timer_step(switch_timer_t *timer)
        }
 
        timer->samplecount = (uint32_t) samples;
-       private_info->reference++;
+       private_info->reference = TIMER_MATRIX[timer->interval].tick + 1;
 
        return SWITCH_STATUS_SUCCESS;
 }
@@ -217,7 +217,7 @@ static switch_status_t timer_next(switch_timer_t *timer)
                check_roll();
                switch_yield(1000);
        }
-
+       
        if (globals.RUNNING == 1) {
                return SWITCH_STATUS_SUCCESS;
        }
@@ -230,7 +230,6 @@ static switch_status_t timer_check(switch_timer_t *timer)
        timer_private_t *private_info = timer->private_info;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-
        if (globals.RUNNING != 1 || !private_info->ready) {
                return SWITCH_STATUS_SUCCESS;
        }
@@ -340,20 +339,25 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
                        tick = 0;
                }
 
-               
-               for (x = 1; x <= MAX_ELEMENTS; x++) {
-                       int i = x * 10;
-                       int index = (current_ms % i == 0) ? i : 0;
+
+               for (x = 0; x <= MAX_ELEMENTS; x++) {
+                       int i = x, index;
+
+                       if (i == 0) {
+                               i = 1;
+                       }
                        
+                       index = (current_ms % i == 0) ? i : 0; 
+
                        if (TIMER_MATRIX[index].count) {
                                TIMER_MATRIX[index].tick++;
-                               if (TIMER_MATRIX[index].tick == MAX_TICK) {
-                                       TIMER_MATRIX[index].tick = 0;
-                                       TIMER_MATRIX[index].roll++;
+                               if (TIMER_MATRIX[x].tick == MAX_TICK) {
+                                       TIMER_MATRIX[x].tick = 0;
+                                       TIMER_MATRIX[x].roll++;
                                }
                        }
                }
-
+               
                if (current_ms == MAX_ELEMENTS) {
                        current_ms = 0;
                }