spa: libcamera: source: move control enumeration to loop

Remove the `goto`s and instead move everything into a loop.
This commit is contained in:
Barnabás Pőcze 2025-07-23 14:06:11 +02:00 committed by Wim Taymans
parent cc187b035b
commit 44c05cfa7b

View file

@ -811,44 +811,35 @@ spa_libcamera_enum_controls(struct impl *impl, struct port *port, int seq,
const ControlInfoMap &info = impl->camera->controls(); const ControlInfoMap &info = impl->camera->controls();
uint8_t buffer[1024]; uint8_t buffer[1024];
struct spa_pod_builder b = { 0 }; struct spa_pod_builder b = { 0 };
struct spa_result_node_params result; spa_result_node_params result = {
struct spa_pod *ctrl; .id = SPA_PARAM_PropInfo,
uint32_t count = 0, skip; };
int res;
result.id = SPA_PARAM_PropInfo;
result.next = start;
auto it = info.begin(); auto it = info.begin();
for (skip = result.next - offset; skip && it != info.end(); skip--) for (auto skip = start - offset; skip && it != info.end(); skip--)
it++; it++;
if (false) { for (result.index = start; num > 0 && it != info.end(); ++it, result.index++) {
next: spa_log_debug(impl->log, "%p: controls[%" PRIu32 "]: %s::%s",
it++; impl, result.index, it->first->vendor().c_str(),
it->first->name().c_str());
spa_pod_builder_init(&b, buffer, sizeof(buffer));
const auto *ctrl = control_details_to_pod(b, *it->first, it->second);
if (!ctrl)
continue;
if (spa_pod_filter(&b, &result.param, ctrl, filter) < 0)
continue;
result.next = result.index + 1;
spa_node_emit_result(&impl->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result);
num -= 1;
} }
result.index = result.next++; return 0;
if (it == info.end())
goto enum_end;
spa_pod_builder_init(&b, buffer, sizeof(buffer));
ctrl = control_details_to_pod(b, *it->first, it->second);
if (!ctrl)
goto next;
if (spa_pod_filter(&b, &result.param, ctrl, filter) < 0)
goto next;
spa_node_emit_result(&impl->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result);
if (++count != num)
goto next;
enum_end:
res = 0;
return res;
} }
struct val { struct val {