After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 358338 - Bad output sound caused by setting up an incorrect number of buffers in ALSA
Bad output sound caused by setting up an incorrect number of buffers in ALSA
Status: RESOLVED FIXED
Product: ekiga
Classification: Applications
Component: general
2.0.x
Other All
: Normal major
: ---
Assigned To: Ekiga maintainers
Ekiga maintainers
: 363419 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-09-29 16:37 UTC by Stelian Pop
Modified: 2007-01-02 17:12 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14



Description Stelian Pop 2006-09-29 16:37:23 UTC
Please describe the problem:
When using some SIP providers and some sound cards, the output sound is very bad (chopped sound). In my particular case, this doesn't happen when I use 500@ekiga.net _OR_ my internal AppleOnboardAudio soundcard. However, it does happen every time I use French Free's SIP service _AND_ an external USB Hercules Muse Pocket LT soundcard.

I traced back the failures to write errors in pwlib's sound_alsa.cxx: Write() is trying to write 480 bytes, but only 320 bytes were allocated previously (2 buffers of 160 bytes).

Looking at the connection logs, I realised this is caused by a RTP payload size difference: when calling 500@ekiga.net I get:
> First receive data: ver=2 pt=PCMA psz=160 m=0 x=0 seq=45877 ts=160 src=1793690214 ccnt=0
but when using Free's SIP service I get:
> First receive data: ver=2 pt=PCMA psz=240 m=0 x=0 seq=121 ts=2457396442 src=40891477 ccnt=0

Notice the psz difference.

In order to correct this issue, Ekiga would need to wait the first packet coming from the net, and only then initialise the soundcard. From what I've seen in the code, it doesn't work this way: Opal is the one setting the buffers, and this seem to be hardcoded to 320, which seem to cause the problem. I'm not familiar with this source code so I may as well be wrong.

A workaround, which does work for me, is to hardcode "storedPeriods = 3;" in 
PSoundChannelALSA::SetBuffers() method.

In case you wonder why it does work on some soundcards, well, it seems that on most of them (but _not_ usb audio), the driver is hardcoded to accept a minimum number of 3 buffers, so snd_pcm_hw_params_set_periods_near() will round up the value ekiga passes, 2, up to 3. Look for example at the linux kernel's sound/aoa/soundbus/i2sbus/i2sbus-pcm.c: hw->periods_min = 3;

I hope all this makes sense :)

Steps to reproduce:
1. 
2. 
3. 


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Damien Sandras 2006-10-06 12:25:10 UTC
Actually the default soundChannelBuffers value is 3 on WIN32 and 2 on Linux.
I have applied your change, and also set it to 3 in ekiga/endpoints/pcss.cpp.

I think that Craig should consider changing the default value to 3 in all cases by default in OPAL directly.

Thanks for the patch!
Comment 2 Damien Sandras 2007-01-02 17:12:33 UTC
*** Bug 363419 has been marked as a duplicate of this bug. ***