Skip to content

Commit

Permalink
Merge pull request #4544 from ronso0/sound-config-error
Browse files Browse the repository at this point in the history
don't wipe inapplicable sound config immediately
  • Loading branch information
daschuer authored Nov 27, 2021
2 parents c78fdf1 + b570bf5 commit bbb70de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/mixxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SettingsManager;
class BroadcastManager;
class SkinLoader;
class SoundManager;
class SoundManagerConfig;
class VinylControlManager;
class WMainMenuBar;

Expand Down
5 changes: 4 additions & 1 deletion src/soundio/soundmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit bbb70de

Please sign in to comment.