[Freeswitch-svn] [commit] r2704 - in freeswitch/trunk/src: . mod/applications/mod_conference mod/codecs/mod_g711 mod/endpoints/mod_exosip mod/timers/mod_threadtimer

Freeswitch SVN anthm at freeswitch.org
Thu Sep 14 18:11:31 EDT 2006


Author: anthm
Date: Thu Sep 14 18:11:30 2006
New Revision: 2704

Modified:
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
   freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/trunk/src/mod/timers/mod_threadtimer/mod_threadtimer.c
   freeswitch/trunk/src/switch.c
   freeswitch/trunk/src/switch_core.c

Log:
misc

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Thu Sep 14 18:11:30 2006
@@ -709,6 +709,10 @@
 	write_frame.data = data;
 	write_frame.buflen = sizeof(data);
 	write_frame.codec = &member->write_codec;
+
+	if (switch_test_flag(member->conference, CFLAG_ANSWERED)) {
+		switch_channel_answer(channel);
+	}
 	
 	/* Start a thread to read data and feed it into the buffer and use this thread to generate output */
 	launch_input_thread(member, switch_core_session_get_pool(member->session));
@@ -957,7 +961,7 @@
 			}
 		}
 	} /* Rinse ... Repeat */
-	
+
 	switch_clear_flag_locked(member, MFLAG_RUNNING);
 	switch_core_timer_destroy(&timer);
 
@@ -2344,9 +2348,12 @@
 		if (conference_outcall(conference, session, bridgeto, 60, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
 			goto done;
 		}
-	} //else 	
+	} else {	
 		// if we're not using "bridge:" set the conference answered flag
-		//switch_set_flag(conference, CFLAG_ANSWERED);
+		// and this isn't an outbound channel, answer the call
+		if (!switch_channel_test_flag(channel, CF_OUTBOUND)) 
+			switch_set_flag(conference, CFLAG_ANSWERED);
+	}
 
 
 

Modified: freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c	Thu Sep 14 18:11:30 2006
@@ -187,8 +187,8 @@
 
 /* Registration */
 
-#if 0
 
+
 static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
 	/*.ianacode */ 0,
@@ -208,7 +208,7 @@
 	/*.destroy */ switch_g711u_destroy
 };
 
-
+#if 0
 static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
 	/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
 	/*.ianacode */ 0,
@@ -268,6 +268,7 @@
 	/*.decode */ switch_g711u_decode,
 	/*.destroy */ switch_g711u_destroy,
 	///*.next */ &g711u_16k_implementation
+	&g711u_8k_60ms_implementation
 };
 
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c	Thu Sep 14 18:11:30 2006
@@ -585,7 +585,7 @@
 										   ms,
 										   flags,
 										   key,
