Finalize basic configuration logic
[staging/agl-audio-plugin.git] / node.c
diff --git a/node.c b/node.c
index c6c59e2..e2c5007 100644 (file)
--- a/node.c
+++ b/node.c
 
 #include <pulsecore/idxset.h>
 
-pa_nodeset *pa_nodeset_init (struct userdata *u)
+agl_nodeset *agl_nodeset_init (struct userdata *u)
 {
-       pa_nodeset *ns;
+       agl_nodeset *ns;
 
        pa_assert (u);
 
-       ns = pa_xnew0 (pa_nodeset, 1);
+       ns = pa_xnew0 (agl_nodeset, 1);
        ns->nodes = pa_idxset_new (pa_idxset_trivial_hash_func,
                                   pa_idxset_trivial_compare_func);
        ns->roles = pa_hashmap_new (pa_idxset_string_hash_func,
@@ -39,10 +39,10 @@ pa_nodeset *pa_nodeset_init (struct userdata *u)
        return ns;
 }
 
-void pa_nodeset_done(struct userdata *u)
+void agl_nodeset_done(struct userdata *u)
 {
-       pa_nodeset *ns;
-       pa_nodeset_map *role, *binary;
+       agl_nodeset *ns;
+       agl_nodeset_map *role, *binary;
        void *state;
        int i;
 
@@ -68,9 +68,30 @@ void pa_nodeset_done(struct userdata *u)
        }
 }
 
+int agl_nodeset_add_role (struct userdata *u, const char *role, agl_node_type type, agl_nodeset_resdef *resdef)
+{
+       agl_nodeset *ns;
+       agl_nodeset_map *map;
+
+       pa_assert (u);
+       pa_assert_se (ns = u->nodeset);
+
+       map = pa_xnew0 (agl_nodeset_map, 1);
+       map->name = pa_xstrdup (role);
+       map->type = type;
+       map->role = pa_xstrdup (role);
+
+       if (resdef) {
+               map->resdef = pa_xnew (agl_nodeset_resdef, 1);
+               memcpy (map->resdef, resdef, sizeof(agl_nodeset_resdef));
+       }
+
+       return pa_hashmap_put (ns->roles, (void *)map->name, map);
+}
+
 agl_node *agl_node_create (struct userdata *u, agl_node *data)
 {
-       pa_nodeset *ns;
+       agl_nodeset *ns;
        agl_node *node;
 
        pa_assert (u);
@@ -132,11 +153,21 @@ const char *agl_node_type_str (agl_node_type type)
        }
 }
 
+const char *agl_node_direction_str (agl_direction direction)
+{
+       switch (direction) {
+               case agl_direction_unknown: return "unknown";
+               case agl_input:             return "input";
+               case agl_output:            return "output";
+               default:                    return "< ??? >";
+       }
+}
+
 agl_node *agl_node_get_from_data (struct userdata *u, agl_direction type, void *data)
 {
        pa_sink_input_new_data *sinp_data;
        pa_source_output_new_data *sout_data;
-       pa_nodeset *nodeset;
+       agl_nodeset *nodeset;
        agl_node *node;
        uint32_t index;
 
@@ -162,7 +193,7 @@ agl_node *agl_node_get_from_data (struct userdata *u, agl_direction type, void *
 
 agl_node *agl_node_get_from_client (struct userdata *u, pa_client *client)
 {
-       pa_nodeset *nodeset;
+       agl_nodeset *nodeset;
        agl_node *node;
        uint32_t index;