4
0

PluginScanPolicy.h 1.1 KB

123456789101112131415161718192021222324
  1. #pragma once
  2. // How long the plugin scan waits for the child process that describes one plugin file (engine/PluginHost.cpp).
  3. // A plugin file can hold many plugins: a Waves "WaveShell" VST3 declares hundreds of classes, and describing each one
  4. // means creating and initialising it. A fixed 30 s limit blacklisted whole Waves bundles as "hung" (REA_rodada107 §2),
  5. // so every Waves plugin of a project fell back to a substitute. The child now reports how many classes the file has
  6. // before describing them, and the limit grows with that number.
  7. #include <algorithm>
  8. namespace lynx::scanpolicy
  9. {
  10. constexpr int baseTimeoutMs = 30000; // a file with one plugin (or whose class count is not known)
  11. constexpr int perClassMs = 2000; // each further class
  12. constexpr int maxTimeoutMs = 45 * 60 * 1000; // never wait longer than this for one file
  13. constexpr int timeoutMs (int classes) noexcept
  14. {
  15. if (classes <= 1)
  16. return baseTimeoutMs;
  17. const auto extra = (long long) (classes - 1) * perClassMs;
  18. return (int) std::min<long long> ((long long) baseTimeoutMs + extra, maxTimeoutMs);
  19. }
  20. } // namespace lynx::scanpolicy