diff --git a/src/blackcore/corefacade.cpp b/src/blackcore/corefacade.cpp index 32fbe8897..7ebcafa5a 100644 --- a/src/blackcore/corefacade.cpp +++ b/src/blackcore/corefacade.cpp @@ -259,14 +259,14 @@ namespace BlackCore c = connect(this->getCContextOwnAircraft(), &CContextOwnAircraft::ps_changedModel, this->getCContextSimulator(), &CContextSimulator::xCtxChangedOwnAircraftModel); Q_ASSERT(c); + } - - // hook up with audio - if (this->getIContextAudio()) - { - c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, this->getCContextAudio(), &CContextAudio::xCtxChangedAircraftCockpit, Qt::QueuedConnection); - Q_ASSERT(c); - } + // special case for the audio related connection (which mutes audio for a changed cockpit) + // hook up with audio if audio context is local + if (this->hasLocalAudio() && m_contextOwnAircraft) + { + c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedAircraftCockpit, this->getCContextAudio(), &CContextAudio::xCtxChangedAircraftCockpit, Qt::QueuedConnection); + Q_ASSERT(c); } // times @@ -452,6 +452,11 @@ namespace BlackCore return static_cast(m_contextAudio); } + bool CCoreFacade::hasLocalAudio() const + { + return m_contextAudio && m_contextAudio->isUsingImplementingObject(); + } + const CContextAudio *CCoreFacade::getCContextAudio() const { Q_ASSERT_X(m_contextAudio && m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object"); diff --git a/src/blackcore/corefacade.h b/src/blackcore/corefacade.h index 51badacf4..91254a874 100644 --- a/src/blackcore/corefacade.h +++ b/src/blackcore/corefacade.h @@ -57,7 +57,7 @@ namespace BlackCore CCoreFacade(const CCoreFacadeConfig &config, QObject *parent = nullptr); //! Destructor - virtual ~CCoreFacade() { this->gracefulShutdown(); } + virtual ~CCoreFacade() override { this->gracefulShutdown(); } //! DBus server (if applicable) const BlackMisc::CDBusServer *getDBusServer() const { return this->m_dbusServer; } @@ -123,6 +123,9 @@ namespace BlackCore //! \remarks only applicable for local object Context::CContextAudio *getCContextAudio(); + //! Local audio context, means audio really runs here + bool hasLocalAudio() const; + //! Context for audio //! \remarks only applicable for local object const Context::CContextAudio *getCContextAudio() const;