[Freeswitch-svn] [commit] r2715 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Sat Sep 16 16:46:52 EDT 2006


Author: anthm
Date: Sat Sep 16 16:46:52 2006
New Revision: 2715

Modified:
   freeswitch/trunk/src/switch_rtp.c

Log:
cleanup

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Sat Sep 16 16:46:52 2006
@@ -474,14 +474,23 @@
 			return SWITCH_STATUS_FALSE;
 		}
 	}
-	switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+
 	if (timer_name) {
-		if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, packet_size, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
-			return SWITCH_STATUS_FALSE;
-		}
 		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
 	}
 
+	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && !timer_name) {
+		timer_name = "soft";
+	}
+
+	if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, packet_size, rtp_session->pool) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting timer [%s] %d bytes per %dms\n", timer_name, packet_size, ms_per_packet);
+	} else {
+		memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error starting timer [%s], async RTP disabled\n", timer_name);
+		switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+	}
+
 	rtp_session->ready++;
 	*new_rtp_session = rtp_session;
 
@@ -727,13 +736,17 @@
 {
 	switch_size_t bytes;
 	switch_status_t status;
-	switch_time_t now = 0;
-	
+	uint8_t check = 1;
+
+	if (!rtp_session->timer.interval) {
+		rtp_session->last_time = switch_time_now();
+	}
+
 	for(;;) {
 		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_STATUS_IS_BREAK(status) && rtp_session->timer.timer_interface) {
+		if (!SWITCH_STATUS_IS_BREAK(status) && rtp_session->timer.interval) {
 			switch_core_timer_step(&rtp_session->timer);
 		}
 		
@@ -795,11 +808,13 @@
 				}
 			}
 		}
-		
-		if ((!rtp_session->timer.timer_interface && (now=switch_time_now()) - rtp_session->last_time > 10000) || 
-			switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS) {
+
+		if (rtp_session->timer.interval) {
+			check = (switch_core_timer_check(&rtp_session->timer) == SWITCH_STATUS_SUCCESS);
+		}
+
+		if (check) {
 			do_2833(rtp_session);
-			rtp_session->last_time = now;
 
 			if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
 				/* We're late! We're Late!*/



More information about the Freeswitch-svn mailing list