mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 14:48:02 +02:00
policy: track the exported session instead of the proxy
The proxy takes more roundtrips to get updated and this makes the policy fail to find a default endpoint at startup, right after the devices have been discovered This also removes the weak ref on the session, since the object manager internally maintains a reference on the objects that it manages.
This commit is contained in:
parent
56f12047ab
commit
2bb534d063
1 changed files with 7 additions and 20 deletions
|
|
@ -19,7 +19,6 @@ struct _WpPolicyManager
|
|||
GList *policies;
|
||||
WpObjectManager *endpoints_om;
|
||||
WpObjectManager *sessions_om;
|
||||
GWeakRef curr_session;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -36,7 +35,6 @@ wp_policy_manager_init (WpPolicyManager *self)
|
|||
{
|
||||
self->endpoints_om = wp_object_manager_new ();
|
||||
self->sessions_om = wp_object_manager_new ();
|
||||
g_weak_ref_init (&self->curr_session, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -46,7 +44,6 @@ wp_policy_manager_finalize (GObject *object)
|
|||
|
||||
g_debug ("WpPolicyManager destroyed");
|
||||
|
||||
g_weak_ref_clear (&self->curr_session);
|
||||
g_clear_object (&self->sessions_om);
|
||||
g_clear_object (&self->endpoints_om);
|
||||
g_list_free_full (self->policies, g_object_unref);
|
||||
|
|
@ -96,16 +93,6 @@ policy_mgr_endpoint_removed (WpObjectManager *om, WpBaseEndpoint *ep,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
policy_mgr_session_changed (WpObjectManager *om, WpPolicyManager *self)
|
||||
{
|
||||
g_autoptr (GPtrArray) arr = NULL;
|
||||
|
||||
arr = wp_object_manager_get_objects (om, WP_TYPE_PROXY_SESSION);
|
||||
if (arr->len > 0)
|
||||
g_weak_ref_set (&self->curr_session, g_ptr_array_index (arr, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_policy_manager_get_instance:
|
||||
* @core: the #WpCore
|
||||
|
|
@ -135,11 +122,8 @@ wp_policy_manager_get_instance (WpCore *core)
|
|||
wp_core_install_object_manager (core, mgr->endpoints_om);
|
||||
|
||||
/* install the object manager to listen to changed sessions */
|
||||
wp_object_manager_add_proxy_interest (mgr->sessions_om,
|
||||
PW_TYPE_INTERFACE_Session, NULL,
|
||||
WP_PROXY_FEATURE_INFO | WP_PROXY_SESSION_FEATURE_DEFAULT_ENDPOINT);
|
||||
g_signal_connect_object (mgr->sessions_om, "objects-changed",
|
||||
(GCallback) policy_mgr_session_changed, mgr, 0);
|
||||
wp_object_manager_add_object_interest (mgr->sessions_om,
|
||||
WP_TYPE_EXPORTED_SESSION, NULL);
|
||||
wp_core_install_object_manager (core, mgr->sessions_om);
|
||||
|
||||
wp_core_register_object (core, g_object_ref (mgr));
|
||||
|
|
@ -151,9 +135,12 @@ wp_policy_manager_get_instance (WpCore *core)
|
|||
WpSession *
|
||||
wp_policy_manager_get_session (WpPolicyManager *self)
|
||||
{
|
||||
g_return_val_if_fail (self, NULL);
|
||||
g_autoptr (GPtrArray) arr = NULL;
|
||||
|
||||
return g_weak_ref_get (&self->curr_session);
|
||||
g_return_val_if_fail (WP_IS_POLICY_MANAGER (self), NULL);
|
||||
|
||||
arr = wp_object_manager_get_objects (self->sessions_om, 0);
|
||||
return (arr->len > 0) ? g_object_ref (g_ptr_array_index (arr, 0)) : NULL;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue