alsa-udev: add property to emit ACP devices

This commit is contained in:
Wim Taymans 2020-12-04 17:30:00 +01:00
parent bec950440b
commit 8cb1db5a61

View file

@ -68,6 +68,7 @@ struct impl {
uint32_t n_cards;
struct spa_source source;
unsigned int use_acp:1;
};
static int impl_udev_open(struct impl *this)
@ -225,7 +226,9 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device *
info = SPA_DEVICE_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Device;
info.factory_name = SPA_NAME_API_ALSA_PCM_DEVICE;
info.factory_name = this->use_acp ?
SPA_NAME_API_ALSA_ACP_DEVICE :
SPA_NAME_API_ALSA_PCM_DEVICE;
info.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_FLAGS |
SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
info.flags = 0;
@ -583,6 +586,7 @@ impl_init(const struct spa_handle_factory *factory,
uint32_t n_support)
{
struct impl *this;
const char *str;
spa_return_val_if_fail(factory != NULL, -EINVAL);
spa_return_val_if_fail(handle != NULL, -EINVAL);
@ -611,6 +615,11 @@ impl_init(const struct spa_handle_factory *factory,
SPA_DEVICE_CHANGE_MASK_PROPS;
this->info.flags = 0;
if (info) {
if ((str = spa_dict_lookup(info, "alsa.use-acp")) != NULL)
this->use_acp = strcmp(str, "true") == 0 || atoi(str) != 0;
}
return 0;
}