diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp index ae4ae6775bad6143aab0c7350a5a088c98f33d04..54309276ecc4ad37fda128528b0dddf4901ac0d6 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp +++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp @@ -200,7 +200,7 @@ AudioStream::createStream (pa_context* c) attributes->tlength = (uint32_t)-1; attributes->prebuf = (uint32_t)-1; attributes->minreq = (uint32_t)-1; - attributes->fragsize = (uint32_t)-1; + attributes->fragsize = 4096; // pa_stream_connect_record (s , NULL , attributes , PA_STREAM_START_CORKED); // pa_stream_connect_record( s , NULL , attributes , PA_STREAM_INTERPOLATE_TIMING ); diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index 1c7db92d307fb445c3c83e7be84757ace3b8601f..e46e1e95240441f6aec5a5f1fe5cfaf758ac3213 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -524,10 +524,14 @@ void PulseLayer::writeToSpeaker (void) int maxNbSamplesToGet = 0; int maxNbBytesToGet = 0; + // test if audio resampling is needed if (_mainBufferSampleRate && ((int)_audioSampleRate != _mainBufferSampleRate)) { + // upsamplefactor is used to compute the number of bytes to get in the ring buffer double upsampleFactor = (double) _mainBufferSampleRate / _audioSampleRate; + // maxNbSamplesToGet is the number of sample to get in the ring buffer which, + // once resampled, will not be over the framesPerBuffer maxNbSamplesToGet = (int) ((double) framesPerBuffer * upsampleFactor); } else { @@ -595,7 +599,7 @@ void PulseLayer::writeToSpeaker (void) void PulseLayer::readFromMic (void) { - const char* data; + const char* data = NULL; size_t r; if (pa_stream_peek (record->pulseStream() , (const void**) &data , &r) < 0 || !data) {