diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-07-19 15:24:56 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-07-19 15:41:37 +0300 |
commit | d1f034055fbb433d155db147752e09580451df04 (patch) | |
tree | 57b43628dec1d40436bb9923ae89c7a0da803429 | |
parent | bb97f3bbd96a9d347e1b7f6cb68d94efaf8db574 (diff) |
simple-cam: Update to the new ControList::get() API
The ControlList::get() function has changed and now returns a
std::optional<T>. Adapt simple-cam accordingly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r-- | simple-cam.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/simple-cam.cpp b/simple-cam.cpp index 4de1b7d..3e17839 100644 --- a/simple-cam.cpp +++ b/simple-cam.cpp @@ -133,18 +133,22 @@ std::string cameraName(Camera *camera) const ControlList &props = camera->properties(); std::string name; - switch (props.get(properties::Location)) { - case properties::CameraLocationFront: - name = "Internal front camera"; - break; - case properties::CameraLocationBack: - name = "Internal back camera"; - break; - case properties::CameraLocationExternal: - name = "External camera"; - if (props.contains(properties::Model)) - name += " '" + props.get(properties::Model) + "'"; - break; + const auto &location = props.get(properties::Location); + if (location) { + switch (*location) { + case properties::CameraLocationFront: + name = "Internal front camera"; + break; + case properties::CameraLocationBack: + name = "Internal back camera"; + break; + case properties::CameraLocationExternal: + name = "External camera"; + const auto &model = props.get(properties::Model); + if (model) + name = " '" + *model + "'"; + break; + } } name += " (" + camera->id() + ")"; |