Jump to content

[Armbian build PR] - armbian-audio-config: Massively speed up script


RSS Bot

Recommended Posts

Description

This script calls amixer to set various mixer volumes, by simply trying a bunch of mixer names for each sound card in the system. In practice, this meant the amixer command was called 158 times for each sound card. The overhead of all these forks and probably also amixer startup added together to produce a noticable slowdown in startup.

For example on an Orange Pi PC, the script took about 6 seconds per soundcard. This was on a system with a few extra USB soundcards (6 alsa cards in total):

$ time bash ./armbian-audio-config.original

 real    0m35.662s
 user    0m20.145s
 sys     0m15.145s

This commit modifies the script to spawn amixer only once per alsa card, passing all the mixer set commands through stdin. This pretty much completely kills the slowdown. On the same 6-card system:

$ time bash ./armbian-audio-config

real    0m0.406s
user    0m0.345s
sys     0m0.229s

How Has This Been Tested?

Copied the script onto an existing system and running it manually. Changed some mixer controls with alsamixer, ran the script an confirmed they were changed back to 100%.

Have not tested a full image build, but I cannot see how this would not work.

Checklist:

  • [X] My code follows the style guidelines of this project
  • [X] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas - N/A
  • [ ] I have made corresponding changes to the documentation - N/A
  • [X] My changes generate no new warnings
  • [ ] Any dependent changes have been merged and published in downstream modules - N/A

View the full article

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines