device: place the number of routes in the nodes

So that we can know if this node has routes or not.
Nodes without routes might need their volumes restored directly
with the node properties, like streams. Nodes with a route need their
volumes set on the device managing the node.
This commit is contained in:
Wim Taymans 2021-03-22 16:37:52 +01:00
parent 8a9c2ae901
commit fc44013d17
2 changed files with 10 additions and 7 deletions

View file

@ -144,7 +144,7 @@ static int emit_node(struct impl *this, struct acp_device *dev)
struct spa_dict_item *items;
const struct acp_dict_item *it;
uint32_t n_items, i;
char device_name[128], path[180], channels[16], ch[12];
char device_name[128], path[180], channels[16], ch[12], routes[16];
char card_id[16], *p;
char positions[SPA_AUDIO_MAX_CHANNELS * 12];
struct spa_device_object_info info;
@ -164,7 +164,7 @@ static int emit_node(struct impl *this, struct acp_device *dev)
info.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
n_items = dev->props.n_items + 6;
n_items = dev->props.n_items + 7;
items = alloca(n_items * sizeof(*items));
snprintf(card_id, sizeof(card), "%d", card->index);
@ -192,9 +192,11 @@ static int emit_node(struct impl *this, struct acp_device *dev)
p += snprintf(p, 12, "%s%s", i == 0 ? "" : ",",
acp_channel_str(ch, sizeof(ch), dev->format.map[i]));
}
items[5] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_POSITION, positions);
n_items = 6;
snprintf(routes, sizeof(routes), "%d", dev->n_ports);
items[6] = SPA_DICT_ITEM_INIT("device.routes", routes);
n_items = 7;
acp_dict_for_each(it, &dev->props)
items[n_items++] = SPA_DICT_ITEM_INIT(it->key, it->value);

View file

@ -180,7 +180,7 @@ static void emit_node(struct impl *this, struct spa_bt_transport *t,
{
struct spa_bt_device *device = this->bt_dev;
struct spa_device_object_info info;
struct spa_dict_item items[5];
struct spa_dict_item items[6];
uint32_t n_items = 0;
char transport[32], str_id[32];
bool is_dyn_node = SPA_FLAG_IS_SET(id, DYNAMIC_NODE_ID_FLAG);
@ -190,10 +190,11 @@ static void emit_node(struct impl *this, struct spa_bt_transport *t,
items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_PROFILE, spa_bt_profile_name(t->profile));
items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_CODEC, get_codec_name(t));
items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_API_BLUEZ5_ADDRESS, device->address);
n_items = 4;
items[4] = SPA_DICT_ITEM_INIT("device.routes", "1");
n_items = 5;
if (!is_dyn_node) {
snprintf(str_id, sizeof(str_id), "%d", id);
items[4] = SPA_DICT_ITEM_INIT("card.profile.device", str_id);
items[5] = SPA_DICT_ITEM_INIT("card.profile.device", str_id);
n_items++;
}