Browse Source

carla-lv2: Fallback to maxBlockLength if host doesn't support nominal

tags/1.9.7
falkTX 9 years ago
parent
commit
71b9d0cbc4
1 changed files with 38 additions and 3 deletions
  1. +38
    -3
      source/plugin/carla-lv2.cpp

+ 38
- 3
source/plugin/carla-lv2.cpp View File

@@ -85,6 +85,7 @@ public:
fIsOffline(false), fIsOffline(false),
fBufferSize(0), fBufferSize(0),
fSampleRate(sampleRate), fSampleRate(sampleRate),
fUsingNominal(false),
fUridMap(nullptr), fUridMap(nullptr),
fURIs(), fURIs(),
fUI(), fUI(),
@@ -150,12 +151,30 @@ public:
CARLA_SAFE_ASSERT_CONTINUE(value > 0); CARLA_SAFE_ASSERT_CONTINUE(value > 0);


fBufferSize = static_cast<uint32_t>(value); fBufferSize = static_cast<uint32_t>(value);
fUsingNominal = true;
} }
else else
{
carla_stderr("Host provides nominalBlockLength but has wrong value type"); carla_stderr("Host provides nominalBlockLength but has wrong value type");
}
break; break;
} }

if (options[i].key == uridMap->map(uridMap->handle, LV2_BUF_SIZE__maxBlockLength))
{
if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Int))
{
const int value(*(const int*)options[i].value);
CARLA_SAFE_ASSERT_CONTINUE(value > 0);

fBufferSize = static_cast<uint32_t>(value);
}
else
{
carla_stderr("Host provides maxBlockLength but has wrong value type");
}
// no break, continue in case host supports nominalBlockLength
}
} }


fUridMap = uridMap; fUridMap = uridMap;
@@ -596,7 +615,7 @@ public:
{ {
if (options[i].key == fUridMap->map(fUridMap->handle, LV2_BUF_SIZE__nominalBlockLength)) if (options[i].key == fUridMap->map(fUridMap->handle, LV2_BUF_SIZE__nominalBlockLength))
{ {
if (options[i].type == fUridMap->map(fUridMap->handle, LV2_ATOM__Int))
if (options[i].type == fURIs.atomInt)
{ {
const int value(*(const int*)options[i].value); const int value(*(const int*)options[i].value);
CARLA_SAFE_ASSERT_CONTINUE(value > 0); CARLA_SAFE_ASSERT_CONTINUE(value > 0);
@@ -609,9 +628,24 @@ public:
else else
carla_stderr("Host changed nominalBlockLength but with wrong value type"); carla_stderr("Host changed nominalBlockLength but with wrong value type");
} }
else if (options[i].key == fUridMap->map(fUridMap->handle, LV2_BUF_SIZE__maxBlockLength) && ! fUsingNominal)
{
if (options[i].type == fURIs.atomInt)
{
const int value(*(const int*)options[i].value);
CARLA_SAFE_ASSERT_CONTINUE(value > 0);

fBufferSize = static_cast<uint32_t>(value);

if (fDescriptor->dispatcher != nullptr)
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, value, nullptr, 0.0f);
}
else
carla_stderr("Host changed maxBlockLength but with wrong value type");
}
else if (options[i].key == fUridMap->map(fUridMap->handle, LV2_CORE__sampleRate)) else if (options[i].key == fUridMap->map(fUridMap->handle, LV2_CORE__sampleRate))
{ {
if (options[i].type == fUridMap->map(fUridMap->handle, LV2_ATOM__Double))
if (options[i].type == fURIs.atomDouble)
{ {
const double value(*(const double*)options[i].value); const double value(*(const double*)options[i].value);
CARLA_SAFE_ASSERT_CONTINUE(value > 0.0); CARLA_SAFE_ASSERT_CONTINUE(value > 0.0);
@@ -1027,6 +1061,7 @@ private:
bool fIsOffline; bool fIsOffline;
uint32_t fBufferSize; uint32_t fBufferSize;
double fSampleRate; double fSampleRate;
bool fUsingNominal;


const LV2_URID_Map* fUridMap; const LV2_URID_Map* fUridMap;




Loading…
Cancel
Save