Audio setup component deferred init,

because in a distributed swift system it takes a moment until the
settings are sychronized this is leading to
undesired "save settings" messages and played sounds
This commit is contained in:
Klaus Basan
2019-01-26 01:24:47 +01:00
committed by Mat Sutcliffe
parent 341f2db406
commit 365c52613a
2 changed files with 19 additions and 2 deletions

View File

@@ -20,6 +20,7 @@
#include <QComboBox> #include <QComboBox>
#include <QToolButton> #include <QToolButton>
#include <QtGlobal> #include <QtGlobal>
#include <QPointer>
using namespace BlackCore; using namespace BlackCore;
using namespace BlackCore::Context; using namespace BlackCore::Context;
@@ -38,6 +39,19 @@ namespace BlackGui
{ {
ui->setupUi(this); ui->setupUi(this);
// deferred init, because in a distributed swift system
// it takes a moment until the settings are sychronized
// this is leading to undesired "save settings" messages and played sounds
QPointer<CAudioSetupComponent> myself(this);
QTimer::singleShot(2500, this, [ = ]
{
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
this->init();
});
}
void CAudioSetupComponent::init()
{
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui"); Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
Q_ASSERT_X(sGui->getIContextAudio(), Q_FUNC_INFO, "Missing Audio context"); Q_ASSERT_X(sGui->getIContextAudio(), Q_FUNC_INFO, "Missing Audio context");
@@ -141,14 +155,14 @@ namespace BlackGui
const QObject *sender = QObject::sender(); const QObject *sender = QObject::sender();
if (sender == ui->cb_SetupAudioInputDevice) if (sender == ui->cb_SetupAudioInputDevice)
{ {
CAudioDeviceInfoList inputDevices = devices.getInputDevices(); const CAudioDeviceInfoList inputDevices = devices.getInputDevices();
if (index >= inputDevices.size()) { return; } if (index >= inputDevices.size()) { return; }
selectedDevice = inputDevices[index]; selectedDevice = inputDevices[index];
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice); sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
} }
else if (sender == ui->cb_SetupAudioOutputDevice) else if (sender == ui->cb_SetupAudioOutputDevice)
{ {
CAudioDeviceInfoList outputDevices = devices.getOutputDevices(); const CAudioDeviceInfoList outputDevices = devices.getOutputDevices();
if (index >= outputDevices.size()) { return; } if (index >= outputDevices.size()) { return; }
selectedDevice = outputDevices[index]; selectedDevice = outputDevices[index];
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice); sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);

View File

@@ -43,6 +43,9 @@ namespace BlackGui
bool playNotificationSounds() const; bool playNotificationSounds() const;
private: private:
//! Init
void init();
//! Reload settings //! Reload settings
void reloadSettings(); void reloadSettings();