Browse Source

Save custom data for plugin bridges

Fixes #611
tags/v1.9.9
falkTX 6 years ago
parent
commit
7a6e711160
4 changed files with 23 additions and 3 deletions
  1. +7
    -0
      source/backend/CarlaPlugin.hpp
  2. +3
    -1
      source/backend/engine/CarlaEngineBridge.cpp
  3. +6
    -0
      source/backend/plugin/CarlaPlugin.cpp
  4. +7
    -2
      source/backend/plugin/CarlaPluginBridge.cpp

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

@@ -262,6 +262,13 @@ public:
*/ */
const CustomData& getCustomData(const uint32_t index) const noexcept; const CustomData& getCustomData(const uint32_t index) const noexcept;


/*!
* Give the plugin a change to update its custom data sets.
*
* @see getCustomDataCount() and getCustomData()
*/
virtual void updateCustomData() noexcept;

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


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

@@ -764,7 +764,9 @@ public:
const uint32_t valueSize(fShmNonRtClientControl.readUInt()); const uint32_t valueSize(fShmNonRtClientControl.readUInt());
char valueStr[valueSize+1]; char valueStr[valueSize+1];
carla_zeroChars(valueStr, valueSize+1); carla_zeroChars(valueStr, valueSize+1);
fShmNonRtClientControl.readCustomData(valueStr, valueSize);

if (valueSize > 0)
fShmNonRtClientControl.readCustomData(valueStr, valueSize);


if (plugin != nullptr && plugin->isEnabled()) if (plugin != nullptr && plugin->isEnabled())
plugin->setCustomData(typeStr, keyStr, valueStr, true); plugin->setCustomData(typeStr, keyStr, valueStr, true);


+ 6
- 0
source/backend/plugin/CarlaPlugin.cpp View File

@@ -269,6 +269,10 @@ const CustomData& CarlaPlugin::getCustomData(const uint32_t index) const noexcep
return pData->custom.getAt(index, kCustomDataFallback); return pData->custom.getAt(index, kCustomDataFallback);
} }


void CarlaPlugin::updateCustomData() noexcept
{
}

std::size_t CarlaPlugin::getChunkData(void** const dataPtr) noexcept std::size_t CarlaPlugin::getChunkData(void** const dataPtr) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(dataPtr != nullptr, 0); CARLA_SAFE_ASSERT_RETURN(dataPtr != nullptr, 0);
@@ -603,6 +607,8 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave)
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Custom Data // Custom Data


updateCustomData();

for (LinkedList<CustomData>::Itenerator it = pData->custom.begin2(); it.valid(); it.next()) for (LinkedList<CustomData>::Itenerator it = pData->custom.begin2(); it.valid(); it.next())
{ {
const CustomData& cData(it.getValue(kCustomDataFallback)); const CustomData& cData(it.getValue(kCustomDataFallback));


+ 7
- 2
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -477,7 +477,10 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Information (current data) // Information (current data)


// TODO - missing getCustomData
void updateCustomData() noexcept override
{
waitForSaved();
}


std::size_t getChunkData(void** const dataPtr) noexcept override std::size_t getChunkData(void** const dataPtr) noexcept override
{ {
@@ -816,7 +819,9 @@ public:
fShmNonRtClientControl.writeCustomData(key, keyLen); fShmNonRtClientControl.writeCustomData(key, keyLen);


fShmNonRtClientControl.writeUInt(valueLen); fShmNonRtClientControl.writeUInt(valueLen);
fShmNonRtClientControl.writeCustomData(value, valueLen);

if (valueLen > 0)
fShmNonRtClientControl.writeCustomData(value, valueLen);


fShmNonRtClientControl.commitWrite(); fShmNonRtClientControl.commitWrite();
} }


Loading…
Cancel
Save