Revision
16003
Author
brian
Date
2009-12-18 17:19:53 -0600 (Fri, 18 Dec 2009)

Log Message

FSCORE-517

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_module_interfaces.h (16002 => 16003)


--- freeswitch/trunk/src/include/switch_module_interfaces.h	2009-12-18 23:00:41 UTC (rev 16002)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h	2009-12-18 23:19:53 UTC (rev 16003)
@@ -583,6 +583,7 @@
 	void *private_info;
 	switch_payload_t agreed_pt;
 	switch_mutex_t *mutex;
+	struct switch_codec *next;
 };
 
 /*! \brief A table of settings and callbacks that define a paticular implementation of a codec */

Modified: freeswitch/trunk/src/switch_core_codec.c (16002 => 16003)


--- freeswitch/trunk/src/switch_core_codec.c	2009-12-18 23:00:41 UTC (rev 16002)
+++ freeswitch/trunk/src/switch_core_codec.c	2009-12-18 23:19:53 UTC (rev 16003)
@@ -97,7 +97,7 @@
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	char tmp[30];
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+	
 	switch_mutex_lock(session->codec_read_mutex);
 
 	if (codec && (!codec->implementation || !switch_core_codec_ready(codec))) {
@@ -109,6 +109,9 @@
 			session->read_codec = session->real_read_codec = codec;
 			session->read_impl = *codec->implementation;
 		} else {
+			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Push codec %s:%d\n",
+							  switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
+			codec->next = session->read_codec;
 			session->read_codec = codec;
 			session->read_impl = *codec->implementation;
 		}
@@ -116,7 +119,17 @@
 		if (session->read_codec == session->real_read_codec) {
 			goto end;
 		}
-		if (session->real_read_codec) {
+		
+		if (session->read_codec->next) {
+			switch_codec_t *old = session->read_codec;
+			session->read_codec = session->read_codec->next;
+			session->read_impl = *session->read_codec->implementation;
+			old->next = NULL;
+			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Restore previous codec %s:%d.\n",
+							  switch_channel_get_name(session->channel), 
+							  session->read_codec->implementation->iananame, session->read_codec->implementation->ianacode);
+			
+		} else if (session->real_read_codec) {
 			session->read_codec = session->real_read_codec;
 			session->read_impl = *session->real_read_codec->implementation;
 			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Restore original codec.\n");

Modified: freeswitch/trunk/src/switch_ivr_play_say.c (16002 => 16003)


--- freeswitch/trunk/src/switch_ivr_play_say.c	2009-12-18 23:00:41 UTC (rev 16002)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	2009-12-18 23:19:53 UTC (rev 16003)
@@ -1081,7 +1081,7 @@
 								  read_impl.number_of_channels,
 								  read_impl.actual_samples_per_second,
 								  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
-			switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+			switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
 			status = SWITCH_STATUS_NOTFOUND;
 			continue;
 		}
@@ -1159,7 +1159,7 @@
 					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
 									  "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
 					switch_core_file_close(fh);
-					switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+					switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
 					status = SWITCH_STATUS_GENERR;
 					continue;
 				}
@@ -1179,7 +1179,7 @@
 				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Setup timer failed!\n");
 				switch_core_codec_destroy(&codec);
 				switch_core_file_close(fh);
-				switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+				switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
 				status = SWITCH_STATUS_GENERR;
 				continue;
 			}
@@ -1476,7 +1476,7 @@
 
 	switch_safe_free(abuf);
 
-	switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
+	switch_core_session_reset(session, SWITCH_FALSE, SWITCH_FALSE);
 	return status;
 }
 
@@ -1513,7 +1513,7 @@
 								  read_impl.number_of_channels,
 								  read_impl.actual_samples_per_second,
 								  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
-			switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+			switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
 			return SWITCH_STATUS_NOTFOUND;
 		}
 		switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
@@ -2100,7 +2100,7 @@
 
 	timer_name = switch_channel_get_variable(channel, "timer_name");
 
-	switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
+	switch_core_session_reset(session, SWITCH_FALSE, SWITCH_FALSE);
 	read_codec = switch_core_session_get_read_codec(session);
 
 	rate = read_impl.actual_samples_per_second;