mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 10:08:15 +02:00
si-std-link: handle node destroy events while linking is in progress
This should solve issues with stale objects lying around, printing warnings and in some cases also crashing things Related to #128, #78
This commit is contained in:
parent
a965196ae2
commit
f3f063760c
3 changed files with 56 additions and 10 deletions
|
|
@ -205,6 +205,15 @@ si_audio_adapter_find_format (WpSiAudioAdapter * self, WpNode * node)
|
|||
return have_format;
|
||||
}
|
||||
|
||||
static void
|
||||
on_proxy_destroyed (WpNode * proxy, WpSiAudioAdapter * self)
|
||||
{
|
||||
if (self->node == proxy) {
|
||||
wp_object_abort_activation (WP_OBJECT (self), "proxy destroyed");
|
||||
si_audio_adapter_reset (WP_SESSION_ITEM (self));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
|
||||
{
|
||||
|
|
@ -255,6 +264,8 @@ si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
|
|||
self->is_autoconnect = str && pw_properties_parse_bool (str);
|
||||
|
||||
self->node = g_object_ref (node);
|
||||
g_signal_connect_object (self->node, "pw-proxy-destroyed",
|
||||
G_CALLBACK (on_proxy_destroyed), self, 0);
|
||||
|
||||
wp_properties_set (si_props, "item.node.supports-encoded-fmts",
|
||||
self->have_encoded ? "true" : "false");
|
||||
|
|
|
|||
|
|
@ -46,6 +46,15 @@ si_node_reset (WpSessionItem * item)
|
|||
WP_SESSION_ITEM_CLASS (si_node_parent_class)->reset (item);
|
||||
}
|
||||
|
||||
static void
|
||||
on_proxy_destroyed (WpNode * proxy, WpSiNode * self)
|
||||
{
|
||||
if (self->node == proxy) {
|
||||
wp_object_abort_activation (WP_OBJECT (self), "proxy destroyed");
|
||||
si_node_reset (WP_SESSION_ITEM (self));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
si_node_configure (WpSessionItem * item, WpProperties *p)
|
||||
{
|
||||
|
|
@ -62,6 +71,8 @@ si_node_configure (WpSessionItem * item, WpProperties *p)
|
|||
return FALSE;
|
||||
|
||||
self->node = g_object_ref (node);
|
||||
g_signal_connect_object (self->node, "pw-proxy-destroyed",
|
||||
G_CALLBACK (on_proxy_destroyed), self, 0);
|
||||
|
||||
wp_properties_set (si_props, "item.factory.name", SI_FACTORY_NAME);
|
||||
wp_session_item_set_properties (WP_SESSION_ITEM (self),
|
||||
|
|
|
|||
|
|
@ -345,10 +345,13 @@ get_ports_and_create_links (WpSiStandardLink *self, WpTransition *transition)
|
|||
|
||||
si_out = WP_SI_LINKABLE (g_weak_ref_get (&self->out_item));
|
||||
si_in = WP_SI_LINKABLE (g_weak_ref_get (&self->in_item));
|
||||
if (!si_out || !si_in) {
|
||||
wp_transition_return_error (transition, g_error_new (WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_INVARIANT,
|
||||
"Failed to create links because one of the nodes was destroyed"));
|
||||
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_out)) ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_in))) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -451,6 +454,14 @@ on_main_adapter_ready (GObject *obj, GAsyncResult * res, gpointer p)
|
|||
main = g_object_get_data (G_OBJECT (transition), "adapter_main");
|
||||
other = g_object_get_data (G_OBJECT (transition), "adapter_other");
|
||||
|
||||
if (!wp_session_item_is_configured (WP_SESSION_ITEM (main->si)) ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (other->si))) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->passthrough) {
|
||||
wp_si_adapter_set_ports_format (other->si, NULL, "passthrough",
|
||||
on_adapters_ready, transition);
|
||||
|
|
@ -476,10 +487,12 @@ configure_and_link_adapters (WpSiStandardLink *self, WpTransition *transition)
|
|||
struct adapter *out, *in, *main, *other;
|
||||
const gchar *str = NULL;
|
||||
|
||||
if (!si_out || !si_in) {
|
||||
wp_transition_return_error (transition, g_error_new (WP_DOMAIN_LIBRARY,
|
||||
WP_LIBRARY_ERROR_INVARIANT,
|
||||
"Failed to create links because one of the adapters was destroyed"));
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_out)) ||
|
||||
!wp_session_item_is_configured (WP_SESSION_ITEM (si_in))) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +584,15 @@ si_standard_link_do_link (WpSiStandardLink *self, WpTransition *transition)
|
|||
g_autoptr (WpSessionItem) si_out = g_weak_ref_get (&self->out_item);
|
||||
g_autoptr (WpSessionItem) si_in = g_weak_ref_get (&self->in_item);
|
||||
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (si_out) ||
|
||||
!wp_session_item_is_configured (si_in)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (WP_IS_SI_ADAPTER (si_out) && WP_IS_SI_ADAPTER (si_in))
|
||||
configure_and_link_adapters (self, transition);
|
||||
else if (!WP_IS_SI_ADAPTER (si_out) && !WP_IS_SI_ADAPTER (si_in))
|
||||
|
|
@ -616,9 +638,11 @@ si_standard_link_enable_active (WpSessionItem *si, WpTransition *transition)
|
|||
/* make sure in/out items are valid */
|
||||
si_out = g_weak_ref_get (&self->out_item);
|
||||
si_in = g_weak_ref_get (&self->in_item);
|
||||
if (!si_out || !si_in) {
|
||||
if (!si_out || !si_in ||
|
||||
!wp_session_item_is_configured (si_out) ||
|
||||
!wp_session_item_is_configured (si_in)) {
|
||||
wp_transition_return_error (transition,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_INVARIANT,
|
||||
g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED,
|
||||
"si-standard-link: in/out items are not valid anymore"));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue