Browse Source

Patch juce processors to work in discovery (no UI code)

tags/1.9.4
falkTX 12 years ago
parent
commit
8b485383e6
4 changed files with 49 additions and 9 deletions
  1. +12
    -8
      source/discovery/carla-discovery.cpp
  2. +25
    -1
      source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp
  3. +8
    -0
      source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp
  4. +4
    -0
      source/modules/juce_audio_processors/processors/juce_AudioProcessor.h

+ 12
- 8
source/discovery/carla-discovery.cpp View File

@@ -15,17 +15,16 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

// if using juce, don't build UI stuff
#define JUCE_PLUGIN_HOST_NO_UI

#include "CarlaBackendUtils.hpp"
#include "CarlaLibUtils.hpp"
#include "CarlaMathUtils.hpp"
#include "CarlaMIDI.h"

#ifdef HAVE_JUCE
# define JUCE_PLUGIN_HOST_NO_UI
# include "juce_audio_processors.h"
# ifndef VESTIGE_HEADER
# undef WANT_VST
# endif
#else
# undef WANT_CSOUND
#endif
@@ -80,7 +79,7 @@ static void print_lib_error(const char* const filename)
DISCOVERY_OUT("error", error);
}

#ifdef WANT_VST
#if defined(WANT_VST) && (defined(VESTIGE_HEADER) || ! defined(HAVE_JUCE))
// --------------------------------------------------------------------------
// VST stuff

@@ -138,9 +137,9 @@ static intptr_t vstHostCanDo(const char* const feature)
if (std::strcmp(feature, "startStopProcess") == 0)
return 1;
if (std::strcmp(feature, "supportShell") == 0)
return -1; // FIXME
return 1;
if (std::strcmp(feature, "shellCategory") == 0)
return -1; // FIXME
return 1;

// non-official features found in some plugins:
// "asyncProcessing"
@@ -1211,7 +1210,7 @@ static void do_lv2_check(const char* const bundle, const bool init)

static void do_vst_check(void*& libHandle, const bool init)
{
#ifdef WANT_VST
#if defined(WANT_VST) && (defined(VESTIGE_HEADER) || ! defined(HAVE_JUCE))
VST_Function vstFn = (VST_Function)lib_symbol(libHandle, "VSTPluginMain");

if (vstFn == nullptr)
@@ -1941,6 +1940,11 @@ int main(int argc, char* argv[])
lib_close(handle);

return 0;

#if defined(WANT_VST) && defined(HAVE_JUCE) && ! defined(VESTIGE_HEADER)
// unused func
do_vst_check(handle, doInit);
#endif
}

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


+ 25
- 1
source/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp View File

