mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: libcamera: source: move control enumeration to loop
Remove the `goto`s and instead move everything into a loop.
(cherry picked from commit 44c05cfa7b)
			
			
This commit is contained in:
		
							parent
							
								
									eb6b9a47fc
								
							
						
					
					
						commit
						f6d3db72a1
					
				
					 1 changed files with 23 additions and 32 deletions
				
			
		| 
						 | 
					@ -810,44 +810,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());
 | 
				
			||||||
 | 
					 | 
				
			||||||
	result.index = result.next++;
 | 
					 | 
				
			||||||
	if (it == info.end())
 | 
					 | 
				
			||||||
		goto enum_end;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
							spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctrl = control_details_to_pod(b, *it->first, it->second);
 | 
							const auto *ctrl = control_details_to_pod(b, *it->first, it->second);
 | 
				
			||||||
		if (!ctrl)
 | 
							if (!ctrl)
 | 
				
			||||||
		goto next;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (spa_pod_filter(&b, &result.param, ctrl, filter) < 0)
 | 
							if (spa_pod_filter(&b, &result.param, ctrl, filter) < 0)
 | 
				
			||||||
		goto next;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							result.next = result.index + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_node_emit_result(&impl->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result);
 | 
							spa_node_emit_result(&impl->hooks, seq, 0, SPA_RESULT_TYPE_NODE_PARAMS, &result);
 | 
				
			||||||
 | 
							num -= 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (++count != num)
 | 
						return 0;
 | 
				
			||||||
		goto next;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum_end:
 | 
					 | 
				
			||||||
	res = 0;
 | 
					 | 
				
			||||||
	return res;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct val {
 | 
					struct val {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue