2

I have to do sudo alsa force-reload to let my system detect my soundcard, before I only got shown a dummy output. But everytime I reboot I have to do this again. I already tried reinstaling alsa-base.

Edit: sudo systemctl status alsa-restore.service returns:

● alsa-restore.service - Save/Restore Sound Card State
 Loaded: loaded (/lib/systemd/system/alsa-restore.service; static; vendor preset: enabled)
 Active: active (exited) since Wed 2020-10-07 17:23:42 CEST; 1min 19s ago
   Docs: man:alsactl(1)
Process: 1285 ExecStartPre=/bin/mkdir -p /run/alsa (code=exited, status=0/SUCCESS)
Process: 1319 ExecStart=/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore (code=exited, status=99)
Main PID: 1319 (code=exited, status=99)

Okt 07 17:23:42 PhilippN-Vostro-5490 alsactl[1319]: Found hardware: "sof-hda-dsp" "Realtek ALC3204" "HDA:8086280b,80860101,00100000 HDA:10ec0236,10280959,00100002 cfg-dmics:2" "" ""
Okt 07 17:23:42 PhilippN-Vostro-5490 alsactl[1319]: Hardware is initialized using a generic method
Okt 07 17:23:42 PhilippN-Vostro-5490 systemd[1]: Starting Save/Restore Sound Card State...
Okt 07 17:23:42 PhilippN-Vostro-5490 systemd[1]: Finished Save/Restore Sound Card State.

Edit 2: journalctl -b | grep alsa returns:

Nov 05 16:44:28 Vostro-5490 systemd-udevd[586]: controlC0: Process '/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore 0' failed with exit code 99.
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: alsa-lib parser.c:2157:(load_toplevel_config) Unable to find the top-level configuration file '/usr/share/alsa/ucm2/ucm.conf'.
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: alsa-lib main.c:997:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: Found hardware: "sof-hda-dsp" "Realtek ALC3204" "HDA:8086280b,80860101,00100000 HDA:10ec0236,10280959,00100002 cfg-dmics:2" "" ""
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: Hardware is initialized using a generic method

2 Answers 2

1

Option 1

Before you go with the custom service below, the way alsa reloads your configureation is by checking if /var/lib/alsa/asound.state exists and what is in it (your list of sound devices) , through the systemd alsa-restore.service that runs at boot (to reload your configuration) and at shutdown (to preserve your last configuration)

It is essential to first check whether that particular service exists with

sudo systemctl status alsa-restore.service

and the status should report

alsa-restore.service - Save/Restore Sound Card State
     Loaded: loaded (/lib/systemd/system/alsa-restore.service; static; vendor preset: enabled)
     Active: active (exited) since Sun 2020-09-27 11:43:13 EDT; 5h 43min ago
       Docs: man:alsactl(1)
   Main PID: 755 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 11833)
     Memory: 0B
     CGroup: /system.slice/alsa-restore.service

Sep 27 11:43:13 FOOT systemd[1]: Starting Save/Restore Sound Card State...
Sep 27 11:43:13 FOOT systemd[1]: Finished Save/Restore Sound Card State.

The alsa-restore.service located in /lib/systemd/system/alsa-restore.service should look like so:


#
# Note that two different ALSA card state management schemes exist and they
# can be switched using a file exist check - /etc/alsa/state-daemon.conf .
#

[Unit]
Description=Save/Restore Sound Card State
Documentation=man:alsactl(1)
ConditionPathExists=!/etc/alsa/state-daemon.conf
ConditionPathExistsGlob=/dev/snd/control*
After=alsa-state.service

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore
ExecStop=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime store

if this service exists, but is disabled, you can enable and start it with

sudo systemctl enable alsa-restore.service
sudo systemctl start alsa-restore.service

If sudo systemctl status alsa-restore.service reports some additional error in its status that causes it to fail, that may need to be solved first.



Option 2

After double-checking alsa force-reload is not a oneshot command wrapper for alsactl but instead it is responsible for the restart of the corresponding alsa service, which occurs in two steps, first stopping, then starting it again.

To summarize, sudo alsa force-reload does is the following

  1. Checking if the command alsactl can be located, and if not it exits right away
  2. Running a script located at /usr/share/alsa/utils.sh which provides some indexing functions among other things.
  3. Checking if /var/lib/alsa/asound.state exists
  4. Running alsactl -E HOME="$ALSACTLHOME" -E XDG_RUNTIME_DIR="${ALSACTLRUNTIME}" restore $CARD >/dev/null 2>&1 to restore volume states for each card found in asound.state

Step #4 is exactly what the alsa-restore.service executes on boot and shutdown under proper operation, hence all the issues point to it being disabled or not there at all.

We already know that alsactl exists on your system because alsa force-reload works, but Next time you reboot and your audio is not automatically reloaded, instead of using alsa force-reload , try running from terminal:

sudo /usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore

If this command restores your audio, then this is what you want to run at startup as a service (and its corresponding version to also run at shutdown), at appropriate moment.

Hence, if alsa-restore.service does not exist on your system, you should then and only then create your own myaudio.service like so:

sudo nano /etc/systemd/system/myaudio.service

Copy the following into it:

[Unit]
Description=Start Audio
ConditionPathExists=!/etc/alsa/state-daemon.conf


[Service]
Type=oneshot
ExecStart=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore
ExecStop=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime store
RemainAfterExit=true


[Install]
WantedBy=sound.target

Saving it, followed by:

sudo systemct enable myaudio.service 
sudo systemctl start myaudio.service 
sudo systemctl status myaudio.service

Which will enable, start and report the status of your new service. If the 3 commands complete without errors, then you can reboot and test it.

3
  • This didn't work. After bootscreen I got only a black screen with my mouse on it. My touchpad doesn't work, but with my mouse i can move my mouse on black screen. I randomly found out, that when i press f12 while boot screen, my system boots normally, I can login but the Audio still isn't working. I logged in this way and disabled the service and removed the .service file. now i can boot normally without pressing F12, but my Audio still isnt working. Do you hve any Ideas left?
    – laalsaas
    Sep 27, 2020 at 14:19
  • Sorry. my mistake. The reason systemd service failed (although it should not have prevented boot) was because of the Type=oneshot designation in the script, which allows for more than one command on the same line in the ExecStart= line. I'm going to update the script, and add a line explaining how to test the service before rebooting to make sure it works.
    – NetIceCat
    Sep 27, 2020 at 20:45
  • systemctl status alsa-restore .service returns additional to your example output this line: Process: 1356 ExecStart=/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore (code=exited, status=99)
    – laalsaas
    Oct 4, 2020 at 6:49
0

This message ¨code=exited, status=99¨ is probably due to not being a member of the audio group.

sudo usermod -a -G audio username

Then reboot and check with:

journalctl -b | grep alsa

2
  • logout is enough instead of rebooting.
    – annahri
    Nov 1, 2020 at 23:19
  • this didn't work. see edit 2 in my Question
    – laalsaas
    Nov 5, 2020 at 15:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .