Skip to content

Commit

Permalink
Merge PR IntelRealSense#22 from Nir-Az/fix_rgb_stability_on_ac
Browse files Browse the repository at this point in the history
Protect deadlock when closing RGB sensor while AC runs
  • Loading branch information
maloel authored Jul 8, 2020
2 parents 5d40288 + 5adcbd3 commit 5ad7289
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/l500/ac-trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,28 @@ namespace ivcam2 {
if( !_own_color_stream.exchange( false ) )
return;

AC_LOG( INFO, "STOPPING color sensor..." );
auto & color_sensor = *_dev.get_color_sensor();
color_sensor.stop();
AC_LOG( INFO, "CLOSING color sensor..." );
color_sensor.close();
AC_LOG( INFO, "Closed!" );
// By using a thread we protect a case that tries to close a sensor from it's processing block callback and creates a deadlock.
std::thread([&]()
{
try
{
AC_LOG(INFO, "STOPPING color sensor...");
auto & color_sensor = *_dev.get_color_sensor();
color_sensor.stop();
AC_LOG(INFO, "CLOSING color sensor...");
color_sensor.close();
AC_LOG(INFO, "Closed!");
}
catch (std::exception& ex)
{
AC_LOG(ERROR, "caught exception in closing color sensor: " << ex.what());
}
catch (...)
{
AC_LOG(ERROR, "unknown exception in closing color sensor");
}
}).detach();

}


Expand Down

0 comments on commit 5ad7289

Please sign in to comment.