Commit graph

8247 commits

Author SHA1 Message Date
Ahmed S. Darwish
b1d47d60fc client audio: Support memfd transport
Now that all layers in the stack support memfd blocks, add memfd
pools support for client context and audio playback data.

Use such memfd pools by default only if the server signals memfd
support in its connection negotiations.

Also add ability for clients to force-disable memfd transport
through the `enable-memfd=' client configuration option.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-27 18:37:07 +05:30
Ahmed S. Darwish
a831e45515 detect: Don't deprecate module-detect on non-Linux systems
The advertised alternative, module-udev-detect, is Linux-specific.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94339
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-25 19:44:10 +03:00
Ahmed S. Darwish
a1713476d5 stream: Document pa_stream_write() size and offset requirements
Both must be in multiples of the stream's sample spec frame size.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-25 16:59:21 +03:00
Tanu Kaskinen
09f11ee482 filter-apply: simplify proplist updating
pa_sink_input_set_property() takes care of logging, so the logging
code is redundant.
2016-04-25 13:50:47 +03:00
Tanu Kaskinen
95dd90ce06 loopback: refactor proplist updating
This saves some proplist allocations and a couple of code lines. Also,
logging is better, because the set_property() functions work with
string values, while the update_proplist() functions assume opaque
binary data, and therefore can't log the property values.
2016-04-25 13:50:47 +03:00
Tanu Kaskinen
16b4624961 sink-input, source-output: remove set_name()
pa_sink_input_set_property() does everything pa_sink_input_set_name()
does.
2016-04-25 13:50:47 +03:00
Tanu Kaskinen
3e7e901ba0 sink-input, source-output: rework property setting
pa_sink_input_update_proplist() is inconvenient in many cases, because
it requires allocating a new proplist, even if the goal is to just set
one property. pa_sink_input_update_properties also can't properly log
property changes, because it has to assume that all values are
arbitrary binary data.

This patch adds pa_sink_input_set_property() for setting a string
value for a single property, and pa_sink_input_set_property_arbitrary()
for setting a binary value for a single property.
pa_sink_input_update_properties() is reimplemented as a wrapper around
pa_sink_input_set_property_arbitrary() to centralize logging and
sending change notifications.

(The above mentions only sink input functions for brevity, but the
same changes are implemented for source outputs too.)
2016-04-25 13:50:47 +03:00
Tanu Kaskinen
085cced42c device-manager, filter-apply: don't reroute streams that have a filter
device-manager reroutes all streams whenever a new device appears.
When filter-apply has loaded a filter for some stream, the filter
device may not be what device-manager considers the best device for
the stream, which means that when an unrelated device appears,
device-manager may break the filtering that filter-apply had set up.

This patch changes filter-apply so that it saves the filter device
name to the stream proplist when it sets up a filter. device-manager
can then check the proplist when it does rerouting, and skip the
rerouting for streams that have a filter applied to them.

The proplist isn't cleaned up when the stream moves away from the
filter device, so before doing any decisions based on the
filter_device property, it should be checked that the stream is
currently routed to the filter device. It seemed simpler to do it this
way compared to setting up stream move monitoring in filter-apply and
removing the property when the stream moves away from the filter
device.
2016-04-25 13:50:47 +03:00
Tanu Kaskinen
13fc833387 don't move streams to devices that are going away
Before a device is unlinked, the unlink hook is fired, and it's
possible that a routing module tries to move streams to the unlinked
device in that hook, because it doesn't know that the device is being
unlinked. Of course, the unlinking is obvious when the code is in an
unlink hook callback, but it's possible that some other module does
something in the unlink hook that in turn triggers some other hook,
and it's this second hook where the routing module may get confused.
This patch adds an "unlink_requested" flag that is set before the
unlink hook is fired, and moving streams to a device with that flag
set is prevented.

This patch is motivated by seeing module-device-manager moving a
stream to a sink that was being unlinked. It was a complex case where
an alsa card was changing its profile, while an echo-cancel sink was
connected to the old alsa sink. module-always-sink loaded a null sink
in the middle of the profile change, and after a stream had been
rescued to the null sink, module-device-manager decided to move it
back to the old alsa sink that was being unlinked. That move made no
sense, so I came up with this patch.
2016-04-25 13:47:13 +03:00
Tanu Kaskinen
0b6e4694a5 echo-cancel: rework move handling
When autoloaded, module-echo-cancel doesn't support moving the sink
input and source output that it creates, but the move prevention was
implemented by manually requesting module unloading in the middle of
the stream move procedure, rather than by just setting the DONT_MOVE
flags. This patch removes the module unloading code from the moving()
callbacks and adds the DONT_MOVE flags. In addition to saving some
code, this also prevents problems related to trying to move streams
connected to the echo cancel sink or source while the echo cancel sink
or source is in the middle of a move too (a crash will happen in such
situation, as demonstrated in
https://bugs.freedesktop.org/show_bug.cgi?id=93443).
2016-04-25 13:47:08 +03:00
Ahmed S. Darwish
26d5b6d199 protocol-native: Disable srbchannel for setups without SCM_CREDENTIALS
srbchannel needs fd passing. Otherwise we get the following error
for systems without SCM_CREDENTIALS support:

    Code should not be reached at pulsecore/pstream-util.c:95,
    function pa_pstream_send_tagstruct_with_fds(). Aborting.

[[ The root cause is that we define HAVE_CREDS only if
SCM_CREDENTIALS is defined, but SCM_CREDENTIALS is a Linux-specific
symbol. Thus HAVE_CREDS is always disabled on Solaris.

And since pulse couples the non-portable creds passing support
with the portable fd passing one, through _35_ places where
HAVE_CREDS is used, a real fix needs a PA redesign -- assuming that
latency on Solaris is something people care about. ]]

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94339
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-24 18:16:34 +03:00
Ahmed S. Darwish
dcbe79bd63 build-sys: Set C language standard to gnu11
Per glibc feature_test_macros(7), setting compiler flags to
-std=c11 (or any c* variant like c99) enforces strict ANSI
mode.

Enforcing strict ANSI makes all declarations under _GNU_SOURCE
unavailable. This leads to build warnings in the form of:

    warning: implicit declaration of function ‘syscall’

Thus replace -std=c11 with -std=gnu11

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-23 12:53:17 +03:00
Sangchul Lee
b5e5475d96 stream-interaction: Fix crash in case of invalid argument for volume
In case of invalid argument for volume, the crash occurs in pa_stream_interaction_done().
pa_xnew() is replaced with pa_xnew0() to fix it.

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
2016-04-20 16:37:18 +03:00
Sangchul Lee
b08f38385d role-ducking: Add support for ducking group
Now, trigger_roles, ducking_roles and volume can be divided into several groups by slash.
That means each group can be affected by its own volume policy.

If we need to apply ducking volume level differently that is triggered from
each trigger role(s), this feature would be useful for this purpose.

For example, let's assume that tts should take music and video's volume down to 40%
whereas voice_recognition should take those and tts's volume down to 20%.
In this case, the configuration can be written as below.
  trigger_roles=tts/voice_recognition ducking_roles=music,video/music,video,tts volume=40%/20%

If one of ducking role is affected by more than two trigger roles simultaneously,
volume of the ducking role will be applied by method of multiplication.
And it works in the same way as before without any slash.

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
2016-04-20 16:31:31 +03:00
Nazar Mokrynskyi
7aac90236b alsa-mixer: Support for Creative SoundBlaster Omni Surround 5.1 USB sound card with latest firmware
`Mic` is now detected as `Mic-In/Mic Array` (there are 2 microphones physically, nice to se this being understood).
`Line` is now detected as `Line In`.
Removed all output modes except officially supported stereo, 5.1 and stereo S/PDIF.
Also microphone/line in now might be used simultaneously with either output mode, yay!
2016-04-19 16:44:41 +03:00
Muhammet Kara
e89271b750 i18n: Updated Turkish translation 2016-04-18 10:46:15 +05:30
Tanu Kaskinen
36d9ae9b2b build-sys: build gtk-test only when glib is enabled
gtk-test pulls in libpulse-mainloop-glib as a dependency, and compiling
glib-mainloop.c fails if glib support is disabled.
2016-04-12 20:32:47 +03:00
Milo Casagrande
36de6cb94d i18n: Update Italian translation
Signed-off-by: Milo Casagrande <milo@milo.name>
2016-04-06 14:00:24 +03:00
Arun Raghavan
c931d41b78 rtp: Do all receive side rate calculations in sink-input domain
The code was mixing sink and sink input domain rate updates, and that
only works if the rate of the RTP stream is the same as the rate of the
sink. This changes all the calcuations to be on the sink-input rate,
since that's the rate we are trying to guess (and resample for).
2016-04-02 21:41:10 +03:00
YunQiang Su
2d12aadc7c i18n: update Simplified Chinese translation 2016-04-02 18:03:09 +03:00
David Henningsson
d3845a0f8a memblock/pstream: Fix two compiler warnings
Fix two compiler warnings recently introduced by the memfd patch set.

Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-04-02 06:24:18 +02:00
Ahmed S. Darwish
27d0a3b388 pstream: Support memfd blocks transport
Now that we have the necessary infrastructure to memexport and
mempimport a memfd memblock, extend that support higher up in the
chain with pstreams.

A PA endpoint can now _transparently_ send a memfd memblock to the
other end by simply calling pa_pstream_send_memblock() – provided
the block's memfd pool was earlier registered with the pstream.

If the pipe does not support memfd transfers, we fall back to
sending the block's full data instead of just its reference.

** Further details:

A single pstream connection usually transfers blocks from multiple
pools including the server's srbchannel mempool, the client's
audio data mempool, and the server's global core mempool.

If these mempools are memfd-backed, we now require registering
them with the pstream before sending any blocks they cover. This
is done to minimize fd passing overhead and avoid fd leaks.

Moreover, to support all these pools without hard-coding their
number or nature in the Pulse communication protocol itself, a new
REGISTER_MEMFD_SHMID command is introduced. That command can be
sent _anytime_ during the pstream's lifetime and is used for
creating on demand SHM ID to memfd mappings.

Suggested-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:55:14 +02:00
Ahmed S. Darwish
ee2db62277 pulsecore: Specially mark global mempools
Color global mempools with a special mark. This special marking
is needed for handling memfd-backed pools.

To avoid fd leaks, memfd pools are registered with the connection
pstream to create an ID<->memfd mapping on both PA endpoints.
Such memory regions are then always referenced by their IDs and
never by their fds, and so their fds can be safely closed later.

Unfortunately this scheme cannot work with global pools since the
registration ID<->memfd mechanism needs to happen for each newly
connected client, and thus the need for a more special handling.
That is, for the pool's fd to be always open :-(

Almost all mempools are now created on a per-client basis. The
only exception is the pa_core's mempool which is still shared
between all clients of the system.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:53:33 +02:00
Ahmed S. Darwish
f8714af56b memimport: Support memfd blocks
To transfer memfd-backed blocks without passing their fd every time,
thus minimizing overhead and avoiding fd leaks, a command is sent
with the memfd fd as ancil data very early on.

This command has an ID that uniquely identifies the memfd region.
Further memfd block references are then exclusively done using this
ID.

This commit implements the details of such 'permanent' mappings on
the receiving end, using memimport segments.

Suggested-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:51:00 +02:00
Ahmed S. Darwish
73e86b1cb1 pulsecore: Introduce memfd support
Memfd is a simple memory sharing mechanism, added by the systemd/kdbus
developers, to share pages between processes in an anonymous, no global
registry needed, no mount-point required, relatively secure, manner.

This patch introduces the necessary building blocks for using memfd
shared memory transfers in PulseAudio.

Memfd support shall also help us in laying out the necessary (but not
yet sufficient) groundwork for application sandboxing, protecting PA
from its clients, and protecting clients data from each other.

We plan to exclusively use memfds, instead of POSIX SHM, on the way
forward.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:47:47 +02:00
Ahmed S. Darwish
1c3a2bcaf1 SHM: Refactor private allocations
pa_shm_create_rw() is responsible for creating two types of memory:
POSIX shared memory and regular malloc()-ed ones.

A third memory type, memfds, will be added later. Thus to add this
extra shared memory type in a sane manner, refactor private memory
allocations into their own static methods.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:46:42 +02:00
Ahmed S. Darwish
b88acd0266 pulsecore: Transform pa_mempool_new() into a factory method
Soon we're going to have three types of memory pools: POSIX shm_open()
pools, memfd memfd_create() ones, and privately malloc()-ed pools.

Thus introduce annotations for the memory types supported and change
pa_mempool_new() into a factory method based on required memory.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:44:34 +02:00
Ahmed S. Darwish
211a520543 srbchannel: Introduce per-client SHM files
The PA daemon currently uses a single SHM file for all clients
sending and receiving commands over the low-latency srbchannel
mechanism.

To avoid leaks between clients in that case, and to provide the
necessary ground work later for sandboxing and memfds, create the
srbchannel SHM files on a per-client basis.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:41:28 +02:00
Ahmed S. Darwish
9bda6e344a pulsecore: Reference count mempools
In future commits, server-wide SHMs will be replaced with per-client
ones that will be dynamically created and freed according to clients
connections open and close.

Meanwhile, current PA design does not guarantee that the per-client
mempool blocks are referenced only by client-specific objects.

Thus reference count the pools and let each memblock inside the pool
itself, or just attached to it, increment the pool's refcount upon
allocation. This way, per-client mempools will only be freed when no
further component in the system holds any references to its blocks.

DiscussionLink: https://goo.gl/qesVMV
Suggested-by: Tanu Kaskinen <tanuk@iki.fi>
Suggested-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:36:52 +02:00
Ahmed S. Darwish
1f5e72264e pulsecore: Cache daemon shm size inside pa_core
The daemon `shm-size-bytes' configuration value was read, and then
directly used, for creating the initial server-wide SHM files.

