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 577498 - Please cleanup ALSA backend
Please cleanup ALSA backend
Status: RESOLVED WONTFIX
Product: ekiga
Classification: Applications
Component: Devices
unspecified
Other All
: Normal normal
: ---
Assigned To: Ekiga maintainers
Ekiga maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2009-03-31 17:11 UTC by Lennart Poettering
Modified: 2020-06-06 16:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Lennart Poettering 2009-03-31 17:11:29 UTC
Please describe the problem:
I while back I sent a private email to Damien and the other Ekiga folks regarding some issues in the ALSA backend for Ekiga/libpt. To make sure that things don't lost or are forgotten here are a few excerpts:

<snip>
That said it would be a good idea if Ekiga would stop enumerating raw
kernel sound cards and instead use the name hinting API. Also you
should play event sounds with libcanberra instead of rolling your
own. libcanberra is a blessed gnome dependency and is both simpler and
more powerful for doing event sounds.
</snip>

And more importantly:

<snip>
Yes. You shouldn't misuse the fragments logic of sound devices. It's
like this:

   The latency is defined by the buffer size.
   The wakeup interval is defined by the fragment size.

The buffer fill level will oscillate between 'full buffer' and 'full
buffer minus 1x fragment size minus OS scheduling latency'. Setting
smaller fragment sizes will increase the CPU load and decrease battery
time since you force the CPU to wake up more often. OTOH it increases
drop out safety, since you fill up playback buffer earlier. Choosing
the fragment size is hence something which you should do balancing out
your needs between power consumption and drop-out safety. With modern
processors and a good OS scheduler like the Linux one setting the
fragment size to anything other than half the buffer size does not
make much sense.

Your ALSA output is configured to set the the fragment size to the
size of your codec audio frames. And that's a bad idea. Because the
codec frame size has not been chosen based on power consumption or
drop-out safety reasoning. It has been chosen by the codec designers
based on different reasoning, such as latency.

You probably configured your backend this ways because the ALSA
library docs say that it is recommended to write to the sound card in
multiples of the fragment size. However deducing from this that you
hence should configure the fragment size to the codec frame size is
wrong!

The best way to implement playback these days for ALSA is to write as
much as snd_pcm_avail() tells you to each time you wake up due to
POLLOUT on the sound card. If that is not a multiple of your codec
frame size then you need to buffer the the remainder of the decoded
data yourself in system memory.

The ALSA fragment size you should noirmally set as large as possible
but that you have at least two fragments in your buffer size.

I hope this explains a bit how frag_size/buffer_size should be
chosen. If you have questions, just ask.

(Oh, ALSA uses the term 'period' for what I call 'fragment'
above. It's synonymous)
</snip>

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Lennart Poettering 2009-03-31 17:27:06 UTC
Oh, and one addition: the code in PSoundChannelALSA::Write() is not particular nice code. Firstly, the error message "Could not write" will usually call snd_strerror() with r=0. Which makes it kind of a useless message. Then, simply looping that call on any error condition is really bad. Also, use snd_pcm_recover() instead of manually checking for errors and then calling _resume() or _prepare(). Please don't do busy loops.
Comment 2 Eugen Dedu 2009-03-31 18:52:42 UTC
You spoke about three things:
- the first one "That said it would be a good idea if Ekiga would stop enumerating raw" - this is a good point.
- the second one, "Yes. You shouldn't misuse the fragments logic of sound devices. It's", has been discussed in http://bugzilla.gnome.org/show_bug.cgi?id=572953 and has been forwarder, please comment there from now on.
- the third one, please create a bug on ptlib/opal bug tracker on sourceforge (https://sourceforge.net/tracker/?group_id=204472&atid=989748).
Comment 3 Lennart Poettering 2009-03-31 19:02:49 UTC
Sorry for the double posting and this many-issues-in-one report!

Sorry for the noise.
Comment 4 Snark 2009-03-31 23:07:59 UTC
Alternativelly, I would gladly welcome help towards making the experimental gstreamer code work, as it would fix every problem at once for ekiga, by pushing things to a more widely shared piece of code (in gstreamer...).
Comment 5 André Klapper 2020-06-06 16:29:25 UTC
Ekiga is not under active development anymore:
https://gitlab.gnome.org/Infrastructure/Infrastructure/-/issues/273

Ekiga saw its last release 7 years ago. The last code commits were 4 years ago.

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this ticket (and transfer the project to GNOME Gitlab, as GNOME Bugzilla is deprecated) if anyone takes the responsibility for active Ekiga development again in the future.