Commit graph

6257 commits

Author SHA1 Message Date
Johan Hedberg
8c0cca7905 bluetooth: sbc: Reduce for-loop induced indentation in sbc_unpack_frame 2011-10-28 15:43:56 +02:00
Siarhei Siamashka
00602537ba bluetooth: sbc: overflow bugfix and audio decoding quality improvement
The "(((audio_sample << 1) | 1) << frame->scale_factor[ch][sb])"
part of expression
    "frame->sb_sample[blk][ch][sb] =
        (((audio_sample << 1) | 1) << frame->scale_factor[ch][sb]) /
        levels[ch][sb] - (1 << frame->scale_factor[ch][sb])"
in "sbc_unpack_frame" function can sometimes overflow 32-bit signed int.
This problem can be reproduced by first using bitpool 128 and encoding
some random noise data, and then feeding it to sbc decoder. The obvious
thing to do would be to change "audio_sample" variable type to uint32_t.

However the problem is a little bit more complicated. According
to the section "12.6.2 Scale Factors" of A2DP spec:
    scalefactor[ch][sb] = pow(2.0, (scale_factor[ch][sb] + 1))

And according to "12.6.4 Reconstruction of the Subband Samples":
    sb_sample[blk][ch][sb] = scalefactor[ch][sb] *
        ((audio_sample[blk][ch][sb]*2.0+1.0) / levels[ch][sb]-1.0);

Hence the current code for calculating "sb_sample[blk][ch][sb]" is
not quite correct, because it loses one least significant bit of
sample data and passes twice smaller sample values to the synthesis
filter (the filter also deviates from the spec to compensate this).
This all has quite a noticeable impact on audio quality. Moreover,
it makes sense to keep a few extra bits of precision here in order
to minimize rounding errors. So the proposed patch introduces a new
SBCDEC_FIXED_EXTRA_BITS constant and uses uint64_t data type
for intermediate calculations in order to safeguard against
overflows. This patch intentionally addresses only the quality
issue, but performance can be also improved later (like replacing
division with multiplication by reciprocal).

Test for the difference of sbc encoding/decoding roundtrip vs.
the original audio file for joint stereo, bitpool 128, 8 subbands
and http://media.xiph.org/sintel/sintel-master-st.flac sample
demonstrates some quality improvement:

=== before ===
    --- comparing original / sbc_encoder.exe + sbcdec ---
    stddev:    4.64 PSNR: 82.97 bytes:170495708/170496000
=== after ===
    --- comparing original / sbc_encoder.exe + sbcdec ---
    stddev:    1.95 PSNR: 90.50 bytes:170495708/170496000
2011-10-28 15:43:48 +02:00
Marcel Holtmann
7aec17c3b6 bluetooth: audio: Update license for shared header files
The header files with constants and structures for audio specific
interaction with Pulseaudio are suppose to be under LGPL license.

For some odd reason a2dp-codecs.h ended up being under GPL license
which is against the intention of this being shared and re-used by
non-GPL programs. Fix this now to avoid any future confusion.
2011-10-28 15:43:42 +02:00
Arun Raghavan
06fc121eef core: Add a string list membership check function
This adds a pa_str_in_list() to check for a given string in a
space-separated list of strings. For now, this is merely present to
avoid duplication of role matching code (intended roles can be a
space-separate list) across modules.
2011-10-28 15:21:09 +02:00
Arun Raghavan
667289679f doc: Correct intended roles property documentation
The documentation says we expect a comma-separate list of intended
roles, but the code splits the string on whitespaces, so this corrects
the documentation to match the implementation.
2011-10-28 14:44:53 +02:00
Dylan Reid
77a68b56ab alsa: Set return code before printing it.
The error message for snd_pcm_hw_params_set_period_wakeup was
printing "ret", but "ret" wasn't being set.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
2011-10-26 16:19:45 +02:00
Colin Guthrie
a3678d241b role-cork: Allow module-role-cork to act globally.
Allow a module argument to specify that we should act globally
rather than just within a given sink.

The default value is to not opporate globally thus retaining the
current behaviour.
2011-10-25 14:01:32 +02:00
Colin Guthrie
679b7ef895 role-cork: Make module-role-cork more generic.
Operate on a list of 'trigger roles' and 'cork roles'. i.e.
react to any stream with a role in the trigger list and apply a
cork to any stream with the a role in the cork list.

The trigger roles default to 'phone' and the cork roles default
to both 'music' and 'video' thus achieving the same functionality
as currently when called without any arguments.
2011-10-25 14:01:32 +02:00
Colin Guthrie
3c5cc34547 role-cork: Rename module-cork-music-on-phone to module-role-cork.
This module will be extended to be a bit more generic so the
old name will soon be obsolete.
2011-10-25 14:01:32 +02:00
Arun Raghavan
3c547194fc gitignore: Update for recent additions
Adds echo-cancel-test and new cmake files
2011-10-21 10:07:31 +05:30
Colin Guthrie
9af153574c conf: Use .nofail when loading module-jackdbus-detect
When starting via a console login, PA will likely not have a session DBus
to play with. As there is no X11 environment, libdbus will be unable
to launch a session DBus for us and thus the module will fail to load
which in turn prevents PA from loading.

