Commit graph

8365 commits

Author SHA1 Message Date
Viktar Vaŭčkievič
5ef9554899 i18n: add Belarusian translation 2016-08-24 17:35:03 +03:00
Peter Meerwald-Stadler
492aafd93d bluetooth: Fix negative array index write
CID 1533121
2016-08-17 17:32:10 +02:00
Peter Meerwald-Stadler
aa1882c93f bluetooth: Reorganize code to avoid Coverity NULL dereference warning
CID 1353122

this is a false-positive because

   if (dbus_message_has_interface(p->message, "org.bluez.Manager") ||
        dbus_message_has_interface(p->message, "org.bluez.Adapter"))
        d = NULL;
    else if (!(d = pa_hashmap_get(y->devices, dbus_message_get_path(p->message)))) {
        pa_log_warn("Received GetProperties() reply from unknown device: %s (device removed?)",
dbus_message_get_path(p->message));
        goto finish2;
    }

d can be NULL only if p->message interface is org.bluez.Manager or
org.bluez.Adapter. If

    dbus_message_is_method_call(p->message, "org.bluez.Device", "GetProperties")

returns true, we know that the interface is org.bluez.Device.

thanks, Tanu!
2016-08-17 17:32:03 +02:00
Peter Meerwald-Stadler
41a2849261 bluetooth: Fix dead code
CID 1353115

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2016-08-16 10:31:44 +02:00
Peter Meerwald-Stadler
4231befa77 bluetooth: Don't free modargs twice
CID1353139

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2016-08-16 10:31:44 +02:00
Peter Meerwald-Stadler
8b076c3ed9 Remove newline at end of log messages
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2016-08-16 07:03:25 +02:00
Peter Meerwald-Stadler
9cc778123f modules: Use pa_assert_se() to check return value of dbus_message_iter_close_container()
CID 1140353

... as it is done everythere else
2016-08-15 23:53:34 +02:00
Peter Meerwald-Stadler
a5dae93d9f tests: Check pa_rtpoll_run() return value
CID 1138499
2016-08-15 23:53:32 +02:00
Peter Meerwald-Stadler
05d964cf81 modules: Check pa_threaded_mainloop_start() return value
CID 1138500
2016-08-15 23:53:32 +02:00
Peter Meerwald-Stadler
b3e4d28d25 stream: Check pa_tagstruct_get_format_info() retval in pa_create_stream_callback()
CID 1137984
2016-08-15 23:53:32 +02:00
Peter Meerwald-Stadler
f173f5a8a5 tests: Assert fillrate > 0 in alsa-time-test
CID 1323592

assert that fillrate is strictly positive
2016-08-15 23:53:32 +02:00
Peter Meerwald-Stadler
61344493bf alsa: Check pa_modargs_get_value_boolean() retval for use_ucm
CID 1137983
2016-08-15 23:53:32 +02:00
Peter Meerwald-Stadler
0a5cff6241 sink-input,source-output: Fix logging, don't overwrite old_value when value == 0 2016-08-15 19:08:49 +02:00
John Paul Adrian Glaubitz
1df21e6ab6 core-util: Use _SC_NPROCESSORS_ONLN instead of _SC_NPROCESSORS_CONF
pa_ncpu() is supposed to report the number of processors available on
the system. For that, it currently calls sysconf(_SC_NPROCESSORS_CONF).
However, since the operating system can disable individual processors,
we should call sysconf(_SC_NPROCESSORS_ONLN) to determine the number
of processors currently available [1]. Consequently, the once-test will
fail since pthread_setaffinity_np() is called with CPUs that are
currently not available.

It might also be advisable to change the code in the future to use CPU
sets on Linux as even the suggested change is not 100% safe but at least
it improves over the existing code. If PulseAudio was to be run in a CPU
set [2], the number of processors available to PulseAudio could be even
less than the number of CPUs currently online (_SC_NPROCESSORS_CONF).

