Browse Source

Simplify some minor bridge code

tags/1.9.4
falkTX 10 years ago
parent
commit
65b6c57175
1 changed files with 31 additions and 31 deletions
  1. +31
    -31
      source/bridges/CarlaBridgePlugin.cpp

+ 31
- 31
source/bridges/CarlaBridgePlugin.cpp View File

@@ -102,9 +102,31 @@ static void initSignalHandler()


// ------------------------------------------------------------------------- // -------------------------------------------------------------------------


#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
static CarlaBridge::CarlaBridgeClient* gBridgeClient = nullptr; static CarlaBridge::CarlaBridgeClient* gBridgeClient = nullptr;
static CarlaString gProjectFilename;

static void gIdle()
{
carla_engine_idle();

if (gBridgeClient != nullptr)
gBridgeClient->oscIdle();


if (gSaveNow)
{
gSaveNow = false;

if (gProjectFilename.isNotEmpty())
{
if (! carla_save_plugin_state(0, gProjectFilename))
carla_stderr("Plugin preset save failed, error was:\n%s", carla_get_last_error());
}
}
}

// -------------------------------------------------------------------------

#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
class CarlaJuceApp : public JUCEApplication, class CarlaJuceApp : public JUCEApplication,
private Timer private Timer
{ {
@@ -135,10 +157,7 @@ public:


void timerCallback() override void timerCallback() override
{ {
carla_engine_idle();

if (gBridgeClient != nullptr)
gBridgeClient->oscIdle();
gIdle();


if (gCloseNow) if (gCloseNow)
{ {
@@ -212,20 +231,20 @@ public:
carla_stderr("Plugin preset load failed, error was:\n%s", carla_get_last_error()); carla_stderr("Plugin preset load failed, error was:\n%s", carla_get_last_error());
} }


gIsInitiated = true;
gBridgeClient = this;
gIsInitiated = true;


#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) #if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)
gBridgeClient = this;
JUCEApplicationBase::createInstance = &juce_CreateApplication; JUCEApplicationBase::createInstance = &juce_CreateApplication;
JUCEApplicationBase::main(JUCE_MAIN_FUNCTION_ARGS); JUCEApplicationBase::main(JUCE_MAIN_FUNCTION_ARGS);
gBridgeClient = nullptr;
#else #else
for (; ! gCloseNow;) for (; ! gCloseNow;)
{ {
idle();
gIdle();
carla_msleep(25); carla_msleep(25);
} }
#endif #endif
gBridgeClient = nullptr;


carla_set_engine_about_to_close(); carla_set_engine_about_to_close();
carla_remove_plugin(0); carla_remove_plugin(0);
@@ -234,32 +253,13 @@ public:
return; (void)argc; (void)argv; return; (void)argc; (void)argv;
} }


void idle()
{
CARLA_SAFE_ASSERT_RETURN(fEngine != nullptr,);

carla_engine_idle();
CarlaBridgeClient::oscIdle();

if (gSaveNow)
{
gSaveNow = false;

if (fProjFilename.isNotEmpty())
{
if (! carla_save_plugin_state(0, fProjFilename.toRawUTF8()))
carla_stderr("Plugin preset save failed, error was:\n%s", carla_get_last_error());
}
}
}

// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// plugin management // plugin management


void saveNow()
void prepareForSave()
{ {
CARLA_SAFE_ASSERT_RETURN(fEngine != nullptr,); CARLA_SAFE_ASSERT_RETURN(fEngine != nullptr,);
carla_debug("CarlaPluginClient::saveNow()");
carla_debug("CarlaPluginClient::prepareForSave()");


carla_prepare_for_save(0); carla_prepare_for_save(0);


@@ -393,7 +393,7 @@ int CarlaBridgeOsc::handleMsgPluginSaveNow()
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1); CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
carla_debug("CarlaBridgeOsc::handleMsgPluginSaveNow()"); carla_debug("CarlaBridgeOsc::handleMsgPluginSaveNow()");


((CarlaPluginClient*)fClient)->saveNow();
((CarlaPluginClient*)fClient)->prepareForSave();
return 0; return 0;
} }




Loading…
Cancel
Save