Upload Source/Helper/HelperPluginHost.h
Browse files- Source/Helper/HelperPluginHost.h +55 -60
Source/Helper/HelperPluginHost.h
CHANGED
|
@@ -1,72 +1,67 @@
|
|
| 1 |
#pragma once
|
| 2 |
|
| 3 |
#include <juce_audio_processors/juce_audio_processors.h>
|
| 4 |
-
#include <juce_gui_basics/juce_gui_basics.h>
|
| 5 |
-
#include <thread>
|
| 6 |
-
#include <atomic>
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
class HelperPluginHost
|
| 11 |
{
|
| 12 |
public:
|
| 13 |
-
HelperPluginHost()
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
//
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
juce::
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
private:
|
| 55 |
-
void audioProcessingLoop();
|
| 56 |
-
|
| 57 |
juce::AudioPluginFormatManager formatManager;
|
| 58 |
-
std::unique_ptr<juce::AudioPluginInstance> plugin;
|
| 59 |
-
|
| 60 |
-
std::thread audioThread;
|
| 61 |
-
std::atomic<bool> processing{false};
|
| 62 |
-
|
| 63 |
-
SharedAudioBuffer* sharedAudio = nullptr;
|
| 64 |
-
SharedSemaphore* inputSem = nullptr;
|
| 65 |
-
SharedSemaphore* outputSem = nullptr;
|
| 66 |
-
|
| 67 |
-
double currentSampleRate = 44100.0;
|
| 68 |
-
int currentBlockSize = 512;
|
| 69 |
-
int currentChannels = 2;
|
| 70 |
-
|
| 71 |
-
std::unique_ptr<juce::DocumentWindow> guiWindow;
|
| 72 |
};
|
|
|
|
| 1 |
#pragma once
|
| 2 |
|
| 3 |
#include <juce_audio_processors/juce_audio_processors.h>
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
// Simplified HelperPluginHost — ONLY tests if a plugin can load.
|
| 6 |
+
// No audio processing, no GUI, no IPC. Just load and report.
|
| 7 |
|
| 8 |
class HelperPluginHost
|
| 9 |
{
|
| 10 |
public:
|
| 11 |
+
HelperPluginHost()
|
| 12 |
+
{
|
| 13 |
+
#if JUCE_PLUGINHOST_VST3
|
| 14 |
+
formatManager.addFormat(new juce::VST3PluginFormat());
|
| 15 |
+
#endif
|
| 16 |
+
#if JUCE_PLUGINHOST_AU
|
| 17 |
+
formatManager.addFormat(new juce::AudioUnitPluginFormat());
|
| 18 |
+
#endif
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// Try to load a plugin. Returns true if successful.
|
| 22 |
+
// If the plugin crashes (abort(), NSAlert, etc.), this process dies
|
| 23 |
+
// and the parent sees exit code != 0.
|
| 24 |
+
bool testLoad(const juce::String& path)
|
| 25 |
+
{
|
| 26 |
+
juce::File pluginFile(path);
|
| 27 |
+
if (!pluginFile.exists())
|
| 28 |
+
return false;
|
| 29 |
+
|
| 30 |
+
juce::OwnedArray<juce::PluginDescription> typesFound;
|
| 31 |
+
|
| 32 |
+
for (int i = 0; i < formatManager.getNumFormats(); ++i)
|
| 33 |
+
{
|
| 34 |
+
auto* format = formatManager.getFormat(i);
|
| 35 |
+
bool isVST3 = pluginFile.getFileExtension() == ".vst3";
|
| 36 |
+
bool isAU = pluginFile.getFileExtension() == ".component";
|
| 37 |
+
|
| 38 |
+
if (isVST3 && format->getName() != "VST3") continue;
|
| 39 |
+
if (isAU && format->getName() != "AudioUnit") continue;
|
| 40 |
+
|
| 41 |
+
format->findAllTypesForFile(typesFound, pluginFile.getFullPathName());
|
| 42 |
+
if (typesFound.size() > 0)
|
| 43 |
+
break;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
if (typesFound.isEmpty())
|
| 47 |
+
return false;
|
| 48 |
+
|
| 49 |
+
juce::String errorMessage;
|
| 50 |
+
auto instance = formatManager.createPluginInstance(
|
| 51 |
+
*typesFound[0], 44100.0, 512, errorMessage);
|
| 52 |
+
|
| 53 |
+
if (instance == nullptr)
|
| 54 |
+
{
|
| 55 |
+
DBG("HelperPluginHost: Load failed: " + errorMessage);
|
| 56 |
+
return false;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
// Successfully loaded — release and report safe
|
| 60 |
+
instance->releaseResources();
|
| 61 |
+
instance.reset();
|
| 62 |
+
return true;
|
| 63 |
+
}
|
| 64 |
|
| 65 |
private:
|
|
|
|
|
|
|
| 66 |
juce::AudioPluginFormatManager formatManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
};
|