From 18ffe1a49d2a2d60e0d9d64e543d033eb988f8bb Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Thu, 3 Sep 2009 18:27:05 -0400
Subject: [PATCH] [#2006] Fix rtp session deletion

---
 sflphone-common/src/sip/sipvoiplink.cpp | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp
index afaa83d7fb..5cf7132756 100644
--- a/sflphone-common/src/sip/sipvoiplink.cpp
+++ b/sflphone-common/src/sip/sipvoiplink.cpp
@@ -730,6 +730,12 @@ SIPVoIPLink::hangup (const CallID& id)
         return false;
     }
 
+    // Release RTP thread
+    if (Manager::instance().isCurrentCall (id)) {
+        _debug ("* SIP Info: Stopping AudioRTP for hangup\n");
+        _audiortp->stop();
+    }
+
     // User hangup current call. Notify peer
     status = pjsip_inv_end_session (call->getInvSession(), 404, NULL, &tdata);
 
@@ -750,13 +756,6 @@ SIPVoIPLink::hangup (const CallID& id)
 
     call->getInvSession()->mod_data[getModId() ] = NULL;
 
-
-    // Release RTP thread
-    if (Manager::instance().isCurrentCall (id)) {
-        _debug ("* SIP Info: Stopping AudioRTP for hangup\n");
-        _audiortp->stop();
-    }
-
     terminateOneCall (id);
 
     removeCall (id);
@@ -778,6 +777,12 @@ SIPVoIPLink::peerHungup (const CallID& id)
         return false;
     }
 
+    // Release RTP thread
+    if (Manager::instance().isCurrentCall (id)) {
+        _debug ("* SIP Info: Stopping AudioRTP for hangup\n");
+        _audiortp->stop();
+    }
+
     // User hangup current call. Notify peer
     status = pjsip_inv_end_session (call->getInvSession(), 404, NULL, &tdata);
 
@@ -794,12 +799,6 @@ SIPVoIPLink::peerHungup (const CallID& id)
 
     call->getInvSession()->mod_data[getModId() ] = NULL;
 
-    // Release RTP thread
-    if (Manager::instance().isCurrentCall (id)) {
-        _debug ("* SIP Info: Stopping AudioRTP for hangup\n");
-        _audiortp->stop();
-    }
-
     terminateOneCall (id);
 
     removeCall (id);
-- 
GitLab