mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-25 17:45:06 +03:00
libcamera: controls: Use std::optional to handle invalid control values
Previously, ControlList::get<T>() would use default constructed objects to indicate that a ControlList does not have the requested Control. This has several disadvantages: 1) It requires types to be default constructible, 2) it does not differentiate between a default constructed object and an object that happens to have the same state as a default constructed object. std::optional<T> additionally stores the information if the object is valid or not, and therefore is more expressive than a default constructed object. Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
ef77e26379
commit
1c4d480185
10 changed files with 44 additions and 44 deletions
|
@ -234,7 +234,7 @@ GstLibcameraSrcState::requestCompleted(Request *request)
|
|||
}
|
||||
|
||||
if (GST_ELEMENT_CLOCK(src_)) {
|
||||
int64_t timestamp = request->metadata().get(controls::SensorTimestamp);
|
||||
int64_t timestamp = request->metadata().get(controls::SensorTimestamp).value_or(0);
|
||||
|
||||
GstClockTime gst_base_time = GST_ELEMENT(src_)->base_time;
|
||||
GstClockTime gst_now = gst_clock_get_time(GST_ELEMENT_CLOCK(src_));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue