Browse Source

Fix crash when removing plugin with active cv control ports

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 4 years ago
parent
commit
d26ecc359a
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 43 additions and 26 deletions
  1. +5
    -0
      source/backend/CarlaEngine.hpp
  2. +24
    -19
      source/backend/engine/CarlaEnginePorts.cpp
  3. +9
    -6
      source/backend/engine/CarlaEnginePorts.hpp
  4. +5
    -1
      source/backend/plugin/CarlaPluginInternal.cpp

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

@@ -657,6 +657,11 @@ public:
*/
bool setCVSourceRange(uint32_t portIndexOffset, float minimum, float maximum);

/*!
* Destroy all ports.
*/
void cleanup();

#ifndef DOXYGEN
protected:
/** @internal */


+ 24
- 19
source/backend/engine/CarlaEnginePorts.cpp View File

@@ -389,25 +389,6 @@ bool CarlaEngineCVSourcePorts::removeCVSource(const uint32_t portIndexOffset)
return false;
}

bool CarlaEngineCVSourcePorts::setCVSourceRange(const uint32_t portIndexOffset, const float minimum, const float maximum)
{
const CarlaRecursiveMutexLocker crml(pData->rmutex);

for (int i = pData->cvs.size(); --i >= 0;)
{
CarlaEngineEventCV& ecv(pData->cvs.getReference(i));

if (ecv.indexOffset == portIndexOffset)
{
CARLA_SAFE_ASSERT_RETURN(ecv.cvPort != nullptr, false);
ecv.cvPort->setRange(minimum, maximum);
return true;
}
}

return false;
}

void CarlaEngineCVSourcePorts::initPortBuffers(const float* const* const buffers,
const uint32_t frames,
const bool sampleAccurate,
@@ -478,6 +459,30 @@ void CarlaEngineCVSourcePorts::initPortBuffers(const float* const* const buffers
}
}

bool CarlaEngineCVSourcePorts::setCVSourceRange(const uint32_t portIndexOffset, const float minimum, const float maximum)
{
const CarlaRecursiveMutexLocker crml(pData->rmutex);

for (int i = pData->cvs.size(); --i >= 0;)
{
CarlaEngineEventCV& ecv(pData->cvs.getReference(i));

if (ecv.indexOffset == portIndexOffset)
{
CARLA_SAFE_ASSERT_RETURN(ecv.cvPort != nullptr, false);
ecv.cvPort->setRange(minimum, maximum);
return true;
}
}

return false;
}

void CarlaEngineCVSourcePorts::cleanup()
{
pData->cleanup();
}

/*
void CarlaEngineCVSourcePorts::mixWithCvBuffer(const float* const buffer,
const uint32_t frames,


+ 9
- 6
source/backend/engine/CarlaEnginePorts.hpp View File

@@ -50,14 +50,17 @@ struct CarlaEngineCVSourcePorts::ProtectedData {

~ProtectedData()
{
{
const CarlaRecursiveMutexLocker crml(rmutex);
CARLA_SAFE_ASSERT(cvs.size() == 0);
}

void cleanup()
{
const CarlaRecursiveMutexLocker crml(rmutex);

for (int i = cvs.size(); --i >= 0;)
delete cvs[i].cvPort;
for (int i = cvs.size(); --i >= 0;)
delete cvs[i].cvPort;

cvs.clear();
}
cvs.clear();
}

CARLA_DECLARE_NON_COPY_STRUCT(ProtectedData)


+ 5
- 1
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -173,7 +173,11 @@ void PluginEventData::clear() noexcept
}

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
cvSourcePorts = nullptr;
if (cvSourcePorts != nullptr)
{
cvSourcePorts->cleanup();
cvSourcePorts = nullptr;
}
#endif
}



Loading…
Cancel
Save