Commit graph

639 commits

Author SHA1 Message Date
Julian Bouzas
10f85549a4 spa-json: make sure we only add encoded string data
The spa_json_encode_string() API does not add a null terminator character. We
need to use the return value to know the size of the encoded string when adding
it to the builder.
2023-01-04 10:07:36 -05:00
George Kiagiadakis
2107e301d6 object-manager: copy the objects array in the iterator
This avoids issues when adding or removing objects while iterating.

Fixes #388
See also pipewire#1840
2022-12-06 12:01:34 +02:00
George Kiagiadakis
63348d8be2 metadata: use an object closure to avoid crashing if the core disconnects early
Fixes: #382
2022-11-30 14:34:33 +02: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
Julian Bouzas
ccf1630f39 main: add --version flag to show current version
Fixes #317
2022-07-29 12:37:44 +00:00
George Kiagiadakis
eb406bdb2c dbus: fix crash when trying to reconnect
When coming from on_sync_reconnect, data points to the WpDBus object
instead of the activation transition.

Fixes: #305
2022-07-13 13:39:10 +03: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
George Kiagiadakis
11902666f9 wp_spa_json_to_string: add since marker 2022-06-27 17:28:36 +03:00
Julian Bouzas
b6e8e7e064 spa-json: encode string in wp_spa_json_new_string() 2022-06-27 10:07:16 +00: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
a19c7f3d2f spa-json: only add the json data represented by its size
The data pointer of a WpSpaJson object can be bigger than the actual WpSpaJson
size. For example, this happens when iterating an array: instead of
re-allocating the nested data into a new region of memory, the iterator uses
the same region of memory as the parent, and just sets the pointer data and size
to the correct location when creating the nested WpSpaJson object.

This patch makes sure only the data represented by the size is added into the
builder when adding a json object, fixing issues that were happening before when
adding nested objects directly from a second WpSpaJson object.
2022-06-27 10:07:16 +00:00
Julian Bouzas
04198820f1 device: add new wp_spa_device_managed_object_new_iterator API 2022-06-27 08:52:36 +00:00
Julian Bouzas
c86410e708 iterator: skip NULL pointers when iterating pointer arrays 2022-06-27 08:52:36 +00:00
Julian Bouzas
3efb83ef08 dbus: fix bus type check when getting instance 2022-06-15 05:52:41 +00:00
Julian Bouzas
cee5ee7c37 core: add API to get virtual machine type 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
2754b9899d link: add link state accessors and change signal 2022-05-30 11:06:46 +03:00
George Kiagiadakis
dacc586898 properties: improve documentation of _get_count() 2022-05-10 15:27:31 +03:00
George Kiagiadakis
2eed279c9d i18n: remove the module and embed the gettext calls into the lua api
There is no need to have this as an optional module, since libintl
is a hard dependency of both PipeWire and GLib. This way we can keep
things a bit simpler and faster (no string copies and plugin lookups)

Bump meson dependency to 0.59 to benefit of the libintl lookup that
is now built into meson's dependency() function.
2022-05-10 15:16:09 +03:00
George Kiagiadakis
85d0ecfb40 si-interfaces: improve documentation on latest api additions 2022-05-10 15:16:09 +03:00
Julian Bouzas
1675b37617 si-adapter: add ports state change signal 2022-05-05 08:09:21 +00:00
George Kiagiadakis
0fba80899c object-interest: don't try to pattern-match NULL strings 2022-04-23 20:14:59 +03:00
Julian Bouzas
e9be326954 spa-json: add _new_from_stringn() API 2022-03-24 04:35:12 -04:00
George Kiagiadakis
17a257ddbe wplua: move under modules/module-lua-scripting
It's unlikely that wplua will ever be useful outside the context
of module-lua-scripting, so let's move it to keep all the code in one place
2022-03-24 09:47:59 +02:00
Julian Bouzas
a68a7cec0e spa-json: allow parsing unquoted keys when getting object properties
Unquoted strings are used in wireplumber and pipewire configuration files.
2022-03-24 07:21:25 +00: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
George Kiagiadakis
8d4fe81ebd spa-json: allocate enough space for parsing strings without looping
The string size is always less or equal to the size of the token (len),
so by allocating len+1 bytes we have enough space to write the whole
token and the null byte, if needed.
2022-03-16 21:11:09 +02:00
Ashok Sidipotu
2248b8ec1f spa-json: Parse unquoted string literals
- pipewire supports parsing unquoted strings and they are used
  extensively in JSON .conf files.
- Extend this support into wireplumber, as it wants to use the pipewire
  like syntax in its JSON .conf files.
2022-03-16 20:51:49 +02:00
Pauli Virtanen
0a605f666c wp: fix behavior of transitions before advanced for first time
wp_transition_get_completed incorrectly returns TRUE for transitions
that have not been advanced at least once, and hence are obviously not
completed.  This is because transitions start at STEP_NONE, and
completed transition is also indicated by STEP_NONE.

Fix this by adding a private flag to track whether transition was
started.

