James Bunton [Sat, 18 Jan 2014 02:48:55 +0000 (13:48 +1100)]
bluetooth: Fix timing to count based on decoded data
Currently the latency information is being updated based on the encoded
SBC data instead of the decoded PCM data. Fixing this required moving
the timing update to be after the packet has been decoded.
James Bunton [Mon, 13 Jan 2014 05:40:59 +0000 (16:40 +1100)]
bluetooth: Don't abort on SBC decoding error
The Nokia E7 running Symbian Belle Refresh seems to generate invalid SBC
packets every few minutes. This causes pulseaudio to disconnect the
stream and log "SBC decoding error (-3)".
If a single packet is bad, pulseaudio should keep playing the stream.
Tanu Kaskinen [Thu, 23 Jan 2014 10:05:52 +0000 (12:05 +0200)]
build-sys: Bump sonames
The bigger than usual bump in libpulse-simple was warranted by the
change in pa_simple_flush() that allows also record streams to be
flushed. There are no changes to the function signature, but it's in
practice a change in the ABI anyway, because new clients using the new
possibility won't work with older versions of the library.
Ben Brewer [Wed, 15 Jan 2014 11:19:46 +0000 (11:19 +0000)]
ladspa-sink: Set a silence memchunk for the memblockq
A crash was observed that was caused by pa_memblockq_peek() returning
a NULL memblock in sink_input_pop_cb(). The scenario where this was
happening was
1. Delete 2 rtp-recv's connected to a ladspa-sink
2. Delete ladspa-sink
3. Delete alsa-sink
4. Create alsa-sink
5. Create ladspa-sink
6. Create 2 rtp-recv's connected to the ladspa-sink
The crash was probably caused by a rewind that made the read index go
negative while the write index was at least zero, causing there to be
a gap in the memblockq. The problematic rewind might have been caused
by adding the rtp-recv stream to the ladspa-sink. That has not been
proven, but this looks very similar to the bug that was fixed in
module-virtual-sink in commit 6bd34156b130c07b130de10111a12ef6dab18b52.
Tanu Kaskinen [Sat, 11 Jan 2014 14:47:56 +0000 (16:47 +0200)]
build-sys: Fix building with --as-needed
pulsecore/core-format.c was recently added to libpulsecommon, and
core-format.c depends on functions in libpulse, which libpulsecommon
doesn't link to. That broke building with --as-needed. This patch adds
pulse/format.c to libpulsecommon, so that core-format.c doesn't need
to depend on libpulse any more. format.c pulls in also the dependency
to json-c.
Reported-By: Jan Steffens <jan.steffens@gmail.com>
Peter Meerwald [Fri, 3 Jan 2014 22:21:26 +0000 (23:21 +0100)]
alsa-card: Don't free the modargs in pa__init
The modargs are in both cases (a succesfull as well as a failed module
initialization) freed already in pa__done().
To avoid leaking modargs memory before they are assigned to u->modargs, the
code is reorganized to first allocate userdata, and then allocate the modargs.
Local variable ma is not needed anymore.
discussion here
http://lists.freedesktop.org/archives/pulseaudio-discuss/2013-December/019661.html
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Reported-by: poljar (Damir Jelić) <poljarinho@gmail.com>
Tanu Kaskinen [Wed, 4 Dec 2013 04:09:23 +0000 (06:09 +0200)]
sink-input, source-output: Interpret missing PCM parameters in format info as a request to decide those parameters at the server end
The "fix flags" (PA_SINK_INPUT_FIX_FORMAT etc.) don't work properly
with the pa_stream_new_extended() interface. This patch fixes it so
that the same effect can be achieved by leaving some of the PCM
parameters unspecified in format info objects. Also, when converting
a sample spec to a format info when using the old pa_stream_new()
interface, the "fix flags" are taken into account in that conversion.
Tanu Kaskinen [Tue, 17 Dec 2013 19:22:50 +0000 (21:22 +0200)]
stream: Remove a volume channel validity check
The check is done for clients that use pa_stream_new() but not for
clients that use pa_stream_new_extended(). This is inconsistent. We
could check that the volume channels match the channels set in the
format info struct that is passed to pa_stream_new_extended(), but
that doesn't work if the format info doesn't contain the channel
information (that can happen if the client wants the server to choose
the channel count for the stream). And it should also be possible to
pass a mono volume for a multi-channel stream. The check could be
extended to handle all these cases, but I don't see much point in
wasting time on that. The server will anyway validate the stream
parameters, it's not particularly important to fail already when the
stream is being created at the client side.
The function will be used in pa_sink_input_new() and
pa_source_output_new() to convert the sample spec given by the client
to a format info object. The set_format, set_rate and set_channels
will be set according to the stream flags (PA_SINK_INPUT_FIX_FORMAT
etc.).
Tanu Kaskinen [Mon, 18 Nov 2013 17:58:37 +0000 (19:58 +0200)]
core-format: Add pa_format_info_to_sample_spec2()
The function will be used in pa_sink_input_new() and
pa_source_output_new(). The fallback parameters are used to merge the
data in the format info with the sink/source sample spec and channel
map, when the format info is lacking some information.
Tanu Kaskinen [Mon, 25 Nov 2013 12:51:37 +0000 (14:51 +0200)]
core-format: Add pa_format_info_get_channels()
This also fixes an issue in pa_format_info_to_sample_spec(): it did
no validation for the channels value. Now the validation is taken care
of in pa_format_info_get_channels().
Tanu Kaskinen [Mon, 25 Nov 2013 12:34:58 +0000 (14:34 +0200)]
core-format: Add pa_format_info_get_rate()
This also fixes an issue in pa_format_info_to_sample_spec(): it did
no validation for the rate value. Now the validation is taken care of
in pa_format_info_get_rate().
Tanu Kaskinen [Mon, 18 Nov 2013 17:43:48 +0000 (19:43 +0200)]
Move pa_format_info_to_sample_spec_fake() to core-format
I will need to use the function from outside libpulse.
I added the channel map argument, because the function will be called
from another function that is expected to initialize the channel map.
I don't know if it's in practice necessary, but it shouldn't do any
harm either.
Tanu Kaskinen [Fri, 3 Jan 2014 11:31:29 +0000 (13:31 +0200)]
caps: Remove the FreeBSD implementation of pa_drop_caps()
Quoting Ryan Lortie from [1]:
I assumed from my reading of the Linux code ("cap_clear()...") that it
was clearing all capabilities of the process when in fact it is only
clearing the "special to root" capabilities.
The FreeBSD version of the code indeed clears _all_ capabilities beyond
ones that the process already has (ie: cannot open any new files, create
sockets, etc.)
This has a pretty obvious adverse effect on pulseaudio's ability to do
what it needs to do -- indeed, it bombs out pretty quickly due to an
inability to read its own config file.
Alexander E. Patrakov [Mon, 21 Oct 2013 23:19:27 +0000 (00:19 +0100)]
Documentation of known misuse of PulseAudio API
Hello.
Over time, I became aware of several instances of tempting but
semantically incorrect usage of PulseAudio API (one from my own bad
proposal of "improving" Wine, one from Parole media player and one
from Webkit-GTK). I want to document these gotchas so that other
developers don't fall for that. See the attached patch.
I have checked that the rendered HTML is correct, but need someone to
confirm the factual accuracy of the proposed changes and, possibly, to
improve the wording.
Tanu Kaskinen [Fri, 20 Dec 2013 19:54:22 +0000 (21:54 +0200)]
caps: Improve log message
I don't like the expression "this Pulseaudio" (even though that's
originally written by me), just "PulseAudio" is enough. Also, on
FreeBSD there's no libcap, so let's refer only to "capabilities".
Ryan Lortie [Tue, 10 Dec 2013 21:47:53 +0000 (16:47 -0500)]
Add support for FreeBSD <sys/capability.h>
cap_init() and friends are Linux-specific, so only use them if we're on
Linux.
Add support for FreeBSD capabilities if we find <sys/capability.h> to be
available there.
Add an #else (not Linux or FreeBSD) case with an #error requesting
contributions for other platforms.
This patch keeps the cap_init check in configure.ac but removes the
error if it fails. This will ensure we link to -lcap if needed, but
won't fail for the case that capabilities are part of the core system
(as on FreeBSD).
We do however, modify the header check to ensure we fail if there is no
<sys/capability.h> at all and we are on a system where it could be
installed. The logic here is that it is better to give the user the
chance to install it than it is to proceed silently with a disabled
security feature on a system where it could easily be supported.
--without-caps remains an option if the user wants to force it.
The journal is a component of systemd, that captures Syslog messages,
Kernel log messages, initial RAM disk and early boot messages as well
as messages written to STDOUT/STDERR of all services, indexes them and
makes this available to the user.
It can be used in parallel, or in place of a traditional syslog daemon,
such as rsyslog or syslog-ng.
The journal offers a couple of improvements over traditional logging
facilities (e.g. advanced filtering capabilities).
This patch adds support for logging directly to the journal using its
native API.
Tanu Kaskinen [Wed, 4 Dec 2013 07:50:11 +0000 (09:50 +0200)]
Add pa_channels_valid()
I think this makes the code a bit nicer to read and write. This also
reduces the chances of off-by-one errors when checking the bounds of
channel count values.
Tanu Kaskinen [Wed, 4 Dec 2013 07:50:10 +0000 (09:50 +0200)]
Add pa_sample_rate_valid()
I think this makes the code a bit nicer to read and write. This also
reduces the chances of off-by-one errors when checking the bounds of
sample rate values.
Tanu Kaskinen [Wed, 4 Dec 2013 07:50:09 +0000 (09:50 +0200)]
Add pa_sample_format_valid()
I think this makes the code a bit nicer to read and write. This also
reduces the chances of off-by-one errors when checking the bounds of
the sample format value.
Ryan Lortie [Tue, 10 Dec 2013 18:27:52 +0000 (13:27 -0500)]
core-util: set_scheduler: check for RLIMIT_RTTIME
set_scheduler() assumes that if sys/resource.h was found then we will
find RLIMIT_RTTIME there, but this is a non-POSIX extension on Linux.
Change the check to ensure that RLIMIT_RTTIME is actually defined.
Linux indeed defines this as a macro, and POSIX specifies that the other
RLIMIT_ constants must be macros, so having this as an #ifdef seems
correct.
Ryan Lortie [Tue, 10 Dec 2013 18:26:17 +0000 (13:26 -0500)]
bootstrap.sh: use /usr/bin/env to find bash
bootstrap.sh uses some non-POSIX features of bash, so we can't use
/bin/sh. Unlike /bin/sh, bash can be installed anywhere in the path, so
we should use /usr/bin/env to find it.
This helps systems that have bash in /usr/local/bin, for example.
Lars-Peter Clausen [Sat, 30 Nov 2013 17:07:24 +0000 (18:07 +0100)]
alsa: Disable timer-scheduling for PCMs with the BATCH flag
PCM Devices which have the BATCH flag set update the PCM pointer only with
period size granularity. Using timer based scheduling does not have any
advantage in this mode. For one devices which have that flag set usually update
the position pointer in software after getting the period interrupt. So
disabling the period interrupt is not possible for this kind of devices.
Furthermore writing to or reading from the buffer slice for the current period
is not possible since the position inside the buffer is not known. On the other
hand the tsched algorithm seems to get easily confused for this kind of
hardware, which results in garbled audio output. This typically means that timer
based scheduling needs to be manually disabled on systems with such devices.
Auto disabling tsched in this case allows these systems to run with the default
configuration.
Kenneth Perry [Thu, 5 Dec 2013 09:19:08 +0000 (11:19 +0200)]
bonjour-publish: Return ports in network byteorder
For DNS-SD (Bonjour) discovery, all ports should be set in network
byteorder instead of host byteorder. Without this, all ports on
little-endian systems (intel) are incorrect.
Peter Meerwald [Fri, 29 Nov 2013 14:32:43 +0000 (15:32 +0100)]
module-remap-sink: Add resample_method argument
the main intent is to make testing different sample rate resampling
implementations easier; so far there is only global control via
resample-method (command line argument and /etc/pulse/daemon.conf)
module-remap-*'s only purpose is resampling (comprising format conversion,
channel remapping, sample rate adjustment), it can easily be introduced
into any audio pipeline
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
Tanu Kaskinen [Wed, 20 Nov 2013 13:42:26 +0000 (15:42 +0200)]
Pass the profile object instead of the profile name to pa_card_set_profile()
When setting attribute foo, or in this case the card profile, in my
opinion the thing passed to the set_foo() function should be of the
type of foo, not a string identifier that can be used to search for
the actual foo in set_foo().
This is mostly a question of taste, but there's at least some small
benefit from passing the actual object: often the profile object is
already available when calling pa_card_set_profile(), so passing the
card name would cause unnecessary searching when pa_card_set_profile()
needs to look up the profile from the hashmap.
Stefan Sperling [Thu, 21 Nov 2013 17:47:42 +0000 (18:47 +0100)]
Fix undefined behaviour in pulseaudio --start.
Don't call pthread_join() to join a thread from a different
process than the thread was created in. Doing so can lead to
undefined behaviour.
On OpenBSD, the symptom was a pulseaudio process with a single
thread waiting forever for other threads to join. Since that
process also held the autospawn lock, starting new pulseaudio
processes with --start kept failing. The problem was analyzed
with help from Philip Guenther.
This patch adds a pa_thread_free_nojoin() function which can
be used to free resources for a thread without a join, as
suggested by Tanu Kaskinen.
See https://bugs.freedesktop.org/show_bug.cgi?id=71738