Commit graph

8438 commits

Author SHA1 Message Date
Juho Hämäläinen
a5f71d1c54 pulsecore: Don't allow unreferencing linked object.
Sink(-input) and source(-output) called unlink function when reference
count dropped to zero. This would result in unlink hooks being called
with an object having a reference count of zero, and this is not a
situation we want modules to have to deal with. It is better to just
remove the redundant unlinking code from sink(-input) and
source(-output) and assert on reference count in unlink functions as well.

It is expected that in well behaving code the owner of an object will
always unlink the object before unreferencing.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-22 12:55:55 +05:30
Aidan Gauland
be4619e3f7 qpaeq: Don't set font-size on widgets
Setting the font-size CSS property on a widget overrides the system
font-size, and since qpaeq provides no mechanism for setting the
application's font-size, we should not do this.

This commit also removes the font-size property from commented-out calls to
setStyleSheet() so that if these are ever reinstated, this behaviour is
not reintroduced.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-22 12:55:55 +05:30
KimJeongYeon
81c8d38084 ladspa-sink: avoid to configure invalid format
LADSPA allows float format only, but module-ladspa-sink possibly
could be loaded with ***any*** 'format' parameter. Therefore noisy
sound heard. This patch avoids to be configured as invalid format.

Signed-off-by: KimJeongYeon <jeongyeon.kim@samsung.com>
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-22 12:55:55 +05:30
Ulrich Eckhardt
111e332556 core-util: Improve pa_replace() behaviour
- Assert that the search string isn't empty.
 - Add test.
 - Improve documentation.
2016-06-22 12:55:55 +05:30
Ulrich Eckhardt
c9c8f4285f core-util-test: Add tests 2016-06-22 12:55:54 +05:30
Ulrich Eckhardt
e1bc479110 core-util-test: Add boilerplate 2016-06-22 12:55:54 +05:30
Tanu Kaskinen
6f0e39d30f pstream: fix revoke callback setting
While investigating bug 95352, I noticed that
pa_pstream_set_revoke_callback() and pa_pstream_set_release_callback()
were identical - both set the release callback.
pa_pstream_set_revoke_callback() was obviously broken - it was setting
the wrong callback.

The only place where set_revoke_callback() is called is in
protocol-native.c. The code there looks like this:

    pa_pstream_set_revoke_callback(c->pstream, pstream_revoke_callback, c);
    pa_pstream_set_release_callback(c->pstream, pstream_release_callback, c);

Since set_release_callback() is called last, the release callback gets
set correctly. The only problem is that the revoke callback stays
unset. What are the consequences of that? The code that calls the
revoke callback looks like this:

    if (p->revoke_callback)
        p->revoke_callback(p, block_id, p->revoke_callback_userdata);
    else
        pa_pstream_send_revoke(p, block_id);

So the intended callback is replaced with a pa_pstream_send_revoke()
call. What does the intended callback, that doesn't get called, do?

    if (!(q = pa_thread_mq_get()))
        pa_pstream_send_revoke(p, block_id);
    else
        pa_asyncmsgq_post(q->outq, PA_MSGOBJECT(userdata), CONNECTION_MESSAGE_REVOKE, PA_UINT_TO_PTR(block_id), 0, NULL, NULL);

So the native protocol's revoke callback is anyway going to call
pa_pstream_send_revoke() when called from the main thread. If the
revoking is done from an IO thread, an asynchronous message is sent to
the main thread instead, and the message handler will then call
pa_pstream_send_revoke().

In conclusion, the only effect of this bug was that
pa_pstream_send_revoke() was sometimes being called from an IO thread
when it should have been called from the main thread. I don't know if
this caused the crash in bug 95352. Probably not.
2016-06-22 12:55:54 +05:30
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
4c42b3ef7c i18n: Add module-allow-passthrough to POTFILES.in 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
7ac5390042 client, protocol-native: Use macros for protocol version/flag access
This makes it easier to read and cleaner in general.
2016-06-22 12:55:54 +05:30
Arun Raghavan
8887f256e0 Update NEWS for 9.0
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-22 12:22:04 +05:30
Arun Raghavan
effb3f1d23 sink-input,source-output: Fix crasher while setting property
We were missing a case where a property is first set, and then cleared
by setting a NULL value.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-21 17:38:21 +05:30
Ahmed S. Darwish
a07b6a8cda pstream: Fix use of uninitialized value: ancillary fd cleanup flag
As reported by valrgrind

  ==30002== Conditional jump or move depends on uninitialised value(s)
  ==30002==    at 0x5CB883C: pa_cmsg_ancil_data_close_fds (pstream.c:193)
  ==30002==    by 0x5CBB161: do_write (pstream.c:759)
  ==30002==    by 0x5CB8B51: do_pstream_read_write (pstream.c:233)
  ==30002==    by 0x5CB8EE8: io_callback (pstream.c:279)
  ...

The pa_cmsg_ancil_data structure has two main guards:
'creds_valid', which implies that it holds credentials
information, and 'nfd', which implies it holds file descriptors.

When code paths create a credentials ancillary data structure,
they just set the 'nfd' guard to zero. Typically, the rest of
pa_cmsg_ancil_data fields related to fds are _all_ left
_uninitialized_.

