[Freeswitch-svn] [commit] r7079 - in freeswitch/trunk: conf/dialplan src src/include/private

Freeswitch SVN anthm at freeswitch.org
Thu Jan 3 19:19:09 EST 2008


Author: anthm
Date: Thu Jan  3 19:19:09 2008
New Revision: 7079

Modified:
   freeswitch/trunk/conf/dialplan/default.xml
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/switch_core_io.c
   freeswitch/trunk/src/switch_core_session.c

Log:
add lock

Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml	(original)
+++ freeswitch/trunk/conf/dialplan/default.xml	Thu Jan  3 19:19:09 2008
@@ -196,6 +196,7 @@
     -->
     <extension name="unpark">
       <condition field="destination_number" expression="^5901$">
+	<action application="answer"/>
 	<action application="fifo" data="5900@$${domain} out nowait"/>
       </condition>
     </extension>
@@ -209,7 +210,7 @@
     -->
     <extension name="park">
       <condition field="source" expression="mod_sofia" continue="on-true"/>
-      <condition field="${sip_refer_to}" expression="park\+(.*)@(.*)>" continue="on-true">
+      <condition field="destination_number" expression="park\+(\d+)" continue="on-true">
 	<action application="fifo" data="$1@$${domain} in undef $${moh_uri}"/>
       </condition>
     </extension> 
@@ -222,7 +223,7 @@
       <condition field="destination_number" expression="^parking$" continue="on-true"/>
       <condition field="${sip_to_params}" expression="fifo\=(\d+)">
 	<action application="answer"/>
-	<action application="fifo" data="$1@$${domain} out undef"/>
+	<action application="fifo" data="$1@$${domain} out nowait"/>
       </condition>
     </extension>
 

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	Thu Jan  3 19:19:09 2008
@@ -119,6 +119,7 @@
 	switch_audio_resampler_t *write_resampler;
 
 	switch_mutex_t *mutex;
+	switch_mutex_t *resample_mutex;
 	switch_thread_cond_t *cond;
 
 	switch_thread_rwlock_t *rwlock;

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Thu Jan  3 19:19:09 2008
@@ -191,11 +191,15 @@
 			switch (status) {
 			case SWITCH_STATUS_RESAMPLE:
 				if (!session->read_resampler) {
-					if (switch_resample_create(&session->read_resampler,
-											   read_frame->codec->implementation->actual_samples_per_second,
-											   read_frame->codec->implementation->bytes_per_frame * 20,
-											   session->read_codec->implementation->actual_samples_per_second,
-											   session->read_codec->implementation->bytes_per_frame * 20, session->pool) != SWITCH_STATUS_SUCCESS) {
+					switch_mutex_lock(session->resample_mutex);
+					status = switch_resample_create(&session->read_resampler,
+													read_frame->codec->implementation->actual_samples_per_second,
+													read_frame->codec->implementation->bytes_per_frame * 20,
+													session->read_codec->implementation->actual_samples_per_second,
+													session->read_codec->implementation->bytes_per_frame * 20, session->pool);
+					switch_mutex_unlock(session->resample_mutex);
+					
+					if (status != SWITCH_STATUS_SUCCESS) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
 						status = SWITCH_STATUS_FALSE;
 						goto done;
@@ -213,8 +217,10 @@
 				break;
 			case SWITCH_STATUS_NOOP:
 				if (session->read_resampler) {
+					switch_mutex_lock(session->resample_mutex);
 					switch_resample_destroy(&session->read_resampler);
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
+					switch_mutex_unlock(session->resample_mutex);					
 				}
 
 				status = SWITCH_STATUS_SUCCESS;
@@ -240,6 +246,7 @@
 #if 0
 		if (session->read_resampler) {
 			short *data = read_frame->data;
+			switch_mutex_lock(session->resample_mutex);
 
 			session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
 			session->read_resampler->to_len =
@@ -249,6 +256,8 @@
 			read_frame->samples = session->read_resampler->to_len;
 			read_frame->datalen = session->read_resampler->to_len * 2;
 			read_frame->rate = session->read_resampler->to_rate;
+			switch_mutex_unlock(session->resample_mutex);
+			
 		}
 #endif
 
@@ -514,11 +523,13 @@
 			case SWITCH_STATUS_RESAMPLE:
 				write_frame = &session->raw_write_frame;
 				if (!session->write_resampler) {
+					switch_mutex_lock(session->resample_mutex);
 					status = switch_resample_create(&session->write_resampler,
 													frame->codec->implementation->actual_samples_per_second,
 													frame->codec->implementation->bytes_per_frame * 20,
 													session->write_codec->implementation->actual_samples_per_second,
 													session->write_codec->implementation->bytes_per_frame * 20, session->pool);
+					switch_mutex_unlock(session->resample_mutex);
 					if (status != SWITCH_STATUS_SUCCESS) {
 						goto done;
 					}
@@ -538,8 +549,10 @@
 				return SWITCH_STATUS_SUCCESS;
 			case SWITCH_STATUS_NOOP:
 				if (session->write_resampler) {
+					switch_mutex_lock(session->resample_mutex);
 					switch_resample_destroy(&session->write_resampler);
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating write resampler\n");
+					switch_mutex_unlock(session->resample_mutex);
 				}
 				write_frame = frame;
 				status = SWITCH_STATUS_SUCCESS;
@@ -552,6 +565,8 @@
 
 		if (session->write_resampler) {
 			short *data = write_frame->data;
+			
+			switch_mutex_lock(session->resample_mutex);
 
 			session->write_resampler->from_len = write_frame->datalen / 2;
 			switch_short_to_float(data, session->write_resampler->from, session->write_resampler->from_len);
@@ -568,6 +583,7 @@
 			write_frame->samples = session->write_resampler->to_len;
 			write_frame->datalen = write_frame->samples * 2;
 			write_frame->rate = session->write_resampler->to_rate;
+			switch_mutex_unlock(session->resample_mutex);
 		}
 
 		if (session->bugs) {
@@ -744,11 +760,14 @@
 								session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
 								write_frame = &session->enc_write_frame;
 								if (!session->read_resampler) {
+									switch_mutex_lock(session->resample_mutex);
 									status = switch_resample_create(&session->read_resampler,
 																	frame->codec->implementation->actual_samples_per_second,
 																	frame->codec->implementation->bytes_per_frame * 20,
 																	session->write_codec->implementation->actual_samples_per_second,
 																	session->write_codec->implementation->bytes_per_frame * 20, session->pool);
+									switch_mutex_unlock(session->resample_mutex);
+									
 									if (status != SWITCH_STATUS_SUCCESS) {
 										goto done;
 									}
@@ -766,8 +785,10 @@
 								break;
 							case SWITCH_STATUS_NOOP:
 								if (session->read_resampler) {
+									switch_mutex_lock(session->resample_mutex);
 									switch_resample_destroy(&session->read_resampler);
 									switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
+									switch_mutex_unlock(session->resample_mutex);
 								}
 								enc_frame->codec = session->write_codec;
 								enc_frame->samples = enc_frame->datalen / sizeof(int16_t);
@@ -788,7 +809,8 @@
 
 							if (session->read_resampler) {
 								short *data = write_frame->data;
-
+								switch_mutex_lock(session->resample_mutex);
+								
 								session->read_resampler->from_len =
 									switch_short_to_float(data, session->read_resampler->from, (int) write_frame->datalen / 2);
 								session->read_resampler->to_len = (uint32_t)
@@ -799,6 +821,8 @@
 								write_frame->samples = session->read_resampler->to_len;
 								write_frame->datalen = session->read_resampler->to_len * 2;
 								write_frame->rate = session->read_resampler->to_rate;
+								switch_mutex_unlock(session->resample_mutex);
+								
 							}
 							if (flag & SFF_CNG) {
 								switch_set_flag(write_frame, SFF_CNG);

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Thu Jan  3 19:19:09 2008
@@ -813,6 +813,7 @@
 	session->enc_read_frame.buflen = sizeof(session->enc_read_buf);
 
 	switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED, session->pool);
+	switch_mutex_init(&session->resample_mutex, SWITCH_MUTEX_NESTED, session->pool);
 	switch_thread_rwlock_create(&session->bug_rwlock, session->pool);
 	switch_thread_cond_create(&session->cond, session->pool);
 	switch_thread_rwlock_create(&session->rwlock, session->pool);



More information about the Freeswitch-svn mailing list