Browse Source

Load state of old win/osx VST2 plugins (before juce/water breakage)

tags/1.9.8
falkTX 7 years ago
parent
commit
9a0116fc6d
1 changed files with 44 additions and 2 deletions
  1. +44
    -2
      source/backend/plugin/CarlaPluginVST2.cpp

+ 44
- 2
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -23,18 +23,22 @@
#include "CarlaMathUtils.hpp" #include "CarlaMathUtils.hpp"
#include "CarlaPluginUI.hpp" #include "CarlaPluginUI.hpp"


#include <pthread.h>

#ifdef CARLA_OS_MAC #ifdef CARLA_OS_MAC
# import <Foundation/Foundation.h> # import <Foundation/Foundation.h>
#endif #endif


#include <pthread.h>

#include "water/memory/ByteOrder.h"

#undef VST_FORCE_DEPRECATED #undef VST_FORCE_DEPRECATED
#define VST_FORCE_DEPRECATED 0 #define VST_FORCE_DEPRECATED 0


#undef kEffectMagic #undef kEffectMagic
#define kEffectMagic (CCONST( 'V', 's', 't', 'P' )) #define kEffectMagic (CCONST( 'V', 's', 't', 'P' ))


using water::ByteOrder;

CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


// ----------------------------------------------------- // -----------------------------------------------------
@@ -362,6 +366,9 @@ public:
CARLA_SAFE_ASSERT_RETURN(data != nullptr,); CARLA_SAFE_ASSERT_RETURN(data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSize > 0,); CARLA_SAFE_ASSERT_RETURN(dataSize > 0,);


if (loadOldSaveFormat(data, dataSize))
return;

if (fLastChunk != nullptr) if (fLastChunk != nullptr)
std::free(fLastChunk); std::free(fLastChunk);


@@ -2347,6 +2354,41 @@ private:


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


static bool compareMagic (int32_t magic, const char* name) noexcept
{
return magic == (int32_t)ByteOrder::littleEndianInt (name)
|| magic == (int32_t)ByteOrder::bigEndianInt (name);
}

static int32_t fxbSwap(const int32_t x) noexcept
{
return (int32_t)ByteOrder::swapIfLittleEndian ((uint32_t) x);
}

bool loadOldSaveFormat(const void* const data, const std::size_t dataSize)
{
if (dataSize < 28)
return false;

const int32_t* const set = (const int32_t*)data;

if (! compareMagic(set[0], "CcnK"))
return false;
if (! compareMagic(set[2], "FBCh"))
return false;
if (fxbSwap(set[3]) > 1)
return false;

const int32_t chunkSize = fxbSwap(set[39]);
CARLA_SAFE_ASSERT_RETURN(chunkSize > 0, false);

if (static_cast<const std::size_t>(chunkSize + 160) > dataSize)
return false;

setChunkData(&set[40], static_cast<const std::size_t>(chunkSize));
return true;
}

static intptr_t carla_vst_hostCanDo(const char* const feature) static intptr_t carla_vst_hostCanDo(const char* const feature)
{ {
carla_debug("carla_vst_hostCanDo(\"%s\")", feature); carla_debug("carla_vst_hostCanDo(\"%s\")", feature);


Loading…
Cancel
Save