Commit graph

6536 commits

Author SHA1 Message Date
Arun Raghavan d95870d8d3 module-echo-cancel: Wire up the webrtc echo canceller
Mostly uses the existing infrastructure, but the webrtc canceller has a
fixed blocksize, so we:

  1. Use the canceller blocksize if configured
  2. Accumulate output data in a ringbuffer
  3. Push out the data in the required chunk size
2021-06-02 17:56:40 -04:00
Arun Raghavan 1349d5334d module-echo-cancel: Drop buffers on overruns
Without this, if we do overrun, we'll never catch this.
2021-06-02 12:50:16 -04:00
Arun Raghavan bbae1adda0 module-echo-cancel: Separate input gathering and output processing
This aggregates buffers from the capture stream and the sink in the
corresponding process callbacks, and runs processing based on the
desired resampler rate if there is one.

We allow the ringbuffer in which we capture buffers to grow to some
extent, as that seems to be required for playback to occur smoothly.
Whether this is hiding some other underlying problem likely needs
investigation.
2021-06-02 12:46:12 -04:00
Arun Raghavan 42196a331d module-echo-cancel: Consolidate includes 2021-06-02 12:46:12 -04:00
Wim Taymans 35e81fbfdc alsa: rework UCM open
Use _alibpref to check if a device needs a UCM local config. Mark
the device as such and use this to set the OPEN_UCM property on
the device.
Open the UCM for a card when the device has the property set. Use the
same logic for loading the UCM as the acp code.

See #1251
2021-06-02 17:25:21 +02:00
Wim Taymans 58d0e44664 pipewire: Add option to disable config files
Add env variable PIPEWIRE_NO_CONFIG to disable parsing
custom config files.
Add a method to check extra options.
Expose valgrind, no-config and no-color as options.
2021-06-02 15:55:24 +02:00
Wim Taymans dde03a7dd3 config: add some comments in the config file
About where to copy and change it.
2021-06-02 15:22:49 +02:00
Wim Taymans e3d3f04780 alsa: if we are passed a UCM device, make sure to open UCM
UCM devices can require local data from use_case_mgr_open() but since
we do that in a separate process, make sure we reopen the use case
manager in case we are passed a UCM device so that the config is
available.

See #1251
2021-06-02 13:23:08 +02:00
Peter Hutterer 1d4b24d02b pipewire: allow NULL pointers in pw_memmap_free()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
2021-06-02 10:56:46 +00:00
Peter Hutterer 71e0cfb5fa pipewire: allow NULL pointers in pw_free_strv()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
2021-06-02 10:56:46 +00:00
Peter Hutterer e0471c6757 pipewire: allow NULL pointers in pw_properties_free()
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.

Patch generated with concinelle with a few manual fixes.
2021-06-02 10:56:46 +00:00
Peter Hutterer a1e821c259 pw-dump: use the spa_ato* helpers for string to number conversions 2021-06-02 07:39:41 +00:00
Peter Hutterer 3796bc814e pipewire: use spa_ato*() to parse properties
For boolean properties:
- passing in NULL no longer crashes and instead returns false
- passing in a string starting with 1 (e.g. "1xyz") no longer resolves to true

For int-based properties:
- passing in NULL no longer crashes and instead returns 0
- passing in invalid numbers no longer resolves to whatever number prefix
  could be parsed (e.g. "123foo" was 123)
2021-06-02 07:39:41 +00:00
Peter Hutterer 6826df07da spa/utils: add spa_atou32, spa_atoi64,spa_atou64, spa_atod, spa_atof
Same as the existing spa_atoi32 but for uint32_t, {u}int64_t, float and
double.
2021-06-02 07:39:41 +00:00
Peter Hutterer c3ab4ec9dc spa: fix documentation for spa_atoi32
The val isn't undefined on failure, it's unmodified.
2021-06-02 07:39:41 +00:00
Peter Hutterer 1a5faa7b52 spa: add a header for ANSI color sequences
Makes the code more readable and guarantees we use the same sequences for the
same colors everywhere.
2021-06-02 14:17:29 +10:00
Barnabás Pőcze 4c13eced55 pulse-server: detach clients from server
When the server or client goes away, detach the client
from the server to avoid potential use-after-free issues
that might occur if the client causes the
unloading of the server it is connected to.