This is fine for now, but soon, such server-wide SHMs will be replaced
with per-client SHM files that will be dynamically created and deleted
according to clients open and close. Thus, appropriately cache this
configuration value.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-02 05:35:02 +02:00
Ahmed S. Darwish
0f48b7c823 log: journal: Prevent duplicate values for CODE_* fields
sd_journal_send() implicitly add fields for the source file,
function name and code line from where it's invoked. As code
location fields CODE_FILE, CODE_LINE and CODE_FUNC are handled
by PA's log module, we do not want the automatic values
supplied by the sd_journal API.

Without suppressing these, both the actual log event source
and the call to sd_journal_send() will be logged:

    $ journalctl -b -f -o json-pretty
    [...]
    CODE_FILE : [ pulsecore/log.c, pulsecore/module.c ],
    CODE_LINE : [ 505, 181 ],
    MESSAGE   : Failed to load module module-gconf
    CODE_FUNC : [ pa_log_levelv_meta, pa_module_load ],
    [...]

(Commit log adapted from abrt libreport commit d1eaae97f0287f)

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-03-25 12:24:01 +02:00
Georg Chini
d9c91f852e stream-interaction: interact if a stream starts corked
This patch deals with the case that applications start new streams corked.
In case of module-role-cork it will only mute the stream because corking is
removed later by the application.
2016-03-21 20:26:57 +02:00
Georg Chini
e5815a0429 role-ducking: use the common code in stream-interaction.c 2016-03-21 14:29:18 +02:00
Georg Chini
2ed0f1cb24 stream-interaction: add ducking functionality 2016-03-21 14:29:02 +02:00
Georg Chini
4731690a21 stream-interaction: Bugfix for improper uncorking behavior with global=1
This patch is based on a recent patch for module-role-ducking from Sangchul Lee
which fixes incorrect behavior when global is set to 1. Original commit can be found
here:
https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=d049c2941e6aef5ff33bcd0b4adece12289302b7
2016-03-18 10:14:31 +02:00
Tanu Kaskinen
71b128aaea filter-apply: fix typo "what" -> "want" 2016-03-17 19:33:28 +02:00
Georg Chini
bc10d26621 role-cork: more cosmetic changes, changed debug output
Change names of shall_interact() and is_trigger_stream() because the names look
like the functions return a boolean. Simpler debugging output.
2016-03-16 13:29:04 +02:00
Georg Chini
c03cf89b33 role-cork: prepare merge with role-ducking: replace "cork" with "interact" where appropriate
Again, interact includes cork and duck.
2016-03-15 13:02:04 +02:00
Georg Chini
f12102857a role-cork: prepare merge with role-ducking: move most code to stream-interaction.c
Filename suggested by Tanu, as it includes both, cork and duck.
2016-03-14 10:46:57 +02:00
Georg Chini
16660789ca role-cork: remove corking on module exit
While module-role-ducking removes the attenuation when the module exits,
module-role-cork does not remove the corking. Added a function for that.
2016-03-13 12:33:16 +02:00
Georg Chini
7f5f25bb1a role-cork: allow cork of all non-trigger streams using cork_roles=any_role
There might be situations where you want to cork all streams that are not
trigger streams. Use cork_roles=any_role to implement this.
2016-03-12 16:55:59 +02:00
Georg Chini
075796d767 role-cork: React to mute/cork of trigger streams and to proplist changes
When a trigger stream changes mute or cork state, the cork streams should
react to this. The same applies if a stream changes its role to or from the
trigger role.
2016-03-11 10:46:22 +02:00
Georg Chini
61164d3b51 role-cork: Don't ignore streams without media.role
When corking do not ignore streams without media.role. Instead treat
them as if media.role="no_role", so that you can specify "no_role" as
trigger or cork role.
2016-03-10 18:12:41 +02:00
Tanu Kaskinen
092eb57974 resampler-test: remove translations
Translators shouldn't be burdened with translating strings in tests.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94435
2016-03-10 17:35:58 +02:00
Gabor Kelemen
104e4adde4 Updated Hungarian translation 2016-03-09 09:54:36 +02:00
Tanu Kaskinen
ff85bc437c card-restore: save the database when shutting down
If u->save_time_event is non-NULL when the module is being unloaded,
it means that there are some changes to the database that haven't
yet been flushed to the disk.

