Commit graph

288 commits

Author SHA1 Message Date
George Kiagiadakis
e88fa840f2 lua: json: add optional argument in the json parse() method to limit the number of recursions
This allows partially parsing a json object, allowing some parts to be
passed on as strings to another component that does its own parsing
(ex. a pipewire module)
2023-11-10 11:27:13 +02:00
Julian Bouzas
227dd97036 m-lua-scripting: always parse JSON to String if its type is not recognized
This allows parsing JSON strings without quotes.
2023-08-11 14:48:13 -04:00
Julian Bouzas
e24e52c6d3 spa-json: encode the string directly into the builder
Some special characters like '\v' are encoded using 6 characters, which
currently does not work because the VLA size asumes a maximum of 4 characters
per encoded special character. This patch refactors this logic to avoid using
VLAs at all and encodes the string directly into the builder.

See #471
2023-06-19 12:03:23 -04:00
Julian Bouzas
e91a9583d8 spa-json: Fix conditional jump on uninitialised value when adding empty strings to builder
Similar to wp_spa_json_builder_add_property(), we need to make sure the dst
array in wp_spa_json_builder_add_string() has room for the null character
because builder_add() expects it.

Fixes #471
2023-06-19 08:07:02 -04:00
matoro
b7d41ac5bd tests: common: crank up timeout for slower devices
Timeout of 3 seconds is too slow for test-si-standard-link on slower
devices, crank this up with plenty of extra margin.  Does not
practically affect running time on faster devices.
2023-04-20 17:53:35 -04:00
Julian Bouzas
6b761c03e1 m-lua-scripting: ignore string/integer table keys when constructing a JSON Array/Object 2023-01-04 11:20:14 -05:00
George Kiagiadakis
afda44286b tests: add unit test verifying we can remove SIs from OMs while iterating
This is a tricky case where iteration matches the last 2 objects
managed by an object manager. When we remove them while iterating,
the last object is not removed because it takes the place of the first
upon removal (side-effect of g_ptr_array_remove_fast()) and the iterator
skips it.

See #388
2022-12-06 12:01:34 +02:00
George Kiagiadakis
43ef01cf89 tests: stop using fake{sink,src} to avoid skipping tests
fakesink/fakesrc are not installed by default with pipewire;
use audiotestsrc and null-sink instead, which are always available
2022-12-06 12:01:34 +02:00
George Kiagiadakis
6fd04f5267 tests: wplua: json: test json object key with spaces and special characters
Related to: #386
2022-12-05 10:13:52 +02:00
Frédéric Danis
44cdce4ac1 bluez: Add Offload SCO nodes routing sample (for PinePhone)
This script selects the correct PinePhone audio routes when the SCO
offload loopback nodes are running.
2022-12-02 11:14:28 +01:00
Tom A. Wagner
7586d4d858 meson: Add options to configure whether to build daemon, tools and modules.
This adds three meson options to enable or disable building daemon, tools, and modules.

Building the daemon or tools depends on building the modules, and disabling modules without disabling
the other two will result in meson giving an appropriate error.

These new options will let users skip building and installing unneeded items when they are not needed,
e.g. when only using the C API in another application.
2022-11-23 10:06:11 +00:00
George Kiagiadakis
5622805178 meson: rename dbus option to dbus-tests
This does not prevent the building of code that needs dbus,
it only prevents building and running tests that need dbus-daemon
to be installed.
2022-10-18 15:54:55 +03:00
Haelwenn (lanodan) Monnier
bfd70aff29 tests: Make dbus-based tests depend on dbus option 2022-10-18 09:49:17 +00:00
Julian Bouzas
55691a0d81 spa-json: always advance to the end of the nested array/object
Fixes size issue with nested objects when they are the last property value of
the parent object.
2022-08-28 10:50:25 -04:00
George Kiagiadakis
9def3f96d2 link: add WP_LINK_FEATURE_ESTABLISHED to track when a link is PAUSED/ACTIVE
This allows to transparently wait until a link is PAUSED before
returning from the activation transition. This way we can also
catch negotiation/allocation errors while activating a link.

PAUSED is used instead of ACTIVE because ACTIVE depends on the
nodes being activated as well. There are cases where a link may not
activate the nodes (ex, a passive link) and the link may remain
PAUSED for a long time.

Related to: #294
2022-07-02 17:10:22 +03:00
Julian Bouzas
0996f5a5ca spa-json: add wp_spa_json_to_string() API
Since the string length returned by wp_spa_pod_get_data() does not always match
the size of the actual json object because it is stored in contiguous memory, we
cannot always rely on that API to get the json string data.

The new wp_spa_pod_to_string() always allocates a new string with the same
length as the json size, guaranteeing that the string returned always represents
the json object, regardless of whether it is nested or not. It is always
recommented to use wp_spa_pod_to_string() unless you know what you are doing.
2022-06-27 10:07:16 +00:00
Julian Bouzas
46e7c5c144 m-reserve-device: use WpDbus API 2022-06-02 12:34:16 -04:00
Julian Bouzas
9183787325 lib: add new WpDbus API 2022-06-02 12:34:16 -04:00
George Kiagiadakis
b4eba2999e examples: add a lua example showing how to load filter-chain from a script 2022-05-11 13:07:39 +03:00
George Kiagiadakis
81af8c2069 lua: sandbox: remove all traces of the minimal_std flag, as it's no longer used 2022-04-23 20:14:59 +03:00
George Kiagiadakis
b29b313e7b tests: wplua: add a test for asynchronous script activation 2022-04-23 20:14:59 +03:00
George Kiagiadakis
ecb6100b77 m-lua-scripting: wrap every script in a WpPlugin and expose async activation api
This allows scripts to declare when they have finished their loading,
so we can now also know when wireplumber is done loading and ready to
handle clients

Related to !313
2022-04-23 20:14:59 +03:00
George Kiagiadakis
9387ce0d95 wplua: implement reference counting of the lua_State 2022-04-23 20:14:59 +03:00
George Kiagiadakis
9c22f6076a wplua: enable the use of require() to load lua libraries from scripts/lib 2022-04-23 20:14:59 +03:00
George Kiagiadakis
e1d0240bc9 wplua: split the functionality of the load functions into smaller functions
The load functions used to do 3 things:
- push the sandbox function on the stack
- load the file and push it as a function on the stack
- call the sandbox (or the file)

Now there are separate functions to do these 3:
- wplua_push_sandbox
- wplua_load_*
- wplua_pcall
2022-04-23 20:14:59 +03:00
Ashok Sidipotu
f032ac00cf properties: Add get count API
This API returns the count of the number of properties or items.
2022-03-24 06:59:39 +00:00
Wim Taymans
f46a801edb tests: use GNU_SOURCE for compiling tests as well
So that strtod_l is found.
2022-03-21 12:01:00 +01:00
George Kiagiadakis
44a09a1050 tests: spa-json: add a test to verify that we can parse the spa-json format
The spa-json parser allows some interesting things to happen, which
are not valid JSON, but we use them for readability in config files...

