Philip Chimento [Thu, 10 Nov 2016 05:22:53 +0000 (21:22 -0800)]
build-sys: Move TLS check after flags additions
Any compiler flags should be set before asking the compiler to check for
thread-local storage with AX_TLS, since compiler flags (in this case
-mmacosx-version-min=10.5) can influence the outcome of that check.
Paul Seyfert [Tue, 8 Nov 2016 11:28:55 +0000 (12:28 +0100)]
shell-completion: update zsh completion for pasuspender
* remove suggestion of '-C' due to incorrect ordering of options for
_arguments
* avoid suggesting multiple options
* add suggestion of "--", followed by executable programs
* after "--server=<hostname>" or "-s <hostname>" suggest "--"
* after "-- <program>" continue standard tab completion
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98639
Pali Rohár [Sun, 11 Sep 2016 14:41:02 +0000 (16:41 +0200)]
bluetooth: Add optional heuristic for switching between hsp and a2dp profiles
Not all VOIP applications (specially those which use alsa) set media.role to
phone. This means we need some heuristic to determinate if we want to switch
from a2dp to hsp profile based on number and types of source output (recording)
streams.
And also some people want to use their bluetooth headset (with microphone) as
their default recording device but some do not want to because of low quality.
This patch implements optional heuristic which is disabled by default. It is
disabled by default to not break experience of current pulseaudio users because
heuristic cannot be optimal. Heuristic is implemented in module-bluetooth-policy
module and decide if pulseaudio should switch to a hsp profile or not. It checks
if there is some source output with pass all these conditions:
* does not have set media.role
* does not use peak resample method (which is used by desktop volume programs)
* has assigned client/application (non virtual stream)
* does not record from monitor of sink
And if yes it switch to hsp profile.
By default this heuristic is disabled and can be enabled when loading module
module-bluetooth-policy with specifying parameter auto_switch=2
Because it is disabled by default nobody will be affected by this change unless
manually change auto_switch parameter.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Hajime Fujita [Mon, 1 Feb 2016 04:16:05 +0000 (22:16 -0600)]
rtp: Introduce pa_rtsp_exec_ready()
In the current RTSP implementation, there is a vulnerable window
between the RTSP object creation and the URL initialization.
If any RTSP command is issued during this period, it will lead to
crash by assertion violation.
This patch introduces pa_rtsp_exec_ready(), which returns if it is
safe to issue RTSP commands.
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Martin Blanchard [Mon, 1 Feb 2016 04:16:04 +0000 (22:16 -0600)]
rtp: Random seq number at the beginning of the session
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Colin Leroy [Mon, 1 Feb 2016 04:16:03 +0000 (22:16 -0600)]
rtp: New pa_rtsp_options function
Add a function performing a call to the OPTIONS request; also,
in some special cases, tuning transport parameters is required (default:
"RTP/AVP/TCP;unicast;interleaved=0-1;mode=record") ! The RAOP client for
example needs to overwrite them.
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Martin Blanchard [Mon, 1 Feb 2016 04:16:01 +0000 (22:16 -0600)]
raop: Add pulsecore/core-utils a pa_str_in_list function
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Martin Blanchard [Mon, 1 Feb 2016 04:16:00 +0000 (22:16 -0600)]
raop: Cosmetic fixes / Match coding style
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Hajime Fujita [Mon, 1 Feb 2016 04:15:59 +0000 (22:15 -0600)]
rtp: Freeing ioline when disconnecting
pa_ioline_close does not free the ioline structure itself, so we
have to unref the structure if we want to free it.
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Hajime Fujita [Mon, 1 Feb 2016 04:15:58 +0000 (22:15 -0600)]
Support IPv6 address in pa_socket_client_new_string()
pa_socket_client_new_string() did not work as expected when an IPv6
address string like "2001:db8::1" is passed as the "name" parameter.
This is because the name parameter is then passed to pa_parse_address(),
which thinks the last colon as a separator between hostname (or address)
and a port number. To prevent pa_parse_address() from doing this, an IPv6
address must be bracketed with "[]" (e.g. "[2001:db8::1]"). [1]
This patch fixes pa_socket_client_new_string() so that it internally
adds brackets to an IPv6 address. This decision is based on a
discussion at [2].
[1]: http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-October/022010.html
[2]: http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-November/022401.html
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Tanu Kaskinen [Thu, 12 Jan 2017 04:31:03 +0000 (06:31 +0200)]
build-sys: add the AGPL license file to tarballs
Tanu Kaskinen [Wed, 18 Jan 2017 03:43:37 +0000 (05:43 +0200)]
update NEWS
Rikard Söderström [Thu, 12 Jan 2017 21:41:52 +0000 (22:41 +0100)]
daemon-conf: changed 'not' to 'note'
Tanu Kaskinen [Thu, 12 Jan 2017 04:45:20 +0000 (06:45 +0200)]
zeroconf-publish: fix unitialized DBusError
BugLink: https://bugs.archlinux.org/task/52484
Moo [Fri, 6 Jan 2017 19:01:25 +0000 (21:01 +0200)]
i18n: add Lithuanian translation
Tanu Kaskinen [Thu, 29 Dec 2016 13:46:53 +0000 (15:46 +0200)]
build-sys: bump sonames
There are no changes in the ABI. libpulse has received bug fixes,
libpulse-simple and libpulse-mainloop-glib have no changes at all.
Tanu Kaskinen [Fri, 30 Dec 2016 15:52:36 +0000 (17:52 +0200)]
memblockq-test: fix incorrect assumption of pa_memblockq_pop_missing() behaviour
The intuitive meaning of "missing" would be the difference between
tlength and the current queue length, and that's how memblockq-test
assumed pa_memblockq_pop_missing() to define the term "missing", but
that was an incorrect assumption, causing the last
pa_memblockq_pop_missing() return value assertion to fail.
This patch fixes the failing assertion and adds some comments about how
the "missing" and "requested" variables in memblockq work.
Tanu Kaskinen [Fri, 30 Dec 2016 15:52:35 +0000 (17:52 +0200)]
memblockq: remove pa_memblockq_missing()
The function isn't used anywhere else than memblockq-test. Also, the
function is confusing, because it defines "missing" differently than
pa_memblockq_pop_missing(). pa_memblockq_missing() calculated the
missing amount like this:
missing = tlength - length,
where "length" is the current queue length. pa_memblockq_pop_missing(),
on the other hand, calculates the missing amount like this:
missing = tlength - length - requested,
where "requested" is an internal variable that keeps track of how much
the server has requested data from the client and how much of the
requests are yet to be fulfilled by the client.
memblockq-test is broken at the moment, because it assumes that
pa_memblockq_pop_missing() calculates "missing" the same way that
pa_memblockq_missing() used to calculate it. A patch for fixing that
will follow.
Tanu Kaskinen [Wed, 28 Dec 2016 21:35:15 +0000 (23:35 +0200)]
LICENSE: add a note about qpaeq being licensed under AGPL
Tanu Kaskinen [Wed, 28 Dec 2016 21:35:14 +0000 (23:35 +0200)]
LICENSE: add a clarification
Tanu Kaskinen [Wed, 28 Dec 2016 14:09:54 +0000 (16:09 +0200)]
Revert "memblockq: remove internal "missing" state variable"
This reverts commit
74251f07864c63439ea847d7287024ac54578d64.
The reverted commit was not intended to make any behavioral changes, but
it broke at least the case where a client writes more data than the
server has requested.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99211
Ahmed S. Darwish [Tue, 20 Dec 2016 09:07:31 +0000 (09:07 +0000)]
pacat: Write to stream only in frame-sized chunks
Current pacat code reads whatever available from STDIN and writes
it directly to the playback stream. A minimal buffer is created
for each read operation; no further reads are then allowed unless
earlier read buffer has been fully consumed by a stream write.
While quite simple, this model breaks upon the new requirements of
writing only frame-aligned data to the stream (commits #1 and #2).
The kernel read syscall can return a length much smaller than the
frame-aligned size requested, leading to invalid unaligned writes.
This can easily be reproduced by choosing a starved STDIN backend:
pacat /dev/random pa_stream_write() failed: EINVAL
echo 1234 | pacat pa_stream_write() failed: EINVAL
or by playing an incomplete WAV file in raw, non-paplay, mode.
So guard against such incomplete kernel reads by writing only in
frame-aligned sizes, while caching any trailing partial frame for
subsequent writes.
Other operation modes are not affected. Non-raw paplay playback is
handled by libsndfile, ensuring complete reads, and recording mode
just writes to the STDOUT fd without any special needs.
CommitReference #1:
22827a5e1e62
CommitReference #2:
150ace90f380
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98475
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=77595
Suggested-by: David Henningsson <diwic@ubuntu.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Tanu Kaskinen [Fri, 16 Dec 2016 15:12:54 +0000 (17:12 +0200)]
build-sys: add LICENSE.WEBKIT to EXTRA_DIST
The file was missing from release tarballs.
Tanu Kaskinen [Wed, 7 Dec 2016 23:59:05 +0000 (01:59 +0200)]
refactor stream attaching/detaching
Move repetitive code into convenience functions. No changes in
behaviour.
Tanu Kaskinen [Wed, 7 Dec 2016 23:59:04 +0000 (01:59 +0200)]
sink, source: remove some assumptions about stream "attached" state
Streams are detached when they are removed or moved away from a device,
or when a filter device that they're connected to is removed or moved.
If these cases overlap, a crash will happen due to "double-detaching".
This can happen if a filter sink is removed, and a stream connected to
that filter sink removes itself when its sink goes away.
Here are the steps in more detail: When a filter sink is unloaded, first
it will unlink its own sink input. This will cause the filter sink's
input to be detached. The filter sink propagates the detachment to all
inputs connected to it using pa_sink_detach_within_thread(). After the
filter sink is done unlinking its own sink input, it will unlink the
sink. This will cause at least module-combine-sink to remove its sink
input if it had one connected to the removed filter sink. When the
combine sink removes its sink input, that input will get detached again,
and a crash follows.
We can relax the assertions a bit, and skip the detach() call if the
sink input is already detached.
I think a better fix would be to unlink the sink before the sink input
when unloading a filter sink - that way we could avoid the
double-detaching - but that would be a much more complicated change. I
decided to go with this simple fix for now.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98617
Tanu Kaskinen [Wed, 7 Dec 2016 23:59:03 +0000 (01:59 +0200)]
sink, source: add missing stream "attached" flag handling
The functions that call attach()/detach() for all streams on a sink or
source didn't update the "attached" flag accordingly. Since the flag is
only used in assertions, this omission didn't cause any harm in normal
use.
Tanu Kaskinen [Wed, 7 Dec 2016 23:59:02 +0000 (01:59 +0200)]
sink, source: unify stream "attached" flag checking
The "attached" flag is only used for asserting that the stream is in the
expected state when attaching or detaching.
Sometimes the flag was checked and updated before calling the attach or
detach callback, and sometimes after. I think it makes more sense to
always check it before calling the callback.
Tanu Kaskinen [Wed, 12 Oct 2016 14:20:41 +0000 (17:20 +0300)]
sink-input, source-output: set sink/source to NULL before the "unlink post" hook
At the time the "unlink post" hook is fired, the stream is not any more
connected to its old device, so it makes sense to reset the sink/source
pointer to NULL before firing the hook. If this is not done, the pointer
may become stale during the "unlink post" hook, because
module-bluetooth-policy does a card profile change in its "unlink post"
callback, so even if the pointer is valid when module-bluetooth-policy's
callback is called, it will be invalid in subsequent callbacks.
Tanu Kaskinen [Wed, 12 Oct 2016 14:20:40 +0000 (17:20 +0300)]
suspend-on-idle: use earlier (safer) hooks for stream unlink notifications
In the "unlink post" hook it's not guaranteed that the stream's old
device exists any more, so let's use the "unlink" hook that is safer.
For example, module-bluetooth-policy does a card profile change in the
source-output "unlink post" hook, which invalidates the source-output's
source pointer.
When the "unlink" hook is fired, the stream is still linked to its
device, which affects the return values of the check_suspend()
functions. The unlinked streams should be ignored by the check_suspend()
functions, so I had to add extra parameters to those functions.
Tanu Kaskinen [Wed, 12 Oct 2016 14:20:39 +0000 (17:20 +0300)]
bluetooth-policy: do A2DP profile restoring a bit later
This fixes a crash that happens if the bluetooth headset is the only
non-monitor source in the system and the last "phone" stream dies.
When the stream dies, the native protocol calls pa_source_output_unlink()
and would call pa_source_output_unref() next, but without this patch,
things happen during the unlinking, and the unreffing ends up being
performed on a stream that is already freed.
pa_source_output_unlink() fires the "unlink" hook before doing anything
else. module-bluetooth-policy then switches the headset profile from HSP
to A2DP within that hook. The HSP source gets removed, and at this point
the dying stream is still connected to it, and needs to be rescued.
Rescuing fails, because there are no other sources in the system, so the
stream gets killed. The native protocol has a kill callback, which again
calls pa_source_output_unlink() and pa_source_output_unref(). This is
the point where the native protocol drops its own reference to the
stream, but another unref call is waiting to be executed once we return
from the original unlink call.
I first tried to avoid the double unreffing by making it safe to do
unlinking recursively, but I found out that there's code that assumes
that once unlink() returns, unlinking has actually occurred (a
reasonable assumption), and at least with my implementation this was not
guaranteed. I now think that we must avoid situations where unlinking
happens recursively. It's just too hairy to deal with. This patch moves
the bluetooth profile switch to happen at a time when the dead stream
isn't any more connected to the source, so it doesn't have to be
rescued or killed.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=97906
Tanu Kaskinen [Tue, 13 Sep 2016 15:43:38 +0000 (18:43 +0300)]
don't assume that pa_asyncq_new() always succeeds
Bug 96741 shows a case where an assertion is hit, because
pa_asyncq_new() failed due to running out of file descriptors.
pa_asyncq_new() is used in only one place (not counting the call in
asyncq-test): pa_asyncmsgq_new(). Now pa_asyncmsgq_new() can fail too,
which requires error handling in many places. One of those places is
pa_thread_mq_init(), which can now fail too, and that needs additional
error handling in many more places. Luckily there weren't any places
where adding better error handling wouldn't have been easy, so there are
many changes in this patch, but they are not complicated.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96741
Tanu Kaskinen [Tue, 20 Sep 2016 09:59:04 +0000 (12:59 +0300)]
rtp: don't use memblocks for non-audio data
pa_memblockq_push() expects all memchunks to be aligned to PCM frame
boundaries, and that means both the index and length fields of
pa_memchunk. pa_rtp_recv(), however, used a memblock for storing both
the RTP packet metadata and the actual audio data. The metadata was
"removed" from the audio data by setting the memchunk index
appropriately, so the metadata stayed in the memblock, but it was not
played back. The metadata length is not necessarily divisible by the PCM
frame size, which caused pa_memblock_push() to crash in an assertion
with some sample specs, because the memchunk index was not properly
aligned. In my tests the metadata length was 12, so it was compatible
with many configurations, but eight-channel audio didn't work.
This patch adds a separate buffer for receiving the RTP packets. As a
result, an extra memcpy is needed for moving the audio data from the
receive buffer to the memblock buffer.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96612
Tanu Kaskinen [Wed, 21 Sep 2016 09:55:08 +0000 (12:55 +0300)]
module: postpone lt_dlclose() until a safe time
When unloading a module, lt_dlclose() may remove the module from memory.
If a module unloads itself, it's not safe to call lt_dlclose()
synchronously from pa_module_unload(), because the execution may return
to the module code that was removed from memory. To avoid this
situation, let's postpone lt_dlclose() until it's safe to call it.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96831
Tanu Kaskinen [Mon, 5 Dec 2016 20:20:42 +0000 (22:20 +0200)]
remove module-xenpv-sink
The module doesn't build any more[1], and when starting to investigate
the build failure, I asked the module author if he'd know something
about the breakage. He said that he didn't know about backward
compatibility problems with libxen, but more importantly, he said that
the module probably doesn't have any users[2]. It doesn't make sense to
keep maintaining a module that doesn't have users, so let's drop it.
[1] https://bugs.freedesktop.org/show_bug.cgi?id=98793
[2] https://lists.freedesktop.org/archives/pulseaudio-discuss/2016-November/027172.html
Juha Kuikka [Sat, 16 Apr 2016 00:37:22 +0000 (17:37 -0700)]
bluetooth: fix race condition in BlueZ5 device disconnection
SW: Pulseaudio 8.0 / BlueZ 5.39
Symptoms:
While disconnecting/reconnecting a paired bluetooth headset (LG HBS750)
audio fails roughly on every other connection.
On a failed connection "pactl list cards" shows the bluetooth device's
card but "Active Profile: off". Issuing "pacmd set-card-profile X
a2dp_sink" makes audio work immediately.
I realized that when this happened, the previous disconnection did not
remove the card, instead it was only configured for "Active Profile:
off" but otherwise left in place.
Upon looking at PA debug logs I saw that the transport for the a2dp_sink
was first set into disconnected state and then into idle state. In
"device_connection_changed_cb()" this causes the
"pa_bluetooth_device_any_transport_connected()" return true and the
module-bluez5-device is not unloaded.
Further investigation shows that this is caused by a race of
module-bluez5-device.c:thread_func() and
MediaPoint1::ClearConfiguration().
When the FD in thread_func() is closed (POLLHUP) an
BLUETOOTH_MESSAGE_STREAM_FD_HUP message is sent into the main thread.
The handler of this message unconditionally sets the transport into IDLE
state. This is a problem if it has already been set into DISCONNECTED
state.
Piotr Drąg [Sun, 27 Nov 2016 15:51:49 +0000 (16:51 +0100)]
i18n: update Polish translation
https://bugs.freedesktop.org/show_bug.cgi?id=98872
Fran Dieguez [Sun, 27 Nov 2016 15:29:16 +0000 (17:29 +0200)]
i18n: add Galician translation
Ahmed S. Darwish [Tue, 22 Nov 2016 20:18:56 +0000 (22:18 +0200)]
stream: Frame-align divided audio segments
Executing below command will not produce any audio:
pacat --channels=3 /dev/urandom
Turns out that pa_stream_write() breaks large audio buffers into
segments of the maximum memblock size available -- a value which
is not necessarily frame aligned.
Meanwhile the server discards any non-aligned client audio, as a
security measure, due to some earlier reported daemon crashes.
Thus divide sent audio to the expected aligned form.
CommitReference-1:
22827a5e1e62
CommitReference-2:
150ace90f380
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98475
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=77595
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Ahmed S. Darwish [Tue, 22 Nov 2016 20:16:10 +0000 (22:16 +0200)]
pacat: Synchronize STDIN and "write stream ready" events
Users reported pacat crashes when playing certain multi-channel
audio. For example:
pacat --channels=2 /dev/zero works
pacat --channels=3 /dev/zero pa_stream_write() failed: EINVAL
pacat --channels=4 /dev/zero works
pacat --channels=5 /dev/zero pa_stream_write() failed: EINVAL
pacat audio playback is pipe-like, from STDIN to PA write stream.
Meanwhile STDIN "ready to read" events got regularly triggered
before the write stream was even created, or at moments where the
stream could not accept any more audio.
In these out-of-sync cases, the write stream could not report the
appropriate buffer lengths it accepts, thus a default of 4K bytes
was chosen -- compatible by luck with some channel counts and
incompatible with others.
Instead of choosing a faulty default in these scenarios, mute the
the STDIN events until the write stream is available & queriable.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98475
Reported-by: Tanu Kaskinen <tanuk@iki.fi>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Ahmed S. Darwish [Fri, 18 Nov 2016 23:54:10 +0000 (01:54 +0200)]
protocol-native: Don't signal memfd support for 9.0 clients
Although such 9.0 clients support memfd transport, they have an
iochannel bug that would break memfd audio if they're run in 32
bit mode over a 64-bit kernel. Influence them to use the POSIX
shared memory model instead.
Also bump the protocol version to exclusively mark such v9.0
libraries. Check commit
451d1d676237c81 for further details.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=97769
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Ahmed S. Darwish [Tue, 15 Nov 2016 16:48:46 +0000 (16:48 +0000)]
iochannel: Strictly specify PF_UNIX ancillary data boundaries
Users reported audio breakage for 32-bit pulse clients connected
to a 64-bit server over memfds. Investigating the issue further,
the problem is twofold:
1. iochannel's file-descriptor passing code is liberal in what it
issues: produced ancillary data object's "data" section exceeds
length field. How such an extra space is handled is a grey area
in the POSIX.1g spec, the IETF RFC #2292 "Advanced Sockets API
for IPv6" memo, and the cmsg(3) manpage.
2. A 64-bit kernel handling of such extra space differs by whether
the app is 64-bit or 32-bit. For 64-bit apps, the kernel
smartly ducks the issue. For 32-bit apps, an -EINVAL is
directly returned; that's due to a kernel CMSG header traversal
bug in the networking stack "32-bit sockets emulation layer".
Compare Linux Kernel's socket.h cmsg_nxthdr() code and the
32-bit emulation layer version of it at net/compat.c
cmsg_compat_nxthdr() for further info. Notice how the former
graciously ignores incomplete CMSGs while the latter _directly_
complains about them -- as of kernel version 4.9-rc5.
(A kernel patch is to be submitted)
Details:
iochannel typically uses sendmsg() for passing FDs & credentials.
>From RFC 2292, sendmsg() control data is just a heterogeneous
array of embedded ancillary objects that can differ in length.
Linguistically, a "control message" is an ancillary data object.
For example, below is a sendmsg() "msg_control" containing two
ancillary objects:
|<---------------------- msg_controllen---------------------->|
| |
|<--- ancillary data object -->|<----- ancillary data object->|
|<------- CMSG_SPACE() ------->|<------- CMSG_SPACE() ------->|
| | |
|<-------- cmsg_len ------->| |<-------- cmsg_len ------->| |
|<------- CMSG_LEN() ------>| |<------- CMSG_LEN() ------>| |
| | | | |
+-----+-----+-----+--+------+--+-----+-----+-----+--+------+--+
|cmsg_|cmsg_|cmsg_|XX|cmsg_ |XX|cmsg_|cmsg_|cmsg_|XX|cmsg_ |XX|
|len |level|type |XX|data[]|XX|len |level|type |XX|data[]|XX|
+-----+-----+-----+--+------+--+-----+-----+-----+--+----+-+--+
^^^^^^^ Ancil Object #1 ^^^^^^^ Ancil Object #2
(control message) (control message)
^
|
+--- sendmsg() "msg_control" points here
Problem is, while passing FDs, iochannel's code try to avoid
variable-length arrays by creating a single cmsg object that can
fit as much FDs as possible:
union {
struct cmsghdr hdr;
uint8_t data[CMSG_SPACE(sizeof(int) * MAX_ANCIL_DATA_FDS)];
} cmsg; ^^^^^^^^^^^^^^^^^^
Most of the time though the number of FDs to be passed is less
than the maximum above, thus "cmsg_len" is set to the _actual_ FD
array size:
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int) * nfd);
^^^
This inconsistency tricks the kernel into thinking that we have 2
ancillay data objects instead of one! First cmsg is valid as
intended, but the second is instantly _corrupt_ since it has a
cmsg_len size of 0 -- thus failing kernel's CMSG_OK() tests.
For 32-bit apps on a 32-bit kernel, and 64-bit apps over a 64-bit
one, the kernel's own CMSG header traversal macros just ignore the
second "incomplete" cmsg. For 32-bit apps over a 64-bit kernel
though, the kernel 32-bit socket emulation macros does not forgive
such incompleteness and directly complains of invalid args (due to
a subtle bug).
Avoid this ugly problem, which can also bite us in a pure 64-bit
environment if MAX_ANCIL_DATA_FDS got extended to 5 FDs, by
setting "cmsg_data[]" array size to "cmsg_len".
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=97769
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Tanu Kaskinen [Fri, 4 Nov 2016 12:43:57 +0000 (14:43 +0200)]
raop: add compatibility with openssl 1.1.0
Openssl 1.1.0 made all structs opaque, which caused a build failure in
raop_client.c. The struct member assignments are now replaced with a
call to RSA_set0_key().
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=96726
Reviewed-by: Felipe Sateler <fsateler@debian.org>
Anton Lundin [Tue, 25 Oct 2016 19:31:34 +0000 (21:31 +0200)]
raop: Correct spelling of KTH
KTH is a Swedish institution of higher education, and in its full name
spelled Kungliga Tekniska högskolan.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Cédric Valmary [Thu, 13 Oct 2016 12:28:43 +0000 (15:28 +0300)]
i18n: update Occitan translation
Mario Blättermann [Wed, 5 Oct 2016 12:16:20 +0000 (15:16 +0300)]
i18n: update German translation
Pali Rohár [Sun, 11 Sep 2016 15:16:38 +0000 (17:16 +0200)]
bluetooth: Add support for automatic switch between hsp and a2dp profiles also for bluez5
Bluez5 uses different profile names as bluez4, so we need to check for
a2dp_sink and headset_head_unit too for bluez5 support.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Philip Withnall [Tue, 20 Sep 2016 17:26:00 +0000 (10:26 -0700)]
zeroconf-discover: fix a memory leak
Coverity CID: #1358700
https://bugs.freedesktop.org/show_bug.cgi?id=97876
Deepak Srivastava [Mon, 19 Sep 2016 08:36:10 +0000 (14:06 +0530)]
xen: Fixed possible memory leak.
module-xenpv-sink.c - In pa__init(...), memory for pa_modargs *ma is not released before returning from function.
Signed-off-by: Deepak Srivastava <srivastava.d@samsung.com>
Pali Rohár [Thu, 15 Sep 2016 15:52:40 +0000 (17:52 +0200)]
bluetooth: bluez5: Add profile name to sinks and sources
See commit
380a7fc2401ea26151e0383adff05314a263ac31.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Marcin Lewandowski [Thu, 30 Jun 2016 10:38:14 +0000 (12:38 +0200)]
core-util: log error if we hit file descriptors limit
Jan Alexander Steffens (heftig) [Fri, 9 Sep 2016 20:09:35 +0000 (22:09 +0200)]
launch: Remove the already implicit After=pulseaudio.socket
Also clarify the comment as to what can actually happen here.
Tanu Kaskinen [Thu, 8 Sep 2016 13:20:04 +0000 (16:20 +0300)]
daemon-conf: enable memfd by default
memfd support was introduced in 9.0, but disabled by default. No issues
have been reported - now is a good time to enable it by default.
Tanu Kaskinen [Mon, 5 Sep 2016 15:57:17 +0000 (18:57 +0300)]
zeroconf-publish: unref D-Bus connection
pa_dbus_bus_get() increments the bus connection refcount, but unreffing
the connection was never done.
Tanu Kaskinen [Mon, 5 Sep 2016 15:55:37 +0000 (18:55 +0300)]
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.
Sylvain Baubeau [Thu, 1 Sep 2016 09:14:05 +0000 (11:14 +0200)]
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.
Peter Meerwald-Stadler [Thu, 18 Aug 2016 14:08:45 +0000 (16:08 +0200)]
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
Peter Meerwald-Stadler [Thu, 18 Aug 2016 07:24:41 +0000 (09:24 +0200)]
tests: Assert granularity range in stripnul.c
granularity must not be larger than buffer size
CID 1138482
Peter Meerwald-Stadler [Wed, 17 Aug 2016 23:06:47 +0000 (01:06 +0200)]
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
Peter Meerwald-Stadler [Wed, 17 Aug 2016 21:52:17 +0000 (23:52 +0200)]
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
Piotr Drąg [Fri, 26 Aug 2016 14:26:03 +0000 (16:26 +0200)]
i18n: fix errors and warnings in Belarusian and Korean translations
Balázs Úr [Wed, 24 Aug 2016 05:34:08 +0000 (07:34 +0200)]
i18n: update Hungarian translation
Viktar Vaŭčkievič [Wed, 24 Aug 2016 14:35:03 +0000 (17:35 +0300)]
i18n: add Belarusian translation
Peter Meerwald-Stadler [Tue, 16 Aug 2016 13:56:40 +0000 (15:56 +0200)]
bluetooth: Fix negative array index write
CID 1533121
Peter Meerwald-Stadler [Tue, 16 Aug 2016 13:33:24 +0000 (15:33 +0200)]
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!
Peter Meerwald-Stadler [Tue, 16 Aug 2016 05:42:16 +0000 (07:42 +0200)]
bluetooth: Fix dead code
CID 1353115
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Peter Meerwald-Stadler [Tue, 16 Aug 2016 05:16:31 +0000 (07:16 +0200)]
bluetooth: Don't free modargs twice
CID1353139
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Peter Meerwald-Stadler [Tue, 16 Aug 2016 05:03:25 +0000 (07:03 +0200)]
Remove newline at end of log messages
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Peter Meerwald-Stadler [Tue, 15 Sep 2015 14:42:58 +0000 (16:42 +0200)]
modules: Use pa_assert_se() to check return value of dbus_message_iter_close_container()
CID 1140353
... as it is done everythere else
Peter Meerwald-Stadler [Tue, 15 Sep 2015 20:34:48 +0000 (22:34 +0200)]
tests: Check pa_rtpoll_run() return value
CID 1138499
Peter Meerwald-Stadler [Tue, 15 Sep 2015 14:49:14 +0000 (16:49 +0200)]
modules: Check pa_threaded_mainloop_start() return value
CID 1138500
Peter Meerwald-Stadler [Tue, 15 Sep 2015 21:11:29 +0000 (23:11 +0200)]
stream: Check pa_tagstruct_get_format_info() retval in pa_create_stream_callback()
CID 1137984
Peter Meerwald-Stadler [Mon, 14 Sep 2015 14:48:10 +0000 (16:48 +0200)]
tests: Assert fillrate > 0 in alsa-time-test
CID 1323592
assert that fillrate is strictly positive
Peter Meerwald-Stadler [Mon, 15 Aug 2016 21:11:50 +0000 (23:11 +0200)]
alsa: Check pa_modargs_get_value_boolean() retval for use_ucm
CID 1137983
Peter Meerwald-Stadler [Mon, 15 Aug 2016 17:08:49 +0000 (19:08 +0200)]
sink-input,source-output: Fix logging, don't overwrite old_value when value == 0
John Paul Adrian Glaubitz [Mon, 4 Jul 2016 18:23:17 +0000 (20:23 +0200)]
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>
Nils Schneider [Thu, 11 Aug 2016 15:58:24 +0000 (17:58 +0200)]
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().
Tanu Kaskinen [Sat, 30 Jul 2016 23:44:55 +0000 (02:44 +0300)]
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
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:54 +0000 (18:45 +0300)]
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.
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:53 +0000 (18:45 +0300)]
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.
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:52 +0000 (18:45 +0300)]
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.
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:51 +0000 (18:45 +0300)]
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).
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:50 +0000 (18:45 +0300)]
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.
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:49 +0000 (18:45 +0300)]
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
Tanu Kaskinen [Sun, 7 Aug 2016 15:45:48 +0000 (18:45 +0300)]
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.
Arun Raghavan [Wed, 10 Aug 2016 15:53:44 +0000 (21:23 +0530)]
stream-interaction: Fix a memory leak
CID: 1352053
Arun Raghavan [Wed, 10 Aug 2016 16:13:32 +0000 (21:43 +0530)]
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
Arun Raghavan [Wed, 10 Aug 2016 16:07:12 +0000 (21:37 +0530)]
source-output: Fix copy-pasto
CID: 1352047
Arun Raghavan [Wed, 10 Aug 2016 15:59:56 +0000 (21:29 +0530)]
sink-input,source-output: Fix a leak during property change logging
CID: 1352052
Peter Meerwald [Wed, 10 Aug 2016 13:22:16 +0000 (15:22 +0200)]
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>
Peter Meerwald [Wed, 10 Aug 2016 13:22:15 +0000 (15:22 +0200)]
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>
Dušan Kazik Kazik [Thu, 28 Jul 2016 06:50:40 +0000 (12:20 +0530)]
i18n: Update Polish translation
Pali Rohár [Sat, 2 Jul 2016 20:26:17 +0000 (22:26 +0200)]
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>
Pierre Ossman [Thu, 19 May 2016 13:54:08 +0000 (15:54 +0200)]
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.
Romain Naour [Wed, 6 Jul 2016 14:04:27 +0000 (16:04 +0200)]
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>
Arun Raghavan [Fri, 22 Jul 2016 09:51:20 +0000 (15:21 +0530)]
memblockq-test: Rename test to something more relevant
We now have a separate test for _pop_missing().
Ulrich Eckhardt [Sun, 26 Jun 2016 19:15:44 +0000 (21:15 +0200)]
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.
Ulrich Eckhardt [Thu, 19 May 2016 19:34:22 +0000 (21:34 +0200)]
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.
Ulrich Eckhardt [Thu, 19 May 2016 20:06:12 +0000 (22:06 +0200)]
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.
Ulrich Eckhardt [Thu, 19 May 2016 18:00:46 +0000 (20:00 +0200)]
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.
Ulrich Eckhardt [Sat, 28 May 2016 09:15:49 +0000 (11:15 +0200)]
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.