Commit graph

6266 commits

Author SHA1 Message Date
Barnabás Pőcze
7d6fc0f544 pulse-server: fix remove proplist command
`command` is never equal to `COMMAND_UPDATE_CLIENT_PROPLIST`,
instead, the check should be against `COMMAND_REMOVE_CLIENT_PROPLIST`.
2023-07-11 16:04:53 +02:00
Barnabás Pőcze
fe45786a5d treewide: add some examples for the spa_auto* macros 2023-07-11 14:23:53 +02:00
Barnabás Pőcze
65d949558b spa: utils: add scope based resource cleanup
systemd, dbus-broker, and many glib applications heavily
utilize the GNU C attribute "cleanup" to achieve C++ RAII-like
semantics for local resource management. This commit introduces
essentialy same mechanism into pipewire.

At the moment, this is inteded to be a strictly private API.

free() and close() as cleanup targets are sufficiently common
to warrant their own special macros:

  spa_autofree char *s = strdup(p);
  // will call `free(s)` at the end of the lifetime of `s`

  spa_autoclose int fd = openat(...);
  // will call `close(fd)` if `fd >= 0` at the end of the lifetime of `fd`

However, with `spa_auto()` or `spa_autoptr()` it is possible to define
other variables that will be cleaned up properly. Currently four are supported:

  spa_autoptr(FILE) f = fopen(...);
  // `f` has type `FILE *`
  // will call `fclose(f)` if `f != NULL`

  spa_autoptr(DIR) d = opendir(...);
  // `d` has type `DIR *`
  // will call `closedir(d)` if `d != NULL`

  spa_autoptr(pw_properties) p = pw_properties_new(NULL, NULL);
  // `p` has type `struct pw_properties *`
  // will call `pw_properties_free(p)`

  spa_auto(pw_strv) v = pw_split_strv(...);
  // `v` has type `char **`
  // will call `pw_strv_free(v)`

It is possible to add support for other types, e.g.

  SPA_DEFINE_AUTOPTR_CLEANUP(pw_main_loop, struct pw_main_loop, {
    // the pointer can be accessed using `*thing`
    // `thing` has type `struct pw_main_loop **`
    spa_clear_ptr(*thing, pw_main_loop_destroy);
  })

  spa_autoptr(pw_main_loop) l = ...;
  // `l` has type `struct pw_main_loop *`
  // will call `pw_main_loop_destroy(l)`

or

  SPA_DEFINE_AUTO_CLEANUP(spa_pod_dynamic_builder, struct spa_pod_dynamic_builder, {
    // `thing` has type `struct spa_pod_dynamic_builder *`
    spa_pod_dynamic_builder_clean(thing);
  })

  spa_auto(spa_pod_dynamic_builder) builder = ...
  // `builder` has type `struct spa_pod_dynamic_builder`
  // will call `spa_pod_dynamic_builder_clean(&builder)`

The first argument is always an arbitrary name. This name must be passed to
`spa_auto()` and `spa_autoptr()` as it is what determines the actual type
and destructor used. The second parameter is the concrete type. For
`SPA_DEFINE_AUTO_CLEANUP()` this is the concrete type to be used, while for
`SPA_DEFINE_AUTOPTR_CLEANUP()` it is the concrete type without the
outermost pointer. That is,

  SPA_DEFINE_AUTOPTR_CLEANUP(A, foo, ...)
  SPA_DEFINE_AUTO_CLEANUP(B, foo, ...)

  spa_autoptr(A) x; // `x` has type `foo *`
  spa_auto(B) y; // `y` has type `foo`

A couple other macros are also added:

  spa_clear_ptr(ptr, destructor)
  // calls `destructor(ptr)` if `ptr != NULL` and sets `ptr` to `NULL`

  spa_clear_fd(fd)
  // calls `close(fd)` if `fd >= 0` and sets `fd` to -1

  spa_steal_ptr(ptr)
  // sets `ptr` to `NULL` and returns the old value,
  // useful for preventing the auto cleanup mechanism from kicking in
  // when returning the pointer from a function

  spa_steal_fd(fd)
  // sets `fd` to -1 and returns the old value
