Ildaeil: Add mutex around plugin load to prevent race conditions
This commit is contained in:
parent
f0750f235e
commit
acc99bef1c
1 changed files with 9 additions and 1 deletions
|
|
@ -241,6 +241,7 @@ struct IldaeilModule : Module {
|
||||||
mutable NativeTimeInfo fCarlaTimeInfo;
|
mutable NativeTimeInfo fCarlaTimeInfo;
|
||||||
|
|
||||||
void* fUI = nullptr;
|
void* fUI = nullptr;
|
||||||
|
Mutex fPluginLoadMutex;
|
||||||
|
|
||||||
float audioDataIn1[BUFFER_SIZE];
|
float audioDataIn1[BUFFER_SIZE];
|
||||||
float audioDataIn2[BUFFER_SIZE];
|
float audioDataIn2[BUFFER_SIZE];
|
||||||
|
|
@ -414,6 +415,7 @@ struct IldaeilModule : Module {
|
||||||
CarlaEngine* const engine = carla_get_engine_from_handle(fCarlaHostHandle);
|
CarlaEngine* const engine = carla_get_engine_from_handle(fCarlaHostHandle);
|
||||||
|
|
||||||
water::XmlDocument xml(projectState);
|
water::XmlDocument xml(projectState);
|
||||||
|
const MutexLocker cml(fPluginLoadMutex);
|
||||||
engine->loadProjectInternal(xml, true);
|
engine->loadProjectInternal(xml, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -635,10 +637,12 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
|
||||||
|
|
||||||
bool idleCallbackActive = false;
|
bool idleCallbackActive = false;
|
||||||
IldaeilModule* const module;
|
IldaeilModule* const module;
|
||||||
|
Mutex& fPluginLoadMutex;
|
||||||
|
|
||||||
IldaeilWidget(IldaeilModule* const m)
|
IldaeilWidget(IldaeilModule* const m)
|
||||||
: ImGuiWidget(),
|
: ImGuiWidget(),
|
||||||
module(m)
|
module(m),
|
||||||
|
fPluginLoadMutex(m->fPluginLoadMutex)
|
||||||
{
|
{
|
||||||
if (module->fCarlaHostHandle == nullptr)
|
if (module->fCarlaHostHandle == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -828,6 +832,8 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
|
||||||
|
|
||||||
carla_set_engine_option(handle, ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, fPluginWillRunInBridgeMode, nullptr);
|
carla_set_engine_option(handle, ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, fPluginWillRunInBridgeMode, nullptr);
|
||||||
|
|
||||||
|
const MutexLocker cml(fPluginLoadMutex);
|
||||||
|
|
||||||
if (carla_add_plugin(handle, BINARY_NATIVE, fPluginType, nullptr, nullptr,
|
if (carla_add_plugin(handle, BINARY_NATIVE, fPluginType, nullptr, nullptr,
|
||||||
label, 0, 0x0, PLUGIN_OPTIONS_NULL))
|
label, 0, 0x0, PLUGIN_OPTIONS_NULL))
|
||||||
{
|
{
|
||||||
|
|
@ -1008,6 +1014,8 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread {
|
||||||
if (path != nullptr)
|
if (path != nullptr)
|
||||||
carla_set_engine_option(module->fCarlaHostHandle, ENGINE_OPTION_PLUGIN_PATH, pluginType, path);
|
carla_set_engine_option(module->fCarlaHostHandle, ENGINE_OPTION_PLUGIN_PATH, pluginType, path);
|
||||||
|
|
||||||
|
const MutexLocker cml(fPluginLoadMutex);
|
||||||
|
|
||||||
if (const uint count = carla_get_cached_plugin_count(pluginType, path))
|
if (const uint count = carla_get_cached_plugin_count(pluginType, path))
|
||||||
{
|
{
|
||||||
fPluginCount = 0;
|
fPluginCount = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue