Commit graph

6919 commits

Author SHA1 Message Date
Stefan Huber
9b6dced2cb echo-cancel-test: When fopen() fails tell which file failed 2013-02-16 21:46:27 +02:00
Stefan Huber
7eff884848 echo-cancel-test: Pass aec_args with module args
The echo canceller module can pass arguments to the EC implementation
via the module parameter aec_args. However, the echo-cancel-test passes
EC arguments via a separate argv[] option, which is inconsistent. Fix
this.
2013-02-16 21:45:26 +02:00
Stefan Huber
8aa30049ec echo-cancel-test: Enable debug log level 2013-02-16 21:39:33 +02:00
Akihiro Tsukada
53807e4a28 add support for MPEG-2 AAC pass-through
Some S/PDIF receivers have AAC decoder.
Only MPEG2 AAC is added,
as I don't have MPEG-4 AAC decoder and cannot test it.
2013-02-16 21:36:39 +02:00
David Henningsson
0785165e5c module: Unload modules in reverse order
Unloading modules in the reverse order is the "more logical" thing
to do, and speeds up shutdown somewhat, e g by not loading
module-null-sink at shutdown.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-16 21:03:46 +02:00
Tanu Kaskinen
77b3ba514c bluetooth: Fix thread teardown code ordering
thread_mq.outq may contain some unprocessed messages, which should be
dispatched before unreffing the sink and source. If the sink and
source are unreffed before all messages to them have been dispatched,
the unreffing won't free the sink and source, and that in turn will
likely cause problems with things getting freed in a wrong order.
2013-02-16 20:48:55 +02:00
Mikel Astiz
5d4b7c4a89 bluetooth: Fix premature acquire attempts
A transport should be considered connected only after the connection
procedure is complete, as expressed in audio_state_to_transport_state().

module-bluetooth-device should be loaded only after at least one
transport is not only created (during configuration), but also
connected.

This fixes the issue of premature acquire attempts sometimes experienced
when a headset is connected (issue not present in v3.0 though).
2013-02-16 16:53:42 +02:00
Tanu Kaskinen
2c666e3e16 idxset: Add pa_idxset_remove_all()
Slightly nicer than using pa_idxset_steal_first() in a loop.
2013-02-16 01:18:59 +02:00
Tanu Kaskinen
31ee1a7d54 hashmap: Add pa_hashmap_remove_all()
Slightly nicer than using pa_hashmap_steal_first() in a loop.
2013-02-16 01:17:04 +02:00
Tanu Kaskinen
061878b5a4 idxset: Use pa_free_cb_t instead of pa_free2_cb_t
There were no users for the userdata pointer.
2013-02-16 01:15:27 +02:00
Tanu Kaskinen
43e7868008 device-port: Remove pa_device_port_hashmap_free() 2013-02-16 01:13:57 +02:00
Tanu Kaskinen
8872c238ba hashmap: Use pa_free_cb_t instead of pa_free2_cb_t
The previous patch removed module-gconf's dependency on the userdata
pointer of the free callback, and that was the only place where the
userdata pointer of pa_free2_cb_t was used, so now there's no need for
pa_free2_cb_t in pa_hashmap_free(). Using pa_free_cb_t instead allows
removing a significant amount of repetitive code.
2013-02-16 01:12:21 +02:00
Tanu Kaskinen
dcf043842e gconf: Remove needless userdata function arguments 2013-02-16 01:12:10 +02:00
Tanu Kaskinen
cfb895438a gconf: Add userdata pointer to struct module_info
This will be useful in simplifying function argument lists.
2013-02-16 01:12:01 +02:00
Peter Meerwald
da5f03b7f5 tests: add test/performance comparison for mixing special-case code
x86-64, i7-870, 3 GHz gcc -O0, 100 TIMES

mix s16 generic 1 channel: 286503 usec (avg: 2865.03, min = 2673, max = 6892, stddev = 425.996).
mix s16 2 streams 1 channel: 136490 usec (avg: 1364.9, min = 1304, max = 1686, stddev = 73.4594).

mix s16 generic 2 channels: 590472 usec (avg: 5904.72, min = 5342, max = 16027, stddev = 1079.34).
mix s16 2 channels: 380369 usec (avg: 3803.69, min = 3570, max = 5041, stddev = 234.831).
mix s16 2 streams: 316254 usec (avg: 3162.54, min = 3034, max = 3536, stddev = 107.716).
mix s16 2 streams 2 channels: 269645 usec (avg: 2696.45, min = 2585, max = 3027, stddev = 87.9661).

