X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=node.c;h=c85d51222d7de82ae9ddbe4f1692011dfe3092d1;hb=cc70e0ae30920ca835bf011f8040afb6fea43f45;hp=1876a67bc49ae03fc357762d81ca24b1c15b9526;hpb=2478974dfde05063cbf0233e3d3c434ca2f46c7c;p=staging%2Fagl-audio-plugin.git diff --git a/node.c b/node.c index 1876a67..c85d512 100644 --- a/node.c +++ b/node.c @@ -20,6 +20,7 @@ * */ #include "node.h" +#include "router.h" #include @@ -129,12 +130,22 @@ agl_node *agl_node_create (struct userdata *u, agl_node *data) } } - /* TODO : register the node to the router */ - /* agl_router_register_node (u, node); */ - return node; } +void agl_node_destroy (struct userdata *u, agl_node *node) +{ + agl_nodeset *ns; + + pa_assert (u); + pa_assert (node); + pa_assert_se (ns = u->nodeset); + + pa_idxset_remove_by_index (ns->nodes, node->index); + + pa_xfree (node); +} + const char *agl_node_type_str (agl_node_type type) { switch (type) { @@ -208,3 +219,24 @@ agl_node *agl_node_get_from_client (struct userdata *u, pa_client *client) return NULL; } + +bool agl_node_has_highest_priority (struct userdata *u, agl_node *node) +{ + agl_nodeset *nodeset; + agl_node *n; + int priority; + uint32_t index; + + pa_assert (u); + pa_assert (node); + pa_assert (nodeset = u->nodeset); + + priority = agl_router_get_node_priority (u, node); + + PA_IDXSET_FOREACH(n, nodeset->nodes, index) { + if ((n != node) && (agl_router_get_node_priority (u, n) >= priority)) + return false; + } + + return true; +}