From 7414d948ad4de0e2b14fb441a0f3945af4378182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sat, 12 Jul 2025 18:53:35 +0200 Subject: [PATCH] spa: libcamera: source: use `union` for transferring control value Use a union since only one member is active at a time, and use the proper `libcamera::ControlType` enum to store the type instead of a bare number. Also remove an unnecessary cast. (cherry picked from commit 0022fc90b715489d575a440783cdd02aada5474c) --- spa/plugins/libcamera/libcamera-source.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index fe7351dd5..a86d20543 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -861,11 +861,13 @@ enum_end: } struct val { - uint32_t type; - float f_val; - int32_t i_val; - bool b_val; + ControlType type; uint32_t id; + union { + bool b_val; + int32_t i_val; + float f_val; + }; }; static int do_update_ctrls(struct spa_loop *loop, @@ -885,7 +887,7 @@ static int do_update_ctrls(struct spa_loop *loop, impl->ctrls.set(d->id, d->f_val); break; case ControlTypeInteger32: - impl->ctrls.set(d->id, (int32_t)d->i_val); + impl->ctrls.set(d->id, d->i_val); break; default: break;