|
@@ -74,6 +74,7 @@ using water::String; |
|
|
static bool gIsInitiated = false; |
|
|
static bool gIsInitiated = false; |
|
|
static volatile bool gCloseNow = false; |
|
|
static volatile bool gCloseNow = false; |
|
|
static volatile bool gSaveNow = false; |
|
|
static volatile bool gSaveNow = false; |
|
|
|
|
|
static volatile bool gLoadNow = false; |
|
|
|
|
|
|
|
|
#if defined(CARLA_OS_UNIX) |
|
|
#if defined(CARLA_OS_UNIX) |
|
|
static void closeSignalHandler(int) noexcept |
|
|
static void closeSignalHandler(int) noexcept |
|
@@ -84,6 +85,10 @@ static void saveSignalHandler(int) noexcept |
|
|
{ |
|
|
{ |
|
|
gSaveNow = true; |
|
|
gSaveNow = true; |
|
|
} |
|
|
} |
|
|
|
|
|
static void loadSignalHandler(int) noexcept |
|
|
|
|
|
{ |
|
|
|
|
|
gLoadNow = true; |
|
|
|
|
|
} |
|
|
#elif defined(CARLA_OS_WIN) |
|
|
#elif defined(CARLA_OS_WIN) |
|
|
static BOOL WINAPI winSignalHandler(DWORD dwCtrlType) noexcept |
|
|
static BOOL WINAPI winSignalHandler(DWORD dwCtrlType) noexcept |
|
|
{ |
|
|
{ |
|
@@ -112,6 +117,11 @@ static void initSignalHandler() |
|
|
sig.sa_flags = SA_RESTART; |
|
|
sig.sa_flags = SA_RESTART; |
|
|
sigemptyset(&sig.sa_mask); |
|
|
sigemptyset(&sig.sa_mask); |
|
|
sigaction(SIGUSR1, &sig, nullptr); |
|
|
sigaction(SIGUSR1, &sig, nullptr); |
|
|
|
|
|
|
|
|
|
|
|
sig.sa_handler = loadSignalHandler; |
|
|
|
|
|
sig.sa_flags = SA_RESTART; |
|
|
|
|
|
sigemptyset(&sig.sa_mask); |
|
|
|
|
|
sigaction(SIGUSR2, &sig, nullptr); |
|
|
#elif defined(CARLA_OS_WIN) |
|
|
#elif defined(CARLA_OS_WIN) |
|
|
SetConsoleCtrlHandler(winSignalHandler, TRUE); |
|
|
SetConsoleCtrlHandler(winSignalHandler, TRUE); |
|
|
#endif |
|
|
#endif |
|
@@ -122,6 +132,31 @@ static void initSignalHandler() |
|
|
static String gProjectFilename; |
|
|
static String gProjectFilename; |
|
|
static CarlaHostHandle gHostHandle; |
|
|
static CarlaHostHandle gHostHandle; |
|
|
|
|
|
|
|
|
|
|
|
static void gLoadPluginState() |
|
|
|
|
|
{ |
|
|
|
|
|
if (File(gProjectFilename).existsAsFile()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (carla_load_plugin_state(gHostHandle, 0, gProjectFilename.toRawUTF8())) |
|
|
|
|
|
carla_stdout("Plugin state loaded successfully"); |
|
|
|
|
|
else |
|
|
|
|
|
carla_stderr("Plugin state load failed, error was:\n%s", carla_get_last_error(gHostHandle)); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
carla_stdout("Previous plugin state in '%s' is non-existent, will use default state", |
|
|
|
|
|
gProjectFilename.toRawUTF8()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void gSavePluginState() |
|
|
|
|
|
{ |
|
|
|
|
|
if (gProjectFilename.isNotEmpty()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (! carla_save_plugin_state(gHostHandle, 0, gProjectFilename.toRawUTF8())) |
|
|
|
|
|
carla_stderr("Plugin preset save failed, error was:\n%s", carla_get_last_error(gHostHandle)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static void gIdle() |
|
|
static void gIdle() |
|
|
{ |
|
|
{ |
|
|
carla_engine_idle(gHostHandle); |
|
|
carla_engine_idle(gHostHandle); |
|
@@ -129,12 +164,13 @@ static void gIdle() |
|
|
if (gSaveNow) |
|
|
if (gSaveNow) |
|
|
{ |
|
|
{ |
|
|
gSaveNow = false; |
|
|
gSaveNow = false; |
|
|
|
|
|
gSavePluginState(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (gProjectFilename.isNotEmpty()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (! carla_save_plugin_state(gHostHandle, 0, gProjectFilename.toRawUTF8())) |
|
|
|
|
|
carla_stderr("Plugin preset save failed, error was:\n%s", carla_get_last_error(gHostHandle)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (gLoadNow) |
|
|
|
|
|
{ |
|
|
|
|
|
gLoadNow = false; |
|
|
|
|
|
gLoadPluginState(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -212,18 +248,7 @@ public: |
|
|
if (! File::isAbsolutePath(gProjectFilename)) |
|
|
if (! File::isAbsolutePath(gProjectFilename)) |
|
|
gProjectFilename = File::getCurrentWorkingDirectory().getChildFile(gProjectFilename).getFullPathName(); |
|
|
gProjectFilename = File::getCurrentWorkingDirectory().getChildFile(gProjectFilename).getFullPathName(); |
|
|
|
|
|
|
|
|
if (File(gProjectFilename).existsAsFile()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (carla_load_plugin_state(gHostHandle, 0, gProjectFilename.toRawUTF8())) |
|
|
|
|
|
carla_stdout("Plugin state loaded successfully"); |
|
|
|
|
|
else |
|
|
|
|
|
carla_stderr("Plugin state load failed, error was:\n%s", carla_get_last_error(gHostHandle)); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
carla_stdout("Previous plugin state in '%s' is non-existent, will start from default state", |
|
|
|
|
|
gProjectFilename.toRawUTF8()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
gLoadPluginState(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
gIsInitiated = true; |
|
|
gIsInitiated = true; |
|
|