x86-64, i7-870, 3 GHz gcc -O2, 1000 TIMES

mix s16 generic 1 channel: 371550 usec (avg: 3715.5, min = 3515, max = 10534, stddev = 760.071).
mix s16 2 streams 1 channel: 207750 usec (avg: 2077.5, min = 2009, max = 2271, stddev = 58.6076).

mix s16 generic 2 channels: 724294 usec (avg: 7242.94, min = 6937, max = 10350, stddev = 363.451).
mix s16 2 channels: 345661 usec (avg: 3456.61, min = 3291, max = 5586, stddev = 256.309).
mix s16 2 streams: 559243 usec (avg: 5592.43, min = 5349, max = 6705, stddev = 223.271).
mix s16 2 streams 2 channels: 390101 usec (avg: 3901.01, min = 3696, max = 5345, stddev = 213.482).

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-16 01:08:10 +02:00
Peter Meerwald
cf8e67ede8 tests: Add NEON mix test cases to cpu-test
on beagle-xm (Cortex-A8)

Initialising ARM NEON optimized mixing functions.
Checking NEON mix
Testing 2-channel mixing performance with 7 sample alignment
func: 2329073 usec (avg: 23290.7, min = 18127, max = 65368, stddev = 10404.2).
orig: 7931126 usec (avg: 79311.3, min = 65002, max = 239411, stddev = 35885.6).

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 23:24:15 +02:00
Peter Meerwald
1e4e586150 mix: Add optimized mix code path for ARM NEON
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 23:02:19 +02:00
Peter Meerwald
7758076d9c mix: Change end pointer to length parameter in mixing function
similar to volume functions, simplifies leftover samples handling
for SIMD'd code path

use concrete pointer type (e.g. int16_t*) instead of void*,
saves several casts

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:53:43 +02:00
Peter Meerwald
c1cac8d82b mix: Add special cases for mixing streams in s16ne format
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:40:07 +02:00
Peter Meerwald
c23963a99f 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>
2013-02-15 21:34:13 +02:00
Peter Meerwald
8fa81a93c9 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>
2013-02-15 21:34:13 +02:00
Peter Meerwald
b123cfa7c9 mix: Combine loops over streams in pa_mix()
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:34:09 +02:00
Peter Meerwald
9fa000bbfc mix: Export function to get/set mixing implementation for a sample format
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:34:03 +02:00
Peter Meerwald
fe455ae013 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>
2013-02-15 21:33:52 +02:00
Peter Meerwald
c90868f2e0 mix: Use table for calc_stream_columes()
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:33:42 +02:00
Peter Meerwald
1335914e72 sample-util: Remove duplicate stdio.h #include
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:33:25 +02:00
Peter Meerwald
95b64804ab 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>
2013-02-15 21:33:07 +02:00
Peter Meerwald
bc8b6eaf95 tests: Volume-test seems to be long-running, set timeout
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:27:07 +02:00
Peter Meerwald
30ce3a14e5 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>
2013-02-15 21:27:07 +02:00
Tanu Kaskinen
505a57d32d 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>
2013-02-15 21:24:36 +02:00
Peter Meerwald
90276fe18d echo-cancel: Use proper float constants in adrian-aec
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-15 21:18:36 +02:00
Tanu Kaskinen
8d9c41e84c echo-cancel: Fix tap weights array alignment 2013-02-15 21:16:37 +02:00
Peter Meerwald
764eabd109 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>
2013-02-14 16:45:54 +02:00
Peter Meerwald
bf29c8dcf7 echo-cancel: Fix memory leak / deinitialization of Adrian AEC
was simply absent

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-14 16:23:38 +02:00
Peter Meerwald
c43e885537 echo-cancel: Output echo canceller name if invalid
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-14 15:25:29 +02:00
Peter Meerwald
db7415b7e9 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>
2013-02-14 15:24:09 +02:00
Peter Meerwald
e845c86c64 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>
2013-02-14 15:06:59 +02:00
Peter Meerwald
425bdc10ec 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>
2013-02-14 14:58:49 +02:00
Mikel Astiz
b84c293ff3 bluetooth: Fix incorrect index check with PA_ELEMENTSOF
The equality case should also be considered an index-out-of-range case.
2013-02-14 14:41:10 +02:00
Stefan Huber
930654a3af resampler: Generate normalized rows in calc_map_table()
Remixing one channel map to another is (except for special cases) done
via a linear mapping between channels, whose corresponding matrix is
computed by calc_map_table(). The k-th row in this matrix corresponds to
the coefficients of the linear combination of the input channels that
result in the k-th output channel. In order to avoid clipping of samples
we require that the sum of these coefficients is (at most) 1. This
commit ensures this.

Prior to this commit tests/remix-test.c gives 52 of 132 matrices that
violate this property. For example:
'front-left,front-right,front-center,lfe' -> 'front-left,front-right'
           prior this commit                  after this commit
         I00   I01   I02   I03              I00   I01   I02   I03
      +------------------------          +------------------------
  O00 | 0.750 0.000 0.375 0.375      O00 | 0.533 0.000 0.267 0.200
  O01 | 0.000 0.750 0.375 0.375      O01 | 0.000 0.533 0.267 0.200

Building the matrix is done in several steps. However, only insufficient
measures are taken in order to preserve a row-sum of 1.0 (or leaves it
at 0.0) after each step. The current patch adds a post-processing step
in order check for each row whether the sum exceeds 1.0 and, if
necessary, normalizes this row. This allows for further simplifactions:
 - The insufficient normalizations after some steps are removed. Gains
   are adapted to (partially) resemble the old matrices.
 - Handling unconnected input channls becomes a lot simpler.
2013-02-07 16:45:13 +02:00
Stefan Huber
1a40af9c3b resampler: Refactor calc_map_table()
- Separate the cases with PA_RESAMPLER_NO_REMAP or PA_RESAMPLER_NO_REMIX
  set and remove redundant if-conditions.
- Fix C90 compiler warning due to mixing code and variable declaration.
- Do not repeatedly count number of left, right and center channels in
  the input channel map.

The logic of calc_map_table() remains unaltered.
2013-02-07 16:09:33 +02:00
Stefan Huber
8f009c8680 resampler: Replace pa_bool_t by bool 2013-02-07 16:06:30 +02:00
Tanu Kaskinen
6db3af6601 daemon: Don't rely on prctl(PR_SET_KEEPCAPS, 0) for dropping caps.
Capability dropping when changing the user in the system
mode was previously implemented by calling
prctl(PR_SET_KEEPCAPS, 0), but that doesn't necessarily
work. It's possible that the KEEPCAPS flag is locked to 1,
in which case the prctl() call fails with EPERM (this
happens at least on Harmattan). This patch implements
explicit capability dropping after changing the user.
2013-02-07 11:59:58 +02:00
Jarkko Suontausta
7e6e3b7044 core: Assert on memchunk divisibility by sample spec in pa_memblockq_push().
Earlier, -1 was returned if the memchunk size was not a multiple of the frame
size. Now, it is verified unconditionally through an assertion. Error code -1
is still returned when the memblock queue is full.

In those few cases where the return value of pa_memblockq_push() is checked,
an overflow is assumed to be the reason in case an error code is returned.
2013-02-07 11:11:55 +02:00
Tanu Kaskinen
3b3d26813f tests: Indicate failure in test-daemon.sh by returning 1 if any test fails. 2013-02-06 14:15:09 +02:00
Tanu Kaskinen
3d81bdd04a build-sys: Add check-daemon target to the top-level Makefile.am. 2013-02-06 14:14:46 +02:00
Tanu Kaskinen
4963db8dc0 udev: Add use_ucm module argument 2013-02-06 14:11:40 +02:00
David Henningsson
83d44139d3 alsa-ucm: Fallback to stereo duplex
If 'PlaybackChannels' and 'CaptureChannels' are absent in the UCM
file for a device, assume the device is stereo duplex.

Reported-by: Luke Yelavich <luke.yelavich@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-06 13:49:57 +02:00
Tanu Kaskinen
4ffb6fd617 dbus: Fix cleanup when removing signal listeners 2013-02-06 12:34:06 +02:00
Tanu Kaskinen
10262197d0 dbus: Fix connection cleanup when killing clients 2013-02-06 12:31:33 +02:00