acp: pass udev PROFILE_SETS to acp device

This commit is contained in:
Wim Taymans 2020-07-28 13:00:45 +02:00
parent e478ba7e34
commit eaf7606e3f
3 changed files with 17 additions and 4 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);