[1] https://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html
[2] http://man7.org/linux/man-pages/man7/cpuset.7.html

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96809
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2016-08-15 17:23:36 +03:00
Nils Schneider
9e4ee38c17 pipe-sink: align buffer
The pipe buffer is likely to be a power of 2 (e.g. 4096 bytes). This
works nicely for 16 bit stereo samples but breaks when using 24 bit
samples.

This patch aligns the buffer using pa_frame_align().
2016-08-13 00:34:18 +03:00
Tanu Kaskinen
32c2a6d64a bluetooth: don't create the HSP/HFP profile twice
create_card_profile() used to get called separately for HSP and HFP,
so if a headset supports both profiles, a profile named
"headset_head_unit" would get created twice. The second instance would
get immediately freed, so that wasn't a particularly serious problem.
However, I think it makes more sense to create the profile only once.
This patch makes things so that before a profile is created, we check
what name that profile would have, and if a profile with that name
already exists, we don't create the profile.

A couple of Yocto releases (jethro and krogoth) have non-upstream
patches that suffer from this double creation. The patches add
associations between profiles and ports, and those associations use
the profile name as the key. When the second profile gets freed, the
associations between the profile and its ports get removed, and since
the profile name is used as the key, this erroneously affects the
first profile too. Crashing ensues.

BugLink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=10018
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
83ac6c5ae5 bluetooth: refactor BlueZ 4 transport state setting
Add transport_set_state() that encapsulates changing the variable,
logging and firing the change hook.

I also made a cosmetic change to the corresponding BlueZ 5 log
message so that both messages have the format that I like.
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
15e3d828dd bluetooth: unify BlueZ 4 and BlueZ 5 profile constant names
This should make it slightly easier to copy code between BlueZ 4 and
BlueZ 5.
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
52a9ee618f bluetooth: unify BlueZ 4 and BlueZ 5 UUID handling
A hashmap is more convenient than a linked list for storing the UUIDs,
so change the BlueZ 4 code accordingly.

Rename the BlueZ 4 UUID constants to match the BlueZ 5 naming.

The only changes to the BlueZ 5 code are the addition of one comment
and making another comment a bit clearer.
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
570288ccc9 bluetooth: update device's valid flag after parsing properties
The properties_received flag affects whether the device should be
considered valid, so let's update the valid flag after setting the
properties_received flag.

There's a call to device_update_valid() anyway later when setting
the device adapters, so this change isn't strictly necessary, but
this makes it more obvious that the code is correct (and less
fragile).
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
eec4d29247 bluetooth: remove a redundant assignment
pa_bluetooth_transport_put() assigns the transport to the device's
transports array, so the caller doesn't have to do that.
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
c538bc7aa4 card-restore: don't switch profiles when availability changes
module-card-restore should only restore the initial state of new
cards, but profile_available_changed_callback() changed the profile
whenever the saved profile became available. That caused interference
with module-bluetooth-policy, which also sets card profiles based on
the availability changes.

The original reason for having this code was to work around the
problem that bluetooth cards used to be created with only one profile
available, and other profiles would become available soon after the
card creation. Now the bluetooth card creation is delayed until all
profiles are available, so this bad workaround can be removed.

Discussion:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2016-August/026575.html
2016-08-10 21:37:33 +03:00
Tanu Kaskinen
d9b885e0f1 bluetooth: wait for all profiles to connect before creating card
The CONNECTION_CHANGED hook is used to notify the discovery module
about new and removed devices. When a bluetooth device connects, the
hook used to be called immediately when the first profile connected.
That meant that only one profile was marked as available during the
card creation, other profiles would get marked as available later.

That makes it hard for module-card-restore to restore the saved
profile, if the saved profile becomes available with some delay.
module-card-restore has a workaround for this problem, but that turned
out to interfere with module-bluetooth-policy, so the workaround will
be removed in the next patch.

The BlueZ 4 code doesn't need changes, because we use the
org.bluez.Audio interface to get a notification when all profiles are
connected.
2016-08-10 21:37:33 +03:00
Arun Raghavan
74c9549a42 stream-interaction: Fix a memory leak
CID: 1352053
2016-08-10 22:23:02 +05:30
Arun Raghavan
fd2c630e33 shm: Wrap memfd-specific code in relevant ifdef
Doesn't really affect logic, but Coverity reports this as dead-code, and
I figure it makes sense to be consistent about our use of HAVE_MEMFD.

CID: 1352045
2016-08-10 22:18:13 +05:30
Arun Raghavan
d0428f47f4 source-output: Fix copy-pasto
CID: 1352047
2016-08-10 22:18:13 +05:30
Arun Raghavan
2599a35721 sink-input,source-output: Fix a leak during property change logging
CID: 1352052
2016-08-10 22:16:50 +05:30
Peter Meerwald
f9985e1cbd build: Check version of check library, require >= 0.9.10
tests/core-util-test.c uses ck_assert_int_lt() which was introduced
in check 0.9.10

make this dependency (with --enable-tests) explicit in configure.ac

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2016-08-10 17:05:01 +03:00
Peter Meerwald
04feab17e3 tests: Include signal.h in core-util-test.c
on oldish Ubuntu 12.04:
tests/core-util-test.c: In function ‘main’:
tests/core-util-test.c:269:66: error: ‘SIGABRT’ undeclared (first use in this function)
     tcase_add_test_raise_signal(tc, modargs_test_replace_fail_1, SIGABRT);

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2016-08-10 16:52:50 +03:00
Dušan Kazik Kazik
e4fa17ddff i18n: Update Polish translation 2016-07-28 12:21:38 +05:30
Pali Rohár
bde2ff8794 bluetooth: Add support for automatic switch between hsp and a2dp profiles
With this patch module-bluetooth-policy automatically switch from a2dp profile
to hsp profile if some VOIP application with media.role=phone wants to start
recording audio.

