alsa-udev: set media class to Alsa/<direction>

This commit is contained in:
Julian Bouzas 2019-08-29 11:16:25 -04:00
parent 11d86fda97
commit faaad1b04d
2 changed files with 11 additions and 9 deletions

View file

@ -59,7 +59,7 @@ on_node_added(WpRemotePipewire *rp, guint id, guint parent_id, gconstpointer p,
struct impl *impl = d;
const struct spa_dict *props = p;
g_autoptr (WpCore) core = wp_module_get_core (impl->module);
const gchar *media_class, *name;
const gchar *media_class, *alsa_media_class, *name;
enum pw_direction direction;
GVariantBuilder b;
g_autoptr (GVariant) endpoint_props = NULL;
@ -82,14 +82,16 @@ on_node_added(WpRemotePipewire *rp, guint id, guint parent_id, gconstpointer p,
name = spa_dict_lookup (props, "node.name");
/* Make sure we don't handle bluetooth nodes */
if (g_str_has_prefix (name, "api.bluez5"))
if (g_str_has_prefix (name, "bluez5"))
return;
/* Set the direction */
/* Set the direction and alsa media class */
if (g_str_has_suffix (media_class, "Source")) {
direction = PW_DIRECTION_OUTPUT;
alsa_media_class = "Alsa/Source";
} else if (g_str_has_suffix (media_class, "Sink")) {
direction = PW_DIRECTION_INPUT;
alsa_media_class = "Alsa/Sink";
} else {
g_critical ("failed to parse alsa direction");
return;
@ -100,7 +102,7 @@ on_node_added(WpRemotePipewire *rp, guint id, guint parent_id, gconstpointer p,
g_variant_builder_add (&b, "{sv}",
"name", g_variant_new_string (name));
g_variant_builder_add (&b, "{sv}",
"media-class", g_variant_new_string (media_class));
"media-class", g_variant_new_string (alsa_media_class));
g_variant_builder_add (&b, "{sv}",
"direction", g_variant_new_uint32 (direction));
g_variant_builder_add (&b, "{sv}",

View file

@ -136,10 +136,10 @@ select_new_endpoint (WpSimplePolicy *self)
if (!self->selected[DIRECTION_SINK]) {
direction = DIRECTION_SINK;
media_class = "Audio/Sink";
media_class = "Alsa/Sink";
} else if (!self->selected[DIRECTION_SOURCE]) {
direction = DIRECTION_SOURCE;
media_class = "Audio/Source";
media_class = "Alsa/Source";
} else
return G_SOURCE_REMOVE;
@ -172,8 +172,8 @@ simple_policy_endpoint_added (WpPolicy *policy, WpEndpoint *ep)
guint32 control_id;
gint direction;
/* we only care about audio device endpoints here */
if (!g_str_has_prefix (media_class, "Audio/"))
/* we only care about alsa device endpoints here */
if (!g_str_has_prefix (media_class, "Alsa/"))
return;
/* verify it has the "selected" control available */
@ -282,7 +282,7 @@ handle_client (WpPolicy *policy, WpEndpoint *ep)
g_variant_dict_init (&d, NULL);
g_variant_dict_insert (&d, "action", "s", "link");
g_variant_dict_insert (&d, "media.class", "s",
is_capture ? "Audio/Source" : "Audio/Sink");
is_capture ? "Alsa/Source" : "Alsa/Sink");
g_object_get (ep, "role", &role, NULL);
if (role)