pa_cmsg_ancil_data_close_fds() has broken the above contract:
it accesses the new 'close_fds_on_cleanup' flag, which is related
to file descriptors, without checking the 'nfd == 0' guard first.
Fix this inconsistency.

Reported-by: Alexander E. Patrakov <patrakov@gmail.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-21 16:30:35 +05:30
Ahmed S. Darwish
3922bbe7eb shm: Fix use of uninitialized value: segment's shared-memory type
As shown by valgrind

  ==10615== Conditional jump or move depends on uninitialised value(s)
  ==10615==    at 0x5CC0483: shm_marker_size (shm.c:97)
  ==10615==    by 0x5CC1685: shm_attach (shm.c:381)
  ==10615==    by 0x5CC1990: pa_shm_cleanup (shm.c:453)
  ==10615==    by 0x5CC068E: sharedmem_create (shm.c:150)
  ...

Solution is to fix the shm_marker_size() signature itself: At
certain code paths like shm_attach(), we don't want to initialize
_any_ field in the passed SHM segment descriptor except after
making sure all error exit conditions have been passed.

Reported-by: Alexander E. Patrakov <patrakov@gmail.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-06-21 16:28:40 +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
Barun Kumar Singh
1d5dfccbb2 resampler: Fix leaking lfe filter on init failure
Fix memory leak in pa_resampler_new() in resampler.c, Deallocating
memory of r->lfe_filter in case of fail.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-27 09:37:37 +05:30
Alexander E. Patrakov
adbaae77d6 Disable LFE remixing by default
The current LFE crossover filter removes low frequencies from the main
channels and puts them into the LFE channel with the wrong amplitude.
It is not known for sure what is the correct relative amplitude (acoustic
measurements are required with real hardware), and changing that might
introduce a new bug, "it clips the LFE channel".

So just disable the feature by default until a better understanding
emerges how it should work. This, essentially, returns the defaults
to their state as of PulseAudio 6.0.

Some more observations:

- Most of available active analog speakers on the market do the
necessary crossover filtering already, and HDMI receivers can be
configured to do that, too, so a crossover filter in PulseAudio is
harmful in these use cases.

- The "laptop with a builtin subwoofer" use case requires manual
configuration anyway because the default crossover frequency (120 Hz) is
wrong for laptop speakers.

- Finally, Windows 10 with a built-in USB audio driver does not synthesize
the LFE channel given a 5.1 card and a stereo audio stream by default.

Hides: https://bugs.freedesktop.org/show_bug.cgi?id=95021
Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
2016-05-24 19:34:44 +03:00
Piotr Drąg
98c36f545e i18n: Update Polish translation 2016-05-18 14:36:12 +03:00
Sachin Kumar Chauhan
6603ee8563 resampler: Fix a memory leak in pa_resampler_ffmpeg_init()
ffmpeg_data was not freed properly before return due to error.
It is now freed properly.

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

Signed-off-by: Sachin Kumar Chauhan <sachin.kc@samsung.com>
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-13 14:22:47 +05:30
Arun Raghavan
47a0171a95 build-sys: Bump sonames for release
Bumping libpulse' version since PA_RATE_MAX was changed.

Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2016-05-12 15:52:44 +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
Deepak Srivastava
ccc83b6cd7 pulsecore: Fixed possible memory leak
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=95291

Signed-off-by: Deepak Srivastava <srivastava.d@samsung.com>
Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-05-06 11:09:17 +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
04040c522f card: add preferred_{input, output}_port
I will modify module-switch-on-port-available so that it will keep
track of which input and output port the user prefers on the card,
based on the user's profile and port switches. The preference needs
to be saved on disk, for which I will use module-card-restore.

To facilitate communication between the two modules, this patch adds
preferred_input_port and preferred_output_port fields to pa_card, and
a hook for monitoring the variable changes. It would be nice if the
two modules would communicate directly with each other, but
implementing that would be somewhat complicated, so I chose this time
for adding the functionality to the core. In theory some other routing
module might want to manage the new variables instead of
module-switch-on-port-available, but admittedly that's not very likely
to happen...
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
Jeremy Huddleston Sequoia
4f7ade31a9 build-sys: Fix check for CoreServices.h
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
Signed-off-by: Arun Raghavan <git@arunraghavan.net>
2016-05-03 08:51:26 +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
Arun Raghavan
d1730ab65a Revert "format: Make pa_format_info_valid() stricter for PCM"
This reverts commit 12a202c510.

This is needed for now to avoid a clash in clients using json-glib. The
commit added a call to json_object_get_type() in client code that didn't
exist before, and this breaks some apps like Rhythmbox and Totem. This
will be fixed in the future by possibly dropping json-c as a dep.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=95135
2016-04-29 17:38:37 +05:30
Ahmed S. Darwish
d2a6afcab3 core: Support memfd transport; bump protocol version
Now that all layers in the stack support memfd blocks, add memfd
support for the daemon's global core mempool. Also introduce
"enable-memfd=" daemon argument and configuration option.

For now, memfd support is an opt-in feature to be activated only
when daemon's enable-memfd= is set to yes.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
2016-04-27 18:37:08 +05:30
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