Fix crash: Processor just lists files from disk — no scan, no binary loading
Browse files- Source/PluginBridgeProcessor.cpp +29 -61
Source/PluginBridgeProcessor.cpp
CHANGED
|
@@ -13,7 +13,6 @@ PluginBridgeProcessor::PluginBridgeProcessor()
|
|
| 13 |
PluginBridgeProcessor::~PluginBridgeProcessor()
|
| 14 |
{
|
| 15 |
mcpServer.stop();
|
| 16 |
-
stopTimer();
|
| 17 |
}
|
| 18 |
|
| 19 |
void PluginBridgeProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
|
@@ -83,76 +82,45 @@ void PluginBridgeProcessor::loadPluginFromFile(const juce::File& file)
|
|
| 83 |
hostManager.loadPlugin(file, getSampleRate(), getBlockSize());
|
| 84 |
}
|
| 85 |
|
| 86 |
-
|
| 87 |
{
|
| 88 |
-
|
| 89 |
-
return;
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
-
scanFormatManager = std::make_unique<juce::AudioPluginFormatManager>();
|
| 95 |
-
#if JUCE_PLUGINHOST_VST3
|
| 96 |
-
scanFormatManager->addFormat(new juce::VST3PluginFormat());
|
| 97 |
-
#endif
|
| 98 |
-
#if JUCE_PLUGINHOST_AU
|
| 99 |
-
scanFormatManager->addFormat(new juce::AudioUnitPluginFormat());
|
| 100 |
-
#endif
|
| 101 |
-
|
| 102 |
-
scanList = std::make_unique<juce::KnownPluginList>();
|
| 103 |
-
|
| 104 |
-
// Build file list to scan
|
| 105 |
-
for (int i = 0; i < scanFormatManager->getNumFormats(); ++i)
|
| 106 |
{
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
*scanList, *format, paths, true, juce::File());
|
| 113 |
-
|
| 114 |
-
// We'll use the scanner directly — start it
|
| 115 |
-
scanners.add(new ScannerState{
|
| 116 |
-
std::make_unique<juce::PluginDirectoryScanner>(
|
| 117 |
-
*scanList, *format, paths, true, juce::File()),
|
| 118 |
-
false
|
| 119 |
-
});
|
| 120 |
}
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
void PluginBridgeProcessor::timerCallback()
|
| 129 |
-
{
|
| 130 |
-
if (currentScannerIndex >= scanners.size())
|
| 131 |
-
{
|
| 132 |
-
// All scanners done
|
| 133 |
-
stopTimer();
|
| 134 |
-
scannedPlugins = scanList->getTypes();
|
| 135 |
-
scanning.store(false);
|
| 136 |
-
scanComplete.store(true);
|
| 137 |
-
scanners.clear();
|
| 138 |
-
scanFormatManager.reset();
|
| 139 |
-
scanList.reset();
|
| 140 |
-
return;
|
| 141 |
-
}
|
| 142 |
|
| 143 |
-
auto
|
| 144 |
-
if (state->done)
|
| 145 |
{
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
| 148 |
}
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
state->done = true;
|
| 154 |
-
currentScannerIndex++;
|
| 155 |
-
}
|
| 156 |
}
|
| 157 |
|
| 158 |
// JUCE plugin entry point
|
|
|
|
| 13 |
PluginBridgeProcessor::~PluginBridgeProcessor()
|
| 14 |
{
|
| 15 |
mcpServer.stop();
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
void PluginBridgeProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
|
|
|
| 82 |
hostManager.loadPlugin(file, getSampleRate(), getBlockSize());
|
| 83 |
}
|
| 84 |
|
| 85 |
+
juce::Array<juce::File> PluginBridgeProcessor::getInstalledPluginFiles() const
|
| 86 |
{
|
| 87 |
+
juce::Array<juce::File> results;
|
|
|
|
| 88 |
|
| 89 |
+
// VST3 directories
|
| 90 |
+
juce::Array<juce::File> vst3Dirs = {
|
| 91 |
+
juce::File("/Library/Audio/Plug-Ins/VST3"),
|
| 92 |
+
juce::File::getSpecialLocation(juce::File::userHomeDirectory)
|
| 93 |
+
.getChildFile("Library/Audio/Plug-Ins/VST3")
|
| 94 |
+
};
|
| 95 |
|
| 96 |
+
for (auto& dir : vst3Dirs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
{
|
| 98 |
+
if (dir.isDirectory())
|
| 99 |
+
{
|
| 100 |
+
auto files = dir.findChildFiles(juce::File::findDirectories, false, "*.vst3");
|
| 101 |
+
results.addArray(files);
|
| 102 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
+
// AU directories
|
| 106 |
+
juce::Array<juce::File> auDirs = {
|
| 107 |
+
juce::File("/Library/Audio/Plug-Ins/Components"),
|
| 108 |
+
juce::File::getSpecialLocation(juce::File::userHomeDirectory)
|
| 109 |
+
.getChildFile("Library/Audio/Plug-Ins/Components")
|
| 110 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
for (auto& dir : auDirs)
|
|
|
|
| 113 |
{
|
| 114 |
+
if (dir.isDirectory())
|
| 115 |
+
{
|
| 116 |
+
auto files = dir.findChildFiles(juce::File::findDirectories, false, "*.component");
|
| 117 |
+
results.addArray(files);
|
| 118 |
+
}
|
| 119 |
}
|
| 120 |
|
| 121 |
+
// Sort alphabetically
|
| 122 |
+
results.sort();
|
| 123 |
+
return results;
|
|
|
|
|
|
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
// JUCE plugin entry point
|