diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 08554b8e8b7334b258b4440e19fe834363e3f0cf..0b20dd318942de418582d63a742c68a2dea9176e 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -395,6 +395,15 @@ bool ManagerImpl::answerCall(const std::string& call_id) return result; } +void ManagerImpl::checkAudio() +{ + if (getCallList().empty()) { + sfl::ScopedLock lock(audioLayerMutex_); + if (audiodriver_) + audiodriver_->stopStream(); + } +} + //THREAD=Main bool ManagerImpl::hangupCall(const std::string& callId) { @@ -435,6 +444,7 @@ bool ManagerImpl::hangupCall(const std::string& callId) if (call) { history_.addCall(call, preferences.getHistoryLimit()); SIPVoIPLink::instance()->hangup(callId, 0); + checkAudio(); saveHistory(); } } catch (const VoipLinkException &e) { @@ -447,6 +457,7 @@ bool ManagerImpl::hangupCall(const std::string& callId) history_.addCall(call, preferences.getHistoryLimit()); VoIPLink *link = getAccountLink(call->getAccountId()); link->hangup(callId, 0); + checkAudio(); saveHistory(); } } @@ -656,6 +667,8 @@ bool ManagerImpl::refuseCall(const std::string& id) return false; getAccountLink(accountid)->refuse(id); + + checkAudio(); } removeWaitingCall(id); @@ -1672,13 +1685,8 @@ void ManagerImpl::peerHungupCall(const std::string& call_id) dbus_.getCallManager()->callStateChanged(call_id, "HUNGUP"); removeWaitingCall(call_id); + checkAudio(); removeStream(call_id); - - if (getCallList().empty()) { - DEBUG("Stop audio stream, there are no calls remaining"); - sfl::ScopedLock lock(audioLayerMutex_); - audiodriver_->stopStream(); - } } //THREAD=VoIP @@ -1692,6 +1700,7 @@ void ManagerImpl::callBusy(const std::string& id) unsetCurrentCall(); } + checkAudio(); removeWaitingCall(id); } @@ -1711,6 +1720,7 @@ void ManagerImpl::callFailure(const std::string& call_id) removeParticipant(call_id); } + checkAudio(); removeWaitingCall(call_id); } diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 6159442154c817bcacd0e1b9364fc03b9aab82f1..f06c6b3666603083b59e1adbbc40a7d16e54c627 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -1050,6 +1050,9 @@ class ManagerImpl { */ AccountMap getAllAccounts() const; + void + checkAudio(); + /** * To handle the persistent history * TODO: move this to ConfigurationManager