[Freeswitch-svn] [commit] r7854 - in freeswitch/trunk/src: . include mod/applications/mod_commands mod/applications/mod_dptools mod/applications/mod_enum mod/dialplans/mod_dialplan_asterisk mod/dialplans/mod_dialplan_directory mod/dialplans/mod_dialplan_xml mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Mon Mar 10 23:45:17 EDT 2008


Author: anthm
Date: Mon Mar 10 23:45:16 2008
New Revision: 7854

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

Log:
fix a bunch of stuff

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Mon Mar 10 23:45:16 2008
@@ -459,9 +459,10 @@
 /*!
   \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 @@
 /*!
   \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.

Modified: freeswitch/trunk/src/include/switch_platform.h
==============================================================================
--- freeswitch/trunk/src/include/switch_platform.h	(original)
+++ freeswitch/trunk/src/include/switch_platform.h	Mon Mar 10 23:45:16 2008
@@ -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

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Mon Mar 10 23:45:16 2008
@@ -504,7 +504,8 @@
 	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;
 
 

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Mon Mar 10 23:45:16 2008
@@ -1081,7 +1081,7 @@
 	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 @@
 		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_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);

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Mon Mar 10 23:45:16 2008
@@ -374,6 +374,17 @@
 	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_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);

Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	Mon Mar 10 23:45:16 2008
@@ -572,10 +572,6 @@
 		free_results(&results);
 	}
 
-	if (extension) {
-		switch_channel_set_state(channel, CS_EXECUTE);
-	}
-
 	return extension;
 
 }

Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c	Mon Mar 10 23:45:16 2008
@@ -284,10 +284,6 @@
 
 	switch_config_close_file(&cfg);
 
-	if (extension) {
-		switch_channel_set_state(channel, CS_EXECUTE);
-	} 
-
 	return extension;
 }
 

Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	Mon Mar 10 23:45:16 2008
@@ -138,11 +138,6 @@
 
 	switch_core_directory_close(&dh);
 
-
-	if (extension) {
-		switch_channel_set_state(channel, CS_EXECUTE);
-	}
-
 	return extension;
 }
 

Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Mon Mar 10 23:45:16 2008
@@ -274,10 +274,6 @@
 	switch_xml_free(xml);
 	xml = NULL;
 
-	if (extension) {
-		switch_channel_set_state(channel, CS_EXECUTE);
-	}
-
   done:
 	switch_xml_free(xml);
 	return extension;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Mon Mar 10 23:45:16 2008
@@ -100,12 +100,14 @@
 
 		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 @@
 			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 @@
 				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 @@
 		}
 		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;
 		

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Mon Mar 10 23:45:16 2008
@@ -1083,20 +1083,20 @@
 	}
 	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);
 }
 

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Mon Mar 10 23:45:16 2008
@@ -93,6 +93,7 @@
 
 					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 @@
 		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 @@
 #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 @@
 				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 @@
 				}
 				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 @@
 			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);
 			}
 		}

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Mon Mar 10 23:45:16 2008
@@ -678,7 +678,7 @@
 	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 @@
 	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_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 @@
 	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);
 	}
 

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Mon Mar 10 23:45:16 2008
@@ -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 @@
 		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 @@
 	/*.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 @@
 			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) {

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Mon Mar 10 23:45:16 2008
@@ -1057,8 +1057,9 @@
 			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;
 			}

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Mon Mar 10 23:45:16 2008
@@ -879,14 +879,12 @@
 	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 @@
 
 		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 @@
 
 		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 };

Modified: freeswitch/trunk/src/switch_time.c
==============================================================================
--- freeswitch/trunk/src/switch_time.c	(original)
+++ freeswitch/trunk/src/switch_time.c	Mon Mar 10 23:45:16 2008
@@ -58,7 +58,7 @@
 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 @@
 	}
 
 	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 @@
 		check_roll();
 		switch_yield(1000);
 	}
-
+	
 	if (globals.RUNNING == 1) {
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -230,7 +230,6 @@
 	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 @@
 			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;
 		}



More information about the Freeswitch-svn mailing list