summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2020-07-03 11:21:57 +0200
committerWim Taymans <wtaymans@redhat.com>2020-07-03 17:33:08 +0200
commit2c07fd5369ae31221389e724ddc2ae409ccfad7b (patch)
tree38c9d5420bb9beb369aa6ca1838737e94250b7a6
parentae7e10b4ff391bf72fae11162a7775e426b92218 (diff)
acp-device: improve %f substitution with card_idwip
-rw-r--r--spa/plugins/alsa/alsa-acp-device.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c
index 397fca6b..ee5dc58d 100644
--- a/spa/plugins/alsa/alsa-acp-device.c
+++ b/spa/plugins/alsa/alsa-acp-device.c
@@ -128,7 +128,7 @@ static int emit_node(struct impl *this, struct acp_device *dev)
char card_id[16], *p;
struct spa_device_object_info info;
struct acp_card *card = this->card;
- const char *stream;
+ const char *stream, *devstr;;
info = SPA_DEVICE_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Node;
@@ -147,10 +147,16 @@ static int emit_node(struct impl *this, struct acp_device *dev)
items = alloca(n_items * sizeof(*items));
snprintf(card_id, sizeof(card), "%d", card->index);
- snprintf(device_name, sizeof(device_name), "%s", dev->device_strings[0]);
- p = strstr(device_name, "%f");
- if (p)
- snprintf(p, 4, "%d%s", card->index, p+2);
+
+ devstr = dev->device_strings[0];
+ p = strstr(devstr, "%f");
+ if (p) {
+ snprintf(device_name, sizeof(device_name), "%.*s%d%s",
+ (int)SPA_PTRDIFF(p, devstr), devstr,
+ card->index, p+2);
+ } else {
+ snprintf(device_name, sizeof(device_name), "%s", devstr);
+ }
snprintf(path, sizeof(path), "alsa:pcm:%s:%s:%s", card_id, device_name, stream);
items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_OBJECT_PATH, path);
items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_API_ALSA_PATH, device_name);