From 0c418d05c32b4c981b764d9f461e121c3f32cdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 7 Aug 2025 18:12:58 +0200 Subject: [PATCH] spa: libcamera: source: extract presence of `SPA_NODE_PARAM_FLAG_TEST_ONLY` Use a boolean named `try_only` instead of checking `flags` each time. (cherry picked from commit dac9e40be65ea27e4f6b32cac190e4bca0527cfe) --- spa/plugins/libcamera/libcamera-source.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index 6c647671b..da124db8d 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -1834,6 +1834,8 @@ next: int port_set_format(struct impl *impl, struct port *port, uint32_t flags, const struct spa_pod *format) { + const bool try_only = SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_TEST_ONLY); + if (format == nullptr) { if (!port->current_format) return 0; @@ -1880,18 +1882,17 @@ int port_set_format(struct impl *impl, struct port *port, return -EINVAL; } - if (port->current_format && !(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) { + if (port->current_format && !try_only) { spa_libcamera_use_buffers(impl, port, nullptr, 0); port->current_format.reset(); } - res = spa_libcamera_set_format(impl, port, &info, flags & SPA_NODE_PARAM_FLAG_TEST_ONLY); + res = spa_libcamera_set_format(impl, port, &info, try_only); if (res < 0) return res; - if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) { + if (!try_only) port->current_format = info; - } } impl->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS;