#881715 alsa-utils: High CPU usage on the default device

Package:
alsa-utils
Source:
alsa-utils
Description:
Utilities for configuring and using ALSA
Submitter:
Andoru
Date:
2017-12-13 19:21:04 UTC
Severity:
normal
#881715#5
Date:
2017-11-14 14:13:44 UTC
From:
To:
As the title says, I'm having a bit of an issue with ALSA, and the high
CPU (~15-20%) usage in some cases. So far on the default device, I've
only noticed this with VLC and foobar2000 (through Wine), but there are
other apps/games that might have the same problem. It's just easy to
tell if an app/ALSA uses too much CPU if you just play some audio files
and you don't have anything else that might need the extra CPU power,
like rendering the video stream or render the graphics. I can fix the
high CPU usage in VLC if I switch the audio sub-device from the Default
to a specific one (in my case: Analog Front Speakers). There is no
change in the audio quality, but the resources used instantly decrease.
The only problem with this is that I can no longer play/hear any audio
from other apps/games (so basically VLC monopolises the card). Also,
this is not possible under Wine, so I can't achieve the same thing for
foobar2000, or other Windows apps/games.
I haven't made any custom
config files for ALSA, except to disable the HDMI audio output (so that
the normal analogue output is used by default in all apps/games), and
I've done that in /etc/modprobe.d/intel-disable-hdmi.conf with this as
it's content:

#881715#10
Date:
2017-11-14 14:24:59 UTC
From:
To:
My bad, I pressed "send" too soon, didn't get to fill in the proper info...
#881715#19
Date:
2017-11-14 17:55:37 UTC
From:
To:
Hi Andoru,

thanks for your bug report.

* Andoru <aekkusu@gmail.com> [2017-11-14 16:13 +0200]:

What makes you think an alsa process eats high cpu usage? Can you
post the tespective line with column headers aou of htop or top
please?

Thanks
Elimar

#881715#26
Date:
2017-11-14 20:03:20 UTC
From:
To:
You skipped a paragraph from my report:
some audio files

///

Sorry... could you elaborate what you mean? What parameters should I start
htop to get he info you need?

#881715#31
Date:
2017-11-14 21:14:08 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-14 22:03 +0200]:

Just run htop while an alsa-process needs high cpu load. Copy the
line which shows that from (h)top to this bug report. Or just file a
screenshot to a puplic server somewhere.

Elimar

#881715#36
Date:
2017-11-14 21:45:21 UTC
From:
To:
VLC playing a FLAC file on the default device:
COMMAND

COMMAND

COMMAND

COMMAND

COMMAND
foobar2000+
COMMAND
foobar2000+
COMMAND
foobar2000+


Let me know if you need any additional info.

Also, in the initial report, I forgot to mention that when I select "Analog
Front Speakers" subdevice in VLC, with some decoders (particularly APE) and
when the sample rate is below 44100Hz, I can hear some distortion
(crackling on high pitched sounds), so I'm guessing the high CPU usage is
maybe due to an inefficient resampler?

#881715#41
Date:
2017-11-15 05:12:28 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-14 23:45 +0200]:

Did you started vlc within wine?

Elimar

#881715#46
Date:
2017-11-15 12:42:24 UTC
From:
To:
No...? Why would I do something silly like that?
#881715#51
Date:
2017-11-15 17:52:26 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-14 23:45 +0200]:

I tried that on 3 different soundcards. I don't get vlc as a htop
COMMAND. It is always /usr/bin/vlc. Please tell me how you fired up
vlc. The %CPU usage isn't reproducible on none of the soundcards
handy for me.

I don't know how you got foobar2000 into Debian but this isn't¬
maintained in the repos, so not relevant to this bug.

Try to cancel all pulseaudio stuff and test again. Let me know....

Elimar

#881715#58
Date:
2017-11-16 00:22:54 UTC
From:
To:
COMMAND. It is always /usr/bin/vlc.

I swear I'm using the native VLC from the Debian repos.

I started VLC through OpenBox's menus, and on that menu the command to
start VLC is simply 'vlc', which probably translates to 'bash -c vlc'. If I
open a media file from the file manager, and there's no running instance of
VLC, I get "/usr/bin/vlc --started-from-file" as the command name under
htop.

Have you actually tried it on a ALC887-VD or a similar integrated chip by
Realtek?

I did not get it through Debian, I simply installed it in the default Wine
prefix.

I apologise, I think I did not mention this in the initial bug report, but
I'm not using PA, nor do I have it installed. That's why I submitted this
bug against ALSA.

#881715#63
Date:
2017-11-16 21:39:05 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-16 02:22 +0200]:

Tested on ALC892, CX20561, emu10k1 and ES1371/1. None of them showed
high cpu usage.

Elimar

#881715#68
Date:
2017-11-16 21:47:58 UTC
From:
To:
cpu usage.

Could you let me know how you configured ALSA? It could be that I might
have misconfigured something, but I wouldn't know what...
Is there some advanced testing/diagnonsis that I could try to do to figure
out what's causing this?

#881715#73
Date:
2017-11-17 07:28:26 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-16 23:47 +0200]:

Nothing special. Just install alsa-utils. No asoundrc. Thats it.

Elimar

#881715#78
Date:
2017-11-17 13:12:20 UTC
From:
To:
Okay... then what is there to do next?
Call me technologically illiterate, or say that I don't know of the inner
workings of ALSA, but I don't think this can be a given that a simple task
such as outputting audio could take 13-20% of a quad core CPU!

#881715#83
Date:
2017-11-17 15:09:46 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-17 15:12 +0200]:

Maybe your speakersystem needs some rectification?

Or you can ask here:
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Elimar

#881715#88
Date:
2017-11-17 15:32:44 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-17 15:12 +0200]:

Do you have a $HOME/.asoundrc?

Did you tried mpg321, moc or any other console player?

Elimar

#881715#93
Date:
2017-11-17 23:47:30 UTC
From:
To:
You mean the external speakers? I use headphones. I don't know what those
have to do with ALSA or this issue I'm having.
<http://mailman.alsa-project.org/mailman/listinfo/alsa-devel>
http://mailman.alsa-project.org/pipermail/alsa-devel/2017-November/126934.html


What should I try specifically?
What parameters should I use?

#881715#98
Date:
2017-11-19 09:47:52 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-18 01:47 +0200]:

I meant .asoundrc. Please notice the dot.

$ find $HOME -name '.asoundrc*'

will do the trick

[...]

$ sudo apt install vorbis-tools
$ ogg123 -d alsa -o surround71 $YOUR_FAVORITE_OGG.ogg
$ man ogg123

With alsamixer you can control the output device.

Elimar

#881715#103
Date:
2017-11-22 06:53:04 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-19 15:11 +0200]:

So I am closing this bug hereby.

Thanks for cooperation
Elimar

#881715#108
Date:
2017-11-22 06:53:04 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-11-19 15:11 +0200]:

So I am closing this bug hereby.

Thanks for cooperation
Elimar

#881715#115
Date:
2017-11-28 13:19:25 UTC
From:
To:
Forgot to check previously, but whenever I use those CLI players you
suggested, they also monopolise the soundcard, making me unable to play
other stuff in parallel, just like how it would happen when setting the
specific subdevice in VLC. So, since I'm not able to use those CLI players
to play with the default device to see if they use the same amount of CPU
as VLC and other players/apps, this issue is still not solved.
That's why I asked you for specific commands that I can use with those CLI
players.

#881715#120
Date:
2017-11-28 20:11:58 UTC
From:
To:
Hi Andoru,

* Andoru <aekkusu@gmail.com> [2017-11-28 15:19 +0200]:

There must be something configured on your system which cauuses your
issue. You don't have an .asoundrc. Did you created an /etc/asound.conf
or adapted some options loading your snd- modules? A clean install of
alsa-utils and libasound2 should work out of the box with no custom
settings!

Do you think to solve your issue with "specific commands"? Just
install Debian's plain alsa and enjoy,

Elimar

#881715#125
Date:
2017-11-28 20:43:53 UTC
From:
To:
* Elimar Riesebieter <riesebie@lxtec.de> [2017-11-28 21:11 +0100]:

[...]

Remove /etc/modprobe.d/intel-disable-hdmi.conf and try again.

Elimar

#881715#130
Date:
2017-12-04 15:02:01 UTC
From:
To:
 > Did you created an /etc/asound.conf

No, I have no such file.

Yes, I mentioned in the first post that I created a rule under
/etc/modprobe.d/ to disable HDMI audio output through the integrated chips.
But you added another reply so you probably noticed that I wrote that
afterwards.
settings!

It *does* work, however, not as it should.
CLI

No, I meant specific commands to test those CLI players with the default
ALSA device (that has that issue with high CPU usage). Or at least to give
some output with which we could have a clue what's causing the CPU usage.

I did, and unsurprisingly it did not help, the same high CPU usage on the
default device, the specific subdevice monopolises the sound card, and on
top of that, most applications that don't offer any settings for setting
which audio card/device/subdevice to use are left without sound because
they automatically choose the first card, which is the HDMI output.

#881715#135
Date:
2017-12-04 19:09:54 UTC
From:
To:
Hi Andoru,

* Andoru <aekkusu@gmail.com> [2017-12-04 17:02 +0200]:

As you are the only one out of 60thsd Debian Alsa users who
reported a high cpu-usage running alsa apps and I can't reproduce
and don't know your system I hereby cancel support from my side.
Hence you'll find a solution, please let me know with a ping to
881715@bugs.debian.org. Maybe you'll find help on user-lists or
alsa-lists. I don't know, though

Elimar

#881715#140
Date:
2017-12-04 19:54:22 UTC
From:
To:
What is there else that you'd like to know? What is it that I should be
doing to diagnose this? That's what I've been asking for the entirety of
this bug report!

I pretty much doubt it since I haven't got any useful info from you, nor
did I get any replies on alsa-users/alsa-dev.

#881715#145
Date:
2017-12-04 21:41:45 UTC
From:
To:
doesn't mean I'm the only one to experience it! I'm sure at least other
Debian users with the same sound chip as mine would probably experience the
same issue, if not users of other distros as well. They probably just
didn't bother reporting it as it is a sort of a minor-ish issue, or they
might've not even noticed it.

Could you (or someone else) perhaps let me know who provided the driver for
ALC887-VD? Maybe that way I could contact them directly.

#881715#150
Date:
2017-12-05 07:27:45 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-12-04 23:41 +0200]:

[...]

alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Elimar

#881715#155
Date:
2017-12-07 07:20:32 UTC
From:
To:
* Andoru <aekkusu@gmail.com> [2017-12-04 21:54 +0200]:

You can try to boot a live-linux like Debian-live, Knoppix, Ubuntu
whatever and check whether your symptoms persist.

Elimar

#881715#160
Date:
2017-12-07 07:32:20 UTC
From:
To:
Yes, I was about to do that. Though those distros all have PulseAudio by
default, so I thought of installing Arch on a separate partition and test
ALSA there.

#881715#165
Date:
2017-12-13 19:17:39 UTC
From:
To:
Okay, so I installed Arch from scratch with a minimalist set-up of OpenBox
and tint2, installed alsa-utils and alsa-tools, and made that modprobe
config file to disable HDMI output, just like I did when I did the
netinstall of Debian. Then installed vlc and played all the files I played
previously (in FLAC, ogg, mp3, etc), and both when using the default device
and when selecting Analog Front Speakers subdevice, the CPU usage rarely
passes the 5% mark. I've also tried foobar2000 through wine, and got the
same result.

Here's some info about the alsa-utils package under Arch: