Commit graph

6945 commits

Author SHA1 Message Date
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
Jyri Sarha
a3b8b6a07e combine: Stop rate adjustments if sink is supended 2013-02-06 12:22:16 +02:00
David Henningsson
163a7dbe8b alsa-sink/source: Better thread names
Now you can actually see *which* sink/source that sends a specific
message to the log, which is quite useful if you have more than
one sound card.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-05 08:40:40 +02:00
Tanu Kaskinen
8cb34c6960 pacat: Handle holes in recording streams.
pa_silence_memory() pulls sample-util as a dependency, so it had to
be moved from libpulsecore to libpulsecommon. sample-util in turn
pulls some more stuff.
2013-02-04 12:07:39 +02:00
Tanu Kaskinen
94ac039b87 padsp: Handle holes in recording streams. 2013-02-04 12:07:36 +02:00
Tanu Kaskinen
dbb94daa0b simple: Handle holes in recording streams. 2013-02-04 12:07:33 +02:00
Peter Meerwald
e66e846418 sconv: Change/fix conversion to/from float32
use (1<<15) instead of 0x7fff as a factor when converting from s16 to float32
use (1<<31) instead of 0x7fffffff as a factor when converting from s32 to float32

the change is motivated by the following desireable properties:
* s16_from_f32(f32_from_s16(x)) == x for all possible s16 values
* x / (1.0f << 15) == x * (1.0f / (1 << 15)) for all x in s16

above changes enable easier optimization while guaranteeing bit-exact results

further, other audio sample conversion code (libavresample) does it the same way

v3 (comments Tanu):
* fix saturation in pa_sconv_s16le_from_f32ne_neon(), use vqrshrn
v2 (comments Tanu):
* fix comments in ARM NEON code
* use llrintf() in pa_sconv_s32le_from_float32ne()

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
Cc: Tanu Kaskinen <tanuk@iki.fi>
2013-02-04 12:07:14 +02:00
David Henningsson
596d9aa740 pactl: Document @DEFAULT_SINK@, @DEFAULT_SOURCE@ and @DEFAULT_MONITOR@
I went to implement the possibility to use the default sink/source
but found that it was already working. So I figured I'd update
the help text instead.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-04 10:01:57 +01:00
Peter Meerwald
3a3c4eb462 resampler: Improve s16<-->s32 conversion, use s16 work format if input or output is s16
Problem: s16 to s32 conversion is performed as s16->float->s32 (via work
format float) for resamplers TRIVIAL, COPY, PEAKS.
Precision and efficiency suffers: e.g. 0x9fff results in 0x9ffe4001 (instead
of 0x9fff0000) and there are two sample format conversions instead of one
conversion.

Solution: If input or output format is s16, then choose the work format
to be s16 as well.

If remapping is to be performed, we could stick to work format float32ne for
precision reseans. This is debateable.

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 10:10:30 +02:00
Peter Meerwald
4b3de4422e resampler: Drop redundant assignment in convert_from_work_format()
r->from_work_format_buf.length is set twice

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 10:08:57 +02:00
Peter Meerwald
34c631c0ae tests: Fix sconv sample correctness in cpu-test
do allow up to one sample difference
cleanup output of signed shorts (use 0xhx)

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 10:06:03 +02:00
Peter Meerwald
db41a4832d sconv: Check for SSE flag before initializing code
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 09:10:44 +02:00
Tanu Kaskinen
e8f1cfd9a5 tests: Fix function argument wrapping style in cpu-test.c. 2013-02-01 09:06:18 +02:00
Peter Meerwald
01a7c6b4e6 tests: Add remap test code to cpu-test
v2 (comments by Paul Menzel):
* generate test samples from -1..1, -0x8000..0x7fff
* check all output samples (not just half of them)

the idea is to compare the output of the C (reference) implementation
against the output of the optimized code path; currently, there are MMX
and SSE implementation for the mono-to-stereo remapper for s16 and float
sample formats

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
Cc: Paul Menzel <paulepanter@users.sourceforge.net>
2013-02-01 08:30:28 +02:00
Peter Meerwald
60aeb3dd23 tests: Test both, SSE and SSE2, sconv in cpu-test
SSE sconv was not tested before, only SSE2 was (on CPUs supporting both
instruction sets)

now both code path are tested on CPUs supporting both

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 07:30:06 +02:00
Peter Meerwald
2c5d3d79ad remap_sse: More specific logging: SSE -> SSE2
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 07:26:16 +02:00
Peter Meerwald
2dc51f3371 tests: Fix potential out-of-bound access violation in svolume cpu-test
nsamples should be forced to be a multiple of channels; do so correctly
and don't make nsamples larger than it actually is

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 07:23:16 +02:00
Peter Meerwald
3a942fc191 tests: Fix conversion typo in cpu-test
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-01 07:23:00 +02:00
poljar (Damir Jelić)
831cae16d4 pactl: Add a command for setting the default sink/source.
This adds two new commands to pactl:
    set-default-sink
    set-default-source

This command has been part of the native protocol for a long time,
no reason not to expose it in pactl.
2013-02-01 07:16:20 +02:00
poljar (Damir Jelić)
a5af95f83d bash-completion: Don't complete devices in the list commands
This fixes some wrong completion for the list commands for example:
    pactl list sinks _sink_name_
2013-02-01 07:11:15 +02:00
Mikel Astiz
58def1fd1d reserve: Fix leaking NameLost signals after release+acquire
The use of the pseudo-blocking D-Bus calls leads to the problem that
NameLost signals are received after the reply to ReleaseName().

The problem with this is that a later acquisition of the same audio
device can potentially receive the NameLost signal corresponding to
the previous instance, due to the fact that the signal hasn't been
popped from the D-Bus message queue.

The simplest approach to solve this problem is to poll the actual name
owner from the D-Bus daemon, in order to make sure that we did really
lose the name.

The proposal uses a blocking call to GetNameOwner to avoid incosistent
states in the internal APIs: it would otherwise be possible to have a
"busy" device before the reservation has been lost, in the unlikely
case if some other process acquires the name before we got the
confirmation that the NameLost was actually true.
2013-01-31 14:04:45 +02:00
Mikel Astiz
cb0f3d2878 reserve: Move get_name_owner() to the public rd_device API
The function is interesting for both rd_device and rd_monitor so make
it part of the rd_device public API to avoid duplicated code.

The decision to move the function to reserve.c is motivated by the fact
that other projects (i.e. jack) use reserve.c only. Therefore, adding a
reserve->reserve-monitor dependency should be avoided.
2013-01-31 13:56:25 +02:00
Tanu Kaskinen
849161f086 bluetooth: Fail if BlueZ tries to give duplicate device addresses. 2013-01-31 09:38:40 +02:00
Mikel Astiz
cd23fbf947 bluetooth: Detect changes in constant properties
The D-Bus API should guarantee that some properties remain constant and
therefore treat changes in such properties as errors.
2013-01-31 09:31:59 +02:00
Mikel Astiz
b531422218 bluetooth: Propagate to property parsers if it is initial value
Add a parameter so that property parsing functions distinguish the
initial case from property changes received later.
2013-01-31 09:31:55 +02:00