No sound output from headphone jack Ubuntu12.04

This happens to me occasionally, running

alsactl restore 

always fixes it (on an XPS computer)


Unable to add comments; so here is an "answer" that is partially a question (I'll might delete it):

On my install I sometimes have an issue with this and to resolve it I go into sound settings and select "Output volume" to OFF then ON and sound gets OK.


Edit:

Have you tried

sudo apt-get install pavucontrol

Run pavucontrol and check settings. I.e. output device Headphones and ensure not muted.


Edit:

Have you disabled autospawn? If not pulseuadio might still be running (but got re-started). To check if PulseAudio daemon is running do i.e.:

pulseaudio --check && echo RUNNIG || echo DOWN

If it is running and everything is OK you should check system log files to see if there is something hinting about faults. As a hack, if restart of daemon is all that is needed, you could add pulseaudio -k to startup to re-start daemon.

If it is running and you want to disable it you'll have to turn autospawn off.

See Disabling PulseAudio

If it is not running you'll might get some useful information using debug.

This would also be useful if you add these settings temporarily to configuration.

Start pulseaudio with

pulseaudio --start --log-level=4 --log-target=file:pulse.log
# Level 4 is debug 

Then start some tune and:

tail -f pulse.log

Unplug jack. Take note of last log entry; should end in something like:

D  [alsa-sink] sink.c: Volume change to 52057 at 83909698687 was written 17 usec late

Insert jack; look for anything that can explain why there is no sound. I.e. my output (working) is:

D  [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in
D  [pulseaudio] device-port.c: Setting port analog-output-speaker to status no
D  [pulseaudio] module-switch-on-port-available.c: finding port analog-output-speaker
D  [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes
D  [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
D  [pulseaudio] module-switch-on-port-available.c: finding port analog-output-headphones
D  [alsa-sink] alsa-mixer.c: Activating path analog-output-headphones
D  [alsa-sink] alsa-mixer.c: Path analog-output-headphones (Headphones), direction=1, priority=90, probed=yes, supported=yes, has_mute=yes, has_volume=yes, has_dB=yes, min_volume=0, max_volume=31, min_dB=-93, max_dB=0
D  [alsa-sink] alsa-mixer.c: Element Master, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x7ffffffffffff, n_channels=1, override_map=yes
D  [alsa-sink] alsa-mixer.c: Element Headphone, direction=1, switch=1, volume=0, volume_limit=-1, enumeration=0, required=0, required_any=4, required_absent=0, mask=0x0, n_channels=0, override_map=yes
D  [alsa-sink] alsa-mixer.c: Element Speaker, direction=1, switch=2, volume=2, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x7ffffffffffff, n_channels=1, override_map=no
D  [alsa-sink] alsa-mixer.c: Element PCM, direction=1, switch=1, volume=1, volume_limit=-1, enumeration=0, required=0, required_any=0, required_absent=0, mask=0x3600000000f66, n_channels=2, override_map=yes
D  [alsa-sink] alsa-mixer.c: Jack Front Headphone, alsa_name='Front Headphone Jack', detection possible
D  [alsa-sink] alsa-mixer.c: Jack Headphone, alsa_name='Headphone Jack', detection unavailable
I  [alsa-sink] alsa-sink.c: Successfully enabled deferred volume.
I  [alsa-sink] alsa-sink.c: Hardware volume ranges from -93.00 dB to 0.00 dB.
I  [alsa-sink] alsa-sink.c: Fixing base volume to 0.00 dB
I  [alsa-sink] alsa-sink.c: Using hardware volume control. Hardware dB scale supported.
I  [alsa-sink] alsa-sink.c: Using hardware mute control.
I  [pulseaudio] sink.c: Changed port of sink 0 "alsa_output.pci-0000_00_1b.0.analog-stereo" to analog-output-headphones
I  [pulseaudio] module-device-restore.c: Restoring volume for sink alsa_output.pci-0000_00_1b.0.analog-stereo.
D  [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
D  [alsa-sink] alsa-sink.c: Requested volume: 0: 100% 1: 100%
D  [alsa-sink] alsa-sink.c:            in dB: 0: 0.00 dB 1: 0.00 dB
D  [alsa-sink] alsa-sink.c: Got hardware volume: 0: 100% 1: 100%
D  [alsa-sink] alsa-sink.c:               in dB: 0: 0.00 dB 1: 0.00 dB
D  [alsa-sink] alsa-sink.c: Calculated software volume: 0: 100% 1: 100% (accurate-enough=yes)
D  [alsa-sink] alsa-sink.c:                      in dB: 0: 0.00 dB 1: 0.00 dB
D  [alsa-sink] sink.c: Volume going up to 65536 at 83942385195
I  [pulseaudio] module-devic2 events suppRestoring mute state for sink alsa_output.pci-0000_00_1b.0.analog-stereo.
D  [alsa-sink] sink.c: Next volume change in 17483 usec
D  [alsa-sink] alsa-sink.c: Requested to rewind 65536 bytes.
D  [alsa-sink] alsa-sink.c: Limited to 2824 bytes.
D  [alsa-sink] alsa-sink.c: before: 706
D  [alsa-sink] alsa-sink.c: after: 706
D  [alsa-sink] alsa-sink.c: Rewound 2824 bytes.
D  [alsa-sink] sink.c: Processing rewind...
D  [alsa-sink] sink.c: latency = 1358
D  [alsa-sink] sink.c: Next volume change in 1358 usec
D  [alsa-sink] sink-input.c: Have to rewind 2824 bytes on render memblockq.
D  [alsa-sink] source.c: Processing rewind...
D  [alsa-sink] sink.c: Next volume change in 1249 usec
D  [alsa-sink] sink.c: Next volume change in 1221 usec
D  [alsa-sink] sink.c: Next volume change in 1201 usec
D  [alsa-sink] sink.c: Next volume change in 872 usec
D  [alsa-sink] sink.c: Next volume change in 842 usec
D  [alsa-sink] sink.c: Next volume change in 819 usec
D  [alsa-sink] sink.c: Next volume change in 799 usec
D  [alsa-sink] sink.c: Next volume change in 764 usec
D  [alsa-sink] sink.c: Next volume change in 744 usec
D  [alsa-sink] sink.c: Volume change to 65536 at 83942369199 was written 0 usec late

Another thing worth checking/hacking is gstreamer-properties (Alt+F2 gstreamer-properties Enter).

If you do not want pulseaudio you could try i.e. jack.