[Freeswitch-svn] [commit] r7835 - in freeswitch/trunk/src: . include

Freeswitch SVN anthm at freeswitch.org
Fri Mar 7 17:40:21 EST 2008


Author: anthm
Date: Fri Mar  7 17:40:20 2008
New Revision: 7835

Modified:
   freeswitch/trunk/src/include/switch_module_interfaces.h
   freeswitch/trunk/src/switch_ivr_play_say.c

Log:
fix MODLANG-53

Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h	(original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h	Fri Mar  7 17:40:20 2008
@@ -297,6 +297,7 @@
 	char *handler;
 	int64_t pos;
 	switch_buffer_t *audio_buffer;
+	switch_buffer_t *sp_audio_buffer;
 	uint32_t thresh;
 	uint32_t silence_hits;
 	uint32_t offset_pos;

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Fri Mar  7 17:40:20 2008
@@ -914,10 +914,13 @@
 			memset(abuf, 0, framelen);
 			olen = ilen;
 			do_speed = 0;
+		} else if (fh->sp_audio_buffer && (switch_buffer_inuse(fh->sp_audio_buffer) > (switch_size_t) (framelen))) {
+			switch_buffer_read(fh->sp_audio_buffer, abuf, framelen);
+			olen = asis ? framelen : ilen;
+			do_speed = 0;
 		} else if (fh->audio_buffer && (switch_buffer_inuse(fh->audio_buffer) > (switch_size_t) (framelen))) {
 			switch_buffer_read(fh->audio_buffer, abuf, framelen);
 			olen = asis ? framelen : ilen;
-			do_speed = 0;
 		} else {
 			olen = FILE_STARTSAMPLES;
 			if (!asis) {
@@ -945,7 +948,7 @@
 		}
 
 		if (!asis && fh->audio_buffer && last_speed > -1 && last_speed != fh->speed) {
-			switch_buffer_zero(fh->audio_buffer);
+			switch_buffer_zero(fh->sp_audio_buffer);
 		}
 
 		if (switch_test_flag(fh, SWITCH_FILE_SEEK)) {
@@ -954,6 +957,7 @@
 			switch_clear_flag(fh, SWITCH_FILE_SEEK);
 		}
 
+
 		if (!asis && fh->speed && do_speed) {
 			float factor = 0.25f * abs(fh->speed);
 			switch_size_t newlen, supplement, step;
@@ -961,11 +965,19 @@
 			switch_size_t wrote = 0;
 
 			supplement = (int) (factor * olen);
+			if (!supplement) {
+				supplement = 1;
+			}
 			newlen = (fh->speed > 0) ? olen - supplement : olen + supplement;
+			
 			step = (fh->speed > 0) ? (newlen / supplement) : (olen / supplement);
 
+			if (!fh->sp_audio_buffer) {
+				switch_buffer_create_dynamic(&fh->sp_audio_buffer, 1024, 1024, 0);
+			}
+
 			while ((wrote + step) < newlen) {
-				switch_buffer_write(fh->audio_buffer, bp, step * 2);
+				switch_buffer_write(fh->sp_audio_buffer, bp, step * 2);
 				wrote += step;
 				bp += step;
 				if (fh->speed > 0) {
@@ -976,13 +988,13 @@
 					f = (float) (*bp + *(bp + 1) + *(bp - 1));
 					f /= 3;
 					s = (short) f;
-					switch_buffer_write(fh->audio_buffer, &s, 2);
+					switch_buffer_write(fh->sp_audio_buffer, &s, 2);
 					wrote++;
 				}
 			}
 			if (wrote < newlen) {
 				switch_size_t r = newlen - wrote;
-				switch_buffer_write(fh->audio_buffer, bp, r * 2);
+				switch_buffer_write(fh->sp_audio_buffer, bp, r * 2);
 				wrote += r;
 			}
 			last_speed = fh->speed;
@@ -1064,6 +1076,7 @@
 	
 	switch_core_file_close(fh);
 	switch_buffer_destroy(&fh->audio_buffer);
+	switch_buffer_destroy(&fh->sp_audio_buffer);
 	if (!asis) {
 		switch_core_codec_destroy(&codec);
 	}



More information about the Freeswitch-svn mailing list