From dfa519935827227d2791e640e3856f9829f930d4 Mon Sep 17 00:00:00 2001
From: Pierre Lespagnol <pierre.lespagnol@savoirfairelinux.com>
Date: Tue, 2 Mar 2021 17:59:57 -0500
Subject: [PATCH] conference: fix audio on incoming rendezvous call

During the detach, the audio input need to be unbinded from
subcalls composing the conference, not from all calls.
For the removeConference, the leaving call is unbinded in
removeAudio and the remaining call is not unbinded (no need
to unbind all and re-bind remaining call)

Gitlab: #414

Change-Id: I900acac1293f0f8c6e13a74309167d7356015089
---
 src/conference.cpp |  4 +++-
 src/manager.cpp    | 12 +-----------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/conference.cpp b/src/conference.cpp
index d6ead086a4..92cecdfe56 100644
--- a/src/conference.cpp
+++ b/src/conference.cpp
@@ -394,7 +394,9 @@ Conference::detach()
     JAMI_INFO("Detach local participant from conference %s", id_.c_str());
 
     if (getState() == State::ACTIVE_ATTACHED) {
-        Manager::instance().getRingBufferPool().unBindAll(RingBufferPool::DEFAULT_ID);
+        for (const auto& p : participants_) {
+            Manager::instance().getRingBufferPool().unBindCallID(getCall(p)->getCallId(), RingBufferPool::DEFAULT_ID);
+        }
 #ifdef ENABLE_VIDEO
         if (auto mixer = getVideoMixer()) {
             mixer->stopInput();
diff --git a/src/manager.cpp b/src/manager.cpp
index f4715ea5ef..7ce39ed1da 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -1244,17 +1244,7 @@ Manager::removeConference(const std::string& conference_id)
 
     emitSignal<DRing::CallSignal::ConferenceRemoved>(conference_id);
 
-    // We now need to bind the audio to the remain participant
-    // Unbind main participant audio from conference
-    getRingBufferPool().unBindAll(RingBufferPool::DEFAULT_ID);
-
-    // bind main participant audio to remaining conference call
-    ParticipantSet participants(iter->second->getParticipantList());
-    auto iter_p = participants.begin();
-    if (iter_p != participants.end())
-        getRingBufferPool().bindCallID(*iter_p, RingBufferPool::DEFAULT_ID);
-
-    // Then remove the conference from the conference map
+    // Remove the conference from the conference map
     pimpl_->conferenceMap_.erase(iter);
     JAMI_DBG("Conference %s removed successfully", conference_id.c_str());
 }
-- 
GitLab