Acked-by: David Henningsson <david.henningsson@canonical.com>
2016-03-08 10:21:13 +02:00
David Henningsson
c87917cf0d alsa-mixer: refactor element_probe and fix >2 channel bug
By refactoring volume probing into its own function, we can reduce
indentation a lot. Also, if an error occurs during the volume probe,
that volume element is now always skipped (instead of taking down
the entire path with it).

Also, a bug for elements with more than two channels is fixed, as
previously, the volume parsing code was continuing, potentially
referencing somewhere outside the array (which has max two channels).

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2016-03-08 08:37:57 +01:00
David Henningsson
f6e1ac2dd2 switch-on-port-available: Switch from HDMI to analog; but not the other way around
If you have headphones plugged in and plug in HDMI; you want sound
to stay on headphones.
If you have HDMI plugged in and you plug in headphones; you want sound
to switch to headphones.

Hence we need to take priority into account as well when determining
whether to switch to a new profile or not.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=93903
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2016-02-26 13:45:53 +01:00
Arun Raghavan
fa2b0b4aad echo-cancel: Convert AGC API to deal with pa_volume_t
It is expected that the underlying AGC mechanism will likely provide a
single volume for the source rather than a per-channel volume. Dealing
with per-channel volumes just adds complexity with regards to the
actual volume setting (depending on whether volume sharing is enabled or
not, we would set the volume on the source output of the virtual source,
and their sample specs may be different).

Using a single volume allows us to sidestep this problem entirely.
2016-02-25 19:06:44 +05:30
Arun Raghavan
05a6af744b echo-cancel: Add beamforming support in the webrtc canceller 2016-02-25 09:17:25 +05:30