Commit graph

2305 commits

Author SHA1 Message Date
Barnabás Pőcze
807fa19319 pulse-server: module-combine-sink: remove unnecessary conditional
After dequeueing the buffer, the code immediately checks if it is NULL,
and never modifies the variable. Therefore there is no need to check
again when the buffer is enqueued.
2022-03-17 21:11:59 +01:00
Barnabás Pőcze
d71dd31dcf pulse-server: module: initialize index
Initialize the index to `SPA_ID_INVALID` when a
module object is created. This way `module_free()`
may be called right after `module_new()`.
2022-03-17 19:35:48 +01:00
Théo Lebrun
344cacd24a module-rt: small fixes
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2022-03-11 18:47:25 +00:00
Théo Lebrun
6798b9a933 module-rt: allow building without RTKit 2022-03-11 18:47:25 +00:00
Wim Taymans
f06ee28140 pulse-server: add sink/source_properties
Support setting extra properties on the sink and source with the
sink/source_properties.
Fix construction of the module arguments, the sink/source.props needs to
be inside the object..

Fixes  #2201
2022-03-11 09:57:37 +01:00
Barnabás Pőcze
8fa4d5c43f pipewire: module-zeroconf-discover: handle when AvahiWatch is freed while dispatching
When a particular AvahiWatch is being dispatched, it cannot
be freed because `watch_callback()` accesses it after
the callback.

Introduce a member (`dispatching`) to coordinate
the deferred freeing in that case.

The timeouts are not affected because the `AvahiTimeout`
object is not accessed after the callback is called.
2022-03-10 21:44:27 +01:00
Wim Taymans
dcbaed1251 pulse-server: also handle fix_ for capture 2022-03-07 10:26:59 +01:00
Wim Taymans
2653e9f129 filter-chain: use property hints
Use property hints to expose int or bool controls.
2022-03-03 21:23:25 +01:00
Wim Taymans
2125ec048d filter-chain: use dynamic builder for param update 2022-03-03 21:22:23 +01:00
Wim Taymans
5a55e1a47a pulse-server: handle pulse.properties
Load properties from pulse.properties section so that they can have
overrides.
2022-03-03 11:59:55 +01:00
Wim Taymans
b645793d7e filter-chain: remove stray debug 2022-03-02 21:43:37 +01:00
Wim Taymans
99f9f729ff handle open_memstream errors
Fixes #2182
2022-03-02 11:48:31 +01:00
Wim Taymans
fdaf4613d8 module-raop: handle and debug read errors
Fixes #2183
2022-03-02 11:28:43 +01:00
Wim Taymans
00d4de3799 module-raop: use the right socket to read from
See #2183
2022-03-02 11:24:40 +01:00
Wim Taymans
e7958fac1b filter-chain: remove limits on ports
Allocate all ports dynamically so that there is no limit anymore.

Fixes #2179
2022-03-02 10:12:22 +01:00
Wim Taymans
c89595d86f protocol: increase some limits 2022-03-02 10:05:27 +01:00
Wim Taymans
b324c02570 filter-chain: use offsets to deref pods
In a dynamic builder we can only save the offsets in the array and
deref after we completed building everything.

Increase the control limits.

See #2179
2022-03-01 21:24:39 +01:00
Wim Taymans
cdf1b15d38 client-node: use dynamic pod builder 2022-03-01 21:07:56 +01:00
Wim Taymans
d3a1b9fe31 spa: add dynamic builder helper
Resizes the buffer dynamically. Be careful with getting the address
of a pod in the buffer, it might not be valid after building more stuff
with the builder.
2022-03-01 20:32:58 +01:00
Wim Taymans
168511c157 filter-chain: do some checks on the number of ports
Try to check that we don't overflow our port arrays.
2022-02-28 20:44:05 +01:00
Wim Taymans
5c44c6cd5c filter-chain: use MAX_CONTROLS for control ports
See #2179
2022-02-28 20:32:35 +01:00
Pauli Virtanen
fb04074335 pulse-server: set also metadata target.object when moving streams
Set also metadata target.object when moving streams, in case the session
manager supports that.
2022-02-28 18:36:26 +00:00
Pauli Virtanen
ab353a8057 module-session-manager: set object.serial on session objects
Session, endpoint, link, and stream objects should also set
object.serial.
2022-02-28 20:11:01 +02:00
Pauli Virtanen
3b94345bbe module-metadata: set object.serial on new client metadata
Client-created metadata should also set object.serial.
2022-02-28 20:11:01 +02:00
Pauli Virtanen
d71cf24183 global: update generation number also in clients without registry
Not all clients have an existing registry, and the registry generation
number will not be updated for them.  However, we would like to check
for stale globals also elsewhere, eg.  metadata, and it must work also
in this case.

