pulseaudio – flash blocks the audio device
On my x86_64 gentoo box, running gnome and therefore pulseaudio, I experienced the problem that when and after playing some flash videos (i.e. youtube) the sound device was blocked and no other application was able to play sound. After killing the plugin sound worked just normal, but that was no convenient way.
64-bit flash plugin for Firefox
My first suspective was the 32-Bit flash plugin I used in my 64-bit Firefox until now. So I replaced it by the new 64-bit plugin, which did not solve the problem, since it does also not use pulseaudio for playback. But I include the steps for completeness here:
echo “=www-plugins/adobe-flash-10.2.161.22_pre20100915 **” >> /etc/portage/package.keywords
emerge adobe-flash
For other linux distributions like Debian, Ubuntu, Redhat or Suse you obviously have to search the appropriate plugin and install it the distribution-specific way. Afterwards you have to remove the 32-bit plugin from nspluginwrapper, which makes 32-bit plugins available for 64-bit firefox:
nspluginwrapper -r /usr/lib/mozilla/plugins/npwrapper.libflashplayer.so
As I stated before this does not solve the problem, but at least it gives one a 64-bit flash plugin 😉
Make alsa applications use the pulseaudio server
There is a pulseaudio plugin for alsa, which is necessary for playback of alsa sound via the pulseaudio server. So the next step is to install this plugin. For gentoo it is contained in the alsa-plugins package. So for the gentoo way:
emerge alsa-plugins
Afterwards make sure that your /etc/asound.conf contains the following lines:
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
After restarting alsa everything that is playing sound via alsa now uses pulseaudio via the plugin and the sound device is no more used concurrently. One can playback via pulseaudio after using flash sites or even at the same time. Mission accomplished!
OSS emulation for pulseaudio
Sadly the above only works for applications directly using the alsa sound system. Applications depending on OSS (i.e. all Java Applications), using the kernel layer alsa oss emulation, still block the audio device, so the the kernel layer OSS emulation is a no go with pulseaudio. Include the corresponding modules in /etc/modprobe.d/blacklist.conf or remove the emulation completely from your kernel configuration.
Of course this only shuts off these applications completely but is neccesary for the further steps to work. We´re lucky, we can use a daemon which provides the OSS devices (/dev/dsp, etc.) and links them via fuse to the pulseaudio daemon. For this we need to load the cuse kernel module (add it to /etc/modules.autoload.d/kernel-2.6 and it gets loaded automatically on next reboot) or when not available add the functionality to your kernel configuration and rebuild your kernel.
Now we´re ready to install ossp, the daemon I mentioned before. It is available from Sourceforge, probably also in your distributions package repository. For gentoo users, as usual there is a more easy way. I found an ebuild for ossp on gentoo bugzilla, which I got to work with minor modifications. You can download the modified ebuild here: [download#40]
To use the ebuild, just copy it to/usr/local/portage/media-sound/ossp/ . You probably have to create the directory. Then run
ebuild /usr/local/portage/media-sound/ossp-1.3.2.ebuild digest
Be sure to include the following line in your /etc/make.conf.
PORTDIR_OVERLAY=”/usr/local/portage”
Also include ossp into your /etc/portage/package.keywords
echo “media-sound/ossp **” >> /etc/portage/package.keywords
Afterwards just
emerge ossp
For having osspd started automatically on every system boot I lazily included it in my /etc/conf.d/local.start.
echo /usr/sbin/osspd >> /etc/conf.d/local.start
Now sound should just work as one expects it to. Different sources can playback at the same time. No blocked devices occur because of concurrency, no matter which sound API the applications use.
Jürgen
References:
BombStrike´s blog: How to use two different computers with two differents OSes seemlessly
September 27th, 2011 at 9:50 am
Oh my god!, I haven’t figured out that damm sound blocking in a very, very long time [/etc/asound.conf], thanks!, it works perfectly.