Saturday, October 19, 2013

Lubuntu, Kubuntu, Xubuntu or Ubuntu: Sound not working after resume from suspend

This post might as well be cataloged as a summary of a continuous frustration that has be fed by the lack of decent audio support in Linux.

I first saw Linux installed in 1999-2000 and it was a RedHat 6.1/6.2 from a computer magazine. From the start one of the first problems was getting the sound card working. I discovered I had to 'modprobe' and when I first heard a sound I loved it. Years went on and I switched to a Slackware 8.0 (booted from floppy :) ). I stayed for 1 month without sound until I found out what I need to do in order to make it run. To this date I consider slackware one of the best operating systems I've ever tried. Later on I switched to Ubuntu (6.04) 'cause I was tired of kernel compilations and lack of a package dependency tool. It was a miracle! Everything worked. I kept using Ubuntu and I never had any problems. I thought the desktop evolved, it was usable. But, I was wrong!

I installed the latest 13.10 Ubuntu/Lubuntu and found out that I had no sound after resume from suspend . I said to myself: "Come on, it must be a mistake, I haven't got a problem like this in years!"

But it seems that this is a known problem for quite a while. And I started searching on the Internet for (at least local) solutions.

My conclusions were that when suspended the audio card/driver remains in an inconsistent state and needs to be somehow restarted. In case of Alsa this is done via:

sudo alsa force-reload

But in my case I couldn't do that without errors that were telling me something like this:

1. Fix the driver (if this is really the case)
2. When executing pm-suspend do the steps that I did... (see man page for scripts executed on suspend)
3. Use a sound server (pulseaudio/jack/esd...) that when going to sleep disconnects gracefully from the /dev/snd/* files and lets the 'alsa force-reload' do the job on resume - before it connects again)

The best choice I believe it is 3 (if 1 is not the issue) because the applications using sound (playing or recording) cannot see any real difference since they are routed through the sound server.

If you know some distros that work in this scenario (after suspend+resume I can hear music), please let me know.

I had the same problem on my Sony Vaio Pro but only when the laptop was unplugged. At first I tried the steps described in this article. They worked but for some reason they were messing up the wifi card after resume. So I decided to simply disable pm powersave hooks related to soundcard and it fixed the problem:

I'm trying to pinpoint the issue. I cannot confirm if it started with making audio on HDMI work. But now (Ubuntu 14.04 LTS) audio seems to fail/stop if I use the 'Videos' application to play MP4 files, (FLV files works fine). But with VLC, all seems working.

Just now (2015-09-11) Some 'video player (flash)' plugin on firefox breaks my audio.

To fix the issue, i do 'sudo alsa force-reload', i can then play the 'file' that broke the audio with VLC. But force-reloading sometimes break the audio that rebooting can fix. Reboot by the way can fix the issue.