Fix crash: Update header — Timer-based scan, no background thread
Browse files
Source/PluginBridgeProcessor.h
CHANGED
|
@@ -5,7 +5,8 @@
|
|
| 5 |
#include "McpServer.h"
|
| 6 |
#include "HostedPluginManager.h"
|
| 7 |
|
| 8 |
-
class PluginBridgeProcessor : public juce::AudioProcessor
|
|
|
|
| 9 |
{
|
| 10 |
public:
|
| 11 |
PluginBridgeProcessor();
|
|
@@ -45,21 +46,33 @@ public:
|
|
| 45 |
// Load plugin (called on message thread)
|
| 46 |
void loadPluginFromFile(const juce::File& file);
|
| 47 |
|
| 48 |
-
// Plugin scanning
|
| 49 |
void startPluginScan();
|
| 50 |
-
bool isScanComplete() const { return scanComplete; }
|
| 51 |
-
bool isScanning() const { return scanning; }
|
| 52 |
const juce::Array<juce::PluginDescription>& getScannedPlugins() const { return scannedPlugins; }
|
| 53 |
|
| 54 |
private:
|
|
|
|
|
|
|
| 55 |
HostedPluginManager hostManager;
|
| 56 |
McpServer mcpServer;
|
| 57 |
static constexpr int kDefaultMcpPort = 16620;
|
| 58 |
|
| 59 |
-
// Plugin scan state
|
| 60 |
juce::Array<juce::PluginDescription> scannedPlugins;
|
| 61 |
std::atomic<bool> scanComplete{false};
|
| 62 |
std::atomic<bool> scanning{false};
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginBridgeProcessor)
|
| 65 |
};
|
|
|
|
| 5 |
#include "McpServer.h"
|
| 6 |
#include "HostedPluginManager.h"
|
| 7 |
|
| 8 |
+
class PluginBridgeProcessor : public juce::AudioProcessor,
|
| 9 |
+
private juce::Timer
|
| 10 |
{
|
| 11 |
public:
|
| 12 |
PluginBridgeProcessor();
|
|
|
|
| 46 |
// Load plugin (called on message thread)
|
| 47 |
void loadPluginFromFile(const juce::File& file);
|
| 48 |
|
| 49 |
+
// Plugin scanning — runs on message thread via Timer (safe for NSAlert-showing plugins)
|
| 50 |
void startPluginScan();
|
| 51 |
+
bool isScanComplete() const { return scanComplete.load(); }
|
| 52 |
+
bool isScanning() const { return scanning.load(); }
|
| 53 |
const juce::Array<juce::PluginDescription>& getScannedPlugins() const { return scannedPlugins; }
|
| 54 |
|
| 55 |
private:
|
| 56 |
+
void timerCallback() override;
|
| 57 |
+
|
| 58 |
HostedPluginManager hostManager;
|
| 59 |
McpServer mcpServer;
|
| 60 |
static constexpr int kDefaultMcpPort = 16620;
|
| 61 |
|
| 62 |
+
// Plugin scan state
|
| 63 |
juce::Array<juce::PluginDescription> scannedPlugins;
|
| 64 |
std::atomic<bool> scanComplete{false};
|
| 65 |
std::atomic<bool> scanning{false};
|
| 66 |
|
| 67 |
+
// Scanner internals (only alive during scan)
|
| 68 |
+
struct ScannerState {
|
| 69 |
+
std::unique_ptr<juce::PluginDirectoryScanner> scanner;
|
| 70 |
+
bool done = false;
|
| 71 |
+
};
|
| 72 |
+
juce::OwnedArray<ScannerState> scanners;
|
| 73 |
+
int currentScannerIndex = 0;
|
| 74 |
+
std::unique_ptr<juce::AudioPluginFormatManager> scanFormatManager;
|
| 75 |
+
std::unique_ptr<juce::KnownPluginList> scanList;
|
| 76 |
+
|
| 77 |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginBridgeProcessor)
|
| 78 |
};
|