Commit graph

1030 commits

Author SHA1 Message Date
Wim Taymans
143fadf68e pulse-server: also remap module property keys and values
When loading a module, remap the pulseaudio properties to pipewire ones
for consistency.

move the media-roles to remap, because it's more about remapping between
pa and pw.

Fixes #2076
2022-02-04 15:15:42 +01:00
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
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
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
432f464297 conf: implement match rules with conf_section_for_each 2022-02-01 16:35:16 +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
Wim Taymans
6543899fe6 pulse-server: implement stream_buffer_attr 2022-01-28 17:34:36 +01:00
Wim Taymans
ce03fc7c15 pulse-server: increase maxlength to match tlength
When we need to increase tlength because of a quantum change, increase
maxlength as well, but clamp it to MAXLENGTH.

See #2069
2022-01-28 16:23:42 +01:00
Wim Taymans
1ac1f914e3 pulse-server: allows allocate MAXLENGTH for the ringbuffer
See #2069
2022-01-28 16:21:03 +01:00
Wim Taymans
5ead4507cc pulse-server: ensure tlength <= maxlength
See #2069
2022-01-28 16:15:26 +01:00
Wim Taymans
ee007eaf6c modules: improve simple-protocol arguments
Use the format parsing code to also parse the channel_map.
Improve serialization of the properties.

See #2068
2022-01-27 16:31:01 +01:00
Wim Taymans
db2719f1f4 pulse-server: always advance the read pointer in underrun
We should always advance the read pointer when we are underrun and
not corked. This will request more bytes from the client to make
things advance.

Fixes #2041
2022-01-25 15:21:31 +01:00
Wim Taymans
b9c8f0f6b9 pulse-server: don't complete drain when corked
A corked stream should not complete a pending drain operation.
2022-01-25 15:20:27 +01:00
Wim Taymans
1b0252c267 Revert "pulse-server: don't ask data when corked"
This reverts commit 3b14afe317.

Breaks mpv..
2022-01-25 13:23:58 +01:00
Wim Taymans
3b14afe317 pulse-server: don't ask data when corked
Don't ask for data when we are corked. Some clients like telegram
don't send data when corked.

See #2041
2022-01-25 13:18:56 +01:00
Wim Taymans
4f57f3cdae pulse-server: allow per-application latency quirks
Make it possible to set latency and buffer parameters in the matching
rules.

Add a rule for speech-dispatcher and force it to some larger latency.
2022-01-22 16:17:09 +01:00
Wim Taymans
7f08cadca4 pulse-server: move quirks to config section
Make a pulse.rules section in the config file with match rules. Add
support for setting custom client properties and quirks.
2022-01-22 11:51:11 +01:00
Wim Taymans
000b448ba3 pulse-server: set the node.name on the input/output
Not on the global property because module-loopback does not read it
from there anymore in order to have unique names.
2022-01-21 17:55:32 +01:00
Wim Taymans
373432a4e7 pulse-server: implement module-x11-bell
Just load the x11-bell module into the pulse server.

See #1668
2022-01-21 17:01:18 +01:00
Barnabás Pőcze
cec9347864 pulse-server: iterate addresses correctly
When creating servers, actually iterate the addresses correctly instead
of only using the first address.

Fixes #2047
2022-01-21 10:25:46 +01:00
Wim Taymans
9935f921c5 pulse-server: use TARGET_OBJECT with the target serial
Use a new TARGET_OBJECT property to ask to be linked to a target by name
or serial. This should deprecate NODE_TARGET later.
2022-01-19 17:09:55 +01:00
Wim Taymans
dec2b1b9a2 pulse-server: set serial to invalid on parse error 2022-01-19 16:57:17 +01:00
Wim Taymans
1d03923a97 pulse-server: use object serial as index
Use the lower 32 bits of the object serial as the index. When there is
an overflow, use an invalid index, which will probably result in a
protocol error.
2022-01-17 12:48:31 +01:00
Wim Taymans
0904a35ba8 pulse-server: make separate index
Separate the id (the pipewire object id) from the index (what we send to
the client to identify the objects).
2022-01-17 12:01:13 +01:00
Wim Taymans
955e4287ab pulse-server: index flags are only used for modules
one flag for the internal extension modules, another flag for the
modules we load in pulse server that don't really have a matching
pipewire module.
2022-01-17 10:28:09 +01:00
Wim Taymans
6a2aea8e0a pulse-server: remove the MONITOR flag
PulseAudio has separate namespaces for sources and sinks so we can reuse
the same id for the sink and its monitor.
2022-01-17 10:25:26 +01:00
Wim Taymans
48e83fc780 pulse-server: find_object -> find_object_by_id 2022-01-17 10:04:28 +01:00
Wim Taymans
3b85369ff6 pulse-server: use key instead of id for the data key 2022-01-17 10:03:02 +01:00
Wim Taymans
b2d221a66c pulse-server: rename obj_id -> id
Simply use id for the object id.
2022-01-17 09:50:41 +01:00
Wim Taymans
5a315d5351 pulse-server: rename some id -> index
It's port_index and profile_index.
2022-01-17 09:49:39 +01:00
Wim Taymans
7c6649b5e5 pulse-server: use quantum_limit
Don't use max_quantum as the upper quantum limit, this is now scaled
with the rate. Use quantum_limit instead. We don't really care about the
max_quantum anymore so get rid of the field.
2022-01-14 16:45:41 +01:00