Skip to content
Snippets Groups Projects
Commit edfe125d authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2333] Adjust pulseaudio fragment size to 4096 (max sflphone's frames per buffer)

parent ee8dd8ff
No related branches found
No related tags found
No related merge requests found
......@@ -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 );
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment