break;
if (aul_app_get_appid_bypid(pid, buf, sizeof(buf)) < 0) {
- pa_log("can't obtain real application name for wrt '%s' (pid %d)", bin, pid);
+ pa_log("can't obtain real application name for wrt '%s' "
+ "(pid %d)", bin, pid);
break;
}
- if ((name = strrchr(buf, '.')))
+ if ((name = strrchr(buf, '.')))
name++;
else
name = buf;
bin = buf;
}
- if ((map = pa_nodeset_get_map_by_binary(u, bin)))
+ if ((map = pa_nodeset_get_map_by_binary(u, bin))) {
+ if (map->role)
+ pa_proplist_sets(pl, PA_PROP_MEDIA_ROLE, map->role);
break;
- }
+ }
+ }
if ((role = pa_proplist_gets(pl, PA_PROP_MEDIA_ROLE)) &&
(map = pa_nodeset_get_map_by_role(u, role)))
pa_nodeset_add_role(u, t->id, t->type, NULL);
for (t = binmap; t->id; t++)
- pa_nodeset_add_binary(u, t->id, t->type, NULL);
+ pa_nodeset_add_binary(u, t->id, t->type, NULL, NULL);
for (p = priormap; p->class; p++)
mir_router_assign_class_priority(u, p->class, p->priority);
},
roles = { music = {0, "mandatory", "exclusive"},
video = {0, "mandatory", "exclusive"},
- test = {0, "mandatory", "exclusive"}
+ test = {0, "mandatory", "exclusive"}
},
binaries = { ['t8j6HTRpuz.MediaPlayer'] = no_resource }
}
map = pa_xnew0(pa_nodeset_map, 1);
map->name = pa_xstrdup(role);
map->type = type;
+ map->role = pa_xstrdup(role);
if (resdef) {
map->resdef = pa_xnew(pa_nodeset_resdef, 1);
if ((map = pa_hashmap_remove(ns->roles, role))) {
pa_xfree((void *)map->name);
+ pa_xfree((void *)map->role);
pa_xfree((void *)map->resdef);
}
}
int pa_nodeset_add_binary(struct userdata *u,
const char *bin,
mir_node_type type,
+ const char *role,
pa_nodeset_resdef *resdef)
{
pa_nodeset *ns;
map = pa_xnew0(pa_nodeset_map, 1);
map->name = pa_xstrdup(bin);
map->type = type;
+ map->role = role ? pa_xstrdup(role) : NULL;
if (resdef) {
map->resdef = pa_xnew(pa_nodeset_resdef, 1);
if ((map = pa_hashmap_remove(ns->binaries, bin))) {
pa_xfree((void *)map->name);
+ pa_xfree((void *)map->role);
pa_xfree((void *)map->resdef);
}
}
struct pa_nodeset_map {
const char *name;
mir_node_type type;
+ const char *role;
pa_nodeset_resdef *resdef;
};
pa_nodeset_map *pa_nodeset_get_map_by_role(struct userdata *, const char *);
int pa_nodeset_add_binary(struct userdata *, const char *, mir_node_type,
- pa_nodeset_resdef *);
+ const char *, pa_nodeset_resdef *);
void pa_nodeset_delete_binary(struct userdata *, const char *);
pa_nodeset_map *pa_nodeset_get_map_by_binary(struct userdata *, const char *);
typedef struct {
const char *name;
pa_bool_t needres;
+ const char *role;
pa_nodeset_resdef resource;
} map_t;
for (r = roles; r->name; r++) {
resdef = r->needres ? &r->resource : NULL;
+ if (r->role && strcmp(r->role, r->name)) {
+ luaL_error(L, "conflicting roles in role definition '%s' (%s)",
+ r->name, r->role);
+ }
+
if (pa_nodeset_add_role(u, r->name, type, resdef)) {
luaL_error(L, "role '%s' is added to mutiple application "
"classes", r->name);
for (b = binaries; b->name; b++) {
resdef = b->needres ? &b->resource : NULL;
- if (pa_nodeset_add_binary(u, b->name, type, resdef)) {
+ if (pa_nodeset_add_binary(u, b->name, type, b->role, resdef)) {
luaL_error(L, "binary '%s' is added to multiple application "
"classes", b->name);
}
int def;
size_t namlen;
const char *name;
- const char *flag;
+ const char *option;
+ const char *role;
map_t *m, *map = NULL;
size_t n = 0;
size_t i, len;
m->needres = FALSE;
break;
+ case LUA_TSTRING:
+ m->needres = FALSE;
+ m->role = mrp_strdup(lua_tostring(L, def));
+ break;
+
case LUA_TTABLE:
m->needres = TRUE;
m->resource.priority = priority;
}
else {
- flag = luaL_checkstring(L, -1);
+ option = luaL_checkstring(L, -1);
rd = &m->resource;
- if (pa_streq(flag, "autorelease"))
+ if (pa_streq(option, "autorelease"))
rd->flags.rset |= RESPROTO_RSETFLAG_AUTORELEASE;
- else if (pa_streq(flag, "mandatory"))
+ else if (pa_streq(option, "mandatory"))
rd->flags.audio |= RESPROTO_RESFLAG_MANDATORY;
- else if (pa_streq(flag, "shared"))
+ else if (pa_streq(option, "shared"))
rd->flags.audio |= RESPROTO_RESFLAG_SHARED;
- else if (!pa_streq(flag, "optional") &&
- !pa_streq(flag, "exclusive") )
+ else if (!pa_streq(option, "optional") &&
+ !pa_streq(option, "exclusive") )
{
- luaL_error(L, "invalid flag '%s' for '%s'", flag,name);
+ if (!m->role)
+ m->role = pa_xstrdup(option);
+ else {
+ luaL_error(L, "multiple role definition '%s','%s'",
+ m->role, option);
+ }
}
}
lua_newtable(L);
for (m = map; m->name; m++) {
- if (!m->needres)
- lua_pushnumber(L, 0);
+ if (!m->needres) {
+ if (m->role)
+ lua_pushstring(L, m->role);
+ else
+ lua_pushnumber(L, 0);
+ }
else {
lua_newtable(L);
lua_pushinteger(L, m->resource.priority);
+ if (m->role)
+ lua_pushstring(L, m->role);
if (m->resource.flags.rset & RESPROTO_RSETFLAG_AUTORELEASE)
lua_pushstring(L, "autorelease");
if (m->resource.flags.audio & RESPROTO_RESFLAG_MANDATORY)
if (map) {
for (m = map; m->name; m++) {
pa_xfree((void *)m->name);
+ pa_xfree((void *)m->role);
}
pa_xfree(map);
}