|
|
@@ -35,22 +35,23 @@ class PluginScannerSubprocess : private ChildProcessWorker, |
|
|
private AsyncUpdater
|
|
|
private AsyncUpdater
|
|
|
{
|
|
|
{
|
|
|
public:
|
|
|
public:
|
|
|
PluginScannerSubprocess()
|
|
|
|
|
|
{
|
|
|
|
|
|
formatManager.addDefaultFormats();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using ChildProcessWorker::initialiseFromCommandLine;
|
|
|
using ChildProcessWorker::initialiseFromCommandLine;
|
|
|
|
|
|
|
|
|
private:
|
|
|
private:
|
|
|
void handleMessageFromCoordinator (const MemoryBlock& mb) override
|
|
|
void handleMessageFromCoordinator (const MemoryBlock& mb) override
|
|
|
{
|
|
|
{
|
|
|
|
|
|
if (mb.isEmpty())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (! doScan (mb))
|
|
|
{
|
|
|
{
|
|
|
const std::lock_guard<std::mutex> lock (mutex);
|
|
|
|
|
|
pendingBlocks.emplace (mb);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
const std::lock_guard<std::mutex> lock (mutex);
|
|
|
|
|
|
pendingBlocks.emplace (mb);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
triggerAsyncUpdate();
|
|
|
|
|
|
|
|
|
triggerAsyncUpdate();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void handleConnectionLost() override
|
|
|
void handleConnectionLost() override
|
|
|
@@ -58,7 +59,6 @@ private: |
|
|
JUCEApplicationBase::quit();
|
|
|
JUCEApplicationBase::quit();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// It's important to run the plugin scan on the main thread!
|
|
|
|
|
|
void handleAsyncUpdate() override
|
|
|
void handleAsyncUpdate() override
|
|
|
{
|
|
|
{
|
|
|
for (;;)
|
|
|
for (;;)
|
|
|
@@ -78,27 +78,55 @@ private: |
|
|
if (block.isEmpty())
|
|
|
if (block.isEmpty())
|
|
|
return;
|
|
|
return;
|
|
|
|
|
|
|
|
|
MemoryInputStream stream { block, false };
|
|
|
|
|
|
const auto formatName = stream.readString();
|
|
|
|
|
|
const auto identifier = stream.readString();
|
|
|
|
|
|
|
|
|
doScan (block);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool doScan (const MemoryBlock& block)
|
|
|
|
|
|
{
|
|
|
|
|
|
AudioPluginFormatManager formatManager;
|
|
|
|
|
|
formatManager.addDefaultFormats();
|
|
|
|
|
|
|
|
|
|
|
|
MemoryInputStream stream { block, false };
|
|
|
|
|
|
const auto formatName = stream.readString();
|
|
|
|
|
|
const auto identifier = stream.readString();
|
|
|
|
|
|
|
|
|
OwnedArray<PluginDescription> results;
|
|
|
|
|
|
|
|
|
PluginDescription pd;
|
|
|
|
|
|
pd.fileOrIdentifier = identifier;
|
|
|
|
|
|
pd.uniqueId = pd.deprecatedUid = 0;
|
|
|
|
|
|
|
|
|
|
|
|
const auto matchingFormat = [&]() -> AudioPluginFormat*
|
|
|
|
|
|
{
|
|
|
for (auto* format : formatManager.getFormats())
|
|
|
for (auto* format : formatManager.getFormats())
|
|
|
if (format->getName() == formatName)
|
|
|
if (format->getName() == formatName)
|
|
|
format->findAllTypesForFile (results, identifier);
|
|
|
|
|
|
|
|
|
|
|
|
XmlElement xml ("LIST");
|
|
|
|
|
|
|
|
|
return format;
|
|
|
|
|
|
|
|
|
for (const auto& desc : results)
|
|
|
|
|
|
xml.addChildElement (desc->createXml().release());
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
const auto str = xml.toString();
|
|
|
|
|
|
sendMessageToCoordinator ({ str.toRawUTF8(), str.getNumBytesAsUTF8() });
|
|
|
|
|
|
|
|
|
if (matchingFormat == nullptr
|
|
|
|
|
|
|| (! MessageManager::getInstance()->isThisTheMessageThread()
|
|
|
|
|
|
&& ! matchingFormat->requiresUnblockedMessageThreadDuringCreation (pd)))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OwnedArray<PluginDescription> results;
|
|
|
|
|
|
matchingFormat->findAllTypesForFile (results, identifier);
|
|
|
|
|
|
sendPluginDescriptions (results);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
AudioPluginFormatManager formatManager;
|
|
|
|
|
|
|
|
|
void sendPluginDescriptions (const OwnedArray<PluginDescription>& results)
|
|
|
|
|
|
{
|
|
|
|
|
|
XmlElement xml ("LIST");
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& desc : results)
|
|
|
|
|
|
xml.addChildElement (desc->createXml().release());
|
|
|
|
|
|
|
|
|
|
|
|
const auto str = xml.toString();
|
|
|
|
|
|
sendMessageToCoordinator ({ str.toRawUTF8(), str.getNumBytesAsUTF8() });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
std::mutex mutex;
|
|
|
std::mutex mutex;
|
|
|
std::queue<MemoryBlock> pendingBlocks;
|
|
|
std::queue<MemoryBlock> pendingBlocks;
|
|
|
|