Hajime Fujita [Sun, 6 Nov 2016 18:54:24 +0000 (12:54 -0600)]
raop: Discard data upon getting EAGAIN on a socket
This patch discards audio data when a socket returns EAGAIN.
This was made based on a suggestion by karlstav
(https://github.com/karlstav), and is supposed to solve Issue #32.
(https://github.com/hfujita/pulseaudio-raop2/issues/32)
Hajime Fujita [Sun, 6 Nov 2016 18:54:23 +0000 (12:54 -0600)]
raop: Disable is_recording flag when tearing down the connection
This patch is based on a similar idea as the previous one -- disabling
the flag right after the session is getting closed, rather than waiting
for a response from the server.
Hajime Fujita [Sun, 6 Nov 2016 18:54:22 +0000 (12:54 -0600)]
raop: Stop recording when RTSP FLUSH is issued
This patch fixes the issue #31.
https://github.com/hfujita/pulseaudio-raop2/issues/31
This patch sets c->is_recording = false when the RTSP FLUSH command
is issued. This avoids a race between the server response and
the record activation in some cases.
Martin Blanchard [Sun, 6 Nov 2016 18:54:21 +0000 (12:54 -0600)]
raop: Add back initial volume RTSP SET_PARAMETER request on connect
Regression introduced in commit 8c6407f:
raop: Merge TCP and UDP code paths + refactoring
Anyway, we need to determine if initial volume has to be setup before
sending RECORD or after:
- Setting it up *before* shouldn't be a problem: sink.c waits for
CONNECT state, set the volume and client.c triggers RECORD only once
he's got the SET_PARAMETER reply from server.
- Setting it up *after* seems to be more difficult if we try not to
send any audio before receiving the SET_PARAMETER reply form server. A
solution may be to send SET_PARAMETER just after the RECORD server
response is received and hope that it get processed by server during the
2sec latency/buffering time...
Attached patch implement that last solution. Works for me, but I cannot
guaranty it will with your hardware...
Hajime Fujita [Sun, 6 Nov 2016 18:54:20 +0000 (12:54 -0600)]
raop: Silently drop out-of-history retransmission request
Martin Blanchard [Sun, 6 Nov 2016 18:54:19 +0000 (12:54 -0600)]
raop: Correctly wrap RTP packet sequence number
Hajime Fujita [Sun, 6 Nov 2016 18:54:18 +0000 (12:54 -0600)]
raop: Add IPv6 support
Hajime Fujita [Sun, 6 Nov 2016 18:54:17 +0000 (12:54 -0600)]
raop: Add address to RAOP device description
Some time one device announces multiple addresses (e.g. IPv4 one
and IPv6 one). Or some user may own multiple RAOP devices with
the same model name.
This patch adds device port to device description so that users
can distinguish appropriate RAOP sink by its address.
Stephen Paul Weber [Sun, 6 Nov 2016 18:54:16 +0000 (12:54 -0600)]
raop: Do not flush when RTSP object is not ready
This patch fixes a crash issue reported at
https://github.com/hfujita/pulseaudio-raop2/issues/9
Colin Leroy [Sun, 6 Nov 2016 18:54:15 +0000 (12:54 -0600)]
raop: Fix packet retransmission
Fix UDP header decoding (sequence number and number of packets);
Fix missing pa_memblock_release() causing assertions after retransmission.
Colin Leroy [Sun, 6 Nov 2016 18:54:14 +0000 (12:54 -0600)]
raop: fix typos
Colin Leroy [Sun, 6 Nov 2016 18:54:13 +0000 (12:54 -0600)]
raop: fix sequence number overflow
Wrap sequence number when we reach uint16_t's max 0xFFFF.
Colin Leroy [Sun, 6 Nov 2016 18:54:12 +0000 (12:54 -0600)]
raop: Fix sink getting destroyed after one use
It is expected to get disconnected after switching back to a
different sink.
Martin Blanchard [Sun, 6 Nov 2016 18:54:11 +0000 (12:54 -0600)]
raop: Remove unimplemented code (PCM and AAC)
Martin Blanchard [Sun, 6 Nov 2016 18:54:10 +0000 (12:54 -0600)]
raop: Rework packet's store memory management
This patch switch the packet-buffer to use core memory pool instead of
manually allocating the room required for storing TCP/UDP packets. Packets
are now stored using pa_memchunk instead of internal struct. Quite a few
malloc saved compare to previous design.
Martin Blanchard [Sun, 6 Nov 2016 18:54:09 +0000 (12:54 -0600)]
raop: Update and standardise source file headers
Martin Blanchard [Sun, 6 Nov 2016 18:54:08 +0000 (12:54 -0600)]
raop: Prefer ALAC encoding to raw PCM if supported by server
ALAC encoding is to be prefered simply because ALAC audio packet reverse-
engineering and implementation is in better shape than raw PCM. Sending ALAC
audio does not mean compressing audio and thus linking an external library to
do so. ALAC packets has the ability to carry uncompressed PCM frames, and
that's what is implemented at the time.
Martin Blanchard [Sun, 6 Nov 2016 18:54:07 +0000 (12:54 -0600)]
raop: Merge TCP and UDP code paths + refactoring
TCP and UDP implementation are following two diffrent code path while code
logic is quite the same. This patch merges both code path into a unique one
and, thus, leads to a big refactoring. Major changes include:
- moving sink implementation to a separate file (raop-sink.c)
- move raop-sink.c protocol specific code to raop-client.c
- modernise RTSP session handling in TCP mode
- reduce code duplications between TCP and UDP modes
- introduce authentication support
- TCP mode does not constantly send silent audio anymore
About authentication: OPTIONS is now issued when the sink is preliminary
loaded. Client authentication appends at that time and credential is kept
for the whole sink lifetime. Later RTSP connection will thus look like this:
ANNOUNCE > 200 OK > SETUP > 200 OK > RECORD > 200 OK (no more OPTIONS). This
behaviour is similar to iTunes one.
Also this patch includes file name changes to match Pulseaudio naming
rules, as most of pulseaudio source code files seem to be using '-'
instead of '_' as a word separator.
Martin Blanchard [Sun, 6 Nov 2016 18:54:06 +0000 (12:54 -0600)]
raop: Add BA (Basic) and DA (Digest) HTTP authentication helpers
RAOP authentication is using standard HTTP challenge-response authentication
scheme. This patch adds two helper functions that generate the proper hash
(for both techniques) given a username, a password and session related tokens.
Martin Blanchard [Sun, 6 Nov 2016 18:54:05 +0000 (12:54 -0600)]
raop: Add a MD5 hashing fuction
MD5 hashing will be needed during the authentication process.
Original patch by Martin Blanchard. Patch splitted by
Hajime Fujita <crisp.fujita@nifty.com>.
Martin Blanchard [Sun, 6 Nov 2016 18:54:04 +0000 (12:54 -0600)]
raop: Move base64 implementation to a util file
Base64 implementation is now in a common file called raop_util.c.
Old Base64 files are removed but copyright is preserved.
Original patch by Martin Blanchard, patch splitted by
Hajime Fujita <crisp.fujita@nifty.com>.
Martin Blanchard [Sun, 6 Nov 2016 18:54:03 +0000 (12:54 -0600)]
raop: Extract encryption related code into a separate file
That makes the raop_client.c code smaller/cleaner and will simplify
addition of more crypto related stuffs like authentication.
Martin Blanchard [Sun, 6 Nov 2016 18:54:02 +0000 (12:54 -0600)]
raop: Better playback resume handling
When playback stops, a FLUSH command is send to the server and the sink
goes to IDLE. If playback resumes quickly, sink goes back to RUNNING
(without being SUSPENDED) and the sink should just start streaming again.
This patch implements this behaviour.
Martin Blanchard [Sun, 6 Nov 2016 18:54:01 +0000 (12:54 -0600)]
raop: Do not send audio before RECORD response
This patch prevents audio packets to be sent before the server
respond to the RECORD command.
Matthias Wabersich [Sun, 6 Nov 2016 18:54:00 +0000 (12:54 -0600)]
raop: Packet retransmission support for UDP
This patch adds an RTP audio packet retransmission support and a
circular buffer implementation for it.
This patch was originally written by Matthias Wabersich [1] and
later debugged and integrated into the latest tree by Hajime Fujita
[1]: https://bugs.freedesktop.org/show_bug.cgi?id=42804#c44
Martin Blanchard [Sun, 6 Nov 2016 18:53:59 +0000 (12:53 -0600)]
raop: Parse server capabilities on discovery
During the discovery phase, raop servers send their capabilities
(supported encryption, audio codec...). These should be passed to the
raop sink via module's arguments.
Original patch written by Martin Blanchard, then modified by Hajime
Fujita <crisp.fujita@nifty.com> based on review comments by
Anton Lundin <glance@acc.umu.se>.
Now resolver_cb always dtrdup()s string blocks given by Avahi,
to make the code easier to maintain.
Hajime Fujita [Sun, 6 Nov 2016 18:53:58 +0000 (12:53 -0600)]
raop: Add UDP protocol handling
There are two versions in the RAOP protocol; one uses TCP and the
other uses UDP. Current raop implementation only supports TCP
version.
This patch adds an initial UDP protocol support for RAOP.
It is based on Martin Blanchard's work
(http://repo.or.cz/w/pulseaudio-raopUDP.git/shortlog/refs/heads/raop)
which is inspired by Christophe Fergeau's work
(https://github.com/zx2c4/pulseaudio-raop2).
Matrin's modifications were edited by Hajime Fujita, so that it
would support both TCP and UDP protocol in a single module.
Also this patch includes a fix that was found thanks to Matthias,
who reported that his ALAC
codec support fixed the issue.
https://bugs.freedesktop.org/show_bug.cgi?id=42804#c30
Hajime Fujita [Sun, 6 Nov 2016 18:53:57 +0000 (12:53 -0600)]
core-util: do in-place search in pa_str_in_list_spaces
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Hajime Fujita [Sun, 6 Nov 2016 18:53:56 +0000 (12:53 -0600)]
core-util: add pa_split_space_in_place function
Reviewed-by: Anton Lundin <glance@acc.umu.se>
Hajime Fujita [Sun, 6 Nov 2016 18:53:55 +0000 (12:53 -0600)]
core-util: add pa_strneq macro
This macro compares if the given two strings, with the maximum length
of n, are equal. Useful for strings that are not NULL-terminated.
Reviewed-by: Anton Lundin <glance@acc.umu.se>
David Mandelberg [Wed, 4 Jan 2017 16:55:49 +0000 (11:55 -0500)]
daemon-conf: add remixing-use-all-sink-channels option
This option controls the PA_RESAMPLER_NO_FILL_SINK flag added in a
previous commit.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=62588
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94563
David Mandelberg [Wed, 4 Jan 2017 16:55:48 +0000 (11:55 -0500)]
remix-test: test the remixer with PA_RESAMPLER_NO_FILL_SINK set
David Mandelberg [Wed, 4 Jan 2017 16:55:47 +0000 (11:55 -0500)]
resampler: Flag for remixing to all sink channels.
Add a flag PA_RESAMPLER_NO_FILL_SINK, which controls whether remixing
should attempt to use all sink channels, versus only the ones needed
to reproduce the source audio.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=62588
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94563
Suggested-by: Alexander E. Patrakov <patrakov@gmail.com>
David Mandelberg [Wed, 4 Jan 2017 16:55:46 +0000 (11:55 -0500)]
remix-test: test the remixer using different flags
This will make it easier to see how the following commit affects the
remixer.
Corentin Noël [Mon, 26 Dec 2016 10:52:06 +0000 (11:52 +0100)]
vala: use the correct syntax
Constants should be declared simply with "const". With struct members,
"static" means that all struct instances share the same variable, i.e.
all instances always see the same value. That's of course already
implied in the concept of "constant". Newer Vala versions don't allow
mixing "const" and "static".
Takashi Sakamoto [Fri, 30 Dec 2016 03:05:20 +0000 (12:05 +0900)]
alsa: remove double calls of snd_pcm_prepare()
In alsa-lib, snd_pcm_hw_params() internally calls snd_pcm_prepare(), thus
user space applications have no need to call snd_pcm_prepare() after calls
of snd_pcm_hw_params(). An explicit calls of snd_pcm_prepare() is expected
in a case to recover PCM substreams.
Current implementation of PulseAudio modules for ALSA playbacking/capturing
results in double calls of snd_pcm_prepare(). The second call for hw plugin
of alsa-lib executes ioctl(2) with SNDRV_PCM_IOCTL_PREPARE command in state
of SNDRV_PCM_STATE_PREPARED for the PCM substream. This has no effects to
the PCM substream as long as corresponding drivers are implemented
correctly.
This commit removes the second call for the reason.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Renjith Thomas [Thu, 15 Dec 2016 07:04:14 +0000 (12:34 +0530)]
bluetooth: fix distorted audio during Bluetooth SCO HFP/HSP playback
Issue: When HFP/HSP profile is used with certain BT chipsets, the
audio sounds heavily distorted, with very slow playback full of noise.
During recording, the samples are dropped and it distorts the recorded
audio samples.
The root cause of both the issues are related to the fixed MTU sizes
in the PA stack, which is 48 bytes. Here, the BT chipset CC256x had
180 bytes MTU and it was being under-utilized and the rate at which
the samples were being accepted where not matching the expected rate,
and hence the distortion.
Solution: The appropriate solution to this problem is by reading the
MTU size of the SCO socket using getsockopts dynamically.
BugLink: http://bit.ly/2gDpGPv
BugLink: http://bit.ly/2hQsARK
Felipe Sateler [Mon, 28 Nov 2016 17:49:06 +0000 (14:49 -0300)]
padsp: allow overriding library install location
The current build script hardcodes the $pkglibdir in the padsp command.
This works and is a reasonable default. However, distributions that
know where they install, can override this path and thus make padsp
work for any architecture that has the library installed by using the
following configure argument:
--with-pulsedsp-location='/usr/\\$$LIB/pulseaudio'
This works because ld.so considers $LIB a variable that will expand to
several location paths, depending on the architecture of the binary
being executed.
In debian, for example, this would work for libpulsedsp.so installed in
/usr/lib/x86_64-linux-gnu/ for amd64 and /usr/lib/i386-linux-gnu/ for
i386, with a single padsp command.
Philip Chimento [Sat, 12 Nov 2016 20:48:44 +0000 (12:48 -0800)]
build-sys: Don't override libtoolize
The autoreconf invocation below will already pick up any overrides the
user might have made to their LIBTOOLIZE variable. Overriding it here
will break on Darwin systems where libtoolize is not called glibtoolize,
and is not necessary, so just remove it.
Tanu Kaskinen [Thu, 10 Nov 2016 11:22:04 +0000 (13:22 +0200)]
x11-bell: ignore volume from X11
X11 has its own bell volume setting, controlled with the "xset b"
command. If we use that volume, then the "System Sounds" slider in
pavucontrol doesn't affect the x11-bell sample volume, which in my
opinion is a bad thing. Ignoring the volume suggestion from X11 allows
module-stream-restore to apply the "event" role volume.
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