Commit graph

2694 commits

Author SHA1 Message Date
Alexander E. Patrakov
768c80f3c3 alsa: reread configuration when opening new devices
If a card has been hot-plugged after pulseaudio start, alsa-lib still has
old configuration in memory, which doesn't have PCM definitions for the
new card. Thus, this error appears, and the device doesn't work:

I: [pulseaudio] (alsa-lib)confmisc.c: Unable to find definition 'cards.USB-Audio.pcm.front.0:CARD=0'
I: [pulseaudio] (alsa-lib)conf.c: function snd_func_refer returned error: No such file or directory
I: [pulseaudio] (alsa-lib)conf.c: Evaluate error: No such file or directory
I: [pulseaudio] (alsa-lib)pcm.c: Unknown PCM front:0
I: [pulseaudio] alsa-util.c: Error opening PCM device front:0: No such file or directory

The snd_config_update_free_global() function makes alsa-lib forget any
cached configuration and reparse all PCM definitions from scratch next
time it is told to open anything.

The trick has been copied from Phonon.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=54029
Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
2016-06-22 12:55:54 +05:30
Arun Raghavan
0985a717f3 allow-passthrough: Use pa_module_hook_connect()
Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-06-22 12:55:54 +05:30
Guillaume Desmottes
14804ba1ca allow-passthrough: Add module to allow passthrough streams always go through
For various use-cases a passthrough stream should have priority over all
other streams and get exclusive access to the sink regardless of whether
any other streams are playing.

