Skip to content

Commit

Permalink
Replace ternary operator with if/else statement to prevent RaspberryP…
Browse files Browse the repository at this point in the history
…i GCC segfault
  • Loading branch information
ev-mp committed Oct 14, 2019
1 parent 73d844b commit 5c3b600
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/hid/hid-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ namespace librealsense

})!= _configured_profiles.end())
{
sensor_data data;
sensor_data data{};
data.sensor = {_id_to_sensor[report.reportId]};

hid_data hid;
hid_data hid{};
hid.x = report.x;
hid.y = report.y;
hid.z = report.z;
Expand Down
8 changes: 5 additions & 3 deletions src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,12 +1136,14 @@ namespace librealsense
{
// The timestamps conversions path comprise of:
// FW TS (32bit) -> USB Phy Layer (no changes) -> Host Driver TS (Extend to 64bit) -> LRS read as 64 bit
// The flow introduces discrepancy with UVC stream which timestamps aer not extended to 64 bit by host driver both for Win and v4l backends.
// The flow introduces discrepancy with UVC stream which timestamps are not extended to 64 bit by host driver both for Win and v4l backends.
// In order to allow for hw timestamp-based synchronization of Depth and IMU streams the latter will be trimmed to 32 bit.
// To revert to the extended 64 bit TS uncomment the next line instead
//auto timestamp = *((uint64_t*)((const uint8_t*)fo.metadata));
auto timestamp = (fo.metadata_size >= platform::hid_header_size) ?
static_cast<uint32_t>(((platform::hid_header*)(fo.metadata))->timestamp) : *((uint32_t*)((const uint8_t*)fo.metadata));
// The ternary operator is replaced by explicit assignment due to an issue with GCC for RaspberryPi that causes segfauls in optimized build.
auto timestamp = *(reinterpret_cast<uint32_t*>(const_cast<void*>(fo.metadata)));
if (fo.metadata_size >= platform::hid_header_size)
timestamp = static_cast<uint32_t>(reinterpret_cast<const platform::hid_header*>(fo.metadata)->timestamp);

// HID timestamps are aligned to FW Default - usec units
return static_cast<rs2_time_t>(timestamp * TIMESTAMP_USEC_TO_MSEC);
Expand Down

0 comments on commit 5c3b600

Please sign in to comment.