[asterisk-commits] russell: branch russell/jack r93154 - /team/russell/jack/apps/app_jack.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Dec 15 13:45:15 CST 2007


Author: russell
Date: Sat Dec 15 13:45:15 2007
New Revision: 93154

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93154
Log:
run resample_process in a loop to ensure all samples get processed

Modified:
    team/russell/jack/apps/app_jack.c

Modified: team/russell/jack/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/russell/jack/apps/app_jack.c?view=diff&rev=93154&r1=93153&r2=93154
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Sat Dec 15 13:45:15 2007
@@ -266,18 +266,35 @@
 
 	if (jack_data->resampler) {
 		float in_buf[f->samples];
-		int in_buf_used;
+		int in_buf_used = 0;
+		int out_buf_used = 0;
 
 		/* XXX Does this need to be normalized? */
 		for (i = 0; i < f->samples; i++)
 			in_buf[i] = s_buf[i];
 
-		/* XXX Need to run this in a loop to ensure all samples get processed */
-		resample_process(jack_data->resampler, jack_data->resample_factor,
-			in_buf, sizeof(in_buf), 0 /* XXX Should this ever get set? */, &in_buf_used, 
-			f_buf, sizeof(f_buf));
+		while (in_buf_used < sizeof(in_buf)) {
+			int res;
+
+			res = resample_process(jack_data->resampler, jack_data->resample_factor,
+				&in_buf[in_buf_used / sizeof(in_buf[0])], sizeof(in_buf) - in_buf_used, 
+				0, &in_buf_used, 
+				&f_buf[out_buf_used / sizeof(f_buf[0])], sizeof(f_buf) - out_buf_used);
+
+			if (res < 0)
+				break;
+
+			out_buf_used += res;
+
+			if (out_buf_used == sizeof(f_buf)) {
+				ast_log(LOG_ERROR, "Output buffer filled ... need to increase its size\n");
+				break;
+			}
+		}
 
 		f_buf_used = sizeof(f_buf[0]) * jack_data->resample_factor;
+		if (f_buf_used > sizeof(f_buf))
+			f_buf_used = sizeof(f_buf);
 	} else {
 		/* No resampling needed */
 




More information about the asterisk-commits mailing list