From 29a23be1f74e46f063ff25b81c4a8859805e2105 Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Mon, 20 Apr 2009 10:58:23 -0400
Subject: [PATCH] [TICKET #1112] Add a test on the voice buffer to send through
 iax packets

---
 src/iaxvoiplink.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp
index bb083633b9..e15f22f50f 100644
--- a/src/iaxvoiplink.cpp
+++ b/src/iaxvoiplink.cpp
@@ -248,12 +248,13 @@ IAXVoIPLink::sendAudioFromMic(void)
 
     int maxBytesToGet, availBytesFromMic, bytesAvail, compSize;
     AudioCodec *ac;
+    IAXCall *currentCall;
 
     // We have to update the audio layer type in case we switched
     // TODO Find out a better way to do it
     updateAudiolayer();
 
-    IAXCall* currentCall = getIAXCall(Manager::instance().getCurrentCallId());
+    currentCall = getIAXCall(Manager::instance().getCurrentCallId());
 
     if (!currentCall) {
         // Let's mind our own business.
@@ -319,7 +320,7 @@ IAXVoIPLink::sendAudioFromMic(void)
         // Send it out!
         _mutexIAX.enterMutex();
         // Make sure the session and the call still exists.
-        if (currentCall->getSession()) {
+        if (currentCall->getSession() && micDataEncoded != NULL) {
             if (iax_send_voice(currentCall->getSession(), currentCall->getFormat(), micDataEncoded, compSize, nbSample_) == -1) {
                 _debug("IAX: Error sending voice data.\n");
             }
-- 
GitLab