Browse Source

Implement initial MOD LV2 license API

pull/20/merge
falkTX 6 years ago
parent
commit
aad1005802
2 changed files with 38 additions and 0 deletions
  1. +28
    -0
      distrho/src/DistrhoPluginLV2.cpp
  2. +10
    -0
      distrho/src/DistrhoPluginLV2export.cpp

+ 28
- 0
distrho/src/DistrhoPluginLV2.cpp View File

@@ -30,6 +30,10 @@
#include "lv2/lv2_kxstudio_properties.h"
#include "lv2/lv2_programs.h"

#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
# include "libmodauth.h"
#endif

#ifdef noexcept
# undef noexcept
#endif
@@ -58,6 +62,9 @@ class PluginLv2
public:
PluginLv2(const double sampleRate, const LV2_URID_Map* const uridMap, const LV2_Worker_Schedule* const worker, const bool usingNominal)
: fUsingNominal(usingNominal),
#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
fRunCount(0),
#endif
fPortControls(nullptr),
fLastControlValues(nullptr),
fSampleRate(sampleRate),
@@ -525,12 +532,21 @@ public:
// Run plugin
if (sampleCount != 0)
{
#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
fRunCount = mod_license_run_begin(fRunCount, sampleCount);
#endif

#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
fPlugin.run(fPortAudioIns, fPortAudioOuts, sampleCount, fMidiEvents, midiEventCount);
#else
fPlugin.run(fPortAudioIns, fPortAudioOuts, sampleCount);
#endif

#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
for (uint32_t i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
mod_license_run_noise(fRunCount, fPortAudioOuts[i], sampleCount, i);
#endif

#if DISTRHO_PLUGIN_WANT_TIMEPOS
// update timePos for next callback
if (d_isNotZero(fLastPositionData.speed))
@@ -847,6 +863,10 @@ private:
PluginExporter fPlugin;
const bool fUsingNominal; // if false use maxBlockLength

#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
uint32_t fRunCount;
#endif

// LV2 ports
#if DISTRHO_PLUGIN_NUM_INPUTS > 0
const float* fPortAudioIns[DISTRHO_PLUGIN_NUM_INPUTS];
@@ -1035,6 +1055,10 @@ static LV2_Handle lv2_instantiate(const LV2_Descriptor*, double sampleRate, cons
}
#endif

#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
mod_check_license(features, DISTRHO_PLUGIN_URI);
#endif

d_lastBufferSize = 0;
bool usingNominal = false;

@@ -1194,7 +1218,11 @@ static const void* lv2_extension_data(const char* uri)
return &directaccess;
#endif

#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
return mod_license_interface(uri);
#else
return nullptr;
#endif
}

#undef instancePtr


+ 10
- 0
distrho/src/DistrhoPluginLV2export.cpp View File

@@ -34,6 +34,10 @@
#include "lv2/lv2_kxstudio_properties.h"
#include "lv2/lv2_programs.h"

#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
# include "mod-license.h"
#endif

#include <fstream>
#include <iostream>

@@ -224,6 +228,9 @@ void lv2_generate_ttl(const char* const basename)
#endif
#if DISTRHO_PLUGIN_WANT_PROGRAMS
pluginString += ",\n <" LV2_PROGRAMS__Interface "> ";
#endif
#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
pluginString += ",\n <" MOD_LICENSE__interface "> ";
#endif
pluginString += ";\n\n";

@@ -241,6 +248,9 @@ void lv2_generate_ttl(const char* const basename)
pluginString += ",\n <" LV2_URID__map "> ";
#if DISTRHO_PLUGIN_WANT_STATE
pluginString += ",\n <" LV2_WORKER__schedule "> ";
#endif
#ifdef DISTRHO_PLUGIN_LICENSED_FOR_MOD
pluginString += ",\n <" MOD_LICENSE__feature "> ";
#endif
pluginString += ";\n\n";



Loading…
Cancel
Save