Browse Source

Use state free-path in carla-lv2 whenever possible

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
b9c681df53
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 22 additions and 4 deletions
  1. +14
    -2
      source/plugin/carla-lv2.cpp
  2. +8
    -2
      source/utils/CarlaLv2Utils.hpp

+ 14
- 2
source/plugin/carla-lv2.cpp View File

@@ -133,7 +133,13 @@ public:

if (fLastProjectPath != nullptr)
{
std::free(fLastProjectPath);
if (fFreePath != nullptr && fFreePath->free_path != nullptr)
fFreePath->free_path(fFreePath->handle, fLastProjectPath);
#ifndef CARLA_OS_WIN
// this is not safe to call under windows
else
std::free(fLastProjectPath);
#endif
fLastProjectPath = nullptr;
}
}
@@ -456,7 +462,13 @@ public:
fLastProjectPath = nullptr;
}

std::free(last);
if (fFreePath != nullptr && fFreePath->free_path != nullptr)
fFreePath->free_path(fFreePath->handle, last);
#ifndef CARLA_OS_WIN
// this is not safe to call under windows
else
std::free(last);
#endif
}

LV2_State_Status lv2_save(const LV2_State_Store_Function store, const LV2_State_Handle handle,


+ 8
- 2
source/utils/CarlaLv2Utils.hpp View File

@@ -1,6 +1,6 @@
/*
* Carla LV2 utils
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -570,6 +570,7 @@ public:
fUsingNominal(false),
fBufferSize(0),
fSampleRate(sampleRate),
fFreePath(nullptr),
fMakePath(nullptr),
fUridMap(nullptr),
fUridUnmap(nullptr),
@@ -590,6 +591,7 @@ public:
return;
}

const LV2_State_Free_Path* freePath = nullptr;
const LV2_State_Make_Path* makePath = nullptr;
const LV2_Options_Option* options = nullptr;
const LV2_URID_Map* uridMap = nullptr;
@@ -598,7 +600,9 @@ public:

for (int i=0; features[i] != nullptr; ++i)
{
/**/ if (std::strcmp(features[i]->URI, LV2_STATE__makePath) == 0)
/**/ if (std::strcmp(features[i]->URI, LV2_STATE__freePath) == 0)
freePath = (const LV2_State_Free_Path*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_STATE__makePath) == 0)
makePath = (const LV2_State_Make_Path*)features[i]->data;
else if (std::strcmp(features[i]->URI, LV2_OPTIONS__options) == 0)
options = (const LV2_Options_Option*)features[i]->data;
@@ -667,6 +671,7 @@ public:
fUridMap = uridMap;
fURIs.map(uridMap);

fFreePath = freePath;
fMakePath = makePath;
fUridUnmap = uridUnmap;
fWorker = worker;
@@ -1183,6 +1188,7 @@ protected:
double fSampleRate;

// LV2 host features
const LV2_State_Free_Path* fFreePath;
const LV2_State_Make_Path* fMakePath;
const LV2_URID_Map* fUridMap;
const LV2_URID_Unmap* fUridUnmap;


Loading…
Cancel
Save