From 88321904113d8e4263e33dbda84c72de58017ce1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 16 Apr 2020 10:20:56 -0400
Subject: [PATCH] call: close audio at the end of a call

hangupCall() remove the calls in a dht pool. This means that the
operation can take quite some time. So, checkAudio() should be
done once the call is removed. In the other case, the audio layer
will remains open forever

Change-Id: Ia28c99001989215045389e141f694e7732bfcd1d
---
 src/call.cpp    | 1 +
 src/manager.cpp | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/call.cpp b/src/call.cpp
index b75637c6ca..eca7f5ab36 100644
--- a/src/call.cpp
+++ b/src/call.cpp
@@ -152,6 +152,7 @@ Call::removeCall()
     setState(CallState::OVER);
     if (Recordable::isRecording())
         Recordable::stopRecording();
+    Manager::instance().checkAudio();
 }
 
 const std::string&
diff --git a/src/manager.cpp b/src/manager.cpp
index dcace10ef5..945e240d90 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -1028,7 +1028,6 @@ Manager::hangupCall(const std::string& callId)
 
     try {
         call->hangup(0);
-        checkAudio();
     } catch (const VoipLinkException &e) {
         JAMI_ERR("%s", e.what());
         return false;
@@ -1190,8 +1189,6 @@ Manager::refuseCall(const std::string& id)
 
     call->refuse();
 
-    checkAudio();
-
     pimpl_->removeWaitingCall(id);
 
     // Disconnect streams
-- 
GitLab