Upload Source/Helper/main.cpp
Browse files- Source/Helper/main.cpp +25 -57
Source/Helper/main.cpp
CHANGED
|
@@ -1,94 +1,62 @@
|
|
| 1 |
#include <juce_audio_processors/juce_audio_processors.h>
|
| 2 |
-
#include <juce_audio_utils/juce_audio_utils.h>
|
| 3 |
#include <juce_gui_basics/juce_gui_basics.h>
|
| 4 |
#include <juce_events/juce_events.h>
|
| 5 |
|
| 6 |
-
#include "SharedAudioBuffer.h"
|
| 7 |
-
#include "IPCProtocol.h"
|
| 8 |
-
#include "Constants.h"
|
| 9 |
#include "HelperPluginHost.h"
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
class HelperApplication : public juce::JUCEApplication
|
| 13 |
{
|
| 14 |
public:
|
| 15 |
const juce::String getApplicationName() override { return "PluginBridgeHelper"; }
|
| 16 |
-
const juce::String getApplicationVersion() override { return
|
| 17 |
|
| 18 |
void initialise(const juce::String& commandLine) override
|
| 19 |
{
|
| 20 |
auto args = juce::StringArray::fromTokens(commandLine, " ", "\"");
|
| 21 |
|
| 22 |
-
|
| 23 |
for (int i = 0; i < args.size() - 1; ++i)
|
| 24 |
{
|
| 25 |
-
if (args[i] == "--
|
| 26 |
-
|
| 27 |
}
|
| 28 |
|
| 29 |
-
if (
|
| 30 |
{
|
| 31 |
-
DBG("HelperApplication: --
|
|
|
|
| 32 |
quit();
|
| 33 |
return;
|
| 34 |
}
|
| 35 |
|
| 36 |
-
DBG("HelperApplication:
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
-
if (!sharedAudio.open(shmName))
|
| 43 |
{
|
| 44 |
-
DBG("HelperApplication:
|
| 45 |
-
|
| 46 |
-
return;
|
| 47 |
}
|
| 48 |
-
|
| 49 |
-
if (!inputSem.open(IPC::getInputSemName(parentPid)) ||
|
| 50 |
-
!outputSem.open(IPC::getOutputSemName(parentPid)))
|
| 51 |
{
|
| 52 |
-
DBG("HelperApplication:
|
| 53 |
-
|
| 54 |
-
return;
|
| 55 |
}
|
| 56 |
|
| 57 |
-
if (!ipcServer->connect())
|
| 58 |
-
{
|
| 59 |
-
DBG("HelperApplication: Failed to connect to parent IPC socket");
|
| 60 |
-
quit();
|
| 61 |
-
return;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
pluginHost->setSharedAudio(&sharedAudio, &inputSem, &outputSem);
|
| 65 |
-
pluginHost->startProcessing();
|
| 66 |
-
ipcServer->sendReady();
|
| 67 |
-
|
| 68 |
-
DBG("HelperApplication: Ready and running");
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
void shutdown() override
|
| 72 |
-
{
|
| 73 |
-
if (pluginHost)
|
| 74 |
-
pluginHost->stopProcessing();
|
| 75 |
-
|
| 76 |
-
ipcServer.reset();
|
| 77 |
-
pluginHost.reset();
|
| 78 |
-
sharedAudio.destroy();
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
void systemRequestedQuit() override
|
| 82 |
-
{
|
| 83 |
quit();
|
| 84 |
}
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
std::unique_ptr<HelperIPC> ipcServer;
|
| 89 |
-
SharedAudioBuffer sharedAudio;
|
| 90 |
-
SharedSemaphore inputSem;
|
| 91 |
-
SharedSemaphore outputSem;
|
| 92 |
};
|
| 93 |
|
| 94 |
START_JUCE_APPLICATION(HelperApplication)
|
|
|
|
| 1 |
#include <juce_audio_processors/juce_audio_processors.h>
|
|
|
|
| 2 |
#include <juce_gui_basics/juce_gui_basics.h>
|
| 3 |
#include <juce_events/juce_events.h>
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
#include "HelperPluginHost.h"
|
| 6 |
+
|
| 7 |
+
// PluginBridgeHelper — TEST MODE ONLY
|
| 8 |
+
// Spawned by PluginBridge to test if a plugin can load safely.
|
| 9 |
+
// If the plugin crashes, only this process dies. Ableton survives.
|
| 10 |
+
//
|
| 11 |
+
// Usage: PluginBridgeHelper --test "/path/to/plugin.vst3"
|
| 12 |
+
// Exit code 0 = safe, exit code 1 = failed to load, crash = unsafe
|
| 13 |
|
| 14 |
class HelperApplication : public juce::JUCEApplication
|
| 15 |
{
|
| 16 |
public:
|
| 17 |
const juce::String getApplicationName() override { return "PluginBridgeHelper"; }
|
| 18 |
+
const juce::String getApplicationVersion() override { return "0.3.0"; }
|
| 19 |
|
| 20 |
void initialise(const juce::String& commandLine) override
|
| 21 |
{
|
| 22 |
auto args = juce::StringArray::fromTokens(commandLine, " ", "\"");
|
| 23 |
|
| 24 |
+
juce::String pluginPath;
|
| 25 |
for (int i = 0; i < args.size() - 1; ++i)
|
| 26 |
{
|
| 27 |
+
if (args[i] == "--test")
|
| 28 |
+
pluginPath = args[i + 1];
|
| 29 |
}
|
| 30 |
|
| 31 |
+
if (pluginPath.isEmpty())
|
| 32 |
{
|
| 33 |
+
DBG("HelperApplication: Usage: --test \"/path/to/plugin.vst3\"");
|
| 34 |
+
setApplicationReturnValue(1);
|
| 35 |
quit();
|
| 36 |
return;
|
| 37 |
}
|
| 38 |
|
| 39 |
+
DBG("HelperApplication: Testing plugin: " + pluginPath);
|
| 40 |
|
| 41 |
+
HelperPluginHost host;
|
| 42 |
+
bool success = host.testLoad(pluginPath);
|
| 43 |
|
| 44 |
+
if (success)
|
|
|
|
| 45 |
{
|
| 46 |
+
DBG("HelperApplication: Plugin loaded successfully — SAFE");
|
| 47 |
+
setApplicationReturnValue(0);
|
|
|
|
| 48 |
}
|
| 49 |
+
else
|
|
|
|
|
|
|
| 50 |
{
|
| 51 |
+
DBG("HelperApplication: Plugin failed to load — UNSAFE");
|
| 52 |
+
setApplicationReturnValue(1);
|
|
|
|
| 53 |
}
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
quit();
|
| 56 |
}
|
| 57 |
|
| 58 |
+
void shutdown() override {}
|
| 59 |
+
void systemRequestedQuit() override { quit(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
};
|
| 61 |
|
| 62 |
START_JUCE_APPLICATION(HelperApplication)
|