David Henningsson [Fri, 2 Dec 2011 09:20:23 +0000 (10:20 +0100)]
Fixup a few things in the new path probing
* If mapping_probe_paths() fails to open the mixer, all paths are now
removed from the mapping's path sets.
* pa_path_set.probed isn't really used for anything (removed).
* If profile probing is configured to be skipped, mapping_paths_probe()
should still be called.
Thanks to Tanu for spotting.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Fri, 25 Nov 2011 14:17:16 +0000 (15:17 +0100)]
alsa: add card ports and path probe cache
To be able to add ports to all profiles, we need to probe all
profiles at startup. To speed this up, we now have a cache of
probes paths which is owned by the profile set. Since paths
are now owned by the profile set, the path set must now have
a hashmap of paths instead of a linked list.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Wed, 30 Nov 2011 11:51:06 +0000 (12:51 +0100)]
alsa: Ignore the virtual "thinkpad-acpi" card
The thinkpad ACPI driver sometimes creates a virtual sound card,
which at best exposes a volume control. Save some startup time, and
unnecessary error messages in the log, by ignoring it.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Maarten Bosmans [Wed, 2 Nov 2011 20:54:16 +0000 (21:54 +0100)]
resamplers: Rework the peaks resampler
The algorithm had been implemented the same way as the trivial resampler. But
an important difference between the two is that the trivial resampler can write
an output as soon as the first corresponding input sample is seen, whereas the
peaks resampler must have read all input samples before writing an output
sample.
With this rework, the peaks resampler now outputs samples correctly when the
input data is spanning multiple memblocks.
Maarten Bosmans [Tue, 22 Nov 2011 15:09:18 +0000 (16:09 +0100)]
pulsecore: Hardcode FRAME_SIZE_MAX_ALLOW
Instead of using PA_SCACHE_ENTRY_SIZE_MAX, the size for FRAME_SIZE_MAX_ALLOW is
set directly to the same value. This removes the need for the core-scache.h
include, which caused an unwanted dependency of libpulsecommon on libpulsecore.
Colin Guthrie [Sun, 27 Nov 2011 14:19:57 +0000 (14:19 +0000)]
pulsecore: Fix issue with circuilar definitions.
Without this fix, errors about previous definitions are generated in
numerous locations.
Example of error:
CC libpulsecore_1.98_la-auth-cookie.lo
In file included from ../../src/pulsecore/source.h:46:0,
from ../../src/pulsecore/sink.h:40,
from ../../src/pulsecore/core.h:50,
from ../../src/pulsecore/shared.h:25,
from ../../src/pulsecore/auth-cookie.c:33:
../../src/pulsecore/device-port.h:40:24: error: redefinition of typedef
'pa_core'
../../src/pulsecore/core.h:29:24: note: previous declaration of
'pa_core' was here
make[3]: *** [libpulsecore_1.98_la-auth-cookie.lo] Error 1
Overall it would be nicer if we could avoid this kind of fix, but it
would require further reorganisation that I'm not prepared to undertake
right now.
David Henningsson [Fri, 25 Nov 2011 14:17:14 +0000 (15:17 +0100)]
Notify port available status changes, and update protocol version
The recommended way of setting available status is to call
pa_device_port_set_available, which will send a subscription event
to the relevant card. It will also fire a hook.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Fri, 25 Nov 2011 14:17:12 +0000 (15:17 +0100)]
Turn device ports into reference counted objects
Since both cards and sinks can hold references to a port, it makes
sense to reference count them. Although no current implementation
actually has sinks with ports but without a card, it felt wrong
to make it harder to make such an implementation in the future.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Arun Raghavan [Thu, 17 Nov 2011 14:31:59 +0000 (20:01 +0530)]
filters: Handle echo-cancel streams better
This makes handling of echo-cancel streams (and potentially other
filters that need to work with multiple streams) cleaner. We do this by
adding the ability to apply filter on a group of streams rather than
always treating streams individually.
This is required, for example, when changing the input source for an
echo-cancel source output. When this happens, we want to change the
module-echo-cancel instance to actually cancel between the new source
and old sink.
To do this when one stream in a group moves, we create a new filter
instance between the current master sink/source pair and move the
relevant streams to the virtual sink/source from this new instance.
Arun Raghavan [Wed, 23 Nov 2011 10:56:40 +0000 (16:26 +0530)]
proplist: Add internal API to get stream group
This moves out code from module-stream-restore and makes an internal API
out of it to get a "stream group" for a given sink input or source output.
This is factored out for reuse in module-filter-*.
The stream group basically provides some means of attaching a logical
identification to the stream (by role, application id, etc.).
Arun Raghavan [Wed, 23 Nov 2011 11:16:12 +0000 (16:46 +0530)]
filters: Fix the master source/sink when autoloaded
When autoloaded, it is expected that module-filter-apply (or whatever is
loading us) will take care of applying the filter on the correct
sink/source master. Instead of adding complexity by tracking what is
currently being filtered, we just disallow filtering anything except the
original master sink/source and let module-filter-apply or whatever is
loading us deal with dynamic sink/source changes.
Arun Raghavan [Tue, 22 Nov 2011 07:54:22 +0000 (13:24 +0530)]
echo-cancel: Use more human-friendly descriptions
This makes what devices are being cancelled clearer in the UI (at the
cost of being somewhat less clear when multiple devices of the same name
are plugged, but at least that's a much smaller set than everyone).
Maarten Bosmans [Thu, 13 Oct 2011 18:54:17 +0000 (20:54 +0200)]
rtpoll: Update comment
to reflect changes made in 32e2cd6d3216f780c4cffed0f8eb3c30f2c8d732
core: get rid of rt sig/timer handling since modern Linux' ppoll() is finally fixed for granularity
Antti-Ville Jansson [Fri, 11 Nov 2011 14:22:24 +0000 (16:22 +0200)]
stream: Fix upload samples' cleanup
In pa_create_stream_callback, a stream is inserted into
s->context->record_streams only if it's a record stream. Otherwise it's
inserted into s->context->playback_streams. However, in stream_unlink the
stream is removed from s->context->playback_streams only if it's a playback
stream and otherwise it's removed from s->context->record_streams.
Thus, if the stream is an upload stream, we first insert it into
s->context->playback_streams in pa_create_stream_callback and then try to
remove it unsuccessfully from s->context->record_streams in stream_unlink. This
means that we are leaking hashmap entries until the context is freed,
constantly consuming more memory with applications that upload and unload a
large number of samples through one context.
Of course, this begs the question whether upload streams even belong in either
of those hashmaps. I don't want to mess around with the code too much at this
point though, so this patch should be a sufficient improvement.
Arun Raghavan [Fri, 4 Nov 2011 10:47:26 +0000 (16:17 +0530)]
echo-cancel: Add infrastructure for cancellers to do AGC
This adds some infrastructure for canceller implementations to also
perform acoustic gain control. Cancellers now have a couple of new API
calls that allow them to get/set capture volume.
This is made slightly complex by the fact that cancellation happens in
thread context while most volume mangling needs to be done in main
context. To deal with this, while getting the volume we save source
volume updates as they are propagated to thread context and use this
cached value for queries. To set the volume, we send an async message to
main context and let that set the source volume.
Arun Raghavan [Mon, 7 Nov 2011 09:31:25 +0000 (15:01 +0530)]
sink,source: Allow sample rate switching with corked streams
This updates corked streams' resamplers when switching sample rates on a
sink/source, which means the restriction of allowing sample rate updates
only when no streams are attached to a sink/source is now relaxed to
preventing updates only when there is a running stream attached.
Arun Raghavan [Thu, 18 Aug 2011 06:26:26 +0000 (11:56 +0530)]
cli: Add a dump-volumes command
The purpose of this command is to print all the internal volume
variables for sinks/sources and all corresponding
sink-inputs/source-outputs to make debugging and reasoning about
volume-related issues easier.
Lars R. Damerow [Thu, 3 Nov 2011 20:14:45 +0000 (21:14 +0100)]
alsa: support fixed latency range in alsa modules
This adds a boolean module parameter to disable automatic dynamic
latency readjustments on underruns, but leaves automatic dynamic
watermark readjustments untouched.
Frédéric Dalleau [Tue, 4 Oct 2011 07:37:25 +0000 (09:37 +0200)]
bluetooth: Set hfgw profile when HandsfreeGateway is playing
Allow module-bluetooth-device to listens to HandsfreeGateway state
changes using DBUS signals. When an handsfree connects, module-bluetooth-device
is loaded and goes to playing state. When the handsfree disconnect audio,
the card profile is set to "off". If the headset connects audio again after
that, the card profile should switch to "hfgw" again to match state of audio
connection.
Frédéric Dalleau [Tue, 4 Oct 2011 07:37:23 +0000 (09:37 +0200)]
bluetooth: Release MediaEnpoint if card profile is set to Off
If card profile is set to "off", the audio stream should be released.
Current implementation releases the stream when the card profile
is changed to "hsp" or "hfgw" again and immediatly reconnects after that.
Frédéric Dalleau [Tue, 4 Oct 2011 07:37:22 +0000 (09:37 +0200)]
bluetooth: Do not unload module-bluetooth-device on ERR or HUP
This happens in the following scenario :
An HandsfreeGateway connects RFCOMM and then SCO. A card appears in
PA and can be used. If for some reason, SCO is disconnected,
module-bluetooth-device is unloaded. The card will disappear, even
if RFCOMM is still connected. After that, it is not possible to
connect SCO again from PA.
Frédéric Dalleau [Tue, 4 Oct 2011 07:37:21 +0000 (09:37 +0200)]
bluetooth: Fix Media Endpoint for HandsfreeGateway
This patch will add the necessary quirks so that pulseaudio can register
an endpoint on the /MediaEndpoint/HFPHS path. This endpoint is to be
used for HFP Handsfree profile.
Maarten Bosmans [Tue, 4 Oct 2011 12:12:20 +0000 (14:12 +0200)]
tests: Revisit which tests to run with make check
Some tests (remix-test, sig2str) only display information, so they are not
useful for automated testing. Others (interpol-test, once-test, thread-test)
do return an error on failure, so should be included in TESTS.
Maarten Bosmans [Tue, 4 Oct 2011 12:01:03 +0000 (14:01 +0200)]
tests: More useful output of make check
Instead of spilling thousands of lines of output, make check now runs the
test-suite in about 100 lines or so. If running under make check, the output of
tests is reduced. The MAKE_CHECK environment variable is used for this, so that
when running the test manually, the full output is still shown. Furthermore,
pa_log is used consistently instead of printf, so that all test output goes to
stderr by default. Colored output from make check goes to stdout.
Maarten Bosmans [Fri, 28 Oct 2011 14:30:05 +0000 (16:30 +0200)]
tests: Make sure tests assert on failures and return error status
When a test program exits with a nonzero return value (or an assert is hit),
the test is regarded as a FAIL.
This makes `make check` a little more useful.
Arun Raghavan [Fri, 7 Oct 2011 10:58:11 +0000 (16:28 +0530)]
echo-cancel: Plug in WebRTC drift compensation
This adds the ability for echo cancellers to provide their own drift
compensation, and hooks in the appropriate bits to implement this in the
WebRTC canceller.
We do this by introducing an alternative model for the canceller. So
far, the core engine just provided a run() method which was given
blocksize-sized chunks of playback and record samples. The new model has
the engine provide play() and record() methods that can (in theory) be
called by the playback and capture threads. The latter would actually do
the processing required.
In addition to this a set_drift() method may be provided by the
implementation. PA will provide periodic samples of the drift to the
engine. These values need to be aggregated and processed over some time,
since the point values vary quite a bit (but generally fit a linear
regression reasonably accurately). At some point of time, we might move
the actual drift calculation into PA and change the semantics of this
function.
NOTE: This needs further testing before being deemed ready for wider use.
Siarhei Siamashka [Thu, 20 Oct 2011 12:47:48 +0000 (15:47 +0300)]
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
Marcel Holtmann [Fri, 26 Aug 2011 18:18:54 +0000 (11:18 -0700)]
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.
Arun Raghavan [Thu, 27 Oct 2011 10:49:18 +0000 (12:49 +0200)]
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.
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.
Colin Guthrie [Mon, 24 Oct 2011 21:35:38 +0000 (23:35 +0200)]
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.