An example use-case is ensuring Kodi can successfully start video
playback (with passthrough) even if an external notification sound
happened to be playing at the same time.

Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-06-22 12:55:54 +05:30
Arun Raghavan
f58e8c405c dbus: Deal with double-counting module-dbus-protocol
We ended up dealing with it once in module init, and once more in the
new module callback. Avoiding it in the second case by name seems to be
the cleanest solution (else, we need to store the module index somewhere
in pa_dbusiface_core, which seems about as bad).

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-29 10:36:47 +05:30
Tanu Kaskinen
9c7e4b8eb9 dbus: fix crash on LoadModule()
Commit ae415b07a0 ("dbus: Use hooks for
module new and removed events") changed the new module monitoring from
the asynchronous subscription system. Previously handle_load_module()
created the new pa_dbusiface_module object before we got
a notification of the loading of the module, but now we get the
notification already within the pa_module_load() call. That resulted
in a crash, because the module_new_cb() created the
pa_dbusiface_module object before pa_module_load() returned, and then
handle_load_module() would create another pa_dbusiface_module object
for the same module.

This patch removes the pa_dbusiface_module_new() call from
handle_load_module(). module_new_cb() is now responsible for all
pa_dbusiface_module object creations, except the ones that are created
during the initialization of module-dbus-protocol.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-29 10:34:26 +05:30
Arun Raghavan
14cf31fe45 module-filter-apply: Fix stale m-d-m property name in comment
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-11 09:20:26 +05:30
Arun Raghavan
408b9f8cc0 alsa: Reread and upate jack status when a card is unsuspended
This is needed so we don't keep stale jack availability information
while the card is suspended.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93259
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-11 09:11:26 +05:30
Tanu Kaskinen
fb52a6a6e6 alsa: ignore jack events when the user is inactive
See the big comment in the code for more details.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=93259
2016-05-10 17:44:38 +05:30
Sachin Kumar Chauhan
a19e1e5382 module-filter-apply: Fix a memory leak
Dynamic memory allocated to 'module_name' and 'fltr' was being leaked.
Its now freed properly before return.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=95293

Signed-off-by: Sachin Kumar Chauhan <sachin.kc@samsung.com>
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-10 17:44:38 +05:30
Arun Raghavan
fcee3da944 module-device-manager: Refine logic to ignore filtered streams
Rather than entirely ignore streams for which we have automatically
loaded a filter, this makes module-device-manager only avoid rerouting
such streams within their existing filter hierarchy.

If, for example, m-d-m decided to move a stream which is currently
routed to speakers/mic which we requested echo cancellation for, to a
USB headset, the previous logic would disallow such a move even though
it was legitimate.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93443

Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-05-07 11:02:01 +05:30
Arun Raghavan
4331733c19 module-filter-apply: Don't implement policy in module-device-manager
This adds an ignore mechanism to module-device-manager and uses that
from within module-filter-apply, rather than having m-d-m have knowledge
of anything related to m-f-a.

Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-05-07 11:00:51 +05:30
Arun Raghavan
87048cc334 module-filter-apply: Remove some dead code
We never actually pass restore=true, so might as well remove any code
that deals with that case.

Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-05-06 13:43:48 +05:30
Tanu Kaskinen
23c15c3b52 switch-on-port-available: prefer ports that have been selected by the user
Let's assume that there are two output ports, and they are on
different profiles:

    * Integrated speakers (priority: 10000, available)
    * HDMI                (priority:  5900, not available)

Then the user plugs in an HDMI monitor with speakers. Since the HDMI
priority is lower than the speaker priority, we don't route to HDMI by
default. However, the user manually switches the profile to use the
HDMI output.

Then the user plugs out the monitor, so we switch back to speakers.
When the monitor is plugged back in, the user needs to manually switch
the audio output again. That should be improved: if the user preferred
to the HDMI output over the speakers, we should remember that and
automatically switch to HDMI whenever it becomes available.

The lack of automatic switching is even worse when the monitor goes to
a sleep mode after some period of inactivity. The monitor audio may
become unavailable, and PulseAudio can't distinguish that from the
case where the monitor is physically unplugged. Even worse, the
monitor may become unavailable for a short while when adjusting the
display parameters (for example, media center software may adjust the
display parameters to match the media that is being played back). In
these cases we clearly should switch automatically back to HDMI when
it becomes available again.

This patch fixes the problem by setting pa_card.preferred_input_port
and pa_card.preferred_output_port when the user changes the card
profile or a port, and switching to the preferred port when it becomes
available.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=93946
2016-05-03 11:49:35 +05:30
Tanu Kaskinen
c4058b8d00 card-restore: restore preferred ports 2016-05-03 11:49:35 +05:30
Tanu Kaskinen
b88f2859a9 switch-on-port-available: avoid repetitive pointer deferencing
Trivial refactoring.
2016-05-03 09:18:28 +05:30
Tanu Kaskinen
a99eb81db3 switch-on-port-available: fix inverted if condition
I'm sure the original intention was to switch the port if the target
port is available on the currently active profile.
2016-05-03 09:18:28 +05:30
Tanu Kaskinen
fe4f96d56e switch-on-port-available: unify input/output switching policy
I don't think there's any reason why the same logic that has
previously added to output profile switching shouldn't be used with
input too.
2016-05-03 09:18:28 +05:30
Juho Hämäläinen
1a1d5086ad stream-restore: With dbus-proto fix segfault if e->device is NULL.
If first part of test is false and e->device is NULL pa_streq will
segfault. Fix by using pa_safe_streq, which checks strings for NULL
before doing strcmp.
2016-04-29 15:52:51 +03:00
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
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
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
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
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
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
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
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
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
Arun Raghavan
cfd3a948de echo-cancel: Remove pa_ prefix on private functions 2016-02-25 09:17:25 +05:30
Arun Raghavan
be5e196c1a echo-cancel: Update a copyright notice 2016-02-25 09:17:25 +05:30
Arun Raghavan
07663b06b3 echo-cancel: Use webrtc's deinterleaved API
This is required to have unequal channel counts on capture in and out
streams, which is needed for beamforming to work. The deinterleaved API
only works with floating point samples.
2016-02-25 09:17:10 +05:30
Arun Raghavan
3133ff8e11 echo-cancel: webrtc canceller supports different in/out channel counts
Needed for upcoming beamforming code.
2016-02-25 09:09:13 +05:30
Arun Raghavan
222a98846c echo-cancel: Improve webrtc canceller error handling a bit 2016-02-25 09:09:13 +05:30