Commit graph

9489 commits

Author SHA1 Message Date
Tanu Kaskinen
414644dff1 device-port: send sink and source change events when availability changes
The lack of change events caused GUIs to not update the port status.

Related bug report:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/941
2020-07-22 22:53:54 +00:00
Eero Nurkkala
1f1fb8eb6b tests: cpu-remap-test.c: fix memory leaks
When compiled with ASAN: -O1 -fsanitize=address -fno-omit-frame-pointer,
the following issues are seen:

==17217==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7fceba414b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7fceb9b3eac9 in pa_xmalloc pulse/xmalloc.c:63
    #2 0x7fceb9b3ed22 in pa_xmemdup pulse/xmalloc.c:94
    #3 0x7fceb9e1eed5 in _pa_xnewdup_internal pulse/xmalloc.h:86
    #4 0x7fceb9e1eed5 in init_remap_c pulsecore/remap.c:580
    #5 0x7fceb9e1efe5 in pa_init_remap_func pulsecore/remap.c:608
    #6 0x5574e72422b7 in remap_init2_test_channels tests/cpu-remap-test.c:303
    #7 0x5574e7242420 in rearrange_special_test tests/cpu-remap-test.c:345
    #8 0x5574e7245ce5 in srunner_run (/home/eenurkka/pulse/pulseaudio/src/.libs/cpu-remap-test+0x9ce5)
...
SUMMARY: AddressSanitizer: 192 byte(s) leaked in 6 allocation(s).

Fix those issues by freeing the allocated resources properly.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2020-07-21 14:57:05 +03:00
Eero Nurkkala
9dd7f48b49 tests: hashmap-test.c: fix memory leak
When compiled with ASAN: -O1 -fsanitize=address -fno-omit-frame-pointer,
the following issue is seen:

==14272==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1072 byte(s) in 1 object(s) allocated from:
    #0 0x7f0180966d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f018039f043 in pa_xmalloc0 pulse/xmalloc.c:74
    #2 0x7f01803c5cc8 in pa_hashmap_new_full pulsecore/hashmap.c:61
    #3 0x7f01803c5df9 in pa_hashmap_new pulsecore/hashmap.c:76
    #4 0x556ee75ff7f4 in remove_all_test tests/hashmap-test.c:96
    #5 0x556ee7602965 in srunner_run (/home/eenurkka/pulse/pulseaudio/src/.libs/hashmap-test+0x6965)

SUMMARY: AddressSanitizer: 1072 byte(s) leaked in 1 allocation(s).

Fix it by freeing the resource properly.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2020-07-21 14:56:59 +03:00
Tanu Kaskinen
5c0ad422a8 remap_neon: use register r12 instead of r7
When the Thumb instructions set is used and frame pointers are enabled
(-fno-omit-frame-pointer), r7 can't be used, because it's used for the
frame pointer. Trying to use r7 caused the compilation to fail.

Thanks to Andre McCurdy for suggesting[1] this fix, all I had to do was to
test that it works. The code builds now, and cpu-remap-test also
succeeds.

[1] https://lists.openembedded.org/g/openembedded-core/message/136786
2020-07-20 13:27:44 +00:00
zhaochengyi
b5a6365f18 pulsecore: Add exception judgment to fix the crash when playing music
When playing music for a period of time, the Shared Memory is
frequently accessed, and occasionally read/write errors occur,
which causes the program to crash

[Current thread is 1 (Thread 0xffff86823010 (LWP 2841))]
(gdb) bt
0  0x0000ffff8702a714 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
1  0x0000ffff870188e8 in __GI_abort () at abort.c:79
2  0x0000ffff873b5728 in do_read (p=p@entry=0x3673a170, re=re@entry=0x3673a338) at pulsecore/pstream.c:856
3  0x0000ffff873b7fd8 in do_pstream_read_write (p=0x3673a170) at pulsecore/pstream.c:248
4  0x0000ffff873b8368 in srb_callback (srb=<optimized out>, userdata=0x3673a170) at pulsecore/pstream.c:287
5  0x0000ffff873b8bec in srbchannel_rwloop (sr=0x36766ae0) at pulsecore/srbchannel.c:190
6  0x0000ffff87339c70 in dispatch_pollfds (m=0x36670db0) at pulse/mainloop.c:655
7  0x0000ffff87339c70 in pa_mainloop_dispatch (m=m@entry=0x36670db0) at pulse/mainloop.c:898
8  0x0000ffff8733a01c in pa_mainloop_iterate (m=0x36670db0, block=<optimized out>, retval=0xffffd9683030) at pulse/mainloop.c:929
9  0x0000ffff8733a0d8 in pa_mainloop_run (m=m@entry=0x36670db0, retval=retval@entry=0xffffd9683030) at pulse/mainloop.c:945
10 0x0000000000406894 in main (argc=<optimized out>, argv=<optimized out>) at daemon/main.c:1144

Signed-off-by: zhaochengyi <zhaochengyi@uniontech.com>
2020-07-20 01:14:54 +00:00
Rafael Fontenelle
f32977831a Update Brazilian Portuguese translation 2020-07-18 15:12:15 +00:00
Hui Wang
c8653c13fa alsa: adjust ucm sink/source priority according to ports priority
On the machines with the ucm used, the different input/output devices
often have different pcm stream, so they often belong to different
sources and sinks, this is greatly different from the design of all
devices connected to a codec (without ucm).

For example, on a machine with ucm2 used:
the internal dmic is on source#0
the external mic is on the source#1
the internal spk is on sink#0
the external headphone is on sink#1

Users expect that after plugging the external device, it will become
the active device automatically. The switch-on-port-available could
make it to be the active_port on its own source/sink, but can't make
source/sink to be default_source/sink since the sources/sinks belong
to the same profile (HiFi usually).

If we adjust the source/sink priority according to ucm ports priority,
the device_port.c could handle the default_source/sink changing then.
Usually we set higher priority for external device than internal
device in the ucm.

In order to bring the lowest side effect on the source/sink priority,
I change the ucm priority to units digit first, then add it to the
original priority.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-07-17 09:20:50 +00:00
Tanu Kaskinen
0e691b9664 build-sys: meson: bump protocol version
This was forgotten in commit 861836c5f7.
2020-07-11 15:17:11 +03:00
Tanu Kaskinen
18bfbd1e1c i18n: Update pulseaudio.pot 2020-07-10 13:44:52 +03:00
Jean-Baptiste Holcroft
f7667f9d6a Translated using Weblate (French)
Currently translated at 100.0% (517 of 517 strings)

Translation: pulseaudio/pulseaudio
Translate-URL: https://translate.fedoraproject.org/projects/pulseaudio/pulseaudio/fr/
2020-07-10 13:42:26 +03:00
Piotr Drąg
fa4f3c685e Translated using Weblate (Polish)
Currently translated at 100.0% (533 of 533 strings)

Translation: pulseaudio/pulseaudio
Translate-URL: https://translate.fedoraproject.org/projects/pulseaudio/pulseaudio/pl/
2020-07-10 13:42:26 +03:00
Oğuz Ersen
76e01f2235 Translated using Weblate (Turkish)
Currently translated at 100.0% (527 of 527 strings)

Translation: pulseaudio/pulseaudio
Translate-URL: https://translate.fedoraproject.org/projects/pulseaudio/pulseaudio/tr/
2020-07-10 13:42:26 +03:00
Hui Wang
ede8cbb131 alsa: make the unsuspend more robust
We met a weird situation on a couple of Lenovo machines and at least
on one Dell machine. First we open the gnome-sound-setting, then
suspend and resume the system, after the system resume back, the audio
devices change to dummy, the audio doesn't work anymore. And pacmd
list-cards shows no available sound card.

Through debugging I found after resume, the alsa receives POLLERR
events and it will call unsuspend to recover the pcm, but at that
moment, the device nodes in /dev/snd/ is not accessible, so the
snd_pcm_open() fails and the pulseaudio unload the module-alsa-card.

Here I add retry and pa_msleep if snd_pcm_open fails, I tested it on
all machines which have this problem, pa_msleep(25) is ok for most of
them, there is only one machine which needs to call pa_msleep(25)
twice, so for safety reason, I set the max retry times to 4.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-07-09 16:43:17 +08:00
Tanu Kaskinen
f12795330b alsa-ucm: Fix NULL pointer handling
get_mixer_device() can return NULL when no mixer device is configured
for the device, so mdev2 can be NULL.
2020-07-06 12:47:19 +03:00
Eero Nurkkala
0b5ab6be5a alsa-ucm: disallow null mdev argument into pa_alsa_open_mixer_by_name()
It's possible for mdev to be NULL. In this case, an assert is taken
in pa_alsa_open_mixer_by_name() with debug builds, and a crash with
release builds. However, it's possible to bypass this trouble by taking
the error path if mdev is NULL.

