Thanks for the suggestion. Applying this to AUs, I tried:
(where knownPluginList is previously declared)
juce::AudioUnitPluginFormat pluginFormat;
juce::FileSearchPath searchPath("~/Library/Audio/Plug-Ins/Components/");
juce::PluginDirectoryScanner pluginScanner(knownPluginList, pluginFormat, searchPath, true, File());
String scanString;
while (pluginScanner.scanNextFile(false, scanString)) {}
This got me similar results – my knownPluginList was filled with every AU available on system (48 AUs), not just those in the specified search path (4 AUs).
Digging into the PluginDirectoryScanner constructor, I noticed the method format.searchPathsForPlugins():
directoriesToSearch.removeRedundantPaths();
setFilesOrIdentifiersToScan (format.searchPathsForPlugins (directoriesToSearch, recursive, allowAsync));
Which points to AudioUnitPluginFormat::searchPathsForPlugins. According to the documentation:
“Searches a suggested set of directories for any plugins in this format.
The path might be ignored, e.g. by AUs, which are found by the OS rather than manually.”
Within this method, the provided FileSearchPath is ignored, and the AudioComponent method AudioComponentFindNext() is used, which uses the OS to iterate for each single AU it is aware of.
StringArray AudioUnitPluginFormat::searchPathsForPlugins (const FileSearchPath&, bool /*recursive*/, bool allowPluginsWhichRequireAsynchronousInstantiation)
{
StringArray result;
AudioComponent comp = nullptr;
for (;;)
{
AudioComponentDescription desc;
zerostruct (desc);
comp = AudioComponentFindNext (comp, &desc);
if (comp == nullptr)
break;
... // abbreviated for post
}
return result;
}
All that to say, it seems like the PluginDirectoryScanner is incapable of following a search path for AUs on MacOS?