mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-19 10:25:05 +03:00
cam: main: Cache lookup of role property
The code handling the stream role option retrieves the role property and converts it to a string in every branch. Cache it and use the cached value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
c153be4fec
commit
422e3e92ad
1 changed files with 8 additions and 6 deletions
|
@ -209,17 +209,19 @@ int CamApp::prepareConfig()
|
||||||
for (auto const &value : streamOptions) {
|
for (auto const &value : streamOptions) {
|
||||||
KeyValueParser::Options opt = value.toKeyValues();
|
KeyValueParser::Options opt = value.toKeyValues();
|
||||||
|
|
||||||
if (!opt.isSet("role")) {
|
std::string role = opt.isSet("role")
|
||||||
roles.push_back(StreamRole::VideoRecording);
|
? opt["role"].toString()
|
||||||
} else if (opt["role"].toString() == "viewfinder") {
|
: "viewfinder";
|
||||||
|
|
||||||
|
if (role == "viewfinder") {
|
||||||
roles.push_back(StreamRole::Viewfinder);
|
roles.push_back(StreamRole::Viewfinder);
|
||||||
} else if (opt["role"].toString() == "video") {
|
} else if (role == "video") {
|
||||||
roles.push_back(StreamRole::VideoRecording);
|
roles.push_back(StreamRole::VideoRecording);
|
||||||
} else if (opt["role"].toString() == "still") {
|
} else if (role == "still") {
|
||||||
roles.push_back(StreamRole::StillCapture);
|
roles.push_back(StreamRole::StillCapture);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Unknown stream role "
|
std::cerr << "Unknown stream role "
|
||||||
<< opt["role"].toString() << std::endl;
|
<< role << std::endl;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue