Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
plugin_scanner_subprocess.h
1// SPDX-FileCopyrightText: © 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3/*
4 * This file incorporates work covered by the following copyright and
5 * permission notice:
6 * ---
7 *
8 * This file is part of the JUCE framework.
9 * Copyright (c) Raw Material Software Limited
10 *
11 * JUCE is an open source framework subject to commercial or open source
12 * licensing.
13 *
14 * By downloading, installing, or using the JUCE framework, or combining the
15 * JUCE framework with any other source code, object code, content or any other
16 * copyrightable work, you agree to the terms of the JUCE End User Licence
17 * Agreement, and all incorporated terms including the JUCE Privacy Policy and
18 * the JUCE Website Terms of Service, as applicable, which will bind you. If you
19 * do not agree to the terms of these agreements, we will not license the JUCE
20 * framework to you, and you must discontinue the installation or download
21 * process and cease use of the JUCE framework.
22 *
23 * JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
24 * JUCE Privacy Policy: https://juce.com/juce-privacy-policy
25 * JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
26 *
27 * Or:
28 *
29 * You may also use this code under the terms of the AGPLv3:
30 * https://www.gnu.org/licenses/agpl-3.0.en.html
31 *
32 * THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
33 * WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
34 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
35 * ---
36 * SPDX-FileCopyrightText: (c) Raw Material Software Limited
37 * SPDX-License-Identifier: AGPL-3.0-only
38 */
39
40#pragma once
41
42#include "zrythm-config.h"
43
44#include "juce_wrapper.h"
45
46namespace zrythm::plugins::scanner
47{
48
52class PluginScannerSubprocess final
53 : private juce::ChildProcessWorker,
54 private juce::AsyncUpdater,
55 private juce::Timer,
56 public juce::JUCEApplication
57{
58public:
59 PluginScannerSubprocess ();
60 ~PluginScannerSubprocess () override;
61 JUCE_DECLARE_NON_COPYABLE (PluginScannerSubprocess)
62 JUCE_DECLARE_NON_MOVEABLE (PluginScannerSubprocess)
63
64private:
65 void handleMessageFromCoordinator (const juce::MemoryBlock &mb) override;
66 void handleConnectionLost () override;
67 void handleAsyncUpdate () override;
68 const juce::String getApplicationName () override
69 {
70 return "Zrythm Plugin Scanner";
71 }
72 const juce::String getApplicationVersion () override { return "v1"; }
73 bool moreThanOneInstanceAllowed () override { return true; }
74 void initialise (const juce::String &commandLineParameters) override;
75 void shutdown () override;
76 void anotherInstanceStarted (const juce::String &commandLine) override;
77 void systemRequestedQuit () override;
78 void suspended () override;
79 void resumed () override;
80
81 juce::OwnedArray<juce::PluginDescription>
82 do_scan (const juce::MemoryBlock &block);
83 void send_results (const juce::OwnedArray<juce::PluginDescription> &results);
84
85 bool has_timed_out () const;
86 void timerCallback () override;
87
88private:
89 std::mutex mutex;
90
94 std::queue<juce::MemoryBlock> pending_blocks_;
95 juce::AudioPluginFormatManager format_manager_;
96 std::unique_ptr<juce::FileLogger> file_logger_;
97
98private:
99 std::chrono::steady_clock::time_point start_time_;
100};
101
102} // namespace zrythm::plugins::scanner