From 2c71884953d7a5574baa36505d5a025024d4b00e Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 3 Jan 2017 20:51:21 +0000 Subject: [PATCH] Allow to force audio driver --- source/carla_backend.py | 1 + source/carla_host.py | 20 ++++++++++++-------- source/carla_settings.py | 11 +++++++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/source/carla_backend.py b/source/carla_backend.py index 3f3747679..98f6bec2d 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -1212,6 +1212,7 @@ class CarlaHostMeta(object): self.transportMode = ENGINE_TRANSPORT_MODE_INTERNAL self.nextProcessMode = ENGINE_PROCESS_MODE_PATCHBAY self.processModeForced = False + self.audioDriverForced = None # settings self.forceStereo = False diff --git a/source/carla_host.py b/source/carla_host.py index a19b84d04..c42904520 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -2327,10 +2327,11 @@ def loadHostSettings(host): return # enums - try: - host.transportMode = settings.value(CARLA_KEY_ENGINE_TRANSPORT_MODE, CARLA_DEFAULT_TRANSPORT_MODE, type=int) - except: - host.transportMode = CARLA_DEFAULT_TRANSPORT_MODE + if host.audioDriverForced is None: + try: + host.transportMode = settings.value(CARLA_KEY_ENGINE_TRANSPORT_MODE, CARLA_DEFAULT_TRANSPORT_MODE, type=int) + except: + host.transportMode = CARLA_DEFAULT_TRANSPORT_MODE if not host.processModeForced: try: @@ -2430,10 +2431,13 @@ def setEngineSettings(host): # driver and device settings # driver name - try: - audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str) - except: - audioDriver = CARLA_DEFAULT_AUDIO_DRIVER + if host.audioDriverForced is not None: + audioDriver = host.audioDriverForced + else: + try: + audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str) + except: + audioDriver = CARLA_DEFAULT_AUDIO_DRIVER # driver options try: diff --git a/source/carla_settings.py b/source/carla_settings.py index 5b9360229..d1fc0a20a 100755 --- a/source/carla_settings.py +++ b/source/carla_settings.py @@ -261,6 +261,10 @@ class CarlaSettingsW(QDialog): if host.isPlugin: self.ui.cb_engine_audio_driver.setEnabled(False) + if host.audioDriverForced is not None: + self.ui.cb_engine_audio_driver.setEnabled(False) + self.ui.tb_engine_driver_config.setEnabled(False) + if host.processModeForced: self.ui.cb_engine_process_mode_jack.setEnabled(False) self.ui.cb_engine_process_mode_other.setEnabled(False) @@ -361,6 +365,9 @@ class CarlaSettingsW(QDialog): if self.host.isPlugin: audioDriver = "Plugin" self.ui.cb_engine_audio_driver.setCurrentIndex(0) + elif self.host.audioDriverForced: + audioDriver = self.host.audioDriverForced + self.ui.cb_engine_audio_driver.setCurrentIndex(0) else: audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str) @@ -376,7 +383,7 @@ class CarlaSettingsW(QDialog): self.ui.tb_engine_driver_config.setEnabled(False) else: self.ui.sw_engine_process_mode.setCurrentIndex(1) - self.ui.tb_engine_driver_config.setEnabled(not self.host.isPlugin) + self.ui.tb_engine_driver_config.setEnabled(self.host.audioDriverForced is None and not self.host.isPlugin) self.ui.cb_engine_process_mode_jack.setCurrentIndex(self.host.nextProcessMode) @@ -489,7 +496,7 @@ class CarlaSettingsW(QDialog): audioDriver = self.ui.cb_engine_audio_driver.currentText() - if audioDriver and not self.host.isPlugin: + if audioDriver and self.host.audioDriverForced is None and not self.host.isPlugin: settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver) if not self.host.processModeForced: