Comment 24 for bug 1068804

I think the bug may be somewhere in ALSA's mixer restore logic in alsactl, but not sure yet. This is how I got to my theory.

I firstly completely disabled pulseaudio from autospawning, and worked with a pure ALSA test environment to make sure pulse wasn't getting in the way. To disable pulse autospawn, read https://wiki.ubuntu.com/PulseAudio/Log.

After disabling pulse, my procedure was as follows:
1. Delete /var/lib/alsa/asound.state. I also deleted Pulse config files other than client.conf for good measure, although this is probably not strictly necessary. At this point, also make sure pulseaudio is shut down/killed.
2. Place the attached config file in /usr/share/alsa/cards. This file will allow you to use aplay with no extra arguments to hear sound out of the Nexus speaker. (I'll probably include this file in alsa-lib to make sure a pure ALSA environment is available, i.e audio works without needing pulse.)
3. Disable the alsa store upstart job, by moving the file out of the way. The job you want is /etc/init/alsa-store.conf.
4. Reboot, and attempt to play a wav file with the aplay command. You will find a few wav files in /usr/share/sounds/alsa. You should hear nothing.
5. Open alsamixer, find the "int spk" control, and turn it on."
6. Play a file again with aplay, you should hear something.
7. As root, manually run "alsactl store", and reboot.
8. Once rebooted, try playing a file with aplay again, and you shouldn't hear anything.

After step 6, I took a snapshot of the mixer into a file with "amixer contents", and again after step 8. Unfortunately, the diff doesn't reveal anything obvious, which is why I suspect some race or something else funky going on with the mixer restore process. As per the above, deleting the state file, and a fresh init of the mixer, and turning on "int spk" gets audio working.

I also took snapshots of the mixer pre-suspend, and post-suspend when again, audio worked fine, and again, nothing obvious shows up.

Here is the diff from first init with int spk turned on, and mixer stored, then after a reboot:
--- mixer-fresh-intspk.txt 2013-02-04 15:52:26.724732002 +1100
+++ mixer-after-store-reboot.txt 2013-02-04 16:13:45.417744002 +1100
@@ -111,7 +111,7 @@
   : values=0
 numid=36,iface=MIXER,name='ADC Switch'
   ; type=BOOLEAN,access=rw------,values=1
- : values=off
+ : values=on
 numid=17,iface=MIXER,name='ADC Capture Switch'
   ; type=BOOLEAN,access=rw------,values=2
   : values=on,on
@@ -170,7 +170,7 @@
   : values=0
 numid=35,iface=MIXER,name='DAC Switch'
   ; type=BOOLEAN,access=rw------,values=1
- : values=off
+ : values=on
 numid=10,iface=MIXER,name='DAC1 Playback Volume'
   ; type=INTEGER,access=rw---R--,values=2,min=0,max=175,step=0
   : values=175,175

And here is the diff between pre-suspend and post-suspend, after the initial mixer store and reboot.
--- mixer-after-store-pre-suspend.txt 2013-02-04 16:31:46.750269002 +1100
+++ mixer-after-store-post-suspend.txt 2013-02-04 16:33:33.111757042 +1100
@@ -513,13 +513,13 @@
   : values=0
 numid=122,iface=MIXER,name='Stereo ADC MIXL ADC1 Switch'
   ; type=BOOLEAN,access=rw------,values=1
- : values=on
+ : values=off
 numid=123,iface=MIXER,name='Stereo ADC MIXL ADC2 Switch'
   ; type=BOOLEAN,access=rw------,values=1
   : values=on
 numid=120,iface=MIXER,name='Stereo ADC MIXR ADC1 Switch'
   ; type=BOOLEAN,access=rw------,values=1
- : values=on
+ : values=off
 numid=121,iface=MIXER,name='Stereo ADC MIXR ADC2 Switch'
   ; type=BOOLEAN,access=rw------,values=1
   : values=on