Commit graph

1030 commits

Author SHA1 Message Date
Wim Taymans
f85b0bfd16 pulse-server: Avoid overflow in stream read/write index
Keep separate counters for the ringbuffer and stream read/write
indexes.

The ringbuffer has 32 bits indexes while the pulse server is required
to keep 64 bit read/write indexes.

Also handle invalid seek flags.

Fixes #1331
2021-06-21 10:50:23 +02:00
Barnabás Pőcze
80e3da9b01 pulse-server: add missing minus sign
Noticed by @QuLogic.

Fixes: 87c00a6f00 ("pulse-server: add missing EWOULDBLOCK check")
2021-06-19 17:28:03 +00:00
George Kiagiadakis
59407d2f08 includes: update all references to extensions to point to pipewire/extensions
This also brings the advantage that all tools, examples, modules, components
can also be compiled standalone out-of-tree using libpipewire from the system
2021-06-18 17:54:18 +03:00
Wim Taymans
bbbc79647f pulse-server: return INTERNAL error for ENFILE/EMFILE 2021-06-18 15:56:55 +02:00
Wim Taymans
def0caf281 pulse-server: handle out-of-files better
When we don't have enough files to accept the connection, clear the
_IN flag so that we don't try to accept if over and over again.
When a client disconnects, set the flag again so that we try to
accecpt new connections again.

See #1305
2021-06-18 15:26:20 +02:00
Wim Taymans
38c721993f pulse-server: limit the amount of connections
Set to 64, like pulseaudio. We might want to configure this.

See #1305
2021-06-17 18:36:28 +02:00
Barnabás Pőcze
58e254ec63 pulse-server: module-zeroconf-publish: remove unnecessary emit
Since !737 it is not required of modules to emit the "loaded"
event if they can load immediately, therefore remove the
unnecessary `module_emit_loaded()` call.

Furthermore remove redundant log messages as well.
2021-06-16 16:40:57 +02:00
Wim Taymans
f43c57afdb pulse-server: add context listener last
Add if after we have done everything else because if there is an
error we don't remove it and there will be an invalid hook registered
in the context.
2021-06-16 12:17:39 +02:00
Sanchayan Maity
96c77e1f2f pulse-server: Implement module-pipe-source 2021-06-16 08:05:51 +00:00
Sanchayan Maity
d5ee0ad8cc module-pipe-sink: Fix usage of spa_strerror
spa_strerror() works with negative error codes and async spa results.
2021-06-16 13:30:48 +05:30
Sanchayan Maity
4be1981f54 module-protocol-pulse: Clean up unused #define ERROR_RETURN 2021-06-15 10:54:48 +05:30
Wim Taymans
b6559289f1 pulse-server: fix compilation on some compilers 2021-06-14 15:43:32 +02:00
Wim Taymans
1bc383a7b7 pipewire-pulse: also store format/channels for sources 2021-06-12 20:30:49 +02:00
Wim Taymans
ba402209ba pulse-server: use PulseAudio name for format and channels
Use the pulseaudio names for the format and channels, like the real
pulseaudio.
2021-06-12 20:29:51 +02:00
Sanchayan Maity
cf93fd7f9a module-protocol-pulse: Add Avahi zeroconf publish module 2021-06-12 17:56:49 +00:00
Sanchayan Maity
e66125ede0 module-protocol-pulse: Factor out some common code
Factor out some of the common code that will be required for zeroconf
support next.
2021-06-12 17:56:49 +00:00
Barnabás Pőcze
bd6f63fecd pulse-server: improve module loading
Modules no longer need to emit the "loaded" event manually
if they can load immediately. In that case, the module loading
code will take care of emitting the event. If they can't,
they must return an async spa result, and emit the "loaded" event
when they see fit.

Fixes #1232
2021-06-11 20:50:30 +02:00
Barnabás Pőcze
4d02233ff3 pulse-server: don't broadcast remove event when a module wasn't loaded 2021-06-11 20:50:30 +02:00
Barnabás Pőcze
f26358e958 pulse-server: module-simple-protocol-tcp: remove unnecessary struct member 2021-06-11 20:50:30 +02:00
Barnabás Pőcze
3eaea123f9 pulse-server: module-simple-protocol-tcp: add module listener 2021-06-11 20:50:30 +02:00
Barnabás Pőcze
12359b490d pulse-server: module-null-sink: provide fallback name
If no `sink_name` has been specified, use "null-sink" to avoid a
NULL pointer dereference later in the function.
2021-06-11 20:50:30 +02:00
Barnabás Pőcze
09c162c8bf pulse-server: module-null-sink: add missing version to events struct 2021-06-11 20:50:30 +02:00
Barnabás Pőcze
6f5b089767 pulse-server: clear hook list when module is freed
Moreover, rename the hook list to "listener_list".
2021-06-11 20:50:30 +02:00
Barnabás Pőcze
d9befc0792 pulse-server: eliminate some memory leaks in modules 2021-06-11 20:50:30 +02:00
Barnabás Pőcze
1d5fb2a7db pulse-server: remove unnecessary struct members 2021-06-11 20:50:30 +02:00
Barnabás Pőcze
cd0eb829dd pulse-server: remove redundant log messages from modules
The same information is printed in
* `on_module_loaded()`,
* `module_load()`, and
* `module_unload()`.
2021-06-11 20:50:30 +02:00
Nicolai Syvertsen
01875ad223 pipewire-pulse: set description
Some applications like TeamSpeak crash when this isn't set.
2021-06-10 22:21:26 +02:00
Arun Raghavan
08daf3f4f4 pulse-server: Add a module-echo-cancel
Fairly straightforwad module to load libpipewire-module-echo-cancel
2021-06-05 17:54:02 +00:00
Wim Taymans
2a8b7594bc pulse-server: avoid overflow
Make sure the requested bytes never go below 0.

See #1258
2021-06-04 09:13:43 +02:00
Barnabás Pőcze
e65afe8fa2 pulse-server: module-combine-sink: remove hooks
Remove hooks when the module is unloaded to avoid
use-after-free issues. Remove the cleanup source as well.

Fixes #1259.
2021-06-04 06:55:08 +00:00
Wim Taymans
669fbf10c1 fix some leaks in error paths 2021-06-03 20:33:59 +02:00
George Kiagiadakis
131832d441 pulse-server: suffix TAG_USEC constants with LL, as they must be 64-bit
Fixes protocol errors on arm
2021-06-03 17:36:19 +03: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
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
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
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
Wim Taymans
913434167d modules: remove some useless device names 2021-05-28 11:20:06 +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
492caf4456 pulse-server: handle errors during create
If a stream is being created and an error occurs we always need to
reply with the pending create_tag.

Fixes #624
2021-05-26 10:44:59 +02:00
Wim Taymans
4e4294dc13 pulse-server: handle NULL dbus connection
Fixes #1224
2021-05-26 10:23:17 +02:00
Peter Hutterer
2cb7b19b7d pulse-server: fix scan-build errors for unused variables
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer
6d19dd0162 pulse-server: if all transport methods failed, fail server creation
No point in keeping a server running if it doesn't listen to anything.
2021-05-26 07:46:55 +00:00