From fc44013d17ea86aa84d8e97ff5ad2cf8e41bb5fc Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 22 Mar 2021 16:37:52 +0100 Subject: [PATCH] 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. --- spa/plugins/alsa/alsa-acp-device.c | 10 ++++++---- spa/plugins/bluez5/bluez5-device.c | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index c2514523d..7069c7849 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -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); diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 3aa73a454..69fba13a4 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -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++; }