|
|
@@ -48,13 +48,15 @@ private: |
|
|
if (mb.isEmpty())
|
|
|
if (mb.isEmpty())
|
|
|
return;
|
|
|
return;
|
|
|
|
|
|
|
|
|
if (! doScan (mb))
|
|
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
const std::lock_guard<std::mutex> lock (mutex);
|
|
|
|
|
|
pendingBlocks.emplace (mb);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
const std::lock_guard<std::mutex> lock (mutex);
|
|
|
|
|
|
|
|
|
|
|
|
if (const auto results = doScan (mb); ! results.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
sendResults (results);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pendingBlocks.emplace (mb);
|
|
|
triggerAsyncUpdate();
|
|
|
triggerAsyncUpdate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -68,26 +70,17 @@ private: |
|
|
{
|
|
|
{
|
|
|
for (;;)
|
|
|
for (;;)
|
|
|
{
|
|
|
{
|
|
|
const auto block = [&]() -> MemoryBlock
|
|
|
|
|
|
{
|
|
|
|
|
|
const std::lock_guard<std::mutex> lock (mutex);
|
|
|
|
|
|
|
|
|
|
|
|
if (pendingBlocks.empty())
|
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
const std::lock_guard<std::mutex> lock (mutex);
|
|
|
|
|
|
|
|
|
auto out = std::move (pendingBlocks.front());
|
|
|
|
|
|
pendingBlocks.pop();
|
|
|
|
|
|
return out;
|
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
|
|
if (block.isEmpty())
|
|
|
|
|
|
|
|
|
if (pendingBlocks.empty())
|
|
|
return;
|
|
|
return;
|
|
|
|
|
|
|
|
|
doScan (block);
|
|
|
|
|
|
|
|
|
sendResults (doScan (pendingBlocks.front()));
|
|
|
|
|
|
pendingBlocks.pop();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
bool doScan (const MemoryBlock& block)
|
|
|
|
|
|
|
|
|
OwnedArray<PluginDescription> doScan (const MemoryBlock& block)
|
|
|
{
|
|
|
{
|
|
|
MemoryInputStream stream { block, false };
|
|
|
MemoryInputStream stream { block, false };
|
|
|
const auto formatName = stream.readString();
|
|
|
const auto formatName = stream.readString();
|
|
|
@@ -106,20 +99,19 @@ private: |
|
|
return nullptr;
|
|
|
return nullptr;
|
|
|
}();
|
|
|
}();
|
|
|
|
|
|
|
|
|
if (matchingFormat == nullptr
|
|
|
|
|
|
|| (! MessageManager::getInstance()->isThisTheMessageThread()
|
|
|
|
|
|
&& ! matchingFormat->requiresUnblockedMessageThreadDuringCreation (pd)))
|
|
|
|
|
|
|
|
|
OwnedArray<PluginDescription> results;
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingFormat != nullptr
|
|
|
|
|
|
&& (MessageManager::getInstance()->isThisTheMessageThread()
|
|
|
|
|
|
|| matchingFormat->requiresUnblockedMessageThreadDuringCreation (pd)))
|
|
|
{
|
|
|
{
|
|
|
return false;
|
|
|
|
|
|
|
|
|
matchingFormat->findAllTypesForFile (results, identifier);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
OwnedArray<PluginDescription> results;
|
|
|
|
|
|
matchingFormat->findAllTypesForFile (results, identifier);
|
|
|
|
|
|
sendPluginDescriptions (results);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
return results;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void sendPluginDescriptions (const OwnedArray<PluginDescription>& results)
|
|
|
|
|
|
|
|
|
void sendResults (const OwnedArray<PluginDescription>& results)
|
|
|
{
|
|
|
{
|
|
|
XmlElement xml ("LIST");
|
|
|
XmlElement xml ("LIST");
|
|
|
|
|
|
|
|
|
@@ -132,9 +124,6 @@ private: |
|
|
|
|
|
|
|
|
std::mutex mutex;
|
|
|
std::mutex mutex;
|
|
|
std::queue<MemoryBlock> pendingBlocks;
|
|
|
std::queue<MemoryBlock> pendingBlocks;
|
|
|
|
|
|
|
|
|
// After construction, this will only be accessed by doScan so there's no need
|
|
|
|
|
|
// to worry about synchronisation.
|
|
|
|
|
|
AudioPluginFormatManager formatManager;
|
|
|
AudioPluginFormatManager formatManager;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
|