m-default-nodes: lift restrictions on media.class for audio nodes

Previously a default source had to be Audio/Source and a default sink
had to be Audio/Sink. This did not account for:
 - monitor sources (Audio/Sink)
 - duplex nodes (Audio/Duplex)
 - virtual sources (Audio/Source/Virtual)

With this change the restriction is now on the number of input/output
ports, so any Audio/* node with output ports is a valid target to select
as a default source, while any Audio/* node with input ports is a valid
target for a default sink.

Fixes #60
This commit is contained in:
George Kiagiadakis
2021-10-05 17:21:06 +03:00
parent 4f97def376
commit 5e14c69108
3 changed files with 68 additions and 19 deletions

View File

@@ -156,7 +156,7 @@ wp_default_nodes_api_get_default_node (WpDefaultNodesApi * self,
{
gint node_t = -1;
for (gint i = 0; i < N_DEFAULT_NODES; i++) {
if (!g_strcmp0 (media_class, MEDIA_CLASS[i])) {
if (!g_strcmp0 (media_class, NODE_TYPE_STR[i])) {
node_t = i;
break;
}
@@ -166,8 +166,6 @@ wp_default_nodes_api_get_default_node (WpDefaultNodesApi * self,
WP_TYPE_NODE,
WP_CONSTRAINT_TYPE_PW_PROPERTY,
PW_KEY_NODE_NAME, "=s", self->defaults[node_t],
WP_CONSTRAINT_TYPE_PW_PROPERTY,
PW_KEY_MEDIA_CLASS, "=s", MEDIA_CLASS[node_t],
NULL);
if (node)
return wp_proxy_get_bound_id (WP_PROXY (node));