2023-07-11 14:23:53 +02:00
Wim Taymans
4456f2efd1 impl-node: remove the node from the target peers
When we destroy a node, we need to remove the node as a current
driver peer.

Not doing this has 2 problems:
- remote drivers still trigger our node
- the client-node does not clean up the memid for the activation and
  we might reuse it later for a new node with the same fd.

See #3316
2023-07-10 16:59:17 +02:00
Wim Taymans
098ac51272 remote-node: don't init/release our special mix
We have SPA_ID_INVALID mix id for all ports to handle the formats and
buffers, we don't need to init/release the mix for this or else our
n_mix accounting is wrong and we might not clear the format right.
2023-07-10 16:56:58 +02:00
Wim Taymans
3e0050d1cd client-node: clear resource after freeing mem
Some of the mem unref might send a message to the client.

This is not actually the case right now but just to be safe for the
future.
2023-07-10 16:55:05 +02:00
Wim Taymans
a966d4806b improve debug 2023-07-10 16:52:39 +02:00
Wim Taymans
f459320968 impl-node: first remove, then add ourselves
First remove ourself from the old driver, then add ourself to the
new driver.

This got changed as a possible error in b8fe832188
2023-07-10 11:15:53 +02:00
Wim Taymans
21d16b1ad5 module-raop: zero uppet timestamp bits
The Audiopro link1 seems to want to upper bits of the timestamp in
sync messages as 0. It still seems to work with Sonos.

See #3247
2023-07-06 17:01:09 +02:00
Wim Taymans
fdc860c71b protocol-native: give an error when loading twice
Instead of silently ignoring the problem. It's possible that it is
loaded with different settings, which would then silently be ignored.
2023-07-06 13:51:37 +02:00
Wim Taymans
48a892aeec module-rtp: support sess.ignore-ssrc globally 2023-07-06 13:08:21 +02:00
Wim Taymans
126e03ec73 rtp: add option to ignore SSRC
This is useful when there is a fixed receiver and the sender can be
restarted.
2023-07-06 12:55:28 +02:00
Wim Taymans
a9a9c72a0a client-node: create mix explicitly 2023-07-06 12:18:27 +02:00
Wim Taymans
fd1fd7a00f module-rtp-source: improve docs a little 2023-07-05 15:29:56 +02:00
Wim Taymans
178f452127 context: upsample small rates up to the default rate
When the samplerate is smaller than half of the default, try to find a
rate less than the default to upsample to.

pavucontrol now asks for a 1/144 rate, which resulted in a graph rate of
88200 before this change.

See #3320
2023-07-05 12:44:05 +02:00
Wim Taymans
bec73f26a7 impl-node: don't log driver twice
When dumping the driver targets, only log the driver once.
2023-07-05 12:02:35 +02:00
Wim Taymans
895e516a75 pulse-server: support latency_msec in module-raop-discover
See #3247
2023-07-04 14:09:15 +02:00
Wim Taymans
b0a7e4a267 gst: lock/unlock around proxy destroy
See #3324
2023-07-04 12:04:29 +02:00
Wim Taymans
4137ff656a module-rt: add option to disable rlimits/portal/rtkit 2023-07-04 11:11:48 +02:00
Wim Taymans
a373d7fde4 module-rt: add comment 2023-07-04 10:36:15 +02:00
Barnabás Pőcze
8c17a6626d treewide: mark some functions static
These were found by enabling the "missing-declarations" warning.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
0eb463ab98 pipewire: module-client-device: include "client-device.h" in "resource-device.c"
So that definitions are checked against declarations.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
eaad2b5a87 pipewire: module-avb: include "avb.h" in "descriptors.h"
So that the "avb.h" header file is self-sufficient.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
c57afbccc1 pipewire: module-avb: add some missing declarations 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
5b05c1c430 pipewire: module-avb: include "avb.h" in "avb.c"
So that definitions are checked against declarations.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
db510e769a pipewire: module-avb: add missing "stddef.h" include in "avb.h"
Including "stddef.h" is needed for `size_t`.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
12be42ed6b pipewire: module-netjack2-manager: remove unused module_schedule_destroy() 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
34809d3081 pipewire: module-netjack2-driver: remove unused module_schedule_destroy() 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
0a00d9c4d7 pipewire: module-ffado-driver: remove unused module_schedule_destroy() 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
0f70256230 pulse-server: include "reply.h" in "reply.h"
So that definitions are checked against declarations.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
3b4a255dec pulse-server: format_info_from_spec(): remove redundant decl 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
1bb714b95e pipewire: utils: make_random(): do not use errno
The function already returns `ssize_t`, so do not use `errno`
to communicate the reason for failure, instead, return the
negative errno.

`pw_getrandom()` was inconsistent in this regard because
sometimes it simply returned a negative errno without
setting `errno`. This change fixes that as well.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
5c0a60af27 pipewire: utils: include "private.h"
So that the definition of `pw_random_init()` is
checked against the declaration.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
3feb6762e4 pipewire: utils: pw_random_init(): do not use old style declaration 2023-07-03 19:40:25 +02:00
Barnabás Pőcze
f8344a3908 pipewire: impl-module: only stat if necessary
On some filesystems, the directory entry type is immediately
available, so use that to check if the entity is a directory,
and only use `stat()` when the entity type cannot be determined
from the directory entry.
2023-07-03 19:40:25 +02:00
Barnabás Pőcze
f82f215bf7 pipewire: modules: add missing "config.h" include in "flatpak-utils.h" 2023-07-03 19:40:25 +02:00
Barnabás Pőcze
54a9b30ed3 pipewire: proxy: remove pw_proxy_get_core()
The above function is not declared in any header files,
nor used by anything, so remove it.
2023-07-03 19:40:25 +02:00
Barnabás Pőcze
aed06dff67 pipewire: thread: include "private.h"
So that the definition of `pw_thread_fill_attr()` is
checked against the declaration.
2023-07-03 19:40:25 +02:00
Barnabás Pőcze
3bb32fb592 pipewire: pw_context_find_export_type(): remove redundant decl
This function is already declared in "context.h".
2023-07-03 19:40:25 +02:00
Barnabás Pőcze
e917dc65a0 pipewire: include "i18n.h"
So that definitions are checked against the declarations.
2023-07-03 19:40:25 +02:00
Barnabás Pőcze
5deb6ccede pipewire: conf: add missing include guard 2023-07-03 19:40:25 +02:00
Wim Taymans
c34a987076 pulse-server: add option to disable fix_ flags
Document the pulse.fix properties.
Add an option to disable handling of the FIX flags when the pulse.fix.
property is set to an invalid value/0.

See #3317
2023-07-03 16:39:32 +02:00
Wim Taymans
4bb85ef6c9 module-rtp: don't use sap port as src port
We bind to the src addr (the interface addr) and so we need a new unused port.
2023-07-03 12:35:36 +02:00
Wim Taymans
eaaa0cd99e modules: improve some docs 2023-06-30 21:44:49 +02:00
Wim Taymans
c13696aca1 filter-chain: simplify biquads 2023-06-30 17:49:29 +02:00
Wim Taymans
d5d8ebeaac pw-cat: only override properties when not already set
This makes it possible to override any of the properties with -P such as
the graph rate.
2023-06-30 16:24:13 +02:00
Wim Taymans
f612ffe8e4 pulse-server: use the fixed rate for graph rate
We need to use the format rate for calculating the buffer size and
latency but the fixated rate for the graph rate.

See #3317
2023-06-30 12:34:25 +02:00
Wim Taymans
91ac3acf3d pulse-server: debug the fixed format/rate/channel 2023-06-30 12:34:25 +02:00
Barnabás Pőcze
0e823d8a0f pipewire: core: static assert member order requirement
The pw_proxy member of pw_core must be the first because the
pw_core object is freed via pw_proxy_destroy() -> pw_proxy_unref().
2023-06-29 23:57:49 +02:00
Barnabás Pőcze
4bec3b56d4 pipewire: pw_proxy_init(): take pointer to core
`pw_proxy::core` must be initialized for `pw_proxy_init()`
to succeed, so take it as a parameter instead of relying
on the caller to initialize that field beforehand.
2023-06-29 23:57:49 +02:00