[asterisk-commits] russell: branch russell/jack r93492 - /team/russell/jack/apps/app_jack.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 17 19:55:06 CST 2007
Author: russell
Date: Mon Dec 17 19:55:05 2007
New Revision: 93492
URL: http://svn.digium.com/view/asterisk?view=rev&rev=93492
Log:
If jackd is running in 8 kHz mode, things are working fine. However, resampling
isn't working yet. Previously it just blew up after making quite a mess of the
stack. Now it just sounds terrible. That's an improvement, I think.
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=93492&r1=93491&r2=93492
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Mon Dec 17 19:55:05 2007
@@ -190,27 +190,28 @@
int out_buf_used = 0;
float f_buf[nframes];
- while (in_buf_used < (nframes * sizeof(float))) {
+ while (in_buf_used < nframes) {
int res;
res = resample_process(jack_data->input_resampler,
jack_data->input_resample_factor,
- &in_buf[in_buf_used / sizeof(in_buf[0])], (nframes * sizeof(float)) - in_buf_used,
+ &in_buf[in_buf_used], nframes - in_buf_used,
0, &in_buf_used,
- &f_buf[out_buf_used / sizeof(f_buf[0])], sizeof(f_buf) - out_buf_used);
+ &f_buf[out_buf_used], ARRAY_LEN(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");
+ if (out_buf_used == ARRAY_LEN(f_buf)) {
+ ast_log(LOG_ERROR, "Output buffer filled ... need to increase its size, "
+ "nframes '%d', out_buf_used '%d'\n", nframes, out_buf_used);
break;
}
}
- for (i = 0; i < nframes; i++)
+ for (i = 0; i < out_buf_used; i++)
s_buf[i] = f_buf[i] * (SHRT_MAX / FLT_MAX);
} else {
/* No resampling needed */
@@ -388,6 +389,8 @@
int16_t *s_buf = f->data;
size_t res;
+ memset(f_buf, 0, sizeof(f_buf));
+
if (!jack_data->output_resample_factor)
alloc_resampler(jack_data, 0);
@@ -396,45 +399,47 @@
int in_buf_used = 0;
int out_buf_used = 0;
+ memset(in_buf, 0, sizeof(in_buf));
+
for (i = 0; i < f->samples; i++)
in_buf[i] = s_buf[i] * (FLT_MAX / SHRT_MAX);
- while (in_buf_used < sizeof(in_buf)) {
+ while (in_buf_used < ARRAY_LEN(in_buf)) {
int res;
res = resample_process(jack_data->output_resampler,
jack_data->output_resample_factor,
- &in_buf[in_buf_used / sizeof(in_buf[0])], sizeof(in_buf) - in_buf_used,
+ &in_buf[in_buf_used], ARRAY_LEN(in_buf) - in_buf_used,
0, &in_buf_used,
- &f_buf[out_buf_used / sizeof(f_buf[0])], sizeof(f_buf) - out_buf_used);
+ &f_buf[out_buf_used], ARRAY_LEN(f_buf) - out_buf_used);
if (res < 0)
break;
out_buf_used += res;
- if (out_buf_used == sizeof(f_buf)) {
+ if (out_buf_used == ARRAY_LEN(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->output_resample_factor;
- if (f_buf_used > sizeof(f_buf))
- f_buf_used = sizeof(f_buf);
+ f_buf_used = out_buf_used;
+ if (f_buf_used > ARRAY_LEN(f_buf))
+ f_buf_used = ARRAY_LEN(f_buf);
} else {
/* No resampling needed */
for (i = 0; i < f->samples; i++)
f_buf[i] = s_buf[i] * (FLT_MAX / SHRT_MAX);
- f_buf_used = sizeof(f_buf[0]) * f->samples;
- }
-
- res = jack_ringbuffer_write(jack_data->output_rb, (const char *) f_buf, f_buf_used);
- if (res != f_buf_used) {
+ f_buf_used = f->samples;
+ }
+
+ res = jack_ringbuffer_write(jack_data->output_rb, (const char *) f_buf, f_buf_used * sizeof(float));
+ if (res != (f_buf_used * sizeof(float))) {
ast_log(LOG_WARNING, "Tried to write %d bytes to the ringbuffer, but only wrote %d\n",
- f_buf_used, res);
+ f_buf_used * sizeof(float), res);
}
return 0;
More information about the asterisk-commits
mailing list