From 244ccfc2acb22e9aaa2a8faf17443656db4174dc Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 30 Nov 2017 23:41:01 +0100 Subject: [PATCH] Make transport controls experimental Closes #546 --- resources/ui/carla_settings.ui | 7 +++++++ source/backend/CarlaBackend.h | 13 +++++++++---- source/backend/CarlaStandalone.cpp | 7 +++++-- source/backend/engine/CarlaEngine.cpp | 7 +++++-- source/backend/engine/CarlaEngineJack.cpp | 2 +- source/carla_backend.py | 11 +++++++---- source/carla_host.py | 23 ++++++++++++++++++++++- source/carla_settings.py | 12 +++++++----- source/carla_shared.py | 2 ++ source/utils/CarlaBackendUtils.hpp | 2 ++ 10 files changed, 67 insertions(+), 19 deletions(-) diff --git a/resources/ui/carla_settings.ui b/resources/ui/carla_settings.ui index 15222b8d3..d997e6c84 100644 --- a/resources/ui/carla_settings.ui +++ b/resources/ui/carla_settings.ui @@ -1786,6 +1786,13 @@ Main + + + + Enable transport controls + + + diff --git a/source/backend/CarlaBackend.h b/source/backend/CarlaBackend.h index b6fdaa7b3..f17a7e8c2 100644 --- a/source/backend/CarlaBackend.h +++ b/source/backend/CarlaBackend.h @@ -1167,26 +1167,31 @@ typedef enum { * @see ENGINE_OPTION_TRANSPORT_MODE */ typedef enum { + /*! + * No transport. + */ + ENGINE_TRANSPORT_MODE_DISABLED = 0, + /*! * Internal transport mode. */ - ENGINE_TRANSPORT_MODE_INTERNAL = 0, + ENGINE_TRANSPORT_MODE_INTERNAL = 1, /*! * Transport from JACK. * Only available if driver name is "JACK". */ - ENGINE_TRANSPORT_MODE_JACK = 1, + ENGINE_TRANSPORT_MODE_JACK = 2, /*! * Transport from host, used when Carla is a plugin. */ - ENGINE_TRANSPORT_MODE_PLUGIN = 2, + ENGINE_TRANSPORT_MODE_PLUGIN = 3, /*! * Special mode, used in plugin-bridges only. */ - ENGINE_TRANSPORT_MODE_BRIDGE = 3 + ENGINE_TRANSPORT_MODE_BRIDGE = 4 } EngineTransportMode; diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index e6e052961..430f1cfd6 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -466,10 +466,13 @@ void carla_set_engine_option(EngineOption option, int value, const char* valueSt break; case CB::ENGINE_OPTION_TRANSPORT_MODE: - CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_TRANSPORT_MODE_INTERNAL && value <= CB::ENGINE_TRANSPORT_MODE_BRIDGE,); + CARLA_SAFE_ASSERT_RETURN(value >= CB::ENGINE_TRANSPORT_MODE_DISABLED && value <= CB::ENGINE_TRANSPORT_MODE_BRIDGE,); gStandalone.engineOptions.transportMode = static_cast(value); delete[] gStandalone.engineOptions.transportExtra; - gStandalone.engineOptions.transportExtra = (valueStr != nullptr) ? carla_strdup_safe(valueStr) : nullptr; + if (value != CB::ENGINE_TRANSPORT_MODE_DISABLED && valueStr != nullptr) + gStandalone.engineOptions.transportExtra = carla_strdup_safe(valueStr); + else + gStandalone.engineOptions.transportExtra = nullptr; break; case CB::ENGINE_OPTION_FORCE_STEREO: diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 8c1b31f36..f93cf46d6 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -1384,11 +1384,14 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch break; case ENGINE_OPTION_TRANSPORT_MODE: - CARLA_SAFE_ASSERT_RETURN(value >= ENGINE_TRANSPORT_MODE_INTERNAL && value <= ENGINE_TRANSPORT_MODE_BRIDGE,); + CARLA_SAFE_ASSERT_RETURN(value >= ENGINE_TRANSPORT_MODE_DISABLED && value <= ENGINE_TRANSPORT_MODE_BRIDGE,); CARLA_SAFE_ASSERT_RETURN(getType() == kEngineTypeJack || value != ENGINE_TRANSPORT_MODE_JACK,); pData->options.transportMode = static_cast(value); delete[] pData->options.transportExtra; - pData->options.transportExtra = (valueStr != nullptr) ? carla_strdup_safe(valueStr) : nullptr; + if (value >= ENGINE_TRANSPORT_MODE_DISABLED && valueStr != nullptr) + pData->options.transportExtra = carla_strdup_safe(valueStr); + else + pData->options.transportExtra = nullptr; pData->time.setNeedsReset(); diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 89578f69f..520953e45 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -1087,7 +1087,7 @@ public: { if (option == ENGINE_OPTION_TRANSPORT_MODE && fClient != nullptr) { - CARLA_SAFE_ASSERT_RETURN(value >= ENGINE_TRANSPORT_MODE_INTERNAL && value <= ENGINE_TRANSPORT_MODE_JACK,); + CARLA_SAFE_ASSERT_RETURN(value >= ENGINE_TRANSPORT_MODE_DISABLED && value <= ENGINE_TRANSPORT_MODE_JACK,); if (value == ENGINE_TRANSPORT_MODE_JACK) { diff --git a/source/carla_backend.py b/source/carla_backend.py index f34df3291..37372dc85 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -836,18 +836,21 @@ ENGINE_PROCESS_MODE_BRIDGE = 4 # Engine transport mode. # @see ENGINE_OPTION_TRANSPORT_MODE +# No transport. +ENGINE_TRANSPORT_MODE_DISABLED = 0 + # Internal transport mode. -ENGINE_TRANSPORT_MODE_INTERNAL = 0 +ENGINE_TRANSPORT_MODE_INTERNAL = 1 # Transport from JACK. # Only available if driver name is "JACK". -ENGINE_TRANSPORT_MODE_JACK = 1 +ENGINE_TRANSPORT_MODE_JACK = 2 # Transport from host, used when Carla is a plugin. -ENGINE_TRANSPORT_MODE_PLUGIN = 2 +ENGINE_TRANSPORT_MODE_PLUGIN = 3 # Special mode, used in plugin-bridges only. -ENGINE_TRANSPORT_MODE_BRIDGE = 3 +ENGINE_TRANSPORT_MODE_BRIDGE = 4 # ------------------------------------------------------------------------------------------------------------ # File Callback Opcode diff --git a/source/carla_host.py b/source/carla_host.py index e7724b8fd..d9ab6bdfa 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -789,7 +789,7 @@ class HostWindow(QMainWindow): self.ui.act_file_save.setEnabled(canSave) self.ui.act_engine_start.setEnabled(False) self.ui.act_engine_stop.setEnabled(True) - self.ui.w_transport.setEnabled(True) + self.ui.w_transport.setEnabled(transportMode != ENGINE_TRANSPORT_MODE_DISABLED) if self.host.isPlugin or not self.fSessionManagerName: self.ui.act_file_open.setEnabled(True) @@ -1519,6 +1519,27 @@ class HostWindow(QMainWindow): self.ui.act_add_jack.setVisible(settings.value(CARLA_KEY_EXPERIMENTAL_JACK_APPS, CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS, type=bool)) + if not (self.host.isControl or self.host.isPlugin): + if settings.value(CARLA_KEY_EXPERIMENTAL_TRANSPORT, CARLA_DEFAULT_EXPERIMENTAL_TRANSPORT, type=bool): + if self.ui.cb_transport_jack.isChecked(): + transportMode = ENGINE_TRANSPORT_MODE_JACK + else: + transportMode = ENGINE_TRANSPORT_MODE_INTERNAL + transportExtra = ":link:" if self.ui.cb_transport_link.isChecked() else "" + else: + # Stop transport if becoming disabled + if self.ui.w_transport.isEnabled() and self.host.is_engine_running(): + self.host.transport_pause() + self.host.transport_relocate(0) + self.host.transport_pause() + + transportMode = ENGINE_TRANSPORT_MODE_DISABLED + transportExtra = "" + + self.ui.w_transport.setEnabled(transportMode != ENGINE_TRANSPORT_MODE_DISABLED) + self.host.transportMode = transportMode + self.host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, transportMode, transportExtra) + self.fMiniCanvasUpdateTimeout = 1000 if self.fSavedSettings[CARLA_KEY_CANVAS_FANCY_EYE_CANDY] else 0 setEngineSettings(self.host) diff --git a/source/carla_settings.py b/source/carla_settings.py index 547a61760..321da044a 100755 --- a/source/carla_settings.py +++ b/source/carla_settings.py @@ -506,6 +506,10 @@ class CarlaSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- # Experimental + self.ui.ch_exp_transport.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_TRANSPORT, + CARLA_DEFAULT_EXPERIMENTAL_TRANSPORT, + type=bool)) + self.ui.ch_exp_jack_apps.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_JACK_APPS, CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS, type=bool)) @@ -667,10 +671,6 @@ class CarlaSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- # Wine - settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, self.ui.ch_exp_jack_apps.isChecked()) - settings.setValue(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, self.ui.ch_exp_load_lib_global.isChecked()) - settings.setValue(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, self.ui.ch_exp_prevent_bad_behaviour.isChecked()) - settings.setValue(CARLA_KEY_WINE_EXECUTABLE, self.ui.le_wine_exec.text()) settings.setValue(CARLA_KEY_WINE_AUTO_PREFIX, self.ui.cb_wine_prefix_detect.isChecked()) settings.setValue(CARLA_KEY_WINE_FALLBACK_PREFIX, self.ui.le_wine_prefix_fallback.text()) @@ -681,7 +681,8 @@ class CarlaSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- # Experimental - settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, self.ui.ch_exp_jack_apps.isChecked()) + settings.setValue(CARLA_KEY_EXPERIMENTAL_TRANSPORT, self.ui.ch_exp_transport.isChecked()) + settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, self.ui.ch_exp_jack_apps.isChecked()) settings.setValue(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, self.ui.ch_exp_load_lib_global.isChecked()) settings.setValue(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, self.ui.ch_exp_prevent_bad_behaviour.isChecked()) @@ -834,6 +835,7 @@ class CarlaSettingsW(QDialog): self.ui.cb_canvas_render_hq_aa.setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and self.ui.cb_canvas_render_hq_aa.isEnabled()) self.ui.ch_engine_force_stereo.setChecked(CARLA_DEFAULT_FORCE_STEREO) self.ui.ch_engine_prefer_plugin_bridges.setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES) + self.ui.ch_exp_transport.setChecked(CARLA_DEFAULT_EXPERIMENTAL_TRANSPORT) # -------------------------------------------------------------------------------------------------------- diff --git a/source/carla_shared.py b/source/carla_shared.py index df379c558..63f18bfa2 100644 --- a/source/carla_shared.py +++ b/source/carla_shared.py @@ -233,6 +233,7 @@ CARLA_KEY_WINE_RT_PRIO_ENABLED = "Wine/RtPrioEnabled" # bool CARLA_KEY_WINE_BASE_RT_PRIO = "Wine/BaseRtPrio" # int CARLA_KEY_WINE_SERVER_RT_PRIO = "Wine/ServerRtPrio" # int +CARLA_KEY_EXPERIMENTAL_TRANSPORT = "Experimental/Transport" # bool CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES = "Experimental/PluginBridges" # bool CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES = "Experimental/WineBridges" # bool CARLA_KEY_EXPERIMENTAL_JACK_APPS = "Experimental/JackApplications" # bool @@ -305,6 +306,7 @@ CARLA_DEFAULT_WINE_BASE_RT_PRIO = 15 CARLA_DEFAULT_WINE_SERVER_RT_PRIO = 10 # Experimental +CARLA_DEFAULT_EXPERIMENTAL_TRANSPORT = False CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES = False CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES = False CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS = False diff --git a/source/utils/CarlaBackendUtils.hpp b/source/utils/CarlaBackendUtils.hpp index 483d20aae..5c0d0a2eb 100644 --- a/source/utils/CarlaBackendUtils.hpp +++ b/source/utils/CarlaBackendUtils.hpp @@ -373,6 +373,8 @@ const char* EngineTransportMode2Str(const EngineTransportMode mode) noexcept { switch (mode) { + case ENGINE_TRANSPORT_MODE_DISABLED: + return "ENGINE_TRANSPORT_MODE_DISABLED"; case ENGINE_TRANSPORT_MODE_INTERNAL: return "ENGINE_TRANSPORT_MODE_INTERNAL"; case ENGINE_TRANSPORT_MODE_JACK: