Two months ago, I wrote a tutorial on configuring a Firewire audio interface as the default sound device in Linux, specifically using Ubuntu distribution.
It works well until Ubuntu release version 12.04 LTS where I encounter some playback issues. The following are some symptoms:
a.) Unable to stream audio when watching Youtube or any audio stream from a web browser.
b.) Unable to route ALSA (Advanced Linux Sound Architecture ) to JACK. This was temporarily fixed by setting “JACK” in the audio output of GNOME Mplayer.
However, being unable to listen to any audio when browsing the web is a serious problem. Hopefully I was able to sort out the problem completely and I would like to share it with you in this troubleshooting tutorial.
Preliminary Confirmation of the Problem
If you are unable to play audio when streaming using ALSA output, you need to confirm if you have correctly routed ALSA to JACK.
Step1.) Launch terminal (Control -ALT- T) and type this command:
vim .asoundrc
Confirm if its there and contain the code as stated here.
.asoundrc is basically located in your Ubuntu home directory, for example:
/home/emerson/.asoundrc
If it’s there and the code is correct, proceed to Step2
Step2.) In this step, you will confirm that ALSA will be able to output audio to JACK when “pcm.jack” is directly called or utilized:
aplay -D pcm.jack /home/your_Ubuntu_username/Desktop/filenameofyourwav.wav
You need to have a WAV file (16-bit/44.1KHz) placed in your Ubuntu desktop to run this test.
If you are able to hear some audio output, it means ALSA routing to JACK is OK when called directly. However software applications that outputs audio to ALSA may not be routed correctly to JACK because of some possible conflict.
Checking for possible conflict
When you are using Firewire audio interface in Linux, you are basically using FFADO drivers for the OS to communicate with the hardware. These drivers will accept JACK at its input and output audio to the sound device via Firewire connection:
JACK === > FFADO === > Firewire audio interface
Meanwhile JACK is a low latency sound server ideal for professional music production. In this tutorial, JACK is configured to received ALSA output.
Or in flow diagram:
ALSA === > JACK
ALSA can also output to PulseAudio instead of using JACK:
ALSA === > PulseAudio
Browsers such as Firefox uses ALSA plug-in when outputting audio. PulseAudio is the sound server used by Ubuntu 12.04. It is most likely installed by your package. The best way to confirm if this is installed is to launch Ubuntu software center and type this word in the search box: pulseaudio
If you see a green check mark on the package, it is installed such as shown below:
Now you need to check the existing ALSA configuration to see where the audio output goes. In the terminal, type this command to access the alsa configuration folder in Ubuntu:
cd /usr/share/alsa
Display the existing files in that directory by typing this command:
ls -l -a
Check if there is file named “pulse-alsa.conf” and “alsa.conf”. These are ALSA configuration files. Specifically, “pulse-alsa.conf” will only exist if PulseAudio is installed in the system.
To understand how they work is to read the configuration file by entering the command:
vim alsa.conf
This is an important part:
It says that ALSA will actually load .asoundrc (the configuration file created in your home directory) and the configuration in the directory named as “alsa.conf.d”.
Try exiting the code editor (type : then q, press enter). Go inside alsa.conf.d directory and read the pulse.conf file.
vim pulse.conf
This is the code:
hook_func.pulse_load_if_running {
lib "libasound_module_conf_pulse.so"
func "conf_pulse_hook_load_if_running"
}
@hooks [
{
func pulse_load_if_running
files [
"/usr/share/alsa/pulse-alsa.conf"
]
errors false
}
]
It says that it will use PulseAudio as the default sound server for applications using ALSA when its running. It will then execute the pulse-alsa.conf that contain this code:
pcm.!default {
type pulse
hint {
show on
description "Playback/recording through the PulseAudio sound server"
}
}
ctl.!default {
type pulse
}
Thus confirming the root cause of the problem. The above code shows that ALSA output is routed to PulseAudio instead to JACK sound server.
The Solution: Disable and Uninstall PulseAudio
Since its confirmed that PulseAudio is interferring the routing from ALSA to JACK, then it needs to be disabled/uninstalled completely.
1.) The simplest way to uninstall is using Ubuntu software center, type “pulseaudio” then select on and click “Remove” – then click “Remove all” to include other dependencies.
2.) Make sure you have turned on your firewire audio interface as well as the monitors/speakers.
3.) Although not necessary, I suggest a restart of your system by entering this command in the terminal:
sudo reboot
And then enter your Ubuntu password.
4.) After the complete restart, launch a terminal and start the ffado dbus server, enter this command:
ffado-dbus-server
5.) After that, enable the ffado mixer:
ffado-mixer
6.) And finally, turn on JACK:
qjackctl
And click “Start”. This should turn on the Firewire connection to your audio hardware. In some audio interface like Focusrite Saffire Pro40, “FW Active” LED will light green.
7.) Switch the main monitor volume of your audio interface to medium.
8.) Let’s use Firefox and go to Youtube to see if the ALSA audio stream will now be routed to JACK. You should be able to listen music coming out of your studio monitors.
Why this will work? By disabling PulseAudio, ALSA will now route audio correctly to JACK then to FFADO/audio interface. If you go again to this path:
/usr/share/alsa
The PulseAudio-ALSA configuration plugin( pulse-alsa.conf) is gone:
Known Limitations
1.) Popular music player such as Rhythmbox will not work. The recommendation is to use GNOME Mplayer that is the preferred player since it will allow configuration of audio output through ALSA or directly to JACK.
Mplayer can also be used when viewing movies in Ubuntu and the audio will work well as long as it properly configured.
2.) There will be some lag, since the audio will still be routed from one place to another. Since this troubleshooting is for playback only, this is not a serious issue.
3.) Other music applications/players might not work unless they are configured to output audio either to ALSA or JACK.
4.) This solution is not perfectly stable and audio will sometimes crash (though not always). You can always close JACK terminal window first and type qjackctl command again. If it cannot be restarted for some reason, it needs a clean reboot on your computer.