By default a2dp profile is used for listening music, but for VOIP calls is
needed profile with microphone support (hsp). So this patch will switch to
hsp profile if some application want to use microphone (and specify it in
media.role as "phone). After recording is stopped profile is switched back
to a2dp. So this patch allows to use bluetooth microphone for VOIP applications
with media.role=phone automatically without need of user interaction.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2016-07-22 16:30:25 +05:30
Pierre Ossman
74251f0786 memblockq: remove internal "missing" state variable
It was a very confusing state variable that required a lot of
fiddling. It was also redundant in that it can be computed from
the other variables, removing any risk of it getting out of sync.
In the same spirit, make sure "requested" also always contains a
sane value, even though it may not be used by every caller.
2016-07-22 16:30:25 +05:30
Romain Naour
a7231692e9 build-sys: C++11 is only required for WebRTC support
Make C++11 support optional and explicitly check for gnu++11.

Stop the build only if no C++11 support has been found and WebRTC
support has been requested.

Fixes:
http://autobuild.buildroot.net/results/d89/d897a94a8b6a52eba03d04c24536f554a7643000

Signed-off-by: Romain Naour <romain.naour@gmail.com>
2016-07-22 16:30:11 +05:30
Arun Raghavan
80c732e4c1 memblockq-test: Rename test to something more relevant
We now have a separate test for _pop_missing().
2016-07-22 15:49:59 +05:30
Ulrich Eckhardt
fec2a3dd05 memblockq-test: Add a test for missing data behaviour
This involves in particular pa_memblockq_missing() and
pa_memblockq_pop_missing(). The test demonstrates that the latter
doesn't work as expected. It should report whenever queue level is
drained below target level. Instead, it reports any case that the queue
level is drained, even when it is still above target level.
2016-07-22 15:49:59 +05:30
Ulrich Eckhardt
ad52f9a6ba memblockq-test: Add test changing the parameters of a queue
When changing e.g. the maximum length, the target length may may have to
be adjusted, too.
2016-07-22 15:18:27 +05:30
Ulrich Eckhardt
8299afdc9a memblockq-test: Add a test that checks initial properties
Make sure that e.g. the initial size is zero and the initially missing
bytes are exactly the target length etc.
2016-07-22 15:18:27 +05:30
Ulrich Eckhardt
a295cb87cf memblockq-test: Some refactoring
- Set the loglevel once in the main entry code instead of in each test function.
 - Check pool allocation succeeded.
 - Reduce code by using utility function to allocate chunks.
 - Improve coverage by using utility function to validate queue invariants.
2016-07-22 15:18:27 +05:30
Ulrich Eckhardt
37b0ce0333 memblockq-test: Utility function to validate queue invariants
In particular, the relations between base, minreq, tlength, length,
missing, maxlength follow certain rules. On change, these invariants can
be violated, which requires additional code to restore them. Setting one
value can thus cause a cascade of changes. This utility function can
assert those invariants after changing something.
2016-07-22 15:18:27 +05:30
Ulrich Eckhardt
ac72e85f0a memblockq-test: Utility function to alloc chunks
This eases creating a chunk from a string for writing tests.
2016-07-22 15:18:27 +05:30
Pierre Ossman
06b84bfd05 tests: add test to verify correct minreq behaviour
Fixed up by Ulrich Eckhardt <ulrich.eckhardt@base-42.de>.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-07-22 14:44:35 +05:30
Pierre Ossman
eeec52caa0 memblockq: move minreq handling in to memblockq
Having it handled in the callers proved to be a poor fit as it
became difficult to handle a shrinking minreq sanely. It could end
up in a state where the request was never sent downstream to the
client.
2016-07-22 14:44:35 +05:30
Tanu Kaskinen
edff1b2204 launch: explain why .service depends on .socket
The reason for depending on the socket unit is rather unobvious, so
let's add a comment to help people reading the service unit file. Felipe
Sateler explained the rationale well in the commit message of
7cb524a77b, so I just copied the same text into the comment.
2016-07-20 23:39:59 +03:00
Felipe Sateler
7cb524a77b launch: make pulseaudio.service properly order and require the socket
This commit fixes two problems:

1. Because there are no implicit dependencies between sockets and services,
   the socket, as set up by systemd will race with the socket, as set up
   by the pulseaudio daemon. This can cause the pulseaudio.socket unit to
   fail (even though the pulseaudio service started just fine), which can
   confuse users.
2. While it is possible to use the service without the socket, it is not
   clear why it would be desirable. And a user installing pulseaudio and
   doing `systemctl --user start pulseaudio` will not get the socket
   started, which might be confusing and problematic if the server is to
   be restarted later on, as the client autospawn feature might kick in.
2016-07-20 23:35:03 +03:00
Arun Raghavan
4cd89aa30d daemon: Tone down system mode snarkiness
We do support system mode for the cases where it makes sense, so it's
really not sensible to be unconditionally snarky at our users for doing
it.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-07-14 18:42:26 +03:00
Georg Chini
dfa4f42480 loopback: Stop tracking max_request and min_memblockq_length
They are not needed any longer because the regulation is now based on the
difference between current and configured latency.
2016-07-14 01:14:03 +03:00
Georg Chini
c03633766c loopback: Adjust rate based on latency difference
Replace the current latency controller with a modified P-controller. For
better readability separate the controller function. For small latency
differences, the controller forms a classical P-controller while it saturates
at 1% deviation from the base rate for large latency differences.
2016-07-14 01:13:53 +03:00
Georg Chini
4a11742652 loopback: Restart timer after 1/3 second
After switching source or sink, call adjust_rates after a third of a second
instead of waiting one full adjust time. This will ensure that latency regulation
starts as soon as possible.
2016-07-14 01:13:43 +03:00
Georg Chini
919cc2f3f9 loopback: Move timer restart and snapshots to timer callback
Restaring the timer and obtaining the latency snapshots belong to the timer callback.
To maintain an adjust time as near as possible to the configured value, the timer is
now restarted immediately at the beginning of the timer callback.
2016-07-14 01:13:32 +03:00
Georg Chini
b494bd62dd loopback: Change memblockq length
The size of the memblockq must be increased to allow for long latencies
at high sample rates.
2016-07-14 01:13:19 +03:00