From b570bf5af5edf905b5ea3c55d3333beb7635f34f Mon Sep 17 00:00:00 2001 From: ronso0 Date: Fri, 26 Nov 2021 21:36:30 +0100 Subject: [PATCH] keep inapplicable sound config until new config is accepted --- src/mixxx.cpp | 20 +++++++++++++------- src/mixxx.h | 1 + src/soundio/soundmanager.cpp | 5 ++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/mixxx.cpp b/src/mixxx.cpp index a1bae22487bf..9c6118cf0c1c 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -61,6 +61,7 @@ #include "skin/legacy/legacyskinparser.h" #include "skin/skinloader.h" #include "soundio/soundmanager.h" +#include "soundio/soundmanagerconfig.h" #include "sources/soundsourceproxy.h" #include "track/track.h" #include "util/db/dbconnectionpooled.h" @@ -640,7 +641,9 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { // https://bugs.launchpad.net/mixxx/+bug/1758189 m_pPlayerManager->loadSamplers(); - // Try open player device If that fails, the preference panel is opened. + // Sound hardware setup + // Try to open configured devices. If that fails, display dialogs + // that allow to either retry, reconfigure devices or exit. bool retryClicked; do { retryClicked = false; @@ -658,11 +661,10 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { } } while (retryClicked); - // test for at least one out device, if none, display another dlg that - // says "mixxx will barely work with no outs" - // In case persisting errors, the user has already received a message - // box from the preferences dialog above. So we can watch here just the - // output count. + // Test for at least one output device. If none, display another dialog + // that says "mixxx will barely work with no outs". + // In case of persisting errors, the user has already received a message + // above. So we can just check the output count here. while (m_pSoundManager->getConfig().getOutputs().count() == 0) { // Exit when we press the Exit button in the noSoundDlg dialog // only call it if result != OK @@ -673,7 +675,10 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { if (continueClicked) { break; } - } + } + // The user has either reconfigured devices or accepted no outputs, + // so it's now safe to write the new config to disk. + m_pSoundManager->getConfig().writeToDisk(); // Load tracks in args.qlMusicFiles (command line arguments) into player // 1 and 2: @@ -1035,6 +1040,7 @@ QDialog::DialogCode MixxxMainWindow::soundDeviceErrorDlg( m_pSoundManager->clearAndQueryDevices(); // This way of opening the dialog allows us to use it synchronously m_pPrefDlg->setWindowModality(Qt::ApplicationModal); + // Open preferences, sound hardware page is selected (default on first call) m_pPrefDlg->exec(); if (m_pPrefDlg->result() == QDialog::Accepted) { return QDialog::Accepted; diff --git a/src/mixxx.h b/src/mixxx.h index ecfce6e1351c..32fdb38ed6f1 100644 --- a/src/mixxx.h +++ b/src/mixxx.h @@ -34,6 +34,7 @@ class SettingsManager; class BroadcastManager; class SkinLoader; class SoundManager; +class SoundManagerConfig; class VinylControlManager; class WMainMenuBar; diff --git a/src/soundio/soundmanager.cpp b/src/soundio/soundmanager.cpp index 44fc58fcabb8..aa1931bfa437 100644 --- a/src/soundio/soundmanager.cpp +++ b/src/soundio/soundmanager.cpp @@ -81,7 +81,10 @@ SoundManager::SoundManager(UserSettingsPointer pConfig, m_config.loadDefaults(this, SoundManagerConfig::ALL); } checkConfig(); - m_config.writeToDisk(); // in case anything changed by applying defaults + // Don't write config to disk, yet -- it may be reset to defaults in case + // previously configured devices were not found. + // Write new config after MixxxMainWindow::noOutputDlg where the user has + // a chance to keep the previous sound config (exit). } SoundManager::~SoundManager() {