mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 17:08:01 +02:00
policy: add a hack that allows some clients to be linked always
This allows the bluealsa gstreamer helper to link to the speakers constantly, with both A2DP and HFP streams. If this is not enabled, only one of those will manage to connect, randomly. This is definitely something to be superseeded by proper policy management implemented with configuration files
This commit is contained in:
parent
07835488a0
commit
d707ec3f20
2 changed files with 33 additions and 3 deletions
|
|
@ -190,6 +190,13 @@ on_audio_adapter_created(GObject *initable, GAsyncResult *res,
|
|||
/* Set the role */
|
||||
self->role = g_strdup (wp_properties_get (props, PW_KEY_MEDIA_ROLE));
|
||||
|
||||
/* HACK to tell the policy module that this endpoint needs to be linked always */
|
||||
if (wp_properties_get (props, "wireplumber.keep-linked")) {
|
||||
g_autofree gchar *c = g_strdup_printf ("Persistent/%s",
|
||||
wp_properties_get (props, "media.class"));
|
||||
g_object_set (self, "media-class", c, NULL);
|
||||
}
|
||||
|
||||
/* Just finish if no streams need to be created */
|
||||
if (!self->streams) {
|
||||
finish_endpoint_creation (self);
|
||||
|
|
|
|||
|
|
@ -273,10 +273,12 @@ handle_client (WpPolicy *policy, WpEndpoint *ep)
|
|||
g_autoptr (WpEndpoint) target = NULL;
|
||||
guint32 stream_id;
|
||||
gboolean is_capture = FALSE;
|
||||
gboolean is_persistent = FALSE;
|
||||
g_autofree gchar *role = NULL;
|
||||
|
||||
/* Detect if the client is doing capture or playback */
|
||||
is_capture = g_str_has_prefix (media_class, "Stream/Input");
|
||||
is_persistent = g_str_has_prefix (media_class, "Persistent/");
|
||||
|
||||
/* Locate the target endpoint */
|
||||
g_variant_dict_init (&d, NULL);
|
||||
|
|
@ -330,7 +332,7 @@ handle_client (WpPolicy *policy, WpEndpoint *ep)
|
|||
* this function is being called after sorting all the client endpoints
|
||||
* and therefore we can safely unlink the previous client
|
||||
*/
|
||||
if (wp_endpoint_is_linked (target) && !is_capture) {
|
||||
if (!is_capture && !is_persistent && wp_endpoint_is_linked (target)) {
|
||||
g_debug ("Unlink target '%s' from other clients",
|
||||
wp_endpoint_get_name (target));
|
||||
wp_endpoint_unlink (target);
|
||||
|
|
@ -393,6 +395,17 @@ simple_policy_rescan_in_idle (WpSimplePolicy *self)
|
|||
handle_client (WP_POLICY (self), ep);
|
||||
}
|
||||
}
|
||||
g_clear_pointer (&endpoints, g_ptr_array_unref);
|
||||
|
||||
endpoints = wp_endpoint_find (core, "Persistent/Stream/Input/Audio");
|
||||
if (endpoints) {
|
||||
/* link all persistent capture clients */
|
||||
for (i = 0; i < endpoints->len; i++) {
|
||||
ep = g_ptr_array_index (endpoints, i);
|
||||
handle_client (WP_POLICY (self), ep);
|
||||
}
|
||||
}
|
||||
g_clear_pointer (&endpoints, g_ptr_array_unref);
|
||||
|
||||
endpoints = wp_endpoint_find (core, "Stream/Output/Audio");
|
||||
if (endpoints && endpoints->len > 0) {
|
||||
|
|
@ -404,6 +417,17 @@ simple_policy_rescan_in_idle (WpSimplePolicy *self)
|
|||
ep = g_ptr_array_index (endpoints, 0);
|
||||
handle_client (WP_POLICY (self), ep);
|
||||
}
|
||||
g_clear_pointer (&endpoints, g_ptr_array_unref);
|
||||
|
||||
endpoints = wp_endpoint_find (core, "Persistent/Stream/Output/Audio");
|
||||
if (endpoints) {
|
||||
/* link all persistent output clients */
|
||||
for (i = 0; i < endpoints->len; i++) {
|
||||
ep = g_ptr_array_index (endpoints, i);
|
||||
handle_client (WP_POLICY (self), ep);
|
||||
}
|
||||
}
|
||||
g_clear_pointer (&endpoints, g_ptr_array_unref);
|
||||
|
||||
self->pending_rescan = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
|
|
@ -425,8 +449,7 @@ simple_policy_handle_endpoint (WpPolicy *policy, WpEndpoint *ep)
|
|||
|
||||
/* TODO: For now we only accept audio stream clients */
|
||||
media_class = wp_endpoint_get_media_class(ep);
|
||||
if (!g_str_has_prefix (media_class, "Stream") ||
|
||||
!g_str_has_suffix (media_class, "Audio")) {
|
||||
if (!g_str_has_suffix (media_class, "Audio")) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue