From 7d4a0bebf171ed9adfa62ade26000cc4540398db Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Thu, 29 Oct 2009 17:40:12 -0400
Subject: [PATCH] [#1933] Add "audio codec not determined" error in IAX

---
 sflphone-common/src/iax/iaxvoiplink.cpp | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sflphone-common/src/iax/iaxvoiplink.cpp b/sflphone-common/src/iax/iaxvoiplink.cpp
index f67faa5eb0..b8d6941dee 100644
--- a/sflphone-common/src/iax/iaxvoiplink.cpp
+++ b/sflphone-common/src/iax/iaxvoiplink.cpp
@@ -245,20 +245,19 @@ IAXVoIPLink::getEvent()
 
     if (call) {
          call->recAudio.recData (spkrDataConverted,micData,nbSampleForRec_,nbSampleForRec_);
+
+	 // Do the doodle-moodle to send audio from the microphone to the IAX channel.
+	 sendAudioFromMic();
     }
 
     // Do the doodle-moodle to send audio from the microphone to the IAX channel.
-    sendAudioFromMic();
+    // sendAudioFromMic();
 
     // Refresh registration.
     if (_nextRefreshStamp && _nextRefreshStamp - 2 < time (NULL)) {
         sendRegister ("");
     }
 
-    // reinitialize speaker buffer for recording (when recording a voice mail)
-    // for (int i = 0; i < nbSampleForRec_; i++)
-    //     spkrDataConverted[i] = 0;
-
 
     // thread wait 3 millisecond
     _evThread->sleep (3);
@@ -285,7 +284,7 @@ IAXVoIPLink::sendAudioFromMic (void)
 
     if (!currentCall) {
 
-
+	_debug("Error no iax call with id \"%s\"\n", Manager::instance().getCurrentCallId().c_str());
         // Let's mind our own business.
         return;
     }
@@ -305,23 +304,26 @@ IAXVoIPLink::sendAudioFromMic (void)
         return;
     }
 
-    ac = currentCall->getCodecMap().getCodec (currentCall -> getAudioCodec());
+    ac = currentCall->getCodecMap().getCodec (currentCall->getAudioCodec());
 
     if (!ac) {
         // Audio codec still not determined.
+	_debug("Error no audio codec determined!\n");
+	
         if (audiolayer) {
             // To keep latency low..
-            audiolayer->flushMic();
+            audiolayer->getMainBuffer()->flush(currentCall->getCallId());
         }
+	
 
         return;
     }
 
-    audiolayer->getMainBuffer()->setInternalSamplingRate(ac->getClockRate());
-
     // Send sound here
     if (audiolayer) {
 
+	audiolayer->getMainBuffer()->setInternalSamplingRate(ac->getClockRate());
+
 	int _mainBufferSampleRate = audiolayer->getMainBuffer()->getInternalSamplingRate();
 
         // we have to get 20ms of data from the mic *20/1000 = /50
-- 
GitLab