[Freeswitch-svn] [commit] r2774 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia mod/timers/mod_softtimer

Freeswitch SVN anthm at freeswitch.org
Thu Sep 21 15:52:56 EDT 2006


Author: anthm
Date: Thu Sep 21 15:52:56 2006
New Revision: 2774

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c
   freeswitch/trunk/src/switch_buffer.c
   freeswitch/trunk/src/switch_rtp.c

Log:
undo abundant evil -props to the man who won't stfu and leave me alone to code <- his request i say that....

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	Thu Sep 21 15:52:56 2006
@@ -1713,6 +1713,8 @@
 				   NUTAG_EARLY_MEDIA(1),				   
 				   NUTAG_AUTOANSWER(0),
 				   NUTAG_AUTOALERT(0),
+				   //NUTAG_ALLOW("REGISTER"),
+				   //SIPTAG_ALLOW_STR("REGISTER"),
 				   SIPTAG_SUPPORTED_STR("100rel, precondition"),
 				   TAG_END());
 				   

Modified: freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c
==============================================================================
--- freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c	(original)
+++ freeswitch/trunk/src/mod/timers/mod_softtimer/mod_softtimer.c	Thu Sep 21 15:52:56 2006
@@ -37,8 +37,6 @@
 static struct {
 	int32_t RUNNING;
 	switch_mutex_t *mutex;
-	uint32_t timer_milliseconds;
-	switch_interval_time_t timer_microseconds;
 } globals;
 
 static const char modname[] = "mod_softtimer";
@@ -60,22 +58,6 @@
 #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].count) {
-			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;
@@ -86,8 +68,6 @@
 		switch_mutex_unlock(globals.mutex);
 		timer->private_info = private_info;
 		private_info->reference = TIMER_MATRIX[timer->interval].tick;
-		set_timer();
-
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -113,7 +93,6 @@
 		switch_yield(1000);
 	}
 	timer->samplecount += timer->samples;
-
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -139,7 +118,6 @@
 	switch_mutex_lock(globals.mutex);
 	TIMER_MATRIX[timer->interval].count--;
 	switch_mutex_unlock(globals.mutex);
-	set_timer();
 	timer->private_info = NULL;
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -187,21 +165,17 @@
 	
 	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 += globals.timer_microseconds;
+		reference += 1000;
 
 		while (switch_time_now() < reference) {
-			//switch_yield((reference - now) - 1000);
-			//switch_yield(globals.timer_microseconds >> 1);
 			switch_yield(1000);
 		}
 
-		current_ms += globals.timer_milliseconds;
+		current_ms++;
 
 		for (x = 0; x < MAX_ELEMENTS; x++) {
 			int i = x, index;

Modified: freeswitch/trunk/src/switch_buffer.c
==============================================================================
--- freeswitch/trunk/src/switch_buffer.c	(original)
+++ freeswitch/trunk/src/switch_buffer.c	Thu Sep 21 15:52:56 2006
@@ -40,7 +40,7 @@
 
 struct switch_buffer {
 	switch_byte_t *data;
-	switch_byte_t *front;
+	switch_byte_t *head;
 	switch_size_t used;
 	switch_size_t datalen;
 	switch_size_t max_len;
@@ -57,7 +57,7 @@
 		&& (new_buffer->data = switch_core_alloc(pool, max_len)) != 0) {
 		new_buffer->datalen = max_len;
 		new_buffer->id = buffer_id++;
-		new_buffer->front = new_buffer->data;
+		new_buffer->head = new_buffer->data;
 		*buffer = new_buffer;
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -86,7 +86,7 @@
 		new_buffer->datalen = start_len;
 		new_buffer->id = buffer_id++;
 		new_buffer->blocksize = blocksize;
-		new_buffer->front = new_buffer->data;
+		new_buffer->head = new_buffer->data;
 		switch_set_flag(new_buffer, SWITCH_BUFFER_FLAG_DYNAMIC);
 		
 		*buffer = new_buffer;
@@ -143,10 +143,11 @@
 		reading = buffer->used;
 	}
 
-	memmove(buffer->data, buffer->data + reading, buffer->datalen - reading);
-	buffer->used -= datalen;
+	memmove(buffer->data, buffer->data + reading, reading);
+	buffer->head = buffer->data;
+	buffer->used -= reading;
 
-	return buffer->datalen;
+	return buffer->used;
 }
 
 SWITCH_DECLARE(switch_size_t) switch_buffer_read(switch_buffer_t *buffer, void *data, switch_size_t datalen)
@@ -166,12 +167,11 @@
 		reading = buffer->used;
 	}
 
-	memcpy(data, buffer->front, reading);
-
-	buffer->front += reading;
+	memcpy(data, buffer->head, reading);
 	buffer->used -= reading;
+	buffer->head += reading;
 
-	//if (buffer->id == 3) printf("%u o %d = %d\n", buffer->id, (uint32_t)reading, (uint32_t)buffer->used);
+	//if (buffer->id == 4) printf("%u o %d = %d\n", buffer->id, (uint32_t)reading, (uint32_t)buffer->used);
 	return reading;
 }
 
@@ -182,28 +182,33 @@
 	assert(buffer != NULL);
 	assert(data != NULL);
 	assert(buffer->data != NULL);
+	
+	if (!datalen) {
+		return buffer->used;
+	}
 
 	freespace = buffer->datalen - buffer->used;
 
-	if (buffer->used && buffer->data != buffer->front) {
-		memmove(buffer->data, buffer->front, buffer->used);
-		buffer->front = buffer->data;
+	if (buffer->data != buffer->head) {
+		memmove(buffer->data, buffer->head, buffer->used);
+		buffer->head = buffer->data;
 	}
 
 	if (switch_test_flag(buffer, SWITCH_BUFFER_FLAG_DYNAMIC)) {
 		if (freespace < datalen) {
 			switch_size_t new_size, new_block_size;
+
 			new_size = buffer->datalen + datalen;
 			new_block_size = buffer->datalen + buffer->blocksize;
 
 			if (new_block_size > new_size) {
 				new_size = new_block_size;
 			}
-
+			buffer->head = buffer->data;
 			if (!(buffer->data = realloc(buffer->data, new_size))) {
 				return 0;
 			}
-			buffer->front = buffer->data;
+			buffer->head = buffer->data;
 			buffer->datalen = new_size;
 		}
 	}
@@ -216,7 +221,7 @@
 		memcpy(buffer->data + buffer->used, data, datalen);
 		buffer->used += datalen;
 	}
-	//if (buffer->id == 3) printf("%u i %d = %d\n", buffer->id, (uint32_t)datalen, (uint32_t)buffer->used);
+	//if (buffer->id == 4) printf("%u i %d = %d\n", buffer->id, (uint32_t)datalen, (uint32_t)buffer->used);
 
 	return buffer->used;
 }
@@ -227,7 +232,7 @@
     assert(buffer->data != NULL);
 
 	buffer->used = 0;
-	
+	buffer->head = buffer->data;
 }
 
 SWITCH_DECLARE(void) switch_buffer_destroy(switch_buffer_t **buffer)

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Thu Sep 21 15:52:56 2006
@@ -389,7 +389,7 @@
 
 	switch_mutex_init(&rtp_session->flag_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
 	switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
-	switch_buffer_create(rtp_session->pool, &rtp_session->dtmf_data.dtmf_buffer, 128);
+	switch_buffer_create_dynamic(&rtp_session->dtmf_data.dtmf_buffer, 128, 128, 0);
 	/* for from address on recvfrom calls */
 	switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, rtp_session->pool);
 	



More information about the Freeswitch-svn mailing list