libcamera: Don't copy StreamConfiguration when iterating

A copy is made in the range-based for loop, and thus all modifications
done in the for loop body are lost, and not actually applied to
the object in the container.

Fix that by taking a reference in the range-based for loop.

Fixes: 4217c9f1aa ("libcamera: camera: Zero streams before validate()")
Fixes: 613d540267 ("pipeline: raspberrypi: Fix handling of colour spaces")
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze 2024-11-26 18:03:05 +00:00 committed by Laurent Pinchart
parent 5d4b7e4b5b
commit 4e557e544b
2 changed files with 4 additions and 4 deletions

View file

@ -1178,8 +1178,8 @@ int Camera::configure(CameraConfiguration *config)
if (ret < 0) if (ret < 0)
return ret; return ret;
for (auto it : *config) for (auto &cfg : *config)
it.setStream(nullptr); cfg.setStream(nullptr);
if (config->validate() != CameraConfiguration::Valid) { if (config->validate() != CameraConfiguration::Valid) {
LOG(Camera, Error) LOG(Camera, Error)

View file

@ -105,7 +105,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_
Status status = Valid; Status status = Valid;
yuvColorSpace_.reset(); yuvColorSpace_.reset();
for (auto cfg : config_) { for (auto &cfg : config_) {
/* First fix up raw streams to have the "raw" colour space. */ /* First fix up raw streams to have the "raw" colour space. */
if (PipelineHandlerBase::isRaw(cfg.pixelFormat)) { if (PipelineHandlerBase::isRaw(cfg.pixelFormat)) {
/* If there was no value here, that doesn't count as "adjusted". */ /* If there was no value here, that doesn't count as "adjusted". */
@ -130,7 +130,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_
rgbColorSpace_->range = ColorSpace::Range::Full; rgbColorSpace_->range = ColorSpace::Range::Full;
/* Go through the streams again and force everyone to the same colour space. */ /* Go through the streams again and force everyone to the same colour space. */
for (auto cfg : config_) { for (auto &cfg : config_) {
if (cfg.colorSpace == ColorSpace::Raw) if (cfg.colorSpace == ColorSpace::Raw)
continue; continue;