diff --git a/source/utils/CarlaThread.hpp b/source/utils/CarlaThread.hpp index 9b5062155..47a6d2fef 100644 --- a/source/utils/CarlaThread.hpp +++ b/source/utils/CarlaThread.hpp @@ -112,12 +112,12 @@ public: # endif pthread_attr_setschedparam(&attr, &sched_param) == 0) { - carla_stdout("CarlaThread with realtime priority successful"); + carla_stdout("CarlaThread setup with realtime priority successful"); } else #endif { - carla_stdout("CarlaThread with realtime priority failed, going with normal priority instead"); + carla_stdout("CarlaThread setup with realtime priority failed, going with normal priority instead"); pthread_attr_destroy(&attr); pthread_attr_init(&attr); } @@ -127,9 +127,17 @@ public: fShouldExit = false; - const bool ok = pthread_create(&handle, &attr, _entryPoint, this) == 0; + bool ok = pthread_create(&handle, &attr, _entryPoint, this) == 0; pthread_attr_destroy(&attr); + if (withRealtimePriority && !ok) + { + carla_stdout("CarlaThread with realtime priority failed on creation, going with normal priority instead"); + pthread_attr_init(&attr); + ok = pthread_create(&handle, &attr, _entryPoint, this) == 0; + pthread_attr_destroy(&attr); + } + CARLA_SAFE_ASSERT_RETURN(ok, false); #ifdef PTW32_DLLPORT CARLA_SAFE_ASSERT_RETURN(handle.p != nullptr, false);