echo-cancel: Enable different blocksizes for sink and source

In order to support different blocksizes for source and sink (e.g, for
4-to-1 beamforming/echo canceling which involves 4 record channels and 1
playback channel) the AEC API is altered:

The blocksize for source and sink may differ (due to different sample
specs) but the number of frames that are processed in one invokation of
the AEC implementation's run() function is the same for the playback and
the record stream. Consequently, the AEC implementation's init()
function initalizes 'nframes' instead of 'blocksize' and the source's
and sink's blocksizes are derived from 'nframes'. The old API also
caused code duplication in each AEC implementation's init function for
the compution of the blocksize, which is eliminated by the new API.

Signed-off-by: Stefan Huber <s.huber@bct-electronic.com>
Acked-by: Peter Meerwald <p.meerwald@bct-electronic.com>
This commit is contained in:
Stefan Huber 2012-12-20 11:33:04 +01:00 committed by Tanu Kaskinen
parent 84e4584322
commit 3a92be3c5c
6 changed files with 88 additions and 84 deletions

View file

@ -57,9 +57,9 @@ static void pa_adrian_ec_fixate_spec(pa_sample_spec *source_ss, pa_channel_map *
pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,
pa_sample_spec *source_ss, pa_channel_map *source_map,
pa_sample_spec *sink_ss, pa_channel_map *sink_map,
uint32_t *blocksize, const char *args)
uint32_t *nframes, const char *args)
{
int framelen, rate, have_vector = 0;
int rate, have_vector = 0;
uint32_t frame_size_ms;
pa_modargs *ma;
@ -77,11 +77,10 @@ pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,
pa_adrian_ec_fixate_spec(source_ss, source_map, sink_ss, sink_map);
rate = source_ss->rate;
framelen = (rate * frame_size_ms) / 1000;
*nframes = (rate * frame_size_ms) / 1000;
ec->params.priv.adrian.blocksize = (*nframes) * pa_frame_size(source_ss);
*blocksize = ec->params.priv.adrian.blocksize = framelen * pa_frame_size (source_ss);
pa_log_debug ("Using framelen %d, blocksize %u, channels %d, rate %d", framelen, ec->params.priv.adrian.blocksize, source_ss->channels, source_ss->rate);
pa_log_debug ("Using nframes %d, blocksize %u, channels %d, rate %d", *nframes, ec->params.priv.adrian.blocksize, source_ss->channels, source_ss->rate);
/* For now we only support SSE */
if (c->cpu_info.cpu_type == PA_CPU_X86 && (c->cpu_info.flags.x86 & PA_CPU_X86_SSE))