- The separator may be = or just a space instead of :
- Strings may be unquoted
- Commas may be omitted
2022-03-16 21:25:07 +02:00
Julian Bouzas
585ad72c7c spa-json: add null character when finishing building json 2022-02-01 16:07:12 +00:00
Julian Bouzas
b0ddd6f890 m-lua-scripting: add Json.Raw constructor 2022-01-26 09:53:24 -05:00
Julian Bouzas
20187e07b5 m-lua-scripting: add WpSpaJson API 2022-01-25 07:20:35 -05:00
Julian Bouzas
4c1574117a spa-json: add new WpSpaJson API 2022-01-25 07:20:35 -05:00
Wim Taymans
7d4369c1af tests: don't leak fd in test 2022-01-21 09:45:29 +01:00
Julian Bouzas
72b3be9e83 m-si-audio-endpoint: use an internal audio adapter session item
Avoids code duplication with si-audio-adapter.
2021-10-21 14:03:10 -04:00
Julian Bouzas
6624eaaf3e m-si-audio-adapter: remove unused audio utilities 2021-10-20 07:41:21 +00:00
Ashok Sidipotu
e2e3c5a69c wp-factory: enumerate pw_factory objects
pw_factory objects allow permissions to be set on its clients,
wp-factory exposes this funtionality to wireplumber clients.
2021-10-19 05:46:46 +00:00
George Kiagiadakis
c444ebaae1 meson: replace deprecated dep.get_pkgconfig_variable() with dep.get_variable() 2021-10-15 12:12:20 +03:00
George Kiagiadakis
03f14105cf si-audio-adapter: find the device format early and store format-specific flags
* find out if the node supports iec958 or dsd
* use spa_pod_fixate() to get the default format of the node, like p-m-s does
* use _enum_formats_sync() to utilize the param cache, assuming that the node
  always has all features enabled (which is always the case when coming from
  an ObjectManager that was defined in Lua)
* simplify the activation / deactivation procedure
* configure nodes with unpositioned channels early, as if they were devices
2021-10-12 20:00:10 +03:00
George Kiagiadakis
e76c67c45c policy: refactor/improve policy-node & session items to fix linking to monitors
* populate most session item properties from create-item.lua to keep
  things more compact and readable
* use a standard naming scheme for the session item properties
* use session item properties instead of node properties in policy-node.lua
* improve policy-node's performance by converting the properties dictionary
  less times for each session item
* refactor some policy logic and make things slighly more readable
* change the accepted values for 'context' in wp_si_linkable_get_ports();
  use "input" and "output" to keep things clear, because the previous use
  of NULL and "reverse" were implying that a node has only one "standard"
  direction, but this is complicated for sinks w/ monitors and duplex nodes
* allow using monitors (which are Audio/Sink nodes in fact) as sources
* treat Audio/Duplex nodes as sinks, like p-m-s does
* respect the "stream.capture.sink" property of streams

Fixes #66
2021-10-08 00:26:41 +03:00
Julian Bouzas
711d1ee686 spa-pod: add support for custom Id properties
Allows creating and parsing Pod Objects with custom properties.
2021-09-21 12:29:54 -04:00
George Kiagiadakis
8949e98d1f remove wpipc
This component has been split out to form a separate project,
moved to https://git.automotivelinux.org/src/pipewire-ic-ipc/
2021-08-19 16:53:28 +03:00
George Kiagiadakis
e6f2dc17ff tests: file-monitor: also remove the 'foo' file at the end of the test 2021-08-19 10:44:31 +03:00
George Kiagiadakis
daa4da5ffc tests: state: remove the "escaped" state file at the end of the test 2021-08-19 10:39:49 +03:00
George Kiagiadakis
07b4a13315 tests: use .local/state instead of .local/.state for the state dir 2021-08-19 10:39:14 +03:00
Julian Bouzas
907a67fcb1 modules: add new API module to monitor files 2021-08-10 11:50:51 +03:00
Julian Bouzas
8b95b4ae23 tests: skip test if specific spa lib is not installed
Avoids tests failing if pipewire was built without the spa lib
2021-07-19 09:40:19 -04:00
Julian Bouzas
eb8f9a1a83 tests: common: add API to check if spa lib is installed
Allows to skip tests if specific spa lib is not installed
2021-07-16 11:49:35 -04:00
Julian Bouzas
2792cecbcf properties: use a boxed WpPropertiesItem type when iterating
Needed for JavaScript bindings
2021-07-15 08:55:00 -04:00
Peter Hutterer
be1a077eaf state: store our WpState files in $XDG_STATE_HOME/wireplumber 2021-07-14 14:44:11 +10:00
George Kiagiadakis
6e6852b391 tests: create wpipc tests sockets also in /tmp with a random name
See #39, #16
2021-07-02 16:34:31 +03:00