Commit graph

63 commits

Author SHA1 Message Date
Ruben Gonzalez
15bdab89c3 logger: minor performance improvement to avoid syscall done by isatty 2024-02-17 11:42:12 +00:00
Wim Taymans
27dbbd40c9 tools: improve indentation 2024-02-09 10:24:34 +01:00
Pauli Virtanen
963ea1f57c tools: make pw-dump/mon/top try to connect to the default manager socket
These tools are used for debugging, and should default to connecting to
the manager socket if present.
2023-10-24 07:08:07 +00:00
Wim Taymans
390f6c9cb8 perm: add a new L permissions
When a client has the L permission on the node, it can make links
between the node even if the owner of the node can't see the other node.
2023-07-28 11:01:43 +02:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Thomas Weißschuh
d4db7e1d9b pw-dump: sort dictionaries
Dictionaries are by default printed in their insertion order.
This is unergonimic when comparing properties created by different
clients, as they may insert them in different orders.
2023-01-06 11:15:17 +00:00
Wim Taymans
c5f7d3a728 param: improve pw_param
Add a sequence number to pw_param.
Add param_info to param_update to filter out the params of the latest
sequence number.

This can be used to track params from a certain sequence number. Update
node, port and device.
2022-10-30 14:57:04 +01:00
Wim Taymans
e6fd5888ee param: add a new user seq field in the param-info
Add a new seq field in the param-info struct. Users can use this
field to keep track of pending param updates.

Store the latest seq number of the param update in the seq field. Remove
all params that don't match the sequence number because they are too
old. This avoids duplicate old params in pw-dump output.

Rework the pulseaudio manager with this same method.
2022-10-27 20:10:33 +02:00
Wim Taymans
d2aa240767 introspect: handle NULL result from info updates 2022-10-27 20:06:54 +02:00
Wim Taymans
9b6e504c19 clean up some more array iterations 2022-10-03 09:20:42 +02:00
Wim Taymans
47e1f38f03 pw-dump: also dump object removal
When in monitor mode, also dump object removal with info/props as
NULL.

Fixes #2426
2022-06-08 16:24:22 +02:00
Quentin Wenger
22fc9eec35 Cleanup argument names in methods and events interfaces
First method argument is object, first event argument is data.

Closes !963
2022-04-15 10:11:49 +02:00
Pauli Virtanen
c66bb65c7a pipewire: don't setlocale from pw_init, let parent app set it
Library code generally shouldn't modify global state, so pw_init()
should not result to changing the C locale.

Instead, set the C locale in main() for tools and daemons.

We'll still setlocale for LC_MESSAGES, to get translated UI elements in
wireplumber. This workaround should be removed eventually...
2022-03-22 21:32:35 +02:00
Wim Taymans
2b16df4e89 spa: add locale independent spa_dtoa
And use this in spa_json_format_float() where we also avoid invalid
json floats.
Use json float format in some places where we serialize json floats.
Add a unit test.

See #2223
2022-03-21 10:41:44 +01:00
Wim Taymans
93b5d440bc json: add locale independent parse and format functions
Use them in pw-dump.
Add some unit tests.

See #2223
2022-03-20 21:04:33 +01:00
Wim Taymans
e82f775fb3 tools: remove listeners 2022-02-09 16:30:13 +01:00
Wim Taymans
afc88a12e5 tools: cleanup up printf
Make all tools output to stdout (pw-mon mostly) so that we can pipe the
output around.
Send errors to stderr.
fprintf(stdout, ...)  -> printf(...)
setlinebuf for stdout so that pipe works better.

See #2110
2022-02-07 17:03:46 +01:00
Wim Taymans
3256c6e5e7 tools: fix compilation with musl 2022-01-27 14:59:11 +01:00
Wim Taymans
b7e0b5437b pw-dump: add pattern matching
Do pattern matching on object properties to also allow lookups on
type, object.path, object.serial and <type>.name.

ex:

  pw-dump alsa_card.usb-BEHRINGER_UMC404HD_192k-00
  pw-dump alsa_input*
  pw-dump Node
2022-01-26 16:31:38 +01:00
Konstantin Kharlamov
a4f3a23095 tools/pw-dump: add support for --color-always 2021-08-31 08:42:15 +00:00
Barnabás Pőcze
f5d51162c4 treewide: mark things static and const
Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.

All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
2021-06-30 14:44:08 +02: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
07d43a001b pw-dump: remember the subject of metadata
So that we can also print it instead of printing 0.
2021-06-16 12:17:30 +02: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
Peter Hutterer
a1e821c259 pw-dump: use the spa_ato* helpers for string to number conversions 2021-06-02 07:39:41 +00:00
Peter Hutterer
1a5faa7b52 spa: add a header for ANSI color sequences
Makes the code more readable and guarantees we use the same sequences for the
same colors everywhere.
2021-06-02 14:17:29 +10:00
Peter Hutterer
7697ed0757 treewide: replace strcmp() == 0 with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Barnabás Pőcze
68f75bbd57 tools/pw-dump: fix parentheses around isatty() call
Previously,

  isatty(fileno(data.out) && getenv("NO_COLOR") == NULL))

