Ubuntu not saving sound settings (Alsa Mixer)

I found that my Creative Soundblaster doesnt play sound if IEC958 is enabled in alsa mixer settings (gnome-alsamixer). So I had to disable it manually every time I boot.

To restore alsa settings automatically at boot:

First save settings after properly configuring it:

alsactl store 0[/code]


sudo alsactl store 0
sudo kate /etc/rc.local[/code]

Add the following to /etc/rc.local:

#!/bin/sh -e

# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.
alsactl restore
exit 0[/code]

If while running alsactl store, you get a message "Cannot open /var/lib/alsa/asound.state for writing: Permission denied", and furthermore another message "Home directory not ours" while running it as sudo, then you have to temporarily change the permissions on the file to enable write

sudo chmod 777 /var/lib/alsa/asound.state
alsactl store 0
sudo chmod 644 /var/lib/alsa/asound.state[/code]

You may also require to clear the pulse audio settings to be certain that they dont get loaded up.

rm ~/.pulse/*[/code]