Fixes object managers sometimes missing object-changed events. How that
happens is the following:

- object activation transitions are advanced in idle callback
- they are aborted on registry global removal events
- registry global removal event can arrive before the idle callback
- wp_object_abort_activation uses wp_transition_get_completed to
  determine whether transition was completed, but it returned bogus
  values on transitions that hadn't been started.
2022-03-05 23:43:02 +02:00
Julian Bouzas
8f4a848223 object: abort queued transitions if current transition failed. 2022-02-21 09:37:44 -05:00
Julian Bouzas
2a6902a634 spa-json: fix format and remove unneded WP_API 2022-02-15 16:19:47 -05:00
Julian Bouzas
e429db7e8c spa-json: fix va_list APIs for different architectures
The va_list type might not always be a pointer in some architectures, so we
cannot guarantee it will be modified after using it for a second time in another
function. This fixes the issue by using macros so args does not get copied, and
always gets modified when using it more than once.
2022-02-09 07:59:59 -05:00
Wim Taymans
88d9b30d7a lib: remove some listeners 2022-02-09 12:38:27 +01:00
Julian Bouzas
585ad72c7c spa-json: add null character when finishing building json 2022-02-01 16:07:12 +00:00
Julian Bouzas
46ab414a04 spa-json: fix coverity scan issues 2022-01-25 21:18:16 -05:00
Julian Bouzas
4c1574117a spa-json: add new WpSpaJson API 2022-01-25 07:20:35 -05:00
Julian Bouzas
411378d9fd spa-pod: add missing API sentinel 2022-01-21 13:59:03 +00:00
Wim Taymans
3239c03e2f lib: assert non-NULL input for wp_spa_pod_equal
It should not be called with NULL values or it'll crash.
2022-01-21 13:55:26 +00:00
Julian Bouzas
bc76cb7d74
spa-pod: fix different architecture errors for boolean values 2022-01-09 10:22:47 +02:00
George Kiagiadakis
e04acbd2a0 docs: remove protected annotations from functions to show them in the docs 2021-12-22 17:09:20 +02:00
George Kiagiadakis
a965196ae2 registry: ensure in-progress activations are aborted when a global is removed
If a global is removed while an activation transition is in progress
and it happens that this activation transition was triggered by an
object manager, it is theoretically possible that this object manager
will then add this proxy after the transition completes, since
the transition is holding a ref on the proxy and therefore it will
not be destroyed. This ensures that the transitions are stopped on time
and the ref is dropped.

Because of this change, it is now also necessary to destroy the pw_proxy
on WpProxy's dispose() function, because if a proxy is removed before
it is bound, the registry aborts the activation but wp_proxy_deactivate()
is not destroying the proxy, since FEATURE_BOUND is not active.
In dispose() we can guarantee that the pw_proxy is destroyed.
2021-12-22 12:51:37 +02:00
George Kiagiadakis
a2921d78db pipewire-obj-mixin: guard against proxy being destroyed while syncing to core 2021-12-21 20:06:07 +02:00
George Kiagiadakis
57d60c383c core: add wp_core_sync_closure()
A variant of wp_core_sync() that can be used with a GClosure
2021-12-21 20:03:58 +02:00
George Kiagiadakis
bc3d9da5f8 object-manager: doc: add note about the installed signal 2021-12-21 12:51:10 +02:00
George Kiagiadakis
5412ca972f log: guard against NULL messages
if for any reason the message field is NULL, replace it with the string
"(null)" and keep going... this avoids crashing the journald logger

Fixes #124
2021-12-20 17:54:14 +02:00
Julian Bouzas
c61ab61ece pipewire-object-mixin: enable feature info when event info is fully processed 2021-12-20 09:54:05 +00:00
Julian Bouzas
4679a4ed71 metadata: unset iterator value before breaking or returning from loop 2021-12-20 09:54:05 +00:00
Barnabás Pőcze
6d7ae691b3 pipewire-object-mixin: use 64-bit type for change_mask
All core `pw_*_info` structures have a 64-bit change mask.
However, the `change_mask` in the session manager extension
info structures is only 32-bit. The differing sizes can cause
problems, especially on big endian architectures at the moment.

See #49
2021-12-15 10:58:37 +01:00
Julian Bouzas
844100360c proxy: abort activation if error or destroyed
This fixes a race condition that can happen when a proxy requests a new feature
(for example WP_NODE_FEATURE_PORTS) and PipeWire destroys the proxy before the
activation finishes. This race condition was causing the current activation
transition of a proxy to never finish, creating a memory leak because the
transition holds a strong reference of the proxy. Appart from this, since the
activation never finishes, WirePlumber could wait forever and not respond to
other requests.

This also removes the wp_proxy_watch_bind_error() API for subclasses as it is
not needed anymore.
2021-12-13 08:37:07 -05:00
Julian Bouzas
93c0b48bd9 object: add new _abort_activation API
Allows aborting an object activation by returning a transition error for all
pending transitions.
2021-12-13 08:37:01 -05:00