Tanu Kaskinen [Sat, 15 Mar 2014 07:37:06 +0000 (09:37 +0200)]
zeroconf-publish: Don't react to messages while shutting down
This fixes a case where pa__done() is called while
AVAHI_MESSAGE_PUBLISH_ALL is waiting for processing. The
pa_asyncmsgq_wait_for(AVAHI_MESSAGE_SHUTDOWN_COMPLETE) call will
process all pending messages, and processing AVAHI_MESSAGE_PUBLISH_ALL
causes publish_all_services(), and that in turn accesses u->services,
which has been already freed at this point. If we are shutting down,
we shouldn't react to any of the messages that the Avahi thread is
sending to the main thread.
Pete Beardmore [Thu, 13 Mar 2014 10:14:40 +0000 (10:14 +0000)]
alsa: Use card description in default sink/source prefix when available
When given an explicit device.description in card_properties, prefer
this information over other default prefixes (e.g. 'Built-in Audio')
when constructing sink/source descriptions.
For example, if I manually configure the card description to be
"FooBar", I then expect that the sinks and created by the card also
have "FooBar" in their description instead of generic "Built-in
Audio".
David Henningsson [Tue, 11 Mar 2014 04:50:10 +0000 (05:50 +0100)]
alsa-mixer: Fix Analog Input showing up on USB Headset
In some cases, "Analog Input" could show up as well as
"Headset Mic" (or "Headphone Mic"), because I forgot to add the
relevant "required-absent" lines when I added the headset mic path.
As a result, both "Analog Input" and "Headset Mic" showed up on the
Logitech USB 530 Headset.
Reported-by: Steve Magoun <steve.magoun@canonical.com> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Peter Meerwald [Thu, 6 Mar 2014 12:15:12 +0000 (13:15 +0100)]
tunnel-source-new: Fix shadow compiler warning
CC modules/module_tunnel_sink_la-module-tunnel.lo
modules/module-tunnel-source-new.c: In function 'read_new_samples':
modules/module-tunnel-source-new.c:145:16: warning: declaration of 'read' shadows a global declaration [-Wshadow]
Tanu Kaskinen [Wed, 29 Jan 2014 18:59:00 +0000 (20:59 +0200)]
alsa: Remove a redundant check
If mixer_handle is not NULL, then hctl_handle won't be NULL either.
The redundant check was confusing, because it looked like we would
leak the mixer_handle if mixer_handle is non-NULL and hctl_handle is
NULL.
James Bunton [Sun, 26 Jan 2014 14:14:39 +0000 (01:14 +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 [Sun, 26 Jan 2014 14:14:38 +0000 (01:14 +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.
Some people want module-rtp-send to send silence when the sink that is
monitored goes idle, and some people want module-rtp-send to pause the
RTP stream to avoid unnecessary bandwidth consumption.
Steps to reproduce:
1) Leave LFE remixing disabled (the default)
2) Start playback of stereo material on e g 5.1 surround, notice nothing in LFE
3) Now change profile to e g 4.0 surround and then back to 5.1 surround
4) Notice that LFE channel is now remixed
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Arun Raghavan [Sun, 8 Dec 2013 22:18:00 +0000 (14:18 -0800)]
protocol-native: Don't enumerate unlinked sinks and sources
This makes sure that there is no window between pa_sink/source_new()
and _put() where enumerating sinks/sources causes an assert (several
calls in sink/source_get_info need a linked sink or source).
Tanu Kaskinen [Sun, 26 Jan 2014 17:11:07 +0000 (19:11 +0200)]
thread-win32: Implement pa_thread_free_nojoin()
This fixes a build error with mingw32:
pulsecore/.libs/libpulsecommon_4.99_la-lock-autospawn.o: In function `unref':
/home/abuild/rpmbuild/BUILD/pulseaudio-4.99.2/src/pulsecore/lock-autospawn.c:123: undefined reference to `pa_thread_free_nojoin'
collect2: error: ld returned 1 exit status
pa_thread_free_nojoin() was initially only implemented for the pthread
based pa_thread backend, because it was incorrectly assumed that
autospawning (the only user of pa_thread_free_nojoin()) is not used on
Windows.
Reported-By: Michael DePaulo <mikedep333@gmail.com>
The patch intends to reduce computational load when resampling AND remapping. The PA
resampler performs the following steps:
sample format conversion -> remapping -> resampling -> sample format conversion
In case the number of output channels is higher than the number of input channels, the
resampler has to be run more often than necessary. E.g. in case of mono to 4-channel remapping,
the resampler runs on 4 channels separately.
To ímprove this, the PA resampler pipeline is made adaptive:
if out-channels <= in-channels:
sample format conversion -> remapping -> resampling -> sample format conversion
if out-channels > in-channels:
sample format conversion -> resampling -> remapping -> sample format conversion
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
Peter Meerwald [Mon, 2 Dec 2013 16:26:59 +0000 (17:26 +0100)]
resampler: Extend fit_buf() helper to copy leftover data to new buffer
the patch changes the interface of the (internal) fit_buf() function:
fit_buf() manages the memblock of the buf chunk, it reallocates the memblock
if the requested number of bytes ('len') if larger than the memblock's size ('size')
and optionally preserves 'copy' bytes
Tanu Kaskinen [Sun, 26 Jan 2014 18:13:50 +0000 (20:13 +0200)]
device-manager: Don't try to use unlinked devices
This fixes an assertion crash:
[pulseaudio] source.c: Assertion 'PA_SOURCE_IS_LINKED(s->state)' failed at pulsecore/source.c:734, function pa_source_update_status(). Aborting.
The crash happened when a Bluetooth headset profile was changed from
a2dp to hsp. During the profile change three devices are created:
a sink, a monitor source for the sink, and a regular source. First
pa_sink/source_new() are called for each device, and that puts the
devices to u->core->sinks/sources. Then, pa_sink_put() is called for
the sink, and that in turn calls pa_source_put() for the source. At
that point module-device-manager decides to reroute all source
outputs. The non-monitor source that the Bluetooth card created hasn't
been linked yet at this stage, because it will only be linked after
the sink and the monitor source have been linked. So,
module-device-manager should take into account during the rerouting
that not all sinks and sources are necessarily linked. This patch does
that.
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.