Skip to content

Commit

Permalink
Merge pull request #4785 from ev-mp/dso-13560
Browse files Browse the repository at this point in the history
Fix a potential out-of-order initialization for A-factor
  • Loading branch information
ev-mp authored Sep 3, 2019
2 parents 0367818 + 29f0068 commit 6e414e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/advanced_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ namespace librealsense
lazy<ds5_color_sensor*> _color_sensor;
lazy<bool> _enabled;
std::shared_ptr<advanced_mode_preset_option> _preset_opt;
bool _rgb_exposure_gain_bind;
bool _amplitude_factor_support;
lazy<bool> _rgb_exposure_gain_bind;
lazy<bool> _amplitude_factor_support;

preset get_all() const;
void set_all(const preset& p);
Expand Down
20 changes: 12 additions & 8 deletions src/ds5/advanced_mode/advanced_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ namespace librealsense
uvc_sensor& depth_sensor)
: _hw_monitor(hwm),
_depth_sensor(depth_sensor),
_color_sensor(nullptr),
_rgb_exposure_gain_bind(false),
_amplitude_factor_support(false)
_color_sensor(nullptr)
{
_enabled = [this]() {
auto results = send_receive(encode_command(ds::fw_cmd::UAMG));
Expand All @@ -40,8 +38,14 @@ namespace librealsense
}
return (ds5_color_sensor*)nullptr;
};
auto fw_ver = firmware_version(_depth_sensor.get_device().get_info(rs2_camera_info::RS2_CAMERA_INFO_FIRMWARE_VERSION));
_amplitude_factor_support = _rgb_exposure_gain_bind = (fw_ver >= firmware_version("5.11.9.0"));
_amplitude_factor_support = [this]() {
auto fw_ver = firmware_version(_depth_sensor.get_device().get_info(rs2_camera_info::RS2_CAMERA_INFO_FIRMWARE_VERSION));
return (fw_ver >= firmware_version("5.11.9.0"));
};
_rgb_exposure_gain_bind = [this]() {
auto fw_ver = firmware_version(_depth_sensor.get_device().get_info(rs2_camera_info::RS2_CAMERA_INFO_FIRMWARE_VERSION));
return (fw_ver >= firmware_version("5.11.9.0"));
};
}

bool ds5_advanced_mode_base::is_enabled() const
Expand Down Expand Up @@ -231,7 +235,7 @@ namespace librealsense

void ds5_advanced_mode_base::get_amp_factor(STAFactor* ptr, int mode) const
{
*ptr = _amplitude_factor_support ? get<STAFactor>(advanced_mode_traits<STAFactor>::group, nullptr, mode) :
*ptr = *_amplitude_factor_support ? get<STAFactor>(advanced_mode_traits<STAFactor>::group, nullptr, mode) :
[]() { STAFactor af; af.amplitude = 0.f; return af; }();
}

Expand Down Expand Up @@ -493,7 +497,7 @@ namespace librealsense

void ds5_advanced_mode_base::set_amp_factor(const STAFactor& val)
{
if (_amplitude_factor_support)
if (*_amplitude_factor_support)
{
set(val, advanced_mode_traits<STAFactor>::group);
_preset_opt->set(RS2_RS400_VISUAL_PRESET_CUSTOM);
Expand Down Expand Up @@ -739,7 +743,7 @@ namespace librealsense
set(p.depth_table , advanced_mode_traits<STDepthTableControl>::group);
set(p.ae , advanced_mode_traits<STAEControl>::group);
set(p.census , advanced_mode_traits<STCensusRadius>::group);
if (_amplitude_factor_support)
if (*_amplitude_factor_support)
set(p.amplitude_factor, advanced_mode_traits<STAFactor>::group);

set_laser_state(p.laser_state);
Expand Down

0 comments on commit 6e414e2

Please sign in to comment.