-										   "soft",
+										   "thread_soft",
 										   &err, switch_core_session_get_pool(tech_pvt->session));
 
 	if (switch_rtp_ready(tech_pvt->rtp_session)) {

Modified: freeswitch/trunk/src/mod/timers/mod_threadtimer/mod_threadtimer.c
==============================================================================
--- freeswitch/trunk/src/mod/timers/mod_threadtimer/mod_threadtimer.c	(original)
+++ freeswitch/trunk/src/mod/timers/mod_threadtimer/mod_threadtimer.c	Thu Sep 14 18:11:30 2006
@@ -37,16 +37,18 @@
 static struct {
 	int32_t RUNNING;
 	switch_mutex_t *mutex;
+	uint32_t timer_milliseconds;
+	uint32_t timer_microseconds;
 } globals;
 
 static const char modname[] = "mod_threadtimer";
 #define MAX_ELEMENTS 1000
 
 struct timer_private {
-	uint32_t tick;
-	uint32_t reference;
+	uint64_t tick;
+	uint64_t reference;
 	uint32_t interval;
-	switch_mutex_t *mutex;
+	//switch_mutex_t *mutex;
 	struct timer_private *next;
 };
 
@@ -60,11 +62,30 @@
 
 static timer_head_t *TIMER_MATRIX[MAX_ELEMENTS+1];
 
+#define IDLE_SPEED 100
+
+static inline void set_timer(void)
+{
+	uint32_t index = 0, min = IDLE_SPEED;
+
+	for(index = 0; index < MAX_ELEMENTS; index++) {
+		if (TIMER_MATRIX[index] && TIMER_MATRIX[index]->private_info) {
+			if (min > index) {
+				min = index;
+			}
+		}
+	}
+
+	globals.timer_milliseconds = min;
+	globals.timer_microseconds = min * 1000;
+}
+
 static inline switch_status_t timer_init(switch_timer_t *timer)
 {
 	timer_private_t *private_info;
 	timer_head_t *head;
 
+
 	if ((private_info = switch_core_alloc(timer->memory_pool, sizeof(*private_info)))) {
 		timer->private_info = private_info;
 		if (!TIMER_MATRIX[timer->interval]) {
@@ -76,35 +97,28 @@
 
 		head = TIMER_MATRIX[timer->interval];
 
-		switch_mutex_init(&private_info->mutex, SWITCH_MUTEX_NESTED, timer->memory_pool);
+		//switch_mutex_init(&private_info->mutex, SWITCH_MUTEX_NESTED, timer->memory_pool);
 		private_info->interval = timer->interval;
 
 		switch_mutex_lock(head->mutex);
 		private_info->next = head->private_info;
 		head->private_info = private_info;
 		switch_mutex_unlock(head->mutex);
-		
+		set_timer();
+
 		return SWITCH_STATUS_SUCCESS;
 	}
 
 	return SWITCH_STATUS_MEMERR;
 }
 
-#define MAX_TICKS 0xFFFFFF00
-#define check_overflow(p) if (p->reference > MAX_TICKS) {\
-		switch_mutex_lock(p->mutex);\
-		p->reference = p->tick = 0;\
-		switch_mutex_unlock(p->mutex);\
-	}\
-
-
 static inline switch_status_t timer_step(switch_timer_t *timer)
 {
 	timer_private_t *private_info = timer->private_info;
 
-	switch_mutex_lock(private_info->mutex);
+	//switch_mutex_lock(private_info->mutex);
 	private_info->reference += private_info->interval;
-	switch_mutex_unlock(private_info->mutex);
+	//switch_mutex_unlock(private_info->mutex);
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -119,7 +133,6 @@
 	while (private_info->tick < private_info->reference) {
 		switch_yield(1000);
 	}
-	check_overflow(private_info);
 	timer->samplecount += timer->samples;
 
 	return SWITCH_STATUS_SUCCESS;
@@ -131,15 +144,14 @@
 	timer_private_t *private_info = timer->private_info;
 	switch_status_t status;
 
-	switch_mutex_lock(private_info->mutex);
+	//switch_mutex_lock(private_info->mutex);
 	if (private_info->tick < private_info->reference) {
 		status = SWITCH_STATUS_FALSE;
 	} else {
 		private_info->reference += private_info->interval;
-		check_overflow(private_info);
 		status = SWITCH_STATUS_SUCCESS;
 	}
-	switch_mutex_unlock(private_info->mutex);
+	//switch_mutex_unlock(private_info->mutex);
 
 	return status;
 }
@@ -167,7 +179,7 @@
 		last = ptr;
 	}
 	switch_mutex_unlock(head->mutex);
-	
+	set_timer();
 	timer->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -205,6 +217,8 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+
+
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
 {
 	switch_time_t reference = switch_time_now();
@@ -214,19 +228,22 @@
 	
 	memset(&globals, 0, sizeof(globals));
 	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+	globals.timer_microseconds = IDLE_SPEED  * 1000;
+	globals.timer_milliseconds = IDLE_SPEED;
 
 	globals.RUNNING = 1;
 
 	while(globals.RUNNING == 1) {
-		reference += 1000;
-		
+		reference += globals.timer_microseconds;
+		//printf("TEST %d\n", globals.timer_microseconds);
 		while (switch_time_now() < reference) {
-			switch_yield(500);
+			//switch_yield((reference - now) - 1000);
+			switch_yield(globals.timer_microseconds >> 1);
 		}
 
-		current_ms++;
+		current_ms += globals.timer_milliseconds;
 
-		for (x = 0; x < 1000; x++) {
+		for (x = 0; x < MAX_ELEMENTS; x++) {
 			int i = x, index;
 			if (i == 0) {
 				i = 1;
@@ -237,9 +254,9 @@
 			if (TIMER_MATRIX[index] && TIMER_MATRIX[index]->private_info) {
 				switch_mutex_lock(TIMER_MATRIX[index]->mutex);
 				for (ptr = TIMER_MATRIX[index]->private_info; ptr; ptr = ptr->next) {
-					switch_mutex_lock(ptr->mutex);
+					//switch_mutex_lock(ptr->mutex);
 					ptr->tick += ptr->interval;
-					switch_mutex_unlock(ptr->mutex);
+					//switch_mutex_unlock(ptr->mutex);
 				}
 				switch_mutex_unlock(TIMER_MATRIX[index]->mutex);
 			}

Modified: freeswitch/trunk/src/switch.c
==============================================================================
--- freeswitch/trunk/src/switch.c	(original)
+++ freeswitch/trunk/src/switch.c	Thu Sep 14 18:11:30 2006
@@ -62,7 +62,7 @@
 #ifdef WIN32
 	SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
 #else
-	//nice(-20);
+	//nice(-19);
 #endif
 }
 

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Thu Sep 14 18:11:30 2006
@@ -3624,6 +3624,7 @@
 		switch_event_fire(&event);
 	}
 
+//#define USE_MLOCKALL
 #ifdef HAVE_MLOCKALL
 #ifdef USE_MLOCKALL
 	mlockall(MCL_CURRENT|MCL_FUTURE);



More information about the Freeswitch-svn mailing list