Browse Source

Remove a hardcoded custom-data key, ignore properties on bridges

tags/v1.9.9
falkTX 7 years ago
parent
commit
34376b2d8f
4 changed files with 63 additions and 56 deletions
  1. +5
    -0
      source/backend/CarlaPlugin.hpp
  2. +1
    -1
      source/backend/engine/CarlaEngineBridge.cpp
  3. +10
    -2
      source/backend/plugin/CarlaPlugin.cpp
  4. +47
    -53
      source/backend/plugin/CarlaPluginLV2.cpp

+ 5
- 0
source/backend/CarlaPlugin.hpp View File

@@ -269,6 +269,11 @@ public:
*/
virtual void updateCustomData() noexcept;

/*!
* Helper function for LV2 plugins, internal use only!
*/
virtual void restoreLV2State() noexcept;

/*!
* Get the complete plugin chunk data into @a dataPtr.
*


+ 1
- 1
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -860,7 +860,7 @@ public:
{
const CustomData& cdata(plugin->getCustomData(i));

if (std::strcmp(cdata.type, CUSTOM_DATA_TYPE_STRING) == 0 && std::strcmp(cdata.key, "CarlaLoadLv2StateNow") == 0 && std::strcmp(cdata.value, "true") == 0)
if (std::strcmp(cdata.type, CUSTOM_DATA_TYPE_PROPERTY) == 0)
continue;

const uint32_t typeLen(static_cast<uint32_t>(std::strlen(cdata.type)));


+ 10
- 2
source/backend/plugin/CarlaPlugin.cpp View File

@@ -273,6 +273,10 @@ void CarlaPlugin::updateCustomData() noexcept
{
}

void CarlaPlugin::restoreLV2State() noexcept
{
}

std::size_t CarlaPlugin::getChunkData(void** const dataPtr) noexcept
{
CARLA_SAFE_ASSERT_RETURN(dataPtr != nullptr, 0);
@@ -837,7 +841,7 @@ void CarlaPlugin::loadStateSave(const CarlaStateSave& stateSave)
// Part 5x - set lv2 state

if (pluginType == PLUGIN_LV2 && pData->custom.count() > 0)
setCustomData(CUSTOM_DATA_TYPE_STRING, "CarlaLoadLv2StateNow", "true", true);
restoreLV2State();

// ---------------------------------------------------------------
// Part 6 - set chunk
@@ -1637,7 +1641,11 @@ void CarlaPlugin::setCustomData(const char* const type, const char* const key, c
// Ignore some keys
if (std::strcmp(type, CUSTOM_DATA_TYPE_STRING) == 0)
{
if (std::strncmp(key, "OSC:", 4) == 0 || std::strncmp(key, "CarlaAlternateFile", 18) == 0 || std::strcmp(key, "guiVisible") == 0)
const PluginType ptype = getType();

if ((ptype == PLUGIN_INTERNAL && std::strncmp(key, "CarlaAlternateFile", 18) == 0) ||
(ptype == PLUGIN_DSSI && std::strcmp (key, "guiVisible") == 0) ||
(ptype == PLUGIN_LV2 && std::strncmp(key, "OSC:", 4) == 0))
return;
}



+ 47
- 53
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -823,7 +823,53 @@ public:
// -------------------------------------------------------------------
// Information (current data)

// nothing
void restoreLV2State() noexcept override
{
if (fExt.state == nullptr)
return;

LV2_State_Status status = LV2_STATE_ERR_UNKNOWN;

{
const ScopedSingleProcessLocker spl(this, true);

try {
status = fExt.state->restore(fHandle, carla_lv2_state_retrieve, this, 0, fFeatures);
} catch(...) {}

if (fHandle2 != nullptr)
{
try {
fExt.state->restore(fHandle, carla_lv2_state_retrieve, this, 0, fFeatures);
} catch(...) {}
}
}

switch (status)
{
case LV2_STATE_SUCCESS:
carla_debug("CarlaPluginLV2::updateLV2State() - success");
break;
case LV2_STATE_ERR_UNKNOWN:
carla_stderr("CarlaPluginLV2::updateLV2State() - unknown error");
break;
case LV2_STATE_ERR_BAD_TYPE:
carla_stderr("CarlaPluginLV2::updateLV2State() - error, bad type");
break;
case LV2_STATE_ERR_BAD_FLAGS:
carla_stderr("CarlaPluginLV2::updateLV2State() - error, bad flags");
break;
case LV2_STATE_ERR_NO_FEATURE:
carla_stderr("CarlaPluginLV2::updateLV2State() - error, missing feature");
break;
case LV2_STATE_ERR_NO_PROPERTY:
carla_stderr("CarlaPluginLV2::updateLV2State() - error, missing property");
break;
case LV2_STATE_ERR_NO_SPACE:
carla_stderr("CarlaPluginLV2::updateLV2State() - error, insufficient space");
break;
}
}

// -------------------------------------------------------------------
// Information (per-plugin data)
@@ -1169,57 +1215,6 @@ public:
if (std::strcmp(type, CUSTOM_DATA_TYPE_PROPERTY) == 0)
return CarlaPlugin::setCustomData(type, key, value, sendGui);

// we should only call state restore once
// so inject this in CarlaPlugin::loadSaveState
if (std::strcmp(type, CUSTOM_DATA_TYPE_STRING) == 0 && std::strcmp(key, "CarlaLoadLv2StateNow") == 0 && std::strcmp(value, "true") == 0)
{
if (fExt.state == nullptr)
return;

LV2_State_Status status = LV2_STATE_ERR_UNKNOWN;

{
const ScopedSingleProcessLocker spl(this, true);

try {
status = fExt.state->restore(fHandle, carla_lv2_state_retrieve, this, 0, fFeatures);
} catch(...) {}

if (fHandle2 != nullptr)
{
try {
fExt.state->restore(fHandle, carla_lv2_state_retrieve, this, 0, fFeatures);
} catch(...) {}
}
}

switch (status)
{
case LV2_STATE_SUCCESS:
carla_debug("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - success", type, key, bool2str(sendGui));
break;
case LV2_STATE_ERR_UNKNOWN:
carla_stderr("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - unknown error", type, key, bool2str(sendGui));
break;
case LV2_STATE_ERR_BAD_TYPE:
carla_stderr("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - error, bad type", type, key, bool2str(sendGui));
break;
case LV2_STATE_ERR_BAD_FLAGS:
carla_stderr("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - error, bad flags", type, key, bool2str(sendGui));
break;
case LV2_STATE_ERR_NO_FEATURE:
carla_stderr("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - error, missing feature", type, key, bool2str(sendGui));
break;
case LV2_STATE_ERR_NO_PROPERTY:
carla_stderr("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - error, missing property", type, key, bool2str(sendGui));
break;
case LV2_STATE_ERR_NO_SPACE:
carla_stderr("CarlaPluginLV2::setCustomData(\"%s\", \"%s\", <value>, %s) - error, insufficient space", type, key, bool2str(sendGui));
break;
}
return;
}

CarlaPlugin::setCustomData(type, key, value, sendGui);
}

@@ -4541,7 +4536,6 @@ public:
carla_debug("CarlaPluginLV2::handleStateRetrieve(%i, %p, %p, %p)", key, size, type, flags);

const char* const skey(carla_lv2_urid_unmap(this, key));

CARLA_SAFE_ASSERT_RETURN(skey != nullptr, nullptr);

const char* stype = nullptr;


Loading…
Cancel
Save