From 4d5e3ee0aec9668e1f48f5e226c3b5dfec06d3fe Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 22 Jan 2020 18:41:11 +0100 Subject: [PATCH] Init context devices deferred as the settings are ONLY available after DBus is initialized * we init in a context constructor * a this time it is not clear: ** if we will use a DBus scenario ** or standalone scenario --- src/blackcore/context/contextaudio.cpp | 20 +++++++++++++++----- src/blackcore/context/contextaudio.h | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index fbf1e827f..5dc919e22 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -139,16 +139,19 @@ namespace BlackCore this->initVoiceClient(); } - const CSettings as = m_audioSettings.getThreadLocal(); - this->setVoiceOutputVolume(as.getOutVolume()); - m_selcalPlayer = new CSelcalPlayer(CAudioDeviceInfo::getDefaultOutputDevice(), this); + // here we are in a base class of one context + // the whole context/facade system is not initialized when this code here is executed - this->changeDeviceSettings(); QPointer myself(this); QTimer::singleShot(5000, this, [ = ] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } - // myself->changeDeviceSettings(); + + const CSettings as = m_audioSettings.getThreadLocal(); + this->setVoiceOutputVolume(as.getOutVolume()); + m_selcalPlayer = new CSelcalPlayer(CAudioDeviceInfo::getDefaultOutputDevice(), this); + + myself->changeDeviceSettings(); myself->onChangedAudioSettings(); myself->onChangedLocalDevices(m_activeLocalDevices); }); @@ -370,6 +373,7 @@ namespace BlackCore void CContextAudioBase::setCurrentAudioDevices(const CAudioDeviceInfo &inputDevice, const CAudioDeviceInfo &outputDevice) { if (!m_voiceClient) { return; } + if (!sApp) { return; } if (!inputDevice.getName().isEmpty() && inputDevice.getName() != m_inputDeviceSetting.get()) { @@ -609,6 +613,12 @@ namespace BlackCore break; } } + + bool CContextAudioBase::isRunningWithLocalCore() + { + return sApp && sApp->isLocalContext(); + } + } // ns } // ns diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index 30d83ea3e..cfb8408ed 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -339,6 +339,9 @@ namespace BlackCore int m_outVolumeBeforeMute = 90; static constexpr int MinUnmuteVolume = 20; //!< minimum volume when unmuted + //! Do we use a local core + static bool isRunningWithLocalCore(); + // settings BlackMisc::CSetting m_audioSettings { this, &CContextAudioBase::onChangedAudioSettings }; BlackMisc::CSetting m_voiceSettings { this, &CContextAudioBase::onChangedVoiceSettings };