spa: libcamera: manager: simplify property emission

There are no conditional properties, so everything can be in the array
initializer, which always deduces the size correctly, so do that.
This commit is contained in:
Barnabás Pőcze 2026-01-14 19:46:59 +01:00 committed by Wim Taymans
parent 187187e41f
commit dbc97942f4

View file

@ -118,9 +118,7 @@ void remove_device(struct impl *impl, struct device *device)
int emit_object_info(struct impl *impl, const struct device *device) int emit_object_info(struct impl *impl, const struct device *device)
{ {
struct spa_device_object_info info; struct spa_device_object_info info;
struct spa_dict_item items[20];
struct spa_dict dict; struct spa_dict dict;
uint32_t n_items = 0;
info = SPA_DEVICE_OBJECT_INFO_INIT(); info = SPA_DEVICE_OBJECT_INFO_INIT();
@ -130,14 +128,14 @@ int emit_object_info(struct impl *impl, const struct device *device)
SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS; SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
info.flags = 0; info.flags = 0;
#define ADD_ITEM(key, value) items[n_items++] = SPA_DICT_ITEM_INIT(key, value) const spa_dict_item items[] = {
ADD_ITEM(SPA_KEY_DEVICE_ENUM_API,"libcamera.manager"); { SPA_KEY_DEVICE_ENUM_API, "libcamera.manager" },
ADD_ITEM(SPA_KEY_DEVICE_API, "libcamera"); { SPA_KEY_DEVICE_API, "libcamera" },
ADD_ITEM(SPA_KEY_MEDIA_CLASS, "Video/Device"); { SPA_KEY_MEDIA_CLASS, "Video/Device" },
ADD_ITEM(SPA_KEY_API_LIBCAMERA_PATH, device->camera->id().c_str()); { SPA_KEY_API_LIBCAMERA_PATH, device->camera->id().c_str() },
#undef ADD_ITEM };
dict = SPA_DICT_INIT(items, n_items); dict = SPA_DICT_INIT_ARRAY(items);
info.props = &dict; info.props = &dict;
spa_device_emit_object_info(&impl->hooks, impl->id_of(*device), &info); spa_device_emit_object_info(&impl->hooks, impl->id_of(*device), &info);