[Freeswitch-svn] [commit] r11422 - freeswitch/branches/1.0/src

FreeSWITCH SVN mikej at freeswitch.org
Thu Jan 22 14:51:26 PST 2009


Author: mikej
Date: Thu Jan 22 16:51:26 2009
New Revision: 11422

Log:
core: fix buffering issues (r:11101,11145)

Modified:
   freeswitch/branches/1.0/src/switch_core_file.c

Modified: freeswitch/branches/1.0/src/switch_core_file.c
==============================================================================
--- freeswitch/branches/1.0/src/switch_core_file.c	(original)
+++ freeswitch/branches/1.0/src/switch_core_file.c	Thu Jan 22 16:51:26 2009
@@ -161,11 +161,12 @@
 
 		if (fh->resampler->to_len < want || fh->resampler->to_len > orig_len) {
 			if (!fh->buffer) {
-				switch_buffer_create_dynamic(&fh->buffer, fh->resampler->to_len * 4, fh->resampler->to_len * 8, fh->resampler->to_len * 32);
+				int factor = fh->resampler->to_len * fh->samplerate / 1000;
+				switch_buffer_create_dynamic(&fh->buffer, factor, factor, 0);
 				switch_assert(fh->buffer);
 			}
 			if (!fh->dbuf) {
-				fh->dbuflen = fh->resampler->to_len * 8;
+				fh->dbuflen = want * 2;
 				fh->dbuf = switch_core_alloc(fh->memory_pool, fh->dbuflen);
 			}
 			switch_assert(fh->resampler->to_len <= fh->dbuflen);
@@ -174,7 +175,7 @@
 			switch_buffer_write(fh->buffer, fh->dbuf, fh->resampler->to_len * 2);
 
 			if (switch_buffer_inuse(fh->buffer) < want * 2) {
-				*len = want - fh->resampler->to_len;
+				*len = want;
 				goto more;
 			}
 			*len = switch_buffer_read(fh->buffer, data, orig_len * 2) / 2;



More information about the Freeswitch-svn mailing list