To avoid failing to update client registry generation, on global
addition which the client would see if it had a registry, send done
message for the new global id instead.
2022-02-27 15:04:23 +02:00
Pauli Virtanen
a9accd1668 protocol-native: footer pre_demarshal must come first
Message footer should be handled before attempting to find the object
the main message is sent to / checking permissions, because it is not
aimed at a specific object.  E.g. the registry generation updates should
be handled regardless of whether the main message is valid or not,
because the updates will not be re-sent.

Fixes registry generation updates sometimes going missing.
2022-02-26 17:48:51 +00:00
Wim Taymans
76aaae2034 pulse-server: get stream id in paused
We can get the stream id when going to PAUSED.
2022-02-24 13:08:50 +01:00
Wim Taymans
6769becac5 module-echo-cancel: fix leak on error
Don't leak the properties on error.
Use and log the error returned from the init function.
2022-02-22 17:27:33 +01:00
Wim Taymans
2cd3427786 pulse-server: fix device.description
We now translate device.description to node.description when parsing
the properties so check for node.description and generate one when
it's not available.

Fixes #2166
2022-02-22 15:27:06 +01:00
Wim Taymans
580f499939 filter-chain: improve error reporting
Don't overwrite the errno from the plugin loader with 0 so that we can
actually report the right error.
2022-02-22 12:42:36 +01:00
Wim Taymans
62ae9b7d30 filter-chain: avoid denormals in biquad
See #1681 #2160
2022-02-21 17:34:52 +01:00
Wim Taymans
edb5664017 pulse-server: fix IEC958 passthrough again
We need to create fake channels when parsing the IEC958 format or
else we get an invalid format and IEC958 passthrough doesn't work.

Ignore the IEC958 formats when collecting formats for the device or else
the fake channels mess with the real channels of the device.

See #1442
2022-02-21 16:53:03 +01:00
Wim Taymans
22ec01d5c0 pulse-server: improve fix_ flags handling
PulseAudio will convert the samplespec/channelmap to a format_info
and omits the input format/rate/channels when the fix flags are set. It
does not use the input values at all.

Do the same in pipewire-pulse, make a single format description without
the requested fields.

This also needs a session manager fix to make it deal with those missing
fields.

See #876
2022-02-21 15:19:08 +01:00
Wim Taymans
e420b9c93c pulse-server: place the final sample rate as property
Use the final negotiated sample rate as node.rate to suggest a rate for
the graph.
2022-02-21 14:54:21 +01:00
Wim Taymans
d6a2b21fbe pulse-server: don't deref freed pending_sample 2022-02-21 11:12:10 +01:00
Wim Taymans
0475adbd35 pulse-server: wait for pending_sample to complete
Wait the reply to be sent and the sample to complete playback before
freeing the sample. Otherwise it might have been possible that the
sample completes before the reply can be sent.
2022-02-21 08:57:15 +01:00
Wim Taymans
1d9be5b25a pulse-server: ref client while completing operations
So that an operation can't accidentally free the client.
2022-02-21 08:56:02 +01:00
Wim Taymans
90eb1c18e0 pulse-server: unlink operation before callback
To ensure that the callback can't accidentally find and free the
operation.
2022-02-21 08:54:50 +01:00
Wim Taymans
d7793501fd pulse-server: free pending sample reply
If the sample finished playing before we finished the roundtrip to
get the sink_index, it will be destroyed. When the roundtrip completes,
it will try to use invalid memoryy and crash.

Make sure we destroy all pending replies before destroying the sample
to avoid this problem.

Fixes #2151
2022-02-20 21:34:53 +01:00
Pauli Virtanen
bf9ef440c3 protocol-native: check invariant for marshaled data
There's an assumption that marshaled messages consist of a single POD,
since we now tag on a footer after it.  This is true for the
protocol-native implementations, which all wrap the message in a single
POD Struct.

To catch protocol-native implementation bugs here later, add assert that
marshaling produces a single POD.
2022-02-20 18:19:13 +02:00
Pauli Virtanen
d44bf0ffc0 impl-core/protocol-native: use generation counter for global registry
Some client messages have bare ids (as opposed to proxies/resources),
eg. as in pw_registry_bind/destroy.  If the client is processing
messages late, these may refer to an object that was already removed,
and the id may now refers to a differnt objects.  I.e. the following
race condition needs to be resolved:

