From 90504256be79c13b7584af8a246ad4f78cb9a7da Mon Sep 17 00:00:00 2001
From: Edric Milaret <edric.ladent-milaret@savoirfairelinux.com>
Date: Thu, 14 Jul 2016 16:20:14 -0400
Subject: [PATCH] fix audio loop being restarted when call is on hold

This caused an "infinite loop" for audio media resulting
in CPU being overcharged for nothing

This fix the problem on MacOS and on GNU/Linux when using PulseAudio
There is still a similar problem with Alsa.

Change-Id: I70e111c59125143d60b657898b04a0b65a638bd6
Tuleap: #576
---
 src/sip/sipcall.cpp | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp
index 4114a7ef4a..c250885295 100644
--- a/src/sip/sipcall.cpp
+++ b/src/sip/sipcall.cpp
@@ -842,12 +842,17 @@ SIPCall::startAllMedia()
 #endif
 
         rtp->updateMedia(remote, local);
-        if (isIceRunning()) {
-            rtp->start(newIceSocket(ice_comp_id + 0),
-                       newIceSocket(ice_comp_id + 1));
-            ice_comp_id += 2;
-        } else
-            rtp->start();
+
+        // Not restarting media loop on hold as it's a huge waste of CPU ressources
+        // because of the audio loop
+        if (getState() != CallState::HOLD) {
+            if (isIceRunning()) {
+                rtp->start(newIceSocket(ice_comp_id + 0),
+                           newIceSocket(ice_comp_id + 1));
+                ice_comp_id += 2;
+            } else
+                rtp->start();
+        }
 
         switch (local.type) {
 #ifdef RING_VIDEO
-- 
GitLab