It is possible that during this process some object managers emit
their "installed" signal, and it is possible that some object managers
are destroyed within the handler of this signal, ending up with a dangling
object manager pointer (since we do not ref object managers in the registry)
and with a modified object_managers list during iteration...
Related to: #534
A core sync is not really necessary here because whatever objects the remote
pipewire daemon has to announce have already been sent to us on a message
and this message is already being processed at this point. This means, we are
not going to be returning to the main loop until all the new objects have been
announced and therefore placed into the tmp globals array. So, we can also use
an idle callback and achieve the same effect of slightly delaying until all
new globals have been announced.
With an idle callback, we can be more agile and add those new objects immediately
after the message has been processed instead of waiting for a pw_core_sync()
reply, which will come in the next message.
This fixes an odd failure of the si-standard-link test after applying the fix
for #517, which was caused by the fact that the test was previously relying on
a delay caused by some unrelated globals being prepared in the object manager
that tries to verify the graph state. After those globals were removed from the
internal preparation queue, the test would fail to detect the link objects
because they were stuck in the tmp_globals array for too long.
With the previous check, any global matching either the type or the global
properties of the interest would be considered for inclusion in the object
manager and would be prepared only to fail the same check later.
The correct way to check is (variable & (X|Y) == (X|Y)), which is what
SPA_FLAG_IS_SET() expands to.
Fixes#517
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
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
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.
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
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.
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.
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.
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.
- 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.
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.
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.