server               client
Global 1 (gen. 1)
                     Global 1
Global 1 remove
Global 1 (gen. 2)
                     Bind/destroy 1

Where the client would bind/destroy the wrong global, since it did not
yet see the messages for the second one.

To keep track of which object the client means, the server keeps track of
the "generation number" of its global registry, and what generation
the client is at.

Each global remembers at what generation of registry they were
registered. When processing the messages that use bare ids, check the
registry generation of the client, to know whether the message refers to
a stale global that was already removed.

Messages where client sends bare ids to server are:

    pw_registry_bind, pw_registry_destroy, metadata_set_property

In pw_registry_* do the staleness check directly. Also add staleness
check in pw_impl_client_check_permissions, so that also the metadata
case is handled.

The generation numbers are passed around in message footers, but only if
they have changed.  When the generation number changes on server, we
send the updated value to the client in a message footer.  When client
has received an update value, it will send the value back in the footer
of the next message it sends to the server.

Based on: Wim Taymans <wtaymans@redhat.com> "impl-core: check serial number"
2022-02-20 16:59:25 +02:00
Pauli Virtanen
680c33d3eb protocol-native: extend v3 protocol with message footers
Extend version 3 protocol with message footers, which are for passing
around global state data that is not addressed to a specific object.

The extension is backward compatible with previous v3 clients, and won't
e.g. result to error spam in logs.

The footer is a single SPA POD, appended after the main message POD.
Because both the protocol message and the message POD record their
length, it's possible to append trailing data. Earlier clients will
ignore any data trailing the message POD.

The footer POD contains a sequence [Id opcode, Struct {...}]*,
so there is room to extend with new opcodes later as necessary.

There are separate marshal/demarshal routines for messages aimed at
resources and proxies.
2022-02-20 16:59:25 +02:00
Pauli Virtanen
c4997fc46d pipewire-pulse: moving DONT_MOVE streams should fail
Pulseaudio return EINVAL for attempts to move DONT_MOVE streams.
2022-02-20 01:30:48 +02:00
Wim Taymans
bb1cd23a1a modules: fix warning 2022-02-18 15:12:27 +01:00
Barnabás Pőcze
d6c5da5678 pipewire: module-x11-bell: mark connection as terminatable
Since XFixes version 6[1] it is possible to mark
an X connection as terminatable. The X server will
gracefully terminate after a timeout if only
terminatable connections remain.

[1]: https://gitlab.freedesktop.org/xorg/lib/libxfixes/-/merge_requests/1
2022-02-18 12:30:53 +01:00
Barnabás Pőcze
c9612225e1 pipewire: module-x11-bell: handle X11 errors
Unfortunately, libX11 has global error and I/O error handlers,
which make it inconvenient to use them from library code.

Since libX11 1.7.0, there is a per-display "exit_handler" which
is called from `_XIOError()`, however, the global I/O error
handler is still called before that, and that - by default -
calls `exit(1)` in `_XDefaultIOError()` after printing the error
to stderr.

To avoid exiting, custom handlers will be registered when
libpipewire-module-x11-bell.so is loaded given that at
that moment the default handlers are installed.

When the shared object is unloaded, the handlers will
be reset to the default ones given that the currently
registered handlers are the ones that were registered
when the module was loaded.

The logic only works correctly if there are no concurrent
calls to `XSet{IO}ErrorHandler()` while `{set,restore}_x11_handlers()`
is running. Since module-x11-bell is probably mostly going to
be loaded in `pipewire-pulse`, this seems like a reasonable
assumption to make.
2022-02-18 12:30:53 +01:00
Barnabás Pőcze
7c70c4e383 pipewire: module-x11-bell: remove unnecessary member
`xkb_event_base` is only ever set and never read. Remove it.
2022-02-18 12:30:53 +01:00
Barnabás Pőcze
45bd8532eb pipewire: use newly added function for deferred module destroy
Use the newly introduced `pw_impl_module_schedule_destroy()`
for deferred module destroy in all modules except
module-example-{sink,source}.
2022-02-18 12:30:53 +01:00
Barnabás Pőcze
4d4c6f20df pipewire: remove work queue checks
Since now `pw_context_get_work_queue()` cannot
fail, the checks can be removed.
2022-02-18 12:30:53 +01:00
Barnabás Pőcze
afda4c81e7 pipewire: module-x11-bell: simplify x11_connect()
Since no cleanup needs to be in `x11_cleanup()`, the
`error` label may be removed and the error codes
can be returned directly.
2022-02-18 12:30:53 +01:00