diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp index 4591770a1d38907138f8826888dc1efca4e22565..21cb6aa5cce900684d7db52891e07521412604fc 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp +++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp @@ -185,8 +185,8 @@ AudioStream::createStream (pa_context* c) // 2048 bytes (1024 int16) is 20 ms at 44100 Hz if (_streamType == PLAYBACK_STREAM) { attributes->maxlength = 32000; - attributes->tlength = 8192; - attributes->prebuf = 2048; + attributes->tlength = 16000; + attributes->prebuf = 1024; attributes->minreq = 512; attributes->fragsize = (uint32_t) -1; pa_stream_connect_playback( s , NULL , attributes, PA_STREAM_INTERPOLATE_TIMING, &_volume, NULL); @@ -196,9 +196,9 @@ AudioStream::createStream (pa_context* c) // attributes->maxlength = 66500; // attributes->fragsize = (uint32_t)-1; - attributes->maxlength = 16000; - attributes->tlength = 8192; - attributes->prebuf = 2048; + attributes->maxlength = 32000; + attributes->tlength = 16000; + attributes->prebuf = 1024; attributes->minreq = 512; attributes->fragsize = (uint32_t) -1; diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index bc45ef84a742c8559b4148e5b7bc52c5651ac76d..f727c1a3d7dfb04d6a4974b9a7d2b36b60cc2780 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -57,8 +57,16 @@ static void stream_moved_callback(pa_stream *s UNUSED, void *userdata UNUSED) static void playback_underflow_callback (pa_stream* s, void* userdata UNUSED) { _debug ("PulseLayer::Buffer Underflow\n"); + + SFLDataFormat* out = (SFLDataFormat*) pa_xmalloc (framesPerBuffer*sizeof(SFLDataFormat)); + bzero (out, framesPerBuffer*sizeof(SFLDataFormat)); + + pa_stream_write (s, out, framesPerBuffer*sizeof(SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE); pa_stream_trigger (s, NULL, NULL); + pa_xfree (out); + + } @@ -485,9 +493,9 @@ void PulseLayer::writeToSpeaker (void) { toGet = framesPerBuffer; - toPlay = ( (int) (toGet * sizeof (SFLDataFormat)) > framesPerBuffer) ? framesPerBuffer : toGet * sizeof (SFLDataFormat); + toPlay = ( (int) (toGet * sizeof (SFLDataFormat)) > framesPerBuffer * sizeof (SFLDataFormat)) ? framesPerBuffer : toGet * sizeof (SFLDataFormat); out = (SFLDataFormat*) pa_xmalloc (toPlay); - file_tone->getNext(out, toPlay/2 , 100); + file_tone->getNext(out, toPlay/sizeof(SFLDataFormat), 100); pa_stream_write (playback->pulseStream(), out, toPlay, NULL, 0, PA_SEEK_RELATIVE); pa_xfree (out);