E.g.:

  pactl load-module module-protocol-native-tcp port=4713
  pactl -s localhost:4713 unload-module module-native-protocol-tcp

See #1240.
2021-06-01 22:11:49 +02:00
Wim Taymans 3889ea5277 pulse-server: add ref to client while processing
Add a ref to the client while processing messages. This way we don't
destroy the client if we destroy the server it is on.

Fixes #1240
2021-06-01 17:48:24 +02:00
Wim Taymans 102b77ea03 pulse-server: don't request already requested data
When we are flushing, don't ask for already requested bytes
or else we end up with too much data in our buffer.

Fixes #1243
2021-06-01 16:59:00 +02:00
Wim Taymans 620e8de52a acp: copy the db_fix key as well
Or else we will try to free the original key twice and segfault.

Fixes #1125
2021-06-01 12:43:08 +02:00
Wim Taymans 0f55ff9e60 stream: clarify buffer onwership and lifecycle
Fixes #1126
2021-06-01 12:25:44 +02:00
Wim Taymans f544e4d87c acp: reset volume when enabling a device
When we enable a device, the node will be created and its software
volume will be set to 100%. Update the device volume with this as
well so that changing the volume has an effect.

Fixes #1198
2021-06-01 11:47:59 +02:00
Wim Taymans e994949d57 properties: make safer serialize_dict implementation
Don't use alloca for the serialized string but instead write the
serialized string directly to the file.

Fixes #1249
2021-06-01 10:37:15 +02:00
Barnabás Pőcze 1cb613ee4b pulse-server: terminate connection in more cases
If any of those two branches are taken, the connection
cannot make forward progress since no data will be read/sent
from/to the client.

For example, sending just 21 invalid bytes to the server
causes the first 20 bytes (client descriptor) to be read,
then rejected, leaving `client->message == NULL`. But since
polling is level triggered, `on_client_data()` and thus
`do_read()` will continue to be called ceaselessly,
thereby spamming the log and wasting resources.
2021-05-31 21:34:58 +02:00
Barnabás Pőcze bc6adbe15d pulse-server: make control flow easier to unserstand
Use a switch statement to make the control flow
a bit easier to understand.
2021-05-31 21:34:58 +02:00
Barnabás Pőcze 87c00a6f00 pulse-server: add missing EWOULDBLOCK check 2021-05-31 21:34:58 +02:00
Barnabás Pőcze ebed44db79 pulse-server: support absolute unix socket paths
If a unix socket address starts with '/', use it
directly as an absolute path, do not prepend
the runtime directory.
2021-05-31 21:34:58 +02:00
Barnabás Pőcze 70c6e6ccc8 pulse-server: only unlink sockets
If the entity specified in a unix socket address exists, check
if it is a socket, and bail out if it is not.
2021-05-31 21:34:58 +02:00
Arun Raghavan f19d998906 pw-jack: Fix empty string checks
shellcheck seems to hate x"$FOO" = x checks, so let's use the
appropriate test arguments instead.
2021-05-31 12:46:18 -04:00
Wim Taymans bc6e11d6e4 audioconvert: move some info to debug 2021-05-31 16:17:43 +02:00
Wim Taymans a248391939 echo-cancel: set latency on the right streams 2021-05-31 16:15:37 +02:00
Wim Taymans 7f912a1cff impl-port: improve Latency param check
We can use the latency param when we have a Writable entry in the
param_info.
2021-05-31 16:13:42 +02:00
Wim Taymans 743eaf4aa2 filter: add PARAM_Latency support
Announce the Latency param in pw-filter.
Mark the latency param as writable. It becomes readable when we provide
a value.
2021-05-31 16:12:26 +02:00
Wim Taymans 8485622923 echo-cancel: reuse buffer on error
Queue the dequeued buffers when there is an error so that we can
recover.
2021-05-31 15:53:34 +02:00
Wim Taymans b0068fd46b media-session: use direction to find the node by name
Also use the stream direction when finding a node by name. We should
only select nodes that have the right direction.
2021-05-31 15:40:26 +02:00
Wim Taymans d37ea7851a echo-cancel: copy some more node properties 2021-05-31 15:17:00 +02:00
Wim Taymans a2cab35365 echo-cancel: use the right node.group 2021-05-31 15:01:33 +02:00
Hui Wang e375930813 alsa-mixer: only use switch to mute Front in the Headphone path
According to the alsa-info.txt in the pipewire issues of #747 and #1206,
the Front Playback Volume is shared by Headphone and Lineout or
Headphone and Speaker, But Headphone, Lineout or Speaker they all have
independent Playback Switch, change to only use switch to mute the
Lineout or Speaker. This could resolve the issues of #747 and #1206.

See #1206 and #747
2021-05-31 13:08:19 +02:00
Wim Taymans 4dc3d79ff2 alsa: sync with pulseaudio 2021-05-31 13:03:52 +02:00
Wim Taymans c803444123 impl-port: only send latency param when supported
Check if the port has latency param and only try to set the
latency param when it appears available. This avoids sending unknown
latency params to an old client and erroring out.
2021-05-31 11:31:18 +02:00
Peter Hutterer 98353560da spa: remove semicolon at end of SPA_LIST_INIT 2021-05-31 07:35:59 +00:00
Peter Hutterer c58498bd92 config.h.meson: drop define for USE_POISONING
This isn't hooked up and takes a bit of effort to hook up across the tree.
Let's remove the define so it doesn't look like we're doing something.
2021-05-31 07:35:59 +00:00
Evgeniy Khramtsov 3cf4bf7cf7 modules: build module-rt only on Linux
RLIMIT_RTTIME is Linux specific, there is no equivalent replacement
for FreeBSD. Save trouble and build module-rt for Linux only, rtkit
WIP fork should be fine on FreeBSD for now.
2021-05-30 15:30:45 +03:00
Barnabás Pőcze 2a8d511be8 pipewire: map: initialize free_list to SPA_ID_INVALID
If `struct pw_map::free_list` is not initialized to `SPA_ID_INVALID`,
then `pw_map_insert()` will try to read `map->items.data[0]` when
inserting the first element, but `data` is a `NULL`
pointer after initialization.
2021-05-30 00:21:43 +02:00
Wim Taymans 0eb46d8ef4 filter: call the process rt_callback 2021-05-29 08:41:37 +02:00
Huang-Huang Bao e953bb3238
meson: fix build if bluez5 option is disabled
Don't look up codecs dependencies and don't include 'bluez5' subdir if 'bluez5' option is disabled or libbluetooth is not found.
See https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/707.
2021-05-28 21:01:38 +08:00
Huang-Huang Bao 38bcec9022
bluez5: add port latency reporting 2021-05-28 20:02:10 +08:00
Huang-Huang Bao d8435cd5fd
bluez5: use definations to index node and port params 2021-05-28 19:40:19 +08:00
Wim Taymans 934caab1e1 stream: emit events from only one thread
Emitting events using the listener_list can not be done from multiple
threads at the same time.  For this reason, make a copy of the events
with the process event and call it explicitly from the data thread.

See #1122
2021-05-28 13:24:10 +02:00
Wim Taymans a138152bef pulse-server: free message when resize fails
Based on patch by Peter Hutterer

Fixes !701
2021-05-28 11:52:29 +02:00