would call `isatty()` with

  fileno(data.out) && getenv("NO_COLOR") == NULL

as its argument. This meant that, for example,

  NO_COLOR=1 pw-dump

would still produce colored output when run with
a TTY as its standard input.

Fix that by moving the parenthesis.

Fixes: af63d08453 ("tools/pw-dump: only print colors if we're connected to a terminal")
2021-05-08 03:57:34 +02:00
Peter Hutterer
af63d08453 tools/pw-dump: only print colors if we're connected to a terminal
We don't want ansi escape codes in the output of `pw-dump > log`. And where
colors are needed after the fact, it's easy to just run `jq . $file`.
2021-05-07 06:57:31 +00:00
Peter Hutterer
2405f0942b spa/buffer: rename SPA_MEMBER to SPA_PTROFF
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
2021-05-06 09:39:39 +00:00
Wim Taymans
23854539fe pw-dump: reparse and format JSON metadata values
Reparse the metadata value as json and dump it. This ensures the JSON
is valid and that the colors are applied properly.
2021-04-13 20:59:42 +02:00
Wim Taymans
bded2a02a0 pw-dump: output Spa:String:JSON values as literal
Don't escape the Spa:String:JSON types in the metadata as it is
supposed to be valid JSON that can be output directly. We might want
to reparse and reformat it later to be sure.
2021-04-13 19:03:06 +02:00
Wim Taymans
3b0b5cb55d pw-dump: print id-xxx for unknown ids
When the id has no info in the type system use id-xxx instead
of "unknown".
2021-03-23 11:32:35 +01:00
Wim Taymans
4873dbcf8e pw-dump: respect NO_COLOR
See no-color.org
2021-03-13 20:30:13 +01:00
Wim Taymans
80825aeaea conf: more work on config changes
Add -c option to pipewire to select config file. Use this to select
the uninstalled conf file.
Rename conf properties, prefix with context.
Simplify the main daemon now that everything can go in config.
Simplify pipewire-pulse now that we can put everything in config, it's
now virtually the same as pipewire but with a differenct config file.
Parse server addresses as array of strings.
2021-02-12 10:31:29 +01:00
Wim Taymans
90d8589fb9 pw-dump: always output colors and add option to disable
-N disables colors now. Usually we want to preserve them in debug
files and grep etc.
Use less -R to get colors

See #698
2021-02-08 19:52:24 +01:00
Wim Taymans
c25bdce645 rework param updates
Make it possible to add a NULL param to the pending list. The NULL
param removes all previous updates.
When applying the updates, the NULL param removes the params from
the target list.

For the cached params in the node/device/port we need to be careful
because multiple clients might ask for updates concurrently. Clear
the pending list whenever a new param update starts so that we always
only keep the last set of updates.

This has two advantages: it actually removes params that become
unreadable or that got removed and it allows us to update the target
list more efficiently in one single loop.
2021-02-05 11:03:47 +01:00
Wim Taymans
994fc1169e Revert "rework param updates"
This reverts commit 5aa7746c95.

Routes are duplicated for some reason, needs more debugging.
2021-02-04 20:56:54 +01:00
Wim Taymans
5aa7746c95 rework param updates
Make it possible to add a NULL param to the pending list. The NULL
param removes all previous updates.
When applying the updates, the NULL param removes the params from
the target list.

This has two advantages: it actually removes params that become
unreadable or that got removed and it allows us to update the target
list more efficiently in one single loop.
2021-02-04 13:26:35 +01:00
Wim Taymans
4c46495c38 pw-dump: don't print unreadable params 2021-02-03 19:27:57 +01:00
Wim Taymans
2b44f42845 pass the complete buffer size to snprintf
There is no reason to pass size-1, snprintf will always put a \0
at the end.
2021-02-02 12:09:29 +01:00
Wim Taymans
2b98b7dc7a pw-dump: print None pod as null 2021-01-22 17:23:33 +01:00
Wim Taymans
f891324e25 pw-dump: mark objects without events as changed
Usually the event function marks the object as changed so when
there is no event function, mark the change immediately so that
we can dump it.
2021-01-19 16:36:55 +01:00
Wim Taymans
5a7f4a619a pw-dump: also dump properties 2021-01-15 09:45:56 +01:00
Wim Taymans
ae263eeffc pw-dump: only dump changed metadata entries 2021-01-14 21:14:16 +01:00
Wim Taymans
688b3c5ed4 pw-dump: only output [] when something changed 2021-01-14 20:17:22 +01:00
Wim Taymans
13cef576c9 pw-dump: dump metadata contents
Fix some leaks
2021-01-14 20:11:15 +01:00
Wim Taymans
792c01aede pw-dump: trigger change in metadata
so that it is displayed
2021-01-14 19:22:40 +01:00
Wim Taymans
a6433b0839 pw-dump: mark new objects without proxy as changed
So that they are actually printed.
2021-01-14 15:39:02 +01:00
Wim Taymans
878240e30a pw-dump: add simple monitor option (-m) 2021-01-11 10:24:39 +01:00