Commit graph

6525 commits

Author SHA1 Message Date
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
Oschowa
8892152b13 meson: Require bluetooth codec library dependencies only when bluez5 is
enabled
2021-05-28 09:49:46 +00:00
Barnabás Pőcze
c851349f17 spa: logger: fix potential buffer overrun when message is long
If the message was too long, then the `vsnprintf()` call would
fill up `location`, leaving no space for the color escape sequence
and the newline, causing a stack buffer overrun here:

  size += snprintf(p + size, len - size, "%s\n", impl->colors ? suffix : "");

Fix that by reserving the last 24 bytes of the message buffer.
2021-05-28 09:40:11 +00:00
Wim Taymans
5a186ece01 alsa: handle plugin errors better
When the plugins can't be loaded, we fail to make a main_loop.
Handle this case instead of segfaulting.

See #1239
2021-05-28 11:38:02 +02:00
Wim Taymans
913434167d modules: remove some useless device names 2021-05-28 11:20:06 +02:00
Wim Taymans
b9efb25605 pulse-tunnel: handle latency a little better
Set a limit on the buffer size.
Announce our latency on the streams.
2021-05-28 11:19:05 +02:00
Barnabás Pőcze
48f03f85a7 pulse-server: add support for IPv6
Add support for listening on IPv6 addresses.
The following address formats are supported:
 * tcp:[<ipv6-addr>]:<port>,
 * tcp:<ipv4-addr>:<port>,
 * tcp:<port>, and
 * unix:<path>.

The IP addresses are parsed using `inet_pton()`,
only the formats supported by that function
are accepted.

The IPv6 address must be surrounded by square brackets,
they do not mean "optional" here. Specifying only the
port is equivalent to the following two addresses:
 * [::]:<port>, and
 * 0.0.0.0:<port>.

Address parsing has been made stricter: the port
must always be specified explicitly.

Fixes #1216.
2021-05-27 21:12:14 +02:00
Barnabás Pőcze
279470bc07 pulse-server: native-protocol-tcp: do not hardcode port
Use `PW_PROTOCOL_PULSE_DEFAULT_PORT` from pulse-server.h
instead of hard-coding the default port.
2021-05-27 19:32:02 +02:00
Wim Taymans
70722c0741 channelmix: provide some more upmix options
If nothing else is possible, also try to upmix from FC

See #1237
2021-05-27 18:08:07 +02:00
Wim Taymans
06cf1e1c00 module: proxy latency params 2021-05-27 16:07:25 +02:00
Wim Taymans
c319ed68d1 jack: implement more latency
Keep both input and output latency on the ports.

When setting the port latency only apply the rate latency values
and assume the node latency does not depend on buffer-size or time.
This is likely true because jack only knows about latency relative
to the rate.
2021-05-27 15:26:09 +02:00
Wim Taymans
e7eba82002 port: keep both output and input latency on port
But only emit latency changes for the latency matching the port.
2021-05-27 15:26:09 +02:00