Reported-by: Jarkko Sankala <jarkko.sankala@offcode.fi>
Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2020-07-06 12:47:19 +03:00
Baurzhan Muftakhidinov
6c58c69bb6 i18n: Add initial Kazakh translation 2020-06-30 07:42:14 +00:00
Tanu Kaskinen
7076e6d0b2 man: Explain the limitations of "pulseaudio --check" 2020-06-22 15:05:26 +00:00
Libin Yang
2ae94c141f device-port: queue CARD CHANGE event before update default sink
In single profile mode (headphone and speaker use different PCMs),
when headphone is plugged in, pa_device_port_set_available() will call
pa_core_update_default_sink/source() before posting
PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE to the gnome.
And pa_core_update_default_sink/source() will post
PA_SUBSCRIPTION_EVENT_SERVER | PA_SUBSCRIPTION_EVENT_CHANGE to the gnome.
So the original event sequence is:
1. PA_SUBSCRIPTION_EVENT_SERVER | PA_SUBSCRIPTION_EVENT_CHANGE
2. PA_SUBSCRIPTION_EVENT_CARD | PA_SUBSCRIPTION_EVENT_CHANGE

In gnome-control-center:
When it receives PA_SUBSCRIPTION_EVENT_SERVER, it will call
req_update_server_info () to update the panel;
When it receives PA_SUBSCRIPTION_EVENT_CARD, it will update
the card information, for example, when the headphone is connected,
it will call gtk_list_store_append() to append the headphone.

Let's use an example to clarify the correct sequence.
Assume we plug in headphone. PA will set the default sink to headphone
from speaker, and hope gnome sound setting "Output Deivce" to highlight to
"headphone". PA should send PA_SUBSCRIPTION_EVENT_CARD firstly to notify
gnome-control-center "headphone" is plugged in. And then it sends
PA_SUBSCRIPTION_EVENT_SERVER to trigger sound setting to highlight
to "headphone".

Signed-off-by: Libin Yang <libin.yang@intel.com>
2020-06-22 14:53:42 +00:00
Tanu Kaskinen
04c554b7d5 sink, source: Use the global configuration for the avoid_resampling default
Previously avoid_resampling was always false unless the sink or source
implementation explicitly configured the variable. The null sink doesn't
explicitly configure it, so it didn't switch the sample rate as
expected when avoid_resampling was enabled.

This change means that also sinks that don't support rate switching can
have avoid_resampling set to true, but I think that's fine, because
pa_sink_reconfigure() doesn't try to do anything if the reconfigure()
callback isn't set.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/923
2020-06-22 14:47:42 +00:00
Taahir Ahmed
d97075c79f Add a basic test suite for pa_hashmap
I spent a little time working through the implementation of
pa_hashmap, and wrote a test suite while doing so.  It tests a few
basic edge cases, like saturating all buckets of the hashtable.
2020-06-22 14:39:14 +00:00
Yuri Chornoivan
e790ed536c i18n: Update poulseaudio.pot 2020-06-21 09:17:42 +00:00
Pali Rohár
d0ed9fa6ac bluetooth: policy: Remove BlueZ 4 related code
Remove what was forgotten in e81e7a2ca5 and 493892434a commits.
2020-06-20 11:39:45 +02:00
Jan Alexander Steffens (heftig)
0547ae49ba
build-sys: meson: Fix detection of SYS_memfd_create
It's a define resolving to a number, not a function.
2020-06-17 20:01:15 +02:00
Jaroslav Kysela
b2d3399793 pactl: print device port type and available group
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
80b993cf55 alsa ucm: set device port type
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
0333c2ba8f alsa: legacy card - implement device port type parser and assignment
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
6618527451 alsa: legacy card - set available_group
Create automatically the groups per paths where
the similar jacks are used.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
1fb449213f alsa-ucm: set available_group (use jack name)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
64eae8d84a protocol: describe v34 (available_group, port type)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
feee531c2b device-port: add type member
The clients might wanna to know for which purpose is the port.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Jaroslav Kysela
861836c5f7 device-port: introduce available_group member
In some cases, the I/O connector functionality can be shared
and we cannot determine the proper purpose automatically.
We just know that something was inserted to the jack.

