Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake option COM_MULTITHREADED to call CoInitializeEx with COINIT_APARTMENTTHREADED flag. #7613

Merged
merged 2 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMake/global_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ macro(global_set_flags)
add_definitions(-DHWM_OVER_XU)
endif()

if(COM_MULTITHREADED)
add_definitions(-DCOM_MULTITHREADED)
endif()

if (ENFORCE_METADATA)
add_definitions(-DENFORCE_METADATA)
endif()
Expand Down
1 change: 1 addition & 0 deletions CMake/lrs_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option(BUILD_WITH_TM2 "Build with support for Intel TM2 tracking device" ON)
option(BUILD_EASYLOGGINGPP "Build EasyLogging++ as a part of the build" ON)
option(BUILD_WITH_STATIC_CRT "Build with static link CRT" ON)
option(HWM_OVER_XU "Send HWM commands over UVC XU control" ON)
option(COM_MULTITHREADED "call CoInitializeEx with COINIT_MULTITHREADED or COINIT_APARTMENTTHREADED flag" ON)
maloel marked this conversation as resolved.
Show resolved Hide resolved
option(BUILD_SHARED_LIBS "Build shared library" ON)
option(BUILD_UNIT_TESTS "Build realsense unit tests. Note that when enabled, additional tests data set will be downloaded from a web server and stored in a temp directory" OFF)
option(BUILD_INTERNAL_UNIT_TESTS "Test package for components under librealsense namespace, requires BUILD_SHARED_LIBS=OFF and BUILD_UNIT_TESTS=ON" OFF)
Expand Down
5 changes: 5 additions & 0 deletions src/mf/mf-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ namespace librealsense
{
wmf_backend::wmf_backend()
{
#ifdef COM_MULTITHREADED
maloel marked this conversation as resolved.
Show resolved Hide resolved
CoInitializeEx(nullptr, COINIT_MULTITHREADED); // when using COINIT_APARTMENTTHREADED, calling _pISensor->SetEventSink(NULL) to stop sensor can take several seconds
#else
CoInitializeEx( nullptr, COINIT_APARTMENTTHREADED ); // Apartment model
#endif

MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET);
}

Expand Down