[Freeswitch-svn] [commit] r9491 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Tue Sep 9 12:31:53 EDT 2008


Author: anthm
Date: Tue Sep  9 12:31:53 2008
New Revision: 9491

Modified:
   freeswitch/trunk/src/include/switch_channel.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/trunk/src/switch_rtp.c

Log:
fix some regression caused last week re: rtp and async timers on and off

Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h	(original)
+++ freeswitch/trunk/src/include/switch_channel.h	Tue Sep  9 12:31:53 2008
@@ -77,7 +77,11 @@
 SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel);
 
 SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state);
-SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to);
+SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, 
+															 switch_channel_flag_t want_flag, 
+															 switch_bool_t pres, 
+															 uint32_t to,
+															 switch_channel_t *super_channel);
 
 SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
 																		const char *file, const char *func, int line, switch_channel_state_t state);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Tue Sep  9 12:31:53 2008
@@ -2133,7 +2133,7 @@
 					switch_channel_clear_flag(tech_pvt->channel, CF_HOLD);
 				} else {
 					switch_channel_stop_broadcast(b_channel);
-					switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
+					switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
 				}
 				switch_core_session_rwunlock(b_session);
 			}

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Tue Sep  9 12:31:53 2008
@@ -650,7 +650,11 @@
 	}
 }
 
-SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to)
+SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, 
+															 switch_channel_flag_t want_flag, 
+															 switch_bool_t pres, 
+															 uint32_t to,
+															 switch_channel_t *super_channel)
 {
 
 	if (to) {
@@ -669,6 +673,15 @@
 		}
 
 		switch_yield(1000);
+
+		if (super_channel && !switch_channel_ready(super_channel)) {
+			return SWITCH_STATUS_FALSE;
+		}
+
+		if (!switch_channel_ready(channel)) {
+			return SWITCH_STATUS_FALSE;
+		}
+
 		if (to && !--to) {
 			return SWITCH_STATUS_TIMEOUT;
 		}

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Tue Sep  9 12:31:53 2008
@@ -368,7 +368,7 @@
 								if ((b_session = switch_core_session_locate(b_uuid))) {
 									switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
 									switch_ivr_broadcast(b_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
-									switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000);
+									switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000, NULL);
 									switch_core_session_rwunlock(b_session);
 								}
 							} else {
@@ -393,7 +393,7 @@
 						if ((b_session = switch_core_session_locate(b_uuid))) {
 							switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
 							switch_channel_stop_broadcast(b_channel);
-							switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
+							switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
 							switch_core_session_rwunlock(b_session);
 						}
 					}
@@ -863,7 +863,7 @@
 	if ((other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (b_session = switch_core_session_locate(other_uuid))) {
 		switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
 		switch_channel_stop_broadcast(b_channel);
-		switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000);
+		switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
 		switch_core_session_rwunlock(b_session);
 	}
 
@@ -907,7 +907,7 @@
 			status = SWITCH_STATUS_SUCCESS;
 			switch_core_session_receive_message(session, &msg);
 
-			switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000);
+			switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
 			switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
 			if ((flags & SMF_REBRIDGE)
@@ -916,7 +916,7 @@
 				other_channel = switch_core_session_get_channel(other_session);
 				switch_assert(other_channel != NULL);
 				switch_core_session_receive_message(other_session, &msg);
-				switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000);
+				switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
 				switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 				switch_channel_clear_state_handler(other_channel, NULL);
 				switch_core_session_rwunlock(other_session);
@@ -934,8 +934,8 @@
 			} else {
 				switch_ivr_uuid_bridge(uuid, other_uuid);
 			}
-			switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000);
-			switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000);
+			switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
+			switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
 		}
 	}
 
@@ -980,8 +980,8 @@
 				} else {
 					switch_ivr_signal_bridge(session, other_session);
 				}
-				switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000);
-				switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000);
+				switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
+				switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
 				switch_core_session_rwunlock(other_session);
 			}
 		}

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Tue Sep  9 12:31:53 2008
@@ -129,7 +129,13 @@
 	switch_channel_set_flag(chan_a, CF_BRIDGED);
 
 
-	switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 1000000);
+	switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
+
+	if (!switch_channel_test_flag(chan_b, CF_BRIDGED)) {
+		switch_channel_hangup(chan_b, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		goto end_of_bridge_loop;
+	}
+
 
 	for (;;) {
 		switch_channel_state_t b_state;
@@ -782,7 +788,7 @@
 				data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data");
 				switch_core_session_execute_application(peer_session, app, data);
 			}
-
+			
 			switch_channel_set_private(peer_channel, "_bridge_", b_leg);
 			switch_channel_set_state(peer_channel, CS_EXCHANGE_MEDIA);
 			audio_bridge_thread(NULL, (void *) a_leg);

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Tue Sep  9 12:31:53 2008
@@ -802,18 +802,15 @@
 		timer_name = NULL;
 	}
 
-	if (!switch_strlen_zero(timer_name)) {
-		rtp_session->timer_name = switch_core_strdup(pool, timer_name);
-		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-		switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-		switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
-	}
-
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) && switch_strlen_zero(timer_name)) {
 		timer_name = "soft";
 	}
 
 	if (!switch_strlen_zero(timer_name)) {
+		rtp_session->timer_name = switch_core_strdup(pool, timer_name);
+		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+		switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+
 		if (switch_core_timer_init(&rtp_session->timer, timer_name, ms_per_packet / 1000, samples_per_interval, pool) == SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
 							  "Starting timer [%s] %d bytes per %dms\n", timer_name, samples_per_interval, ms_per_packet);
@@ -822,6 +819,9 @@
 			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);
 		}
+	} else {
+		switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+		switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
 	}
 
 	rtp_session->ready = 1;
@@ -1243,10 +1243,6 @@
 			goto end;
 		}
 
-		if (bytes == 1) {
-			continue;
-		}
-
 		if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && switch_sockaddr_get_port(rtp_session->from_addr)) {
 			const char *tx_host;
 			const char *old_host;



More information about the Freeswitch-svn mailing list