If the user subsequently logs into X11 this it will still not be possible
to load the module as the server will be ignorant of the X11 and DBus
environment variables so a longer term solution for handling this should
be found.
2011-10-20 14:29:06 +01:00
Arun Raghavan
5bb9d52b7e solaris: Use real_volume for set/get volume
This got missed when other bits were updated. Patch submitted by
Brian Cameron <brian.cameron@oracle.com>.
2011-10-20 15:05:04 +05:30
Arun Raghavan
4ce0eb18c2 native: Fix Solaris build
tcpwrappers has some Solaris-specific quirks that need to be dealt with.
Patch submitted by Brian Cameron <brian.cameron@oracle.com>.
2011-10-20 15:04:34 +05:30
Colin Guthrie
d80a3cf56e Update LICENSE.
Some of the license wording was less than clear. Try to clarify the
different GPL 'downgrade' scenarios but also be generic to ensure that
those packagers where GPL is a problem check thoroughly before they ship.

Inspired by comments from Brian Cameron @ Oracle via fdo#41822
2011-10-20 10:05:46 +01:00
Tanu Kaskinen
12fe756993 alsa: Handle the "profile" modarg in module-alsa-card 2011-10-20 09:28:44 +05:30
Daniel Mack
9a1eee5c43 osx: module_bonjour_publish needs to be linked against libprotocol-native.la 2011-10-19 23:57:00 +01:00
Colin Guthrie
ce546b22eb build-sys: Provide a simple CMake Config setup (similar to pkgconfig)
I'd rather not have to do this, as I don't really see the point in
duplicating what is done in pkgconfig, but this is likely the
easiest way to avoid nasty hacks.
2011-10-19 23:49:23 +01:00
Arun Raghavan
034006ec90 sink,source: Account for corked streams in update_rate()
pa_sink/source_used_by() ignores corked/monitor streams, but we need to
make sure there aren't any of these while updating rate (at least for
now -- this is a restriction that would be nice to get rid of).
2011-10-18 09:53:20 +05:30
Pierre-Louis Bossart
72377fcad5 alsa: fix list of sampling rates
add all standard audio rates

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-18 09:00:58 +05:30
Arun Raghavan
e67440e220 alsa: Probe sink/source sample rates
This probes sink and source sample rates and uses this information to
validate rate changes and check incoming passthrough formats.
2011-10-17 22:52:47 +05:30
Arun Raghavan
3555634e6e alsa: Remove unused variable 2011-10-17 21:16:23 +05:30
Arun Raghavan
59d058dea4 sink,source: Handle equal default and alternate sample rates 2011-10-17 20:20:14 +05:30
Arun Raghavan
ac469a25c0 sink,source: Add the ability to disable alternat sample rate switching
Setting the alternate sample rate to 0 in config disables this feature.
2011-10-17 20:16:37 +05:30
Arun Raghavan
b9ff90fef8 source: Bring rate update code in sync with sink code
Basically adds code to handle passthrough sources. This isn't a tested
path at the moment, but in the future, when we do wish to support these,
it'll save us the trouble of having to sync all the code again.
2011-10-17 20:09:50 +05:30
Pierre-Louis Bossart
b232fbd8f8 alsa: support for alternate sampling rate
This is where the actual changes happen.
Some additional checks would be required to make sure the
rate is actually supported
Tested with both PCM and passthrough streams

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-17 20:09:50 +05:30
Pierre-Louis Bossart
f0ec495938 sink,source: support for rate update
Avoid resampling or use integer resampling when supported by the
sinks/sources

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-17 20:09:46 +05:30
Pierre-Louis Bossart
5bcfd2b630 core: infrastructure for alternate sampling rate
New parameter to avoid resampling. BIG power savings here...

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2011-10-17 19:23:26 +05:30
Arun Raghavan
31a9f195fa build-sys: Minor CXXFLAGS fix
Set it on echo-cancel-test only if webrtc support is enabled.
2011-10-17 17:09:24 +05:30
Arun Raghavan
6df6eb959e echo-cancel: Add the WebRTC echo canceller
This adds the WebRTC echo canceller as another module-echo-cancel
backend. We're exposing both the full echo canceller as well as the
mobile echo control version as modargs.

Pending items:

1. The mobile canceller doesn't seem to work at the moment.

2. We still need to add bits to hook in drift compensation (to support
   sink and source from different devices).

