π π A Python library for audio.
C audioaudio-processingaudio-productionaudio-researchaudio-unitaugmentationjucemachine-learningpybind11pythonvst3vst3-host
Don't crash if no display device is available.
Peter Sobot31a8b2242db0
diff --git a/pedalboard/ExternalPlugin.h b/pedalboard/ExternalPlugin.hindex 62434fd..2e97dd7 100644--- a/pedalboard/ExternalPlugin.h+++ b/pedalboard/ExternalPlugin.h@@ -762,6 +762,11 @@ public:"Pedalboard error and should be reported.");}+ if (!juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()) {+ throw std::runtime_error(+ "Editor cannot be shown - no visual display devices available.");+ }+if (!juce::MessageManager::getInstance()->isThisTheMessageThread()) {throw std::runtime_error("Plugin UI windows can only be shown from the main thread.");diff --git a/tests/test_external_plugins.py b/tests/test_external_plugins.pyindex 79e94a1..9d66f50 100644--- a/tests/test_external_plugins.py+++ b/tests/test_external_plugins.py@@ -657,15 +657,21 @@ def test_show_editor(plugin_filename: str):# Run this test in a subprocess, as otherwise we'd block this thread:full_plugin_filename = os.path.join(TEST_PLUGIN_BASE_PATH, platform.system(), plugin_filename)try:- subprocess.check_call(+ subprocess.check_output([psutil.Process(os.getpid()).exe(),"-c","import pedalboard;"- f" pedalboard.load_plugin(\"{full_plugin_filename}\").show_editor()",+ f'pedalboard.load_plugin(r"{full_plugin_filename}").show_editor();',],timeout=5,+ stderr=subprocess.STDOUT,)+ except subprocess.CalledProcessError as e:+ if b"no visual display devices available" in e.output:+ pass+ else:+ raiseexcept subprocess.TimeoutExpired:# This is good: the UI was shown, no issues.pass