Skip to content

Commit

Permalink
Added options to PluginListComponent and PluginDirectoryScanner to al…
Browse files Browse the repository at this point in the history
…low scanning of a specific set of files
  • Loading branch information
julianstorer committed Jan 31, 2018
1 parent f71df87 commit bb5bbf3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
Expand Up @@ -47,8 +47,18 @@ PluginDirectoryScanner::PluginDirectoryScanner (KnownPluginList& listToAddTo,
allowAsync (allowPluginsWhichRequireAsynchronousInstantiation)
{
directoriesToSearch.removeRedundantPaths();
setFilesOrIdentifiersToScan (format.searchPathsForPlugins (directoriesToSearch, recursive, allowAsync));
}

filesOrIdentifiersToScan = format.searchPathsForPlugins (directoriesToSearch, recursive, allowAsync);
PluginDirectoryScanner::~PluginDirectoryScanner()
{
list.scanFinished();
}

//==============================================================================
void PluginDirectoryScanner::setFilesOrIdentifiersToScan (const StringArray& filesOrIdentifiers)
{
filesOrIdentifiersToScan = filesOrIdentifiers;

// If any plugins have crashed recently when being loaded, move them to the
// end of the list to give the others a chance to load correctly..
Expand All @@ -57,16 +67,10 @@ PluginDirectoryScanner::PluginDirectoryScanner (KnownPluginList& listToAddTo,
if (crashed == filesOrIdentifiersToScan[j])
filesOrIdentifiersToScan.move (j, -1);

applyBlacklistingsFromDeadMansPedal (listToAddTo, deadMansPedalFile);
applyBlacklistingsFromDeadMansPedal (list, deadMansPedalFile);
nextIndex.set (filesOrIdentifiersToScan.size());
}

PluginDirectoryScanner::~PluginDirectoryScanner()
{
list.scanFinished();
}

//==============================================================================
String PluginDirectoryScanner::getNextPluginFileThatWillBeScanned() const
{
return format.getNameOfPluginFromIdentifier (filesOrIdentifiersToScan [nextIndex.get() - 1]);
Expand Down
Expand Up @@ -72,6 +72,12 @@ class JUCE_API PluginDirectoryScanner
~PluginDirectoryScanner();

//==============================================================================
/** Sets a specific list of filesOrIdentifiersToScan to scan.
N.B. This list must match the format passed to the constructor.
@see AudioPluginFormat::searchPathsForPlugins
*/
void setFilesOrIdentifiersToScan (const StringArray& filesOrIdentifiersToScan);

/** Tries the next likely-looking file.
If dontRescanIfAlreadyInList is true, then the file will only be loaded and
Expand Down
Expand Up @@ -338,10 +338,10 @@ void PluginListComponent::setLastSearchPath (PropertiesFile& properties, AudioPl
class PluginListComponent::Scanner : private Timer
{
public:
Scanner (PluginListComponent& plc, AudioPluginFormat& format, PropertiesFile* properties,
bool allowPluginsWhichRequireAsynchronousInstantiation, int threads,
Scanner (PluginListComponent& plc, AudioPluginFormat& format, const StringArray& filesOrIdentifiers,
PropertiesFile* properties, bool allowPluginsWhichRequireAsynchronousInstantiation, int threads,
const String& title, const String& text)
: owner (plc), formatToScan (format), propertiesToUse (properties),
: owner (plc), formatToScan (format), filesOrIdentifiersToScan (filesOrIdentifiers), propertiesToUse (properties),
pathChooserWindow (TRANS("Select folders to scan..."), String(), AlertWindow::NoIcon),
progressWindow (title, text, AlertWindow::NoIcon),
progress (0.0), numThreads (threads), allowAsync (allowPluginsWhichRequireAsynchronousInstantiation),
Expand All @@ -352,7 +352,9 @@ class PluginListComponent::Scanner : private Timer
// You need to use at least one thread when scanning plug-ins asynchronously
jassert (! allowAsync || (numThreads > 0));

if (path.getNumPaths() > 0) // if the path is empty, then paths aren't used for this format.
// If the filesOrIdentifiersToScan argumnent isn't empty, we should only scan these
// If the path is empty, then paths aren't used for this format.
if (filesOrIdentifiersToScan.isEmpty() && path.getNumPaths() > 0)
{
#if ! JUCE_IOS
if (propertiesToUse != nullptr)
Expand Down Expand Up @@ -389,6 +391,7 @@ class PluginListComponent::Scanner : private Timer
private:
PluginListComponent& owner;
AudioPluginFormat& formatToScan;
StringArray filesOrIdentifiersToScan;
PropertiesFile* propertiesToUse;
ScopedPointer<PluginDirectoryScanner> scanner;
AlertWindow pathChooserWindow, progressWindow;
Expand Down Expand Up @@ -482,7 +485,11 @@ class PluginListComponent::Scanner : private Timer
scanner.reset (new PluginDirectoryScanner (owner.list, formatToScan, pathList.getPath(),
true, owner.deadMansPedalFile, allowAsync));

if (propertiesToUse != nullptr)
if (! filesOrIdentifiersToScan.isEmpty())
{
scanner->setFilesOrIdentifiersToScan (filesOrIdentifiersToScan);
}
else if (propertiesToUse != nullptr)
{
setLastSearchPath (*propertiesToUse, formatToScan, pathList.getPath());
propertiesToUse->saveIfNeeded();
Expand Down Expand Up @@ -560,7 +567,12 @@ class PluginListComponent::Scanner : private Timer

void PluginListComponent::scanFor (AudioPluginFormat& format)
{
currentScanner.reset (new Scanner (*this, format, propertiesToUse, allowAsync, numThreads,
scanFor (format, StringArray());
}

void PluginListComponent::scanFor (AudioPluginFormat& format, const StringArray& filesOrIdentifiersToScan)
{
currentScanner.reset (new Scanner (*this, format, filesOrIdentifiersToScan, propertiesToUse, allowAsync, numThreads,
dialogTitle.isNotEmpty() ? dialogTitle : TRANS("Scanning for plug-ins..."),
dialogText.isNotEmpty() ? dialogText : TRANS("Searching for all possible plug-in files...")));
}
Expand Down
Expand Up @@ -76,6 +76,11 @@ class JUCE_API PluginListComponent : public Component,
/** Triggers an asynchronous scan for the given format. */
void scanFor (AudioPluginFormat&);

/** Triggers an asynchronous scan for the given format and scans only the given files or identifiers.
@see AudioPluginFormat::searchPathsForPlugins
*/
void scanFor (AudioPluginFormat&, const StringArray& filesOrIdentifiersToScan);

/** Returns true if there's currently a scan in progress. */
bool isScanning() const noexcept;

Expand Down

0 comments on commit bb5bbf3

Please sign in to comment.