@@ -187,6 +187,7 @@ static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstI
static int shellUIDToCreate = 0;
static int insideVSTCallback = 0;
#ifndef JUCE_PLUGIN_HOST_NO_UI
class IdleCallRecursionPreventer
{
public:
@@ -210,6 +211,9 @@ private:
};
class VSTPluginWindow;
#else
struct IdleCallRecursionPreventer{};
#endif
//==============================================================================
// Change this to disable logging of various VST activities
@@ -236,6 +240,7 @@ static void* NewCFMFromMachO (void* const machofp) noexcept
}
#endif
#ifndef JUCE_PLUGIN_HOST_NO_UI
//==============================================================================
#if JUCE_LINUX
@@ -340,6 +345,7 @@ namespace
}
}
#endif
#endif
//==============================================================================
@@ -710,9 +716,13 @@ static const int defaultVSTBlockSizeValue = 512;
//==============================================================================
//==============================================================================
#ifndef JUCE_PLUGIN_HOST_NO_UI
class VSTPluginInstance : public AudioPluginInstance,
private Timer,
private AsyncUpdater
#else
class VSTPluginInstance : public AudioPluginInstance
#endif
{
public:
VSTPluginInstance (const ModuleHandle::Ptr& module_)
@@ -783,8 +793,10 @@ public:
UseResFile (module->resFileId);
#endif
#ifndef JUCE_PLUGIN_HOST_NO_UI
// Must delete any editors before deleting the plugin instance!
jassert (getActiveEditor() == 0);
#endif
_fpreset(); // some dodgy plugs fuck around with this
@@ -1242,6 +1254,7 @@ public:
void setCurrentProgramStateInformation (const void* data, int size) override { loadFromFXBFile (data, size); }
//==============================================================================
#ifndef JUCE_PLUGIN_HOST_NO_UI
void timerCallback() override
{
if (dispatch (effIdle, 0, 0, 0, 0) == 0)
@@ -1253,6 +1266,7 @@ public:
// indicates that something about the plugin has changed..
updateHostDisplay();
}
#endif
VstIntPtr handleCallback (VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt)
{
@@ -1270,6 +1284,7 @@ public:
#pragma warning (pop)
#endif
#ifndef JUCE_PLUGIN_HOST_NO_UI
case audioMasterIdle:
if (insideVSTCallback == 0 && MessageManager::getInstance()->isThisTheMessageThread())
{
@@ -1298,6 +1313,7 @@ public:
case audioMasterUpdateDisplay: triggerAsyncUpdate(); break;
case audioMasterIOChanged: setLatencySamples (effect->initialDelay); break;
case audioMasterNeedIdle: startTimer (50); break;
#endif
case audioMasterGetSampleRate: return (VstIntPtr) (getSampleRate() > 0 ? getSampleRate() : defaultVSTSampleRateValue);
case audioMasterGetBlockSize: return (VstIntPtr) (getBlockSize() > 0 ? getBlockSize() : defaultVSTBlockSizeValue);
@@ -1383,10 +1399,12 @@ public:
case audioMasterGetVendorString:
case audioMasterGetProductString:
{
String hostName ("Juce VST Host");
String hostName ("Carla");
#ifndef JUCE_PLUGIN_HOST_NO_UI
if (JUCEApplicationBase* app = JUCEApplicationBase::getInstance())
hostName = app->getApplicationName();
#endif
hostName.copyToUTF8 ((char*) ptr, (size_t) jmin (kVstMaxVendorStrLen, kVstMaxProductStrLen) - 1);
break;
@@ -1893,6 +1911,7 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginInstance)
};
#ifndef JUCE_PLUGIN_HOST_NO_UI
//==============================================================================
static Array <VSTPluginWindow*> activeVSTWindows;
@@ -2616,12 +2635,17 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginWindow)
};
#endif
//==============================================================================
AudioProcessorEditor* VSTPluginInstance::createEditor()
{
#ifndef JUCE_PLUGIN_HOST_NO_UI
return hasEditor() ? new VSTPluginWindow (*this)
: nullptr;
#else
return nullptr;
#endif
}
//==============================================================================


+ 8
- 0
source/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp View File

@@ -44,9 +44,11 @@ AudioProcessor::AudioProcessor()
AudioProcessor::~AudioProcessor()
{
#ifndef JUCE_PLUGIN_HOST_NO_UI
// ooh, nasty - the editor should have been deleted before the filter
// that it refers to is deleted..
jassert (activeEditor == nullptr);
#endif
#if JUCE_DEBUG
// This will fail if you've called beginParameterChangeGesture() for one
@@ -219,12 +221,15 @@ void AudioProcessor::editorBeingDeleted (AudioProcessorEditor* const editor) noe
{
const ScopedLock sl (callbackLock);
#ifndef JUCE_PLUGIN_HOST_NO_UI
if (activeEditor == editor)
activeEditor = nullptr;
#endif
}
AudioProcessorEditor* AudioProcessor::createEditorIfNeeded()
{
#ifndef JUCE_PLUGIN_HOST_NO_UI
if (activeEditor != nullptr)
return activeEditor;
@@ -243,6 +248,9 @@ AudioProcessorEditor* AudioProcessor::createEditorIfNeeded()
}
return ed;
#else
return nullptr;
#endif
}
//==============================================================================


+ 4
- 0
source/modules/juce_audio_processors/processors/juce_AudioProcessor.h View File

@@ -366,11 +366,13 @@ public:
*/
virtual bool hasEditor() const = 0;
#ifndef JUCE_PLUGIN_HOST_NO_UI
//==============================================================================
/** Returns the active editor, if there is one.
Bear in mind this can return nullptr, even if an editor has previously been opened.
*/
AudioProcessorEditor* getActiveEditor() const noexcept { return activeEditor; }
#endif
/** Returns the active editor, or if there isn't one, it will create one.
This may call createEditor() internally to create the component.
@@ -656,7 +658,9 @@ protected:
private:
Array<AudioProcessorListener*> listeners;
#ifndef JUCE_PLUGIN_HOST_NO_UI
Component::SafePointer<AudioProcessorEditor> activeEditor;
#endif
double sampleRate;
int blockSize, numInputChannels, numOutputChannels, latencySamples;
bool suspended, nonRealtime;


Loading…
Cancel
Save