Commit graph

5302 commits

Author SHA1 Message Date
Wim Taymans
8c10080324 pulse-server: make sure we don't exceed maxlength
Make sure the various buffer attributes don't exceed maxlength.
Add some SPA_ROUND_UP and SPA_ROUND_DOWN macros.

Fixes #2100
2022-02-04 11:59:57 +01:00
Wim Taymans
877dc77645 conf: move rule matching to config
And remove duplicated code. This is generally useful and sufficiently
generic API to include.
2022-02-04 10:43:31 +01:00
Barnabás Pőcze
cc73053512 treewide: meson.build: use feature.allowed()
Since meson 0.59.0, a feature object has an `allowed()`
method which returns true when the feature is set to
'enabled' or 'auto'.

Utilize that instead of the previously used

  not feature.disabled()
2022-02-04 00:15:59 +01:00
Barnabás Pőcze
15e7a61aa7 treewide: only define feature macros when the feature is available
Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing

  if cond
    cdata.set('X', 1)
  endif

with

  cdata.set('X', cond)
2022-02-04 00:15:59 +01:00
Barnabás Pőcze
9afffc1815 meson.build: only set HAVE_DBUS once
HAVE_DBUS is already set in the top-level meson.build file.
2022-02-04 00:15:59 +01:00
Wim Taymans
ae077a4967 doc: update with config overrides info 2022-02-03 17:31:01 +01:00
Wim Taymans
7ac809618e pw-link: improve help and error messages
See #2089
2022-02-03 16:39:52 +01:00
Wim Taymans
a947faeaa0 pw-link: clarify -L option
-L is enabled by default, unless -m is specified.
2022-02-03 16:30:06 +01:00
Wim Taymans
b5cd6d02fd pw-link: fix -L comment 2022-02-03 16:22:21 +01:00
George Kiagiadakis
ee2e6412d3 pipewiresink: set a default channel map if the number of channels is fixed
This allows remaping streams using pipewiresink to match the channel layout
of the target device
2022-02-03 15:10:25 +02:00
Wim Taymans
7506d12b07 examples: filter can return NULL buffers 2022-02-03 11:15:46 +01:00
Wim Taymans
0659f090fc filter-chain: add FL to FL-FR duplication 2022-02-03 11:03:24 +01:00
Wim Taymans
92e58eeb4f link-factory: allow usage without a client
So that it can be used in the config files.

Fixes #2095
2022-02-02 21:34:23 +01:00
Wim Taymans
1a911a9ccd resource: allow NULL resource in error
And then log en error instead.
We can remove some awkward patterns in modules.
2022-02-02 21:33:33 +01:00
Wim Taymans
8aea38e81a resource: fix log topic 2022-02-02 21:32:28 +01:00
Wim Taymans
336bc0eee5 log: add pw_logtv macro 2022-02-02 21:31:49 +01:00
Wim Taymans
4341d27c2c pulse-server: don't make fake channels for iec958
Just leave the channels as they were.

See #1442
2022-02-02 17:41:23 +01:00
Wim Taymans
33607f769c pulse-server: don't update channels when unset 2022-02-02 17:40:57 +01:00
Barnabás Pőcze
e63dee6075 pulse-server: check reference count of sample when freeing it
When the pulse server context is being freed, only a single reference
should be alive to each sample because the pending samples
are all destroyed beforehand.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
f181210b29 pulse-server: properly unload modules
Instead of simply calling `module_free()`, actually unload
the modules when the pulse server context is being freed.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
a79bb60754 pulse-server: clean up everything when the context is destroyed
Clean everything up when the context is destroyed to avoid
problems stemming from the destruction order of objects
in the context.

Furthermore, free messages after all clients have been freed
because `client_free()` may very well call `message_free()`
which would lead to memory leaks if `impl->free_messages` were
processed first.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
1bf00720e3 pulse-server: do not manage client lifetime during stream cleanup
A stream's lifetime is tied to that of the client, it cannot outlive
the client object. Streams also do not increase the client's reference
count. It is not possible for a stream to exist after the corresponding
client has been destroyed.

Hence it is not necessary to manage the client's reference count
or lifetime in `do_destroy_stream()`. All works related to a particular
stream are cancelled in `stream_free()`, which is called
before the client is destroyed.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
194c0f9c99 pulse-server: stream: remove done flag
When the `done` flag was first added in
9f9be7d7f2, it was
actually needed because cleanup was implemented
using a per-client eventfd which was signalled when
something related to the particular client needed
to be freed. The function that ran, then, checked
each stream's `done` flag, and freed them as necessary.

However, since c70a5de526,
the stream cleanup is done using a work queue, and as
a consequence, the `done` flag is no longer needed.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
4426da6a62 pulse-server: client: remove disconnecting flag
When the `disconnecting` flag was first added in
d44fdabea1, a client's
streams were not explicitly destroyed when it was freed,
instead, only the client's pw_core was disconnected,
which then caused all related streams to be destroyed.

Thus there needed to be a way to determine why the stream's
state changed to PW_STREAM_STATE_UNCONNECTED as it may have
been because the client is disconnecting or because the
stream has been "killed" in some other way.

The `COMMAND_{PLAYBACK,RECORD}_STREAM_KILLED` command
only needed to be sent to the client in the second case.

