diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index c83e7bd2d1..69c81248d7 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -77,7 +77,7 @@ namespace librealsense explicit ds5_depth_sensor(ds5_device* owner, std::shared_ptr uvc_device, std::unique_ptr timestamp_reader) - : uvc_sensor(ds::DEPTH_STEREO, uvc_device, move(timestamp_reader), owner), _owner(owner), _depth_units(0) + : uvc_sensor(ds::DEPTH_STEREO, uvc_device, move(timestamp_reader), owner), _owner(owner), _depth_units(-1) {} rs2_intrinsics get_intrinsics(const stream_profile& profile) const override @@ -166,7 +166,7 @@ namespace librealsense return results; } - float get_depth_scale() const override { return _depth_units; } + float get_depth_scale() const override { if (_depth_units < 0) _depth_units = get_option(RS2_OPTION_DEPTH_UNITS).query(); return _depth_units; } void set_depth_scale(float val){ _depth_units = val; } @@ -193,7 +193,7 @@ namespace librealsense } protected: const ds5_device* _owner; - std::atomic _depth_units; + mutable std::atomic _depth_units; float _stereo_baseline_mm; };