From eaf7606e3f690d719e6b3b39ec3264a2fa9e6c1e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 28 Jul 2020 13:00:45 +0200 Subject: [PATCH] acp: pass udev PROFILE_SETS to acp device --- spa/include/spa/monitor/device.h | 2 ++ spa/plugins/alsa/alsa-acp-device.c | 14 +++++++++++--- spa/plugins/alsa/alsa-udev.c | 5 ++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/spa/include/spa/monitor/device.h b/spa/include/spa/monitor/device.h index e46049023..d20470a10 100644 --- a/spa/include/spa/monitor/device.h +++ b/spa/include/spa/monitor/device.h @@ -286,6 +286,8 @@ struct spa_device_methods { * "webcam", "microphone", "headset", * "headphone", "hands-free", "car", "hifi", * "computer", "portable" */ +#define SPA_KEY_DEVICE_PROFILE "device.profile " /**< profile for the device */ +#define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set" /**< profile set for the device */ #ifdef __cplusplus diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index 3df5f856a..757cd450f 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -793,6 +793,8 @@ impl_init(const struct spa_handle_factory *factory, { struct impl *this; const char *str; + struct acp_dict_item items[4]; + uint32_t n_items = 0; spa_return_val_if_fail(factory != NULL, -EINVAL); spa_return_val_if_fail(handle != NULL, -EINVAL); @@ -820,14 +822,20 @@ impl_init(const struct spa_handle_factory *factory, reset_props(&this->props); - if (info && (str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH))) - snprintf(this->props.device, sizeof(this->props.device)-1, "%s", str); + if (info) { + if ((str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH)) != NULL) + snprintf(this->props.device, sizeof(this->props.device)-1, "%s", str); + if ((str = spa_dict_lookup(info, SPA_KEY_DEVICE_PROFILE_SET)) != NULL) + items[n_items++] = ACP_DICT_ITEM_INIT("profile-set", str); + if ((str = spa_dict_lookup(info, SPA_KEY_DEVICE_PROFILE)) != NULL) + items[n_items++] = ACP_DICT_ITEM_INIT("profile", str); + } spa_log_debug(this->log, "probe card %s", this->props.device); if ((str = strchr(this->props.device, ':')) == NULL) return -EINVAL; - this->card = acp_card_new(atoi(str+1), NULL); + this->card = acp_card_new(atoi(str+1), &ACP_DICT_INIT(items, n_items)); if (this->card == NULL) return -errno; diff --git a/spa/plugins/alsa/alsa-udev.c b/spa/plugins/alsa/alsa-udev.c index aac39d8b9..ab4be13ca 100644 --- a/spa/plugins/alsa/alsa-udev.c +++ b/spa/plugins/alsa/alsa-udev.c @@ -190,7 +190,7 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device * snd_ctl_t *ctl_hndl; const char *str; char path[32]; - struct spa_dict_item items[22]; + struct spa_dict_item items[23]; uint32_t n_items = 0; int res, pcm; @@ -239,6 +239,9 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device * if ((str = udev_device_get_property_value(dev, "PULSE_NAME")) && *str) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_NAME, str); + if ((str = udev_device_get_property_value(dev, "PULSE_PROFILE_SET")) && *str) + items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PROFILE_SET, str); + if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && *str) items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_CLASS, str);