However, at the moment, all streams of a client are explicitly
destroyed before it's pw_core is disconnected. This makes the
`disconnecting` flag unnecessary, thus it can be removed.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
f5e561c2fe pulse-server: module: remove unused client argument
None of the modules use the `client` argument in their
unload callbacks. Remove it.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
bc2914b3e9 pulse-server: pending-sample: move reference counting
Move the reference counting from `pending_sample_free()`
into `on_sample_done()` so that the client's references
are managed in a single place.

The reason why `pending_sample_free()` cannot simply call
`client_unref()` is that `client_free()` may be called from
`manager_disconnect()` regardless of the reference count,
and, in turn, `pending_sample_free()` may be called,
which could then lead to a recursive call to `client_free()`.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
29a288ebae pulse-server: pending-sample: remove done flag
The `done` member of the `pending_sample` struct is only ever
set, but never read. Remove it.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
9447dbe4f8 pulse-server: remove unnecessary include 2022-02-02 15:40:43 +00:00
Barnabás Pőcze
5db2c6cc32 pulse-server: simplify a condition
`a || (!a && b)` equals `a || b` due to the
short-circuiting nature of `||` and `&&`.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
6d0075b4e9 pulse-server: client: cancel related work queue jobs 2022-02-02 15:40:43 +00:00
Barnabás Pőcze
78aaa0a3dd pulse-server: client: move to cleanup list on detach
Move a client to the `impl->cleanup_clients` list right
after it has been removed its server's `clients` list.
2022-02-02 15:40:43 +00:00
Barnabás Pőcze
d2edb1ab16 pulse-server: client: do not leave dangling pointers behind 2022-02-02 15:40:43 +00:00
Wim Taymans
f38837d9e2 conf: look in conf.d directories and merge all sections
Load all sections found in all prefix/name.conf.d directories and add
them to the config as overrides.
If for example jack.conf is loaded, check in:

  /usr/share/pipewire/jack.conf.d/
  /etc/pipewire/jack.conf.d/
  $XDG_CONFIG_HOME/pipewire/jack.conf.d/
     or ~/.config/pipewire/jack.conf.d/

For .conf files and also process the sections. The files are processed
in sorted order so 10-remap.conf can be used to specify the order.

When processing a section, first the global conf is applied and then the
overrides in their order.

This makes it possible to override properties or add modules,
objects and custom matching rules.

Since the merging logic is handled either internally or by the
application, we can add more syntax later to do more complex merges.

See #207
2022-02-02 14:58:15 +01:00
Wim Taymans
92e851f61b conf: improve debug 2022-02-02 12:41:36 +01:00
Wim Taymans
58ebe0f88a conf: Parse the whole config with properties
There is no need to call the callbacks when reading the config file,
just store all properties.
We're only going to extract one when iterating later.
2022-02-02 12:37:49 +01:00
Wim Taymans
f273e2a716 conf: emit callback for config sections
Instead of reading all config section in properties, emit a callback
for each section, allow for filtering on a particular section as
well. In the callback, update the section value in the properties.

Deprecate get_conf_section(), it can't support multiple section
updates.
2022-02-01 17:16:33 +01:00
Wim Taymans
5839400aa0 context: implement prop updates with for_each 2022-02-01 16:51:59 +01:00
Wim Taymans
432f464297 conf: implement match rules with conf_section_for_each 2022-02-01 16:35:16 +01:00
Wim Taymans
0ac87a14cd context: move context method to right header file. 2022-02-01 16:30:43 +01:00
Wim Taymans
d6218b65ab conf: parse the context sections with iterator
Make a new function that calls a callback for each config section
and use that to parse the config sections internally.
2022-02-01 16:27:21 +01:00
Wim Taymans
50de4b1886 conf: add some properties in the conf
Add the path, prefix and name in the config properties.
2022-02-01 15:55:17 +01:00
Wim Taymans
2b569861b1 conf: refactor path generation
Make different methods for the different paths to search.
2022-02-01 15:37:48 +01:00
Wim Taymans
2013fb56cf conf: refactor abs path
We can simplify the check by shifting the prefix and name and use
the same code for both the config and state path.
2022-02-01 15:25:48 +01:00
Wim Taymans
65c487564b context: add a function to merge config properties
Add a function that takes a section and merges the properties into
a target properties. Replace some usage of get_config_section().
2022-02-01 15:11:45 +01:00
Wim Taymans
24c97b1c7e context: add force-quantum and force-rate property
Add a node.force-quantum and node.force-rate property. When no global
quantum or rate is enforce with settings, the last updated node property
is used as the quantum.

Make jack use the force-quantum property when set_buffersize is used to
make sure that the quantum is not just a suggestion but a hard forced
one. This makes it possible for ardour or other jack apps to raise the
quantum above the max-quantum but also ensure that it will not change
by any other application (unless other jack apps).

Fixes #2079
2022-01-31 17:59:18 +01:00
Wim Taymans
54d50b943f global: move serial counter to context 2022-01-31 17:34:30 +01:00
Wim Taymans
dbab29d9db pulse-server: improve remap sink/source properties
Make the NODE_DESCRIPTION based on target sink or node.name
2022-01-31 12:40:38 +01:00
Wim Taymans
7ec920b0af pulse-server: improve remap sink/source properties
Make the same MEDIA_NAME and NODE_DESCRIPTION for both streams.
Make a better NODE_NAME for the other stream with a prefix.
2022-01-31 12:07:49 +01:00
Wim Taymans
115875dc5b pulse-server: add more properties
Add device.class property
2022-01-29 11:21:31 +01:00
Wim Taymans
78ff44b91d pulse-server: fill description for remap module
See #2076
2022-01-29 11:11:44 +01:00