The most controversial part of this patch would probably be the
mandatory build-time dependency on a C++ compiler. If the optional
--enable-webrtc-aec is set, then there's also a dependency on libstdc++.
2011-10-17 16:42:59 +05:30
Arun Raghavan
dbe8f2e595 macro: typedef pa_bool_t to bool instead of _Bool
They're functionally equivalent, and the former lets the header be
included in C++ as well.
2011-10-17 16:42:59 +05:30
Arun Raghavan
e40bddc946 echo-cancel: Simplify checking if AEC is active
This removes the active_mask bits and just check source and sink states
directly.
2011-10-17 16:42:59 +05:30
Tanu Kaskinen
a88b1d5cd4 alsa: New modarg "paths_dir" for module-alsa-card
The new module argument can be used to provide a custom
directory for loading alsa path configuration files. This is
useful for testing: no need to be root to create test
configuration files.
2011-10-17 12:54:23 +05:30
David Henningsson
ca6057316d Fix deferred volume not being applied if sink is closed
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-10-17 09:50:16 +05:30
Arun Raghavan
bb4b8f896e build-sys: Drop libsamplerate from pulsecommon deps
This was erroneously added in:

    commit d766b38e1b
    build: Remove unnecessary flags in AM_CFLAGS
2011-10-17 09:43:38 +05:30
Arun Raghavan
21bfe455da filter-apply: Move sink/source unlink callbacks before m-s-r
module-stream-restore and modile-filter-apply can get into an infinite
loop if m-s-r is called before m-f-a (m-s-r rescues a stream and
attaches it to a sink/source, which then triggers m-f-a to move it back
to the filter sink/source, and so on). The purpose of the m-f-a hooks is
to beat m-s-r, so moving them to be run first.
2011-10-12 17:54:46 +05:30
Maarten Bosmans
b453e13ede qpaeq: Make it python3 and python2 compatible 2011-10-12 13:05:13 +05:30
Arun Raghavan
4bd357ae57 echo-cancel: Don't process if sink is unconnected
If there's no playback data, there's no point in actually processing the
capture data.
2011-10-12 13:04:57 +05:30
Maarten Bosmans
89f00f3e4c tests: Fix calculation of memblock size in resampler-test
And remove useless volume scaling.
2011-10-12 11:11:06 +05:30
Tanu Kaskinen
6d58497dd1 daemon: Don't treat it as a fatal error if we can't connect to the session bus
http://lists.freedesktop.org/archives/pulseaudio-discuss/2011-June/010276.html
2011-10-12 10:51:24 +05:30
Maarten Bosmans
3c4d43d9dc pacat: Fail early if the media name cannot be set
Otherwise you get an "invalid argument" error from pa_stream_new later.
2011-10-11 22:48:25 +05:30
Maarten Bosmans
3b7c6b21f4 Do something sensible when compiled without iconv support
Without this fix, pacat won't start up, because it is unable to set the stream name.
2011-10-11 22:48:21 +05:30
Arun Raghavan
518338ac0e echo-cancel: Close debug files on module unload 2011-10-10 22:18:22 +05:30
Arun Raghavan
5c28acb1db namereg: Don't set default sink/source on get()
This removes the nasty side-effect that a call to
pa_namereg_get_default_{source,sink}() will also *set* the default
source/sink.

This is a more complete fix for commit 766dbc68 ("conf: Make sure
module-dbus-protocol is loaded after module-default-device-restore")

https://bugs.freedesktop.org/show_bug.cgi?id=40897
2011-10-10 16:08:43 +05:30
Arun Raghavan
f1e41a78cc echo-cancel: Drop sink/source samples before processing begins
This moves the bits that skip source/sink samples for resync from inside
the processing loop to just before. The actual effect should be the
the same.
2011-10-10 13:27:17 +05:30
Arun Raghavan
17011fcf70 echo-cancel: Skip processing till there's enough data
This makes sure that we only perform any processing (resync or actual
cancellation) after the source provides enough data to actuall run the
canceller.
2011-10-10 13:26:27 +05:30
Arun Raghavan
cee6011572 echo-cancel: Skip canceller when no source outputs are connected
When a source-output isn't connected to our virtual source, we skip echo
cancellation altogether. This makes sense in general, and makes sure
that we don't end up adjusting for delay/drift when nothing is
connected. This should make convergence faster when the canceller
actually starts being used.
2011-10-10 13:26:06 +05:30
Arun Raghavan
4cacb1b670 echo-cancel: Increase threshold for resyncing, make it configurable
This increase the threshold for difference between the playback and
capture stream before samples are dropped from 1ms to 5ms (the
cancellers are generally robust to this much and higher). Also, we make
this a module parameter to allow easier experimentation with different
values.
2011-10-10 13:25:46 +05:30
Arun Raghavan
0429fe6153 echo-cancel: Don't crash if adjust_time = 0 2011-10-10 13:25:40 +05:30
Arun Raghavan
f9b59e457c echo-cancel: Remove redundant variable 2011-10-10 13:25:35 +05:30
Arun Raghavan
3f5c5582f4 echo-cancel: Add a standalone test program
This is useful to test the canceller implementation on data from disk
rather than testing live. Handy for comparing implementations reliably.
2011-10-10 13:25:25 +05:30