Commit graph

8574 commits

Author SHA1 Message Date
Tanu Kaskinen
c73bbee878 zeroconf-publish: unref D-Bus connection
pa_dbus_bus_get() increments the bus connection refcount, but unreffing
the connection was never done.
2016-09-05 18:59:27 +03:00
Tanu Kaskinen
de2f560137 zeroconf-publish: fix uninitialized variable
get_icon_name() returns the icon_name variable, and without this
change the function might exit before icon_name is initialized.
2016-09-05 18:59:27 +03:00
Sylvain Baubeau
963b3ea695 zeroconf: use local icon for shared devices
systemd-hostnamed provides an icon for the machine it is running on.
If it is running, module-zeroconf-publish uses this icon for the
'icon-name' attribute in the Avahi properties. module-zeroconf-discover
passes this icon to module-tunnel using the module parameter
{sink/source}_properties.

This allows to display a portable, desktop or phone instead of
the generic sound card icon.
2016-09-05 18:59:03 +03:00
Peter Meerwald-Stadler
83f0a34ea6 sample: Assert validity of sample_spec
passing an invalid sample_spec to
pa_sample_size_of_format(),
pa_frame_size(),
pa_bytes_per_second(),
pa_bytes_to_usec(),
pa_usec_to_bytes()
currently gives a result of 0

this is problematic as
(a) it leads to many potential divide-by-zero issues flagged by Coverity,
(b) pa_sample_spec_valid() is called often and the mostly unnecessary validation
of the sample_spec cannot be optimized away due to pa_return_val_if_fail()
(c) nobody checks the result for 0 and the behaviour is not documented

this patch replaces pa_return_val_if_fail() with pa_assert()

note that this commit changes the API!
note that pa_return_val_if_fail() strangely logs an assertion, but then happily
continues...

fixes numerious CIDs
2016-09-04 23:06:04 +02:00
Peter Meerwald-Stadler
250fd43bdc tests: Assert granularity range in stripnul.c
granularity must not be larger than buffer size

CID 1138482
2016-09-02 14:52:53 +02:00
Peter Meerwald-Stadler
45d9030638 core: Replace PA_PAGE_SIZE with pa_page_size()
PA_PAGE_SIZE using sysconf() may return a negative number

CID 1137925, CID 1137926, CID 1138485

instead of calling sysconf() directly, add function pa_page_size()
which uses the guestimate 4096 in case sysconf(_SC_PAGE_SIZE) fails

using PA_ONCE to only evaluate sysconf() once
2016-09-02 14:52:53 +02:00
Peter Meerwald-Stadler
c99efbffd6 padsp: Fix flush and improve error handling
read() can return a number of bytes read less than k

in addition, handle EAGAIN and EOF

CID 1137981
2016-09-02 14:52:53 +02:00
Piotr Drąg
114a429cf4 i18n: fix errors and warnings in Belarusian and Korean translations 2016-08-27 18:41:51 +03:00
Balázs Úr
bdc1ba6bd8 i18n: update Hungarian translation 2016-08-24 17:39:46 +03:00
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