diff --git a/spa/plugins/libcamera/libcamera-device.cpp b/spa/plugins/libcamera/libcamera-device.cpp index 63afae727..40f314f1e 100644 --- a/spa/plugins/libcamera/libcamera-device.cpp +++ b/spa/plugins/libcamera/libcamera-device.cpp @@ -234,13 +234,11 @@ const struct spa_device_methods impl_device = { int impl_get_interface(struct spa_handle *handle, const char *type, void **interface) { - struct impl *impl; + auto *impl = reinterpret_cast(handle); spa_return_val_if_fail(handle != NULL, -EINVAL); spa_return_val_if_fail(interface != NULL, -EINVAL); - impl = (struct impl *) handle; - if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &impl->device; else diff --git a/spa/plugins/libcamera/libcamera-manager.cpp b/spa/plugins/libcamera/libcamera-manager.cpp index 97c2e0b74..ea254fa74 100644 --- a/spa/plugins/libcamera/libcamera-manager.cpp +++ b/spa/plugins/libcamera/libcamera-manager.cpp @@ -331,13 +331,11 @@ const struct spa_device_methods impl_device = { int impl_get_interface(struct spa_handle *handle, const char *type, void **interface) { - struct impl *impl; + auto *impl = reinterpret_cast(handle); spa_return_val_if_fail(handle != NULL, -EINVAL); spa_return_val_if_fail(interface != NULL, -EINVAL); - impl = (struct impl *) handle; - if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &impl->device; else diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index 72f80b361..37001e90d 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -875,8 +875,9 @@ int do_update_ctrls(struct spa_loop *loop, size_t size, void *user_data) { - struct impl *impl = (struct impl *)user_data; - const struct val *d = (const struct val *)data; + auto *impl = static_cast(user_data); + const auto *d = static_cast(data); + switch (d->type) { case ControlTypeBool: impl->ctrls.set(d->id, d->b_val); @@ -1281,7 +1282,7 @@ int do_remove_source(struct spa_loop *loop, size_t size, void *user_data) { - struct impl *impl = (struct impl *)user_data; + auto *impl = static_cast(user_data); if (impl->source.loop) spa_loop_remove_source(loop, &impl->source); return 0; @@ -1456,15 +1457,15 @@ int impl_node_set_param(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param) { - struct impl *impl = (struct impl*)object; + auto *impl = static_cast(object); spa_return_val_if_fail(impl != NULL, -EINVAL); switch (id) { case SPA_PARAM_Props: { - struct spa_pod_object *obj = (struct spa_pod_object *) param; - struct spa_pod_prop *prop; + const auto *obj = reinterpret_cast(param); + const struct spa_pod_prop *prop; if (param == NULL) { impl->device_id.clear(); @@ -1476,8 +1477,9 @@ int impl_node_set_param(void *object, switch (prop->key) { case SPA_PROP_device: - strncpy(device, (char *)SPA_POD_CONTENTS(struct spa_pod_string, &prop->value), - sizeof(device)-1); + strncpy(device, + static_cast(SPA_POD_CONTENTS(struct spa_pod_string, &prop->value)), + sizeof(device) - 1); impl->device_id = device; break; default: @@ -1982,8 +1984,8 @@ int process_control(struct impl *impl, struct spa_pod_sequence *control) switch (c->type) { case SPA_CONTROL_Properties: { - struct spa_pod_prop *prop; - struct spa_pod_object *obj = (struct spa_pod_object *) &c->value; + const auto *obj = reinterpret_cast(&c->value); + const struct spa_pod_prop *prop; SPA_POD_OBJECT_FOREACH(obj, prop) { spa_libcamera_set_control(impl, prop); @@ -2064,13 +2066,11 @@ const struct spa_node_methods impl_node = { int impl_get_interface(struct spa_handle *handle, const char *type, void **interface) { - struct impl *impl; + auto *impl = reinterpret_cast(handle); spa_return_val_if_fail(handle != NULL, -EINVAL); spa_return_val_if_fail(interface != NULL, -EINVAL); - impl = (struct impl *) handle; - if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &impl->node; else