Introduce a group identifier (a simple string - unique
per group) which helps to determine the proper ports
for the application. The user interface may be used
to set the wanted behaviour.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-17 06:06:12 +00:00
Wim Taymans
9315bbdfe5 modules: fix some small memory leaks 2020-06-16 12:40:39 +02:00
Libin Yang
1778f76c78 core-subscribe: add PA_SUBSCRIPTION_EVENT_CARD in dump_event
fac_table[] lacks of PA_SUBSCRIPTION_EVENT_CARD item. This will cause
pulseaudio crash when it tries to dump the PA_SUBSCRIPTION_EVENT_CARD
event when DEBUG is defined.

Signed-off-by: Libin Yang <libin.yang@intel.com>
2020-06-10 09:11:06 +00:00
Hui Wang
3549a4d926 alsa-mixer: store the ucm_device with the order of their priority
There is some case that multiple ucm devices share an amixer Jack
like "Headphones", "Headset" and "Mic2" share the "Headphone Mic Jack",
When the Jack state is changed, the module-switch-on-port-available
will process them in the order they are in the jack->ucm_devices, and
the last device will decide the final setting.

But usually users put priority for those devices and expect the
final setting is based on the highest priority device if there is no
other policies like manual selection. So here do some change to store
the ucm_devices according to their priority (from low to high).

For example, we have ucm devices definition like below (ucm2):
               SectionDevice."Mic2" {
                        Comment "Headphones Stereo Microphone"
			...
                        Value {
                                CapturePriority 200
				...
                }

                SectionDevice."Headset" {
                        Comment "Headset Mono Microphone"
			...
                        Value {
                                CapturePriority 300
				...
                        }
                }

Without this patch, the final setting is based on Mic2, after applying
this patch, the final setting is based on the Headset (with higher
priority than Mic2).

Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-06-10 08:46:51 +03:00
Tanu Kaskinen
fb3e4bb54c raop-sink: Fix compiler warnings
There were three maybe-uninitialized warnings when building with
Autotools (for some reason I don't see these with Meson):

modules/raop/raop-sink.c: In function ‘thread_func’:
modules/raop/raop-sink.c:543:16: warning: ‘intvl’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             if (intvl < now + u->block_usec) {
                ^
In file included from ./pulsecore/macro.h:270,
                 from ./pulsecore/cpu-x86.h:25,
                 from ./pulsecore/cpu.h:23,
                 from ./pulsecore/core.h:26,
                 from modules/raop/raop-sink.c:48:
./pulsecore/log.h:129:28: warning: ‘check_timing_count’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define pa_log_warn(...)   pa_log_level_meta(PA_LOG_WARN,   __FILE__, __LINE__, __func__, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~~
modules/raop/raop-sink.c:404:14: note: ‘check_timing_count’ was declared here
     uint32_t check_timing_count;
              ^~~~~~~~~~~~~~~~~~
modules/raop/raop-sink.c:500:27: warning: ‘last_timing’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                 pa_usec_t since = now - last_timing;
                           ^~~~~

I moved the intvl variable initialization out of the for loop, because
it looked like the variable value is supposed to be remembered between
the iterations. I don't know if the variable declaration (without
initialization) in the beginning of the loop caused the compiler to
touch the variable between iterations, probably not, but I'm pretty sure
that's undefined behaviour.

Other than that maybe-undefined behaviour, these compiler warnings may
be false positives, since the variables are initialized when u->first is
true.

I initialized the three variables in to the same value as what is used
when resetting them when u->first is true. I didn't test these changes,
but they look safe to me.
2020-06-04 15:37:00 +00:00
Hugo Osvaldo Barrera
ee6caebbb0 Delete .travis.yml 2020-06-04 12:31:36 +00:00
Tanu Kaskinen
1fe37e6d4b stream-restore: Forget pre-14.0 stream routing
Prior to commits f899d5f466 and
f62a49b8cf, GNOME's sound settings
overwrote the routing for all entries in the stream-restore database
when selecting a device. Now we prevent that from happening (see the
aforementioned commits), but the old overwritten settings can still be in
the database after updating to PulseAudio 14.0, and they can cause
problems, as documented here:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/832

We can't distinguish between devices set by GNOME's sound settings
and devices set by the user, so this patch discards all old device
settings, even though that is going to cause PulseAudio to forget routing
settings for many users. This is less bad than keeping the incorrect
routing settings in the database, because it's difficult for users to
figure out how to fix the situation when e.g. speaker test tones go to
the internal speakers no matter what device is selected as the default,
whereas old manual configuration can be restored restored by doing the
manual configuration again. Also, it's probably more common to have at
some point changed the default device in GNOME's sound settings than it
is to have any manual per-stream routing settings.

This is disabled by default, because this causes data loss, but
distributions that use GNOME are recommended to enable this with
the --enable-stream-restore-clear-old-devices (Autotools) or
-Dstream-restore-clear-old-devices=true (Meson) build option.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/832
2020-06-01 18:24:16 +00:00
Tanu Kaskinen
2ac2b445fc stream-restore: Fix a potential crash in pa_namereg_is_valid_name()
pa_namereg_is_valid_name() will hit an assertion if the name string is
NULL. Maybe it would make sense to change pa_namereg_is_valid_name() so
that it would return false on NULL, but I didn't want to change the
function semantics at this time.

e->device and e->card can be NULL even when device_valid and card_valid
are set to true if the database contains bad data.

I ran into this crash while developing new code, I haven't seen the
crash in the wild.
2020-06-01 18:24:16 +00:00
Tanu Kaskinen
46c263acc9 stream-restore: Drop the version field from the entry struct
Storing the version in the entry struct is pointless. We should always
write entries using the current version. When we encounter older
versions when reading, those need to be converted to the current version
anyway, because all code that uses the entry struct assumes that the
data is stored according to the current version semantics.

We're currently at the first version of the database entries, so
currently there's no version conversion happening. I have a patch that
will increment the entry version, so this is preparation for that.
2020-06-01 18:24:16 +00:00
Tanu Kaskinen
3dc525df5d thread-mainloop: Extend the locking documentation a bit
Make it more clear which objects require locking. I remember talking to
multiple people for whom that wasn't immediately clear from the
documentation.
2020-05-27 09:41:40 +03:00
Tanu Kaskinen
36a4923f9b Point to SupportedAudioFormats wiki page where appropriate
I documented the supported PCM sample formats and compressed audio
encodings in the wiki, let's add some pointers to the new documentation.
2020-04-23 15:24:24 +00:00
Rafael Fontenelle
743fa02c5f i18n: Update Brazilian Portuguese translation 2020-04-23 16:43:51 +03:00
roshal
81c24738d5 man: remove space 2020-04-12 22:10:15 +03:00
StefanBruens
faac387ce9 raop: Send initial timing packet to prime UDP connection tracking
In case the local UDP port is blocked by a firewall by default, send
an initial timing packet so the connection tracking will accept the
response packages.

Otherwise, the connection will fail with an 'RTSP/1.0 500 Internal
Server Error' after some timeout.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/840
2020-04-10 18:44:13 +00:00
efim
58482aa9c5 add comma 2020-04-10 04:41:57 +00:00
Georg Chini
9c7e49fa10 stream-restore: Restore preferred device for new streams
Currently the preferred device will not be restored for new streams if the
device is currently not avilable. This patch fixes the problem.
2020-04-09 17:33:03 +00:00
Tanu Kaskinen
924743e612 meson: Remove libpulse dep from libpulsecore
libpulsecore is not supposed to depend on the client library.

Removing the dependency caused build failures, which are fixed by adding
more stuff to libpulsecommon.
2020-04-09 14:51:21 +00:00
Jaroslav Kysela
5eb02e31a6 alsa sink/source: fix the mixer initialization
- remove duplicate mixer initialization in sink
- use the similar mixer initialization for source like for sink

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-04-09 16:42:28 +03:00
Jaroslav Kysela
fc5f263e59 ucm: fix the port / ucm device activation on boot
The UCM device must be activated using the pa_alsa_ucm_set_port()
call on boot (the sink creation time). In case when the
mixer controls are not defined for the application in the
UCM configuration, the mixer_handle is NULL.

Call the pa_alsa_ucm_set_port() before the mixer_handle check.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-04-09 16:42:28 +03:00
Tanu Kaskinen
77d00b1cce i18n: Add pulseaudio.pot to version control
Since the .pot file can be automatically generated, it hasn't been
included in the git repository so far. However, we're planning[1] to
start using Fedora's Weblate translation service, and it requires the
.pot file to be in the repository.

[1] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/785
2020-03-26 15:16:49 +00:00