X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=router.c;h=ead298f7c90d7cdbc6b5f79b9e72e312dac5fdc3;hb=refs%2Ftags%2F4.99.5;hp=4ef018003dc3c001354796733e053fda5836934d;hpb=cc70e0ae30920ca835bf011f8040afb6fea43f45;p=staging%2Fagl-audio-plugin.git diff --git a/router.c b/router.c index 4ef0180..ead298f 100644 --- a/router.c +++ b/router.c @@ -252,6 +252,34 @@ bool agl_router_assign_class_to_rtgroup (struct userdata *u, agl_node_type class return true; } +agl_rtgroup * agl_router_get_rtgroup_from_class (struct userdata *u, agl_node_type class, uint32_t zone, agl_direction type) +{ + agl_router *router; + pa_hashmap *rtable; + agl_rtgroup ***classmap; + agl_rtgroup **zonemap; + agl_rtgroup * rtg; + + pa_assert (u); + pa_assert_se (router = u->router); + pa_assert (class >= 0 && class < router->maplen); + pa_assert (zone < AGL_ZONE_MAX); + pa_assert (type == agl_input || type == agl_output); + + if (type == agl_input) { + rtable = router->rtgroups.input; + classmap = router->classmap.input; + } else { + rtable = router->rtgroups.output; + classmap = router->classmap.output; + } + + zonemap = classmap[zone]; + rtg = zonemap[class]; + + return rtg; +} + void agl_router_assign_class_priority (struct userdata *u, agl_node_type class, int priority) { agl_router *router; @@ -300,11 +328,7 @@ bool agl_router_apply_node_priority_effect (struct userdata *u, agl_node *node, pa_assert_se (router = u->router); pa_assert_se (nodeset = u->nodeset); - /* do we have a routing group associated with this node ? It may have a custom effect */ - if (node->direction == agl_input) - rtg = pa_hashmap_get (router->rtgroups.input, agl_node_type_str (node->type)); - else - rtg = pa_hashmap_get (router->rtgroups.output, agl_node_type_str (node->type)); + rtg = agl_router_get_rtgroup_from_class(u, node->type, 0, node->direction); /* now let us compare priorities, and apply effect if needed */ /* "new" case */ @@ -354,14 +378,14 @@ void agl_router_register_node (struct userdata *u, agl_node *node) /* we try to discover node routing group from the configuration, "Phone" for instance, * see defaults in "config.c. Otherwise we just say NULL, a.k.a. default */ + rtg = agl_router_get_rtgroup_from_class(u, node->type, 0, node->direction); + if (node->direction == agl_input) { - rtg = pa_hashmap_get (router->rtgroups.input, agl_node_type_str (node->type)); if (rtg) implement_default_route (u, node, rtg->node, agl_utils_new_stamp ()); else implement_default_route (u, node, NULL, agl_utils_new_stamp ()); } else { - rtg = pa_hashmap_get (router->rtgroups.output, agl_node_type_str (node->type)); if (rtg) implement_default_route (u, rtg->node, node, agl_utils_new_stamp ()); else @@ -476,9 +500,9 @@ void implement_default_route (struct userdata *u, uint32_t stamp) { if (start->direction == agl_input) - agl_switch_setup_link (u, start, end, false); + agl_switch_setup_link (u, start, end); else - agl_switch_setup_link (u, end, start, false); + agl_switch_setup_link (u, end, start); } agl_node *find_default_route (struct userdata *u, agl_node *start, uint32_t stamp)