mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-29 13:14:14 -04:00
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:
parent
187187e41f
commit
dbc97942f4
1 changed files with 7 additions and 9 deletions
|
|
@ -118,9 +118,7 @@ void remove_device(struct impl *impl, struct device *device)
|
|||
int emit_object_info(struct impl *impl, const struct device *device)
|
||||
{
|
||||
struct spa_device_object_info info;
|
||||
struct spa_dict_item items[20];
|
||||
struct spa_dict dict;
|
||||
uint32_t n_items = 0;
|
||||
|
||||
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;
|
||||
info.flags = 0;
|
||||
|
||||
#define ADD_ITEM(key, value) items[n_items++] = SPA_DICT_ITEM_INIT(key, value)
|
||||
ADD_ITEM(SPA_KEY_DEVICE_ENUM_API,"libcamera.manager");
|
||||
ADD_ITEM(SPA_KEY_DEVICE_API, "libcamera");
|
||||
ADD_ITEM(SPA_KEY_MEDIA_CLASS, "Video/Device");
|
||||
ADD_ITEM(SPA_KEY_API_LIBCAMERA_PATH, device->camera->id().c_str());
|
||||
#undef ADD_ITEM
|
||||
const spa_dict_item items[] = {
|
||||
{ SPA_KEY_DEVICE_ENUM_API, "libcamera.manager" },
|
||||
{ SPA_KEY_DEVICE_API, "libcamera" },
|
||||
{ SPA_KEY_MEDIA_CLASS, "Video/Device" },
|
||||
{ SPA_KEY_API_LIBCAMERA_PATH, device->camera->id().c_str() },
|
||||
};
|
||||
|
||||
dict = SPA_DICT_INIT(items, n_items);
|
||||
dict = SPA_DICT_INIT_ARRAY(items);
|
||||
info.props = &dict;
|
||||
spa_device_emit_object_info(&impl->hooks, impl->id_of(*device), &info);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue