diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp
index dbf024d996719a4b6cb97270ef889057c0829872..86f12f3dc7fca2cd0f511a6efd23e7253cdefddb 100644
--- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp
+++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp
@@ -158,7 +158,7 @@ AudioStream::stream_state_callback (pa_stream* s, void* user_data)
             // pa_buffer_attr *buffattr = (pa_buffer_attr *)pa_xmalloc (sizeof(pa_buffer_attr));
             _debug ("Audio: maxlength %u", pa_stream_get_buffer_attr (s)->maxlength);
             _debug ("Audio: tlength %u", pa_stream_get_buffer_attr (s)->tlength);
-            _debug ("Audio: prebug %u", pa_stream_get_buffer_attr (s)->prebuf);
+            _debug ("Audio: prebuf %u", pa_stream_get_buffer_attr (s)->prebuf);
             _debug ("Audio: minreq %u", pa_stream_get_buffer_attr (s)->minreq);
             _debug ("Audio: fragsize %u", pa_stream_get_buffer_attr (s)->fragsize);
             _debug ("Audio: samplespec %s", pa_sample_spec_snprint (str, sizeof (str), pa_stream_get_sample_spec (s)));
diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp
index 6e0640380a5fcee63f602792891d7d4c5e681bd3..9535592bc22a637bb6c6c0bc84f8659ca763e3ec 100644
--- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp
+++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp
@@ -528,7 +528,7 @@ bool PulseLayer::createStreams (pa_context* c)
     pa_stream_set_moved_callback (record->pulseStream(), stream_moved_callback, this);
     pa_stream_set_latency_update_callback (record->pulseStream(), latency_update_callback, this);
 
-    ringtone = new AudioStream (c, m, RINGTONE_STREAM_NAME, RINGTONE_STREAM, _audioSampleRate*2);
+    ringtone = new AudioStream (c, m, RINGTONE_STREAM_NAME, RINGTONE_STREAM, _audioSampleRate);
 
     if (inSourceList (ringtoneDevice)) {
         ringtone->connectStream (&ringtoneDevice);
@@ -684,8 +684,9 @@ void PulseLayer::processCaptureData (void)
 
     // Handle the mic
     // We check if the stream is ready
-    if (record && (record->pulseStream()) && (pa_stream_get_state (record->pulseStream()) == PA_STREAM_READY))
+    if (record && (record->pulseStream()) && (pa_stream_get_state (record->pulseStream()) == PA_STREAM_READY)) {
         readFromMic();
+    }
 
 }
 
diff --git a/sflphone-common/src/audio/sound/audiofile.cpp b/sflphone-common/src/audio/sound/audiofile.cpp
index 6b024ade1d9864856d6a10a8295808826f32417e..fa764df75b4d88c0863b4c7aa8cf4174941bb277 100644
--- a/sflphone-common/src/audio/sound/audiofile.cpp
+++ b/sflphone-common/src/audio/sound/audiofile.cpp
@@ -31,15 +31,17 @@
  *  shall include the source code for the parts of OpenSSL used as well
  *  as that of the covered work.
  */
-#include "audiofile.h"
-#include "audio/codecs/codecDescriptor.h"
-#include "audio/samplerateconverter.h"
 #include <fstream>
 #include <math.h>
 #include <samplerate.h>
 #include <cstring>
+#include <limits.h>
 
+#include "audiofile.h"
+#include "audio/codecs/codecDescriptor.h"
+#include "audio/samplerateconverter.h"
 
+#include "manager.h"
 
 RawFile::RawFile() : _filename()
     , _codec (NULL)
@@ -180,7 +182,7 @@ RawFile::loadFile (const std::string& filename, AudioCodec* codec , unsigned int
 
 WaveFile::WaveFile () : _byte_counter (0)
     , _nb_channels (1)
-    , _file_size (0)
+    , _fileLength (0)
     , _data_offset (0)
     , _channels (0)
     , _data_type (0)
@@ -249,13 +251,10 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
 {
 
     _debug ("WaveFile: Opening %s", fileName.c_str());
-
     _file_stream.open (fileName.c_str(), std::ios::in | std::ios::binary);
 
     char riff[4] = {};
-
     _file_stream.read (riff, 4);
-
     if (strncmp ("RIFF", riff, 4) != 0) {
         _debug ("WaveFile: File is not of RIFF format");
         return false;
@@ -263,12 +262,10 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
 
     // Find the "fmt " chunk
     char fmt[4] = {};
-
     while (strncmp ("fmt ", fmt, 4) != 0) {
         _file_stream.read (fmt, 4);
         _debug ("Searching... \"fmt \"");
     }
-
     SINT32 chunk_size;         // fmt chunk size
     unsigned short format_tag; // data compression tag
 
@@ -278,7 +275,6 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
     _debug ("WaveFile: Chunk size: %d", chunk_size);
     _debug ("WaveFile: Format tag: %d", format_tag);
 
-
     if (format_tag != 1) { // PCM = 1, FLOAT = 3
         _debug ("WaveFile: File contains an unsupported data format type");
         return false;
@@ -289,40 +285,30 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
     // Get number of channels from the header.
     SINT16 chan;
     _file_stream.read ( (char*) &chan, 2);
-
     _channels = chan;
-
     _debug ("WaveFile: Channel %d", _channels);
 
 
     // Get file sample rate from the header.
     SINT32 srate;
     _file_stream.read ( (char*) &srate, 4);
-
     _file_rate = (double) srate;
-
     _debug ("WaveFile: Sampling rate %d", srate);
 
     SINT32 avgb;
     _file_stream.read ( (char*) &avgb, 4);
-
-    _debug ("WaveFile: Average byte %d", avgb);
+    _debug ("WaveFile: Average byte %d", avgb);\
 
     SINT16 blockal;
     _file_stream.read ( (char*) &blockal, 2);
-
     _debug ("WaveFile: Block alignment %d", blockal);
 
 
     // Determine the data type
     _data_type = 0;
-
     SINT16 dt;
     _file_stream.read ( (char*) &dt, 2);
-
     _debug ("WaveFile: dt %d", dt);
-
-
     if (format_tag == 1) {
         if (dt == 8)
             _data_type = 1; // SINT8;
@@ -331,24 +317,13 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
         else if (dt == 32)
             _data_type = 3; // SINT32;
     }
-    /*
-      else if ( format_tag == 3 )
-      {
-        if (temp == 32)
-          dataType_ = FLOAT32;
-        else if (temp == 64)
-          dataType_ = FLOAT64;
-      }
-    */
     else {
         _debug ("WaveFile: File's bits per sample with is not supported");
         return false;
     }
 
-
     // Find the "data" chunk
     char data[4] = {};
-
     while (strncmp ("data", data, 4)) {
         _file_stream.read (data, 4);
         _debug ("Searching... data");
@@ -364,33 +339,53 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
     // Get length of data from the header.
     SINT32 bytes;
     _file_stream.read ( (char*) &bytes, 4);
-
     _debug ("WaveFile: data size in byte %d", bytes);
 
-    _file_size = 8 * bytes / dt / _channels;  // sample frames
-
-    _debug ("WaveFile: data size in frame %ld", _file_size);
+    _fileLength = 8 * bytes / dt / _channels;  // sample frames
+    _debug ("WaveFile: data size in frame %ld", _fileLength);
 
     // Should not be longer than a minute
-    if (_file_size > (unsigned int) (60*srate))
-        _file_size = 60*srate;
+    if (_fileLength > (unsigned int) (60*srate))
+        _fileLength = 60*srate;
 
-    SFLDataFormat *tempBuffer = new SFLDataFormat[_file_size];
-
-    if (!tempBuffer)
+    SFLDataFormat *tempBuffer = new SFLDataFormat[_fileLength];
+    if (!tempBuffer) {
         return false;
+    }
 
     SFLDataFormat *tempBufferRsmpl = NULL;
 
-    _file_stream.read ( (char *) tempBuffer, _file_size*sizeof (SFLDataFormat));
+    _file_stream.read ( (char *) tempBuffer, _fileLength*sizeof (SFLDataFormat));
+
+    // mix two channels together if stereo
+    if(_channels == 2) {
+    	int tmp = 0;
+    	unsigned j = 0;
+    	for(unsigned int i = 0; i < _fileLength-1; i+=2) {
+    		tmp = (tempBuffer[i] + tempBuffer[i+1]) / 2;
+    		// saturate
+    		if(tmp > SHRT_MAX) {
+    			tmp = SHRT_MAX;
+    		}
+    		tempBuffer[j++] = (SFLDataFormat)tmp;
+    	}
+
+    	_fileLength /= 2;
+    }
+    else if(_channels > 2) {
+    	_debug("WaveFile: unsupported number of channels");
+		delete [] tempBuffer;
+    	return false;
+    }
 
     // compute size of final buffer
     int nbSample;
 
     if (srate != audioSamplingRate) {
-        nbSample = (int) ( (float) _file_size * ( (float) audioSamplingRate / (float) srate));
-    } else
-        nbSample = _file_size;
+        nbSample = (int) ( (float) _fileLength * ( (float) audioSamplingRate / (float) srate));
+    } else {
+        nbSample = _fileLength;
+    }
 
     int totalprocessed = 0;
 
@@ -398,7 +393,7 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl
     if (srate != audioSamplingRate) {
 
         // initialize remaining samples to process
-        int remainingSamples = _file_size;
+        int remainingSamples = _fileLength;
 
         tempBufferRsmpl = new SFLDataFormat[nbSample];
 
diff --git a/sflphone-common/src/audio/sound/audiofile.h b/sflphone-common/src/audio/sound/audiofile.h
index 0e175d9b918bfec8e99adb3673ff11ac0f86a07e..46734fe2ca3eb0206ce635f429c868ec2cd92ed4 100644
--- a/sflphone-common/src/audio/sound/audiofile.h
+++ b/sflphone-common/src/audio/sound/audiofile.h
@@ -169,7 +169,7 @@ class WaveFile : public AudioFile
 
         int _nb_channels;
 
-        unsigned long _file_size;
+        unsigned long _fileLength;
 
         unsigned long _data_offset;