libcamera: emit device removal event

We need to emit the device id with NULL info to emit a device remove
event.

Also indent some code properly.
This commit is contained in:
Wim Taymans 2022-11-14 15:37:42 +01:00
parent 4da154c3a9
commit a57590e334
2 changed files with 6 additions and 5 deletions

View file

@ -77,8 +77,8 @@ static int emit_object_info(struct impl *this, uint32_t id)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "libcamera"); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "libcamera");
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Video/Device"); items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Video/Device");
info.props = &SPA_DICT_INIT(items, n_items); info.props = &SPA_DICT_INIT(items, n_items);
spa_device_emit_object_info(&this->hooks, id, &info); spa_device_emit_object_info(&this->hooks, id, &info);
return 1; return 1;
} }
@ -112,18 +112,18 @@ impl_device_add_listener(void *object, struct spa_hook *listener,
const struct spa_device_events *events, void *data) const struct spa_device_events *events, void *data)
{ {
struct impl *this = object; struct impl *this = object;
struct spa_hook_list save; struct spa_hook_list save;
spa_return_val_if_fail(this != NULL, -EINVAL); spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(events != NULL, -EINVAL); spa_return_val_if_fail(events != NULL, -EINVAL);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data); spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
emit_device_info(this, true); emit_device_info(this, true);
emit_object_info(this, 0); emit_object_info(this, 0);
spa_hook_list_join(&this->hooks, &save); spa_hook_list_join(&this->hooks, &save);
listener->removed = impl_hook_removed; listener->removed = impl_hook_removed;
listener->priv = this; listener->priv = this;

View file

@ -208,6 +208,7 @@ static void try_remove_camera(struct impl *impl, const Camera *camera)
return; return;
spa_log_info(impl->log, "camera removed: %s", device->camera->id().c_str()); spa_log_info(impl->log, "camera removed: %s", device->camera->id().c_str());
spa_device_emit_object_info(&impl->hooks, device->id, NULL);
remove_device(impl, device); remove_device(impl, device);
} }