Friday, September 15, 2006
Firefox, Linux and Audio
Popularity of flash based video distribution sites like YouTube has made Firefox with its flash player an important component of today's desktop. But it is often the case with not-so-new (SuSE 10.0 and earlier) Linux desktops that audio refuses to work. Most common reason for audio not working is when some other process or program has taken control of the sound device, and Flash player can not access it. Fortunately, fixing this problem is easy, provided your system is not too old.
Fix: Firefox is started by a shell script named firefox, usually located in /usr/bin/. This script executes the mozilla firefox binary with appropriate options. To fix the sound problem, you need to start this binary with aoss. This translates to editing /usr/bin/firefox as root, and modifying the line containing
$MOZ_PROGRAM $@to
aoss $MOZ_PROGRAM $@Note that these instructions are tested with SuSE 9.3 and 10.0, and some things may vary depending on the distro in use.
Some history: Old linux used oss as its sound interface. OSS is not capable of sound mixing that enables multiple programs to use the sound device simultaneously. KDE's aRts was used on top of OSS for a long time as a temporary solution as aRts provided software mixing. But aRts is buggy, and is not well supported by many non-KDE applications. Finally, OSS was replaced by a new advanced sound interface, ALSA in 2002. ALSA can use hardware capabilities of audio device to mix sound coming from multiple sources, and in case hardware does not support sound mixing, ALSA provides a software implementation of mixer named dmix.
Flash player: Flash is a proprietary software, owned by a commercial organization with sole purpose of making money. It still uses OSS, as porting it to use ALSA would not have created any extra money for Macromedia/Adobe. aoss is a script that can provide OSS emulation to applications requiring OSS, while actually using ALSA. So when Firefox is run with aoss, Flash player uses ALSA in place of OSS. On newer linux distributions (openSUSE 10.1 and later), Firefox is configured by default to use aoss.