bluetooth: Fix incorrect index check with PA_ELEMENTSOF

The equality case should also be considered an index-out-of-range case.
build-sys: ALSA use-case manager requires ALSA library >= 1.0.24

alsa/use-case.h in needed
require at least version 1.0.24 in configure.ac

prevents the following error at compile time:
  CC     libalsa_util_la-alsa-util.lo
In file included from modules/alsa/alsa-mixer.h:51,
                 from modules/alsa/alsa-util.h:36,
                 from modules/alsa/alsa-util.c:46:
modules/alsa/alsa-ucm.h:27:22: error: use-case.h: No such file or directory
In file included from modules/alsa/alsa-mixer.h:51,
                 from modules/alsa/alsa-util.h:36,
                 from modules/alsa/alsa-util.c:46:
modules/alsa/alsa-ucm.h:89: error: expected ‘)’ before ‘*’ token
modules/alsa/alsa-ucm.h:169: error: expected specifier-qualifier-list before ‘snd_use_case_mgr_t’
make[3]: *** [libalsa_util_la-alsa-util.lo] Error 1

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
build-sys: Properly check for HAVE_DBUS in module-ladspa-sink

prevents
  CC     module_ladspa_sink_la-module-ladspa-sink.lo
modules/module-ladspa-sink.c:1332:5: warning: "HAVE_DBUS" is not defined
modules/module-ladspa-sink.c:1370:5: warning: "HAVE_DBUS" is not defined
in case HAVE_DBUS is not available

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
echo-cancel: Add function pa_echo_canceller_blocksize_power2()

computes EC block size in frames (rounded down to nearest power-of-2) based
on sample rate and milliseconds

move code from speex AEC implementation to module-echo-cancel such that
functionality can be reused by other AEC implementations

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
echo-cancel: Output echo canceller name if invalid

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
echo-cancel: Fix memory leak / deinitialization of Adrian AEC

was simply absent

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
echo-cancel: Fix zeroing of w in AEC_leaky()

bug probably caused by alignment requirement; sizeof(a->w) is a pointer, sizeof(a->w_arr) is an array

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
echo-cancel: Fix tap weights array alignment
echo-cancel: Use proper float constants in adrian-aec

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
echo-cancel: Fix uninitialized variable dotp_xf_xf of AEC struct

Initialize the variable to zero by using pa_xnew0() instead of
pa_xnew(). This also allows us to remove a bunch of other zero
initialization statements.

Reported-by: Peter Meerwald <p.meerwald@bct-electronic.com>
resampler: Resample first followed by remapping if have more out channels than in channels

The patch intends to reduce computational load when resampling AND remapping. The PA
resampler performs the following steps:

sample format conversion -> remapping -> resampling -> sample format conversion

In case the number of output channels is higher than the number of input channels, the
resampler has to be run more often than necessary. E.g. in case of mono to 4-channel remapping,
the resampler runs on 4 channels separately.

To ímprove this, the PA resampler pipeline is made adaptive:

if out-channels <= in-channels:
sample format conversion -> remapping -> resampling -> sample format conversion
if out-channels > in-channels:
sample format conversion -> resampling -> remapping -> sample format conversion

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
tests: Volume-test seems to be long-running, set timeout

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
core: Move pa_mix() into new file mix.c

idea is to allow optimized code path (similar to volume code)
and rework/specialize mixing cases to enable runtime performance improvements

no functionality changes in this patch

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
sample-util: Remove duplicate stdio.h #include

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
mix: Use table for calc_stream_columes()

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
mix: Split pa_mix() code using function table

have individual function for mixing stream with different sample format instead
of huge case block in pa_mix()

shorter functions, prepare for optimized code path

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
mix: Export function to get/set mixing implementation for a sample format

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
mix: Combine loops over streams in pa_mix()

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
core: Refactor code to multiply s16 by volume

move code to function pa_mult_s16_volume() in sample-util.h
use 64 bit integers on 64 bit platforms (it's faster)

on i5, 2.5GHz (64-bit)

Running suite(s): Mult-s16
32 bit mult: 1272300 usec (avg: 12723, min = 12533, max = 18749, stddev = 620.48).
64 bit mult: 852241 usec (avg: 8522.41, min = 8420, max = 9148, stddev = 109.388).
100%: Checks: 1, Failures: 0, Errors: 0

on Pentium D, 3.4GHz (32-bit)

Running suite(s): Mult-s16
32 bit mult: 2228504 usec (avg: 22285, min = 18775, max = 29648, stddev = 3865.59).
64 bit mult: 5546861 usec (avg: 55468.6, min = 55028, max = 64924, stddev = 978.981).
100%: Checks: 1, Failures: 0, Errors: 0

on TI DM3730, Cortex-A8, 800MHz (32-bit)

Running suite(s): Mult-s16
32 bit mult: 23708900 usec (avg: 237089, min = 191864, max = 557312, stddev = 77503.6).
64 bit mult: 22190039 usec (avg: 221900, min = 177978, max = 480469, stddev = 68520.5).
100%: Checks: 1, Failures: 0, Errors: 0

there is a test program called mult-s16-test which checks that the functions compute the
same results, and compares runtime

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
tests: Add mult-s16 test

test mostly compares runtime of 64 bit vs 32 bit s16ne-by-volume multiplication

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>