From d76fee13539eb38ff2c4c611e2e2d510c1c41bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Tue, 5 Aug 2025 15:08:00 +0200 Subject: [PATCH] spa: libcamera: source: use dynamic builder for controls Use a dynamic spa pod builder when enumerating controls since previous changes can report more information from any given control. Also increase the stack buffer size to 4096 bytes. (cherry picked from commit e6f767d41da09e50ba864bbe7b816575028a7e20) --- spa/plugins/libcamera/libcamera-source.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index d3b6ca49b..2563136f0 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -882,8 +883,9 @@ spa_libcamera_enum_controls(struct impl *impl, struct port *port, int seq, const struct spa_pod *filter) { const ControlInfoMap &info = impl->camera->controls(); - uint8_t buffer[1024]; - struct spa_pod_builder b = { 0 }; + spa_auto(spa_pod_dynamic_builder) b = {}; + spa_pod_builder_state state; + uint8_t buffer[4096]; spa_result_node_params result = { .id = SPA_PARAM_PropInfo, }; @@ -892,18 +894,21 @@ spa_libcamera_enum_controls(struct impl *impl, struct port *port, int seq, for (auto skip = start - offset; skip && it != info.end(); skip--) it++; + spa_pod_dynamic_builder_init(&b, buffer, sizeof(buffer), 4096); + spa_pod_builder_get_state(&b.b, &state); + for (result.index = start; num > 0 && it != info.end(); ++it, result.index++) { spa_log_debug(impl->log, "%p: controls[%" PRIu32 "]: %s::%s", impl, result.index, it->first->vendor().c_str(), it->first->name().c_str()); - spa_pod_builder_init(&b, buffer, sizeof(buffer)); + spa_pod_builder_reset(&b.b, &state); - const auto *ctrl = control_details_to_pod(b, *it->first, it->second); + const auto *ctrl = control_details_to_pod(b.b, *it->first, it->second); if (!ctrl) continue; - if (spa_pod_filter(&b, &result.param, ctrl, filter) < 0) + if (spa_pod_filter(&b.b, &result.param, ctrl, filter) < 0) continue; result.next = result.index + 1;