Kevin Vance - Dealing with 32-bit Flash on Linux... AGAIN.

Entries | Archive | Friends | Friends' Friends | User Info

01:25 pm

Dealing with 32-bit Flash on Linux... AGAIN.

Tuesday, June 15th, 2010
Previous Entry Add to Memories Share Next Entry
Tags, , ,

Adobe recently patched a vulnerability in the Flash plugin. But they didn't release a fix for the 64-bit version, officially (and effectively) abandoning it. This posed a problem for me, since I can't get audio out of a 32-bit program.

Back when I built my current Linux machine, I decided that the motherboard's included "Bernstein audio module" daughter card was good enough. The only killer feature it was missing was hardware mixing. This turned into a huge problem. Most Linux distros' solution to software mixing is PulseAudio, and a perfectly reasonable thing to do with Pulse on a new Linux install is to remove it entirely. Pulse has a lot of nifty bells and whistles, but it's built on a terrible foundation. Integral to the Pulse experience are stutters, pops, and wandering audio-video synchronization.

After giving up on Pulse, I turned to JACK. JACK has some features too, but more of the kind that are useful to musicians and professionals than to home users. Where Pulse can automatically downmix a 5.1 audio stream to my 4.0 speaker setup, JACK would require that I manually edit the channel mappings, or use a program like JACK Rack to filter the audio through a LADSPA plugin. However, JACK makes up for this by providing reliable, low-latency mixing.

It turns out that there's one more problem with JACK. Its wire protocol is not compatible across different CPU architectures. A 32-bit JACK client cannot talk to a 64-bit JACK server. This didn't affect me until the 64-bit version of Flash was dropped. Now I have a problem: if I want Flash videos to have sound, I have to run PulseAudio and endure its many problems, or give Flash exclusive control of the soundcard like it's 1997.

There's only one thing for it: jam Pulse in between the audio source and JACK.

Audio routing diagram

This is accomplished by forcing Pulse to use JACK as an output instead of detecting your hardware. Comment out the autodetection stuff, and add the JACK module in /etc/pulse/default.pa:

### Automatically load driver modules depending on the hardware available
#.ifexists module-udev-detect.so
#load-module module-udev-detect
#.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
#load-module module-detect
#.endif
load-module module-jack-sink channels=4

And edit ~/.asoundrc to use Pulse by default, but provide a JACK device for programs that can use it:

# Use PulseAudio by default
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

# Use JACK for the OSS wrapper
pcm.dsp0 {
    type plug
    slave.pcm "jack"
}

# ALSA JACK support (64-bit ONLY!)
pcm.jack {
        type jack
        playback_ports {
                0 alsa_pcm:playback_1
                1 alsa_pcm:playback_2
        }
        capture_ports {
                0 alsa_pcm:capture_1
                1 alsa_pcm:capture_2
        }
}

Now programs that need good audio support (e.g. MythTV, MPlayer) can use JACK directly, and programs that don't (or can't) can use Pulse. This is really stupid, and only barely seems to work. I've been manually killing and restarting the Pulse audio server and the Flash plugin a lot (thanks, Google Chrome!). But it seems to be the best of a bunch of bad options.

Link )Reply )

Comments
[User Picture]From: wikle
2010-06-17 02:10 am (UTC)

(Link)

I like the happy sun in your diagram. It makes me think of ruins in a bioware fantasy rpg.





See... I contributed!
[User Picture]From: kvance
2010-06-17 02:27 am (UTC)

Ham!

(Link)

Good contribution!
[User Picture]From: gen_witt
2010-06-18 01:31 am (UTC)

(Link)

People keep telling me that Pulse works now. I'm sticking to dmix for the time being though.
[User Picture]From: kvance
2010-06-18 01:25 pm (UTC)

(Link)

I used dmix for a while, but it only seemed to let one local user at a time access the soundcard. jackd in promiscuous mode mixes sound for every user in the 'audio' group.

Edited at 2010-06-18 01:26 pm (UTC)
From: (Anonymous)
2010-07-02 04:36 pm (UTC)

(Link)

Use ipc_perm.
[User Picture]From: kvance
2010-07-02 04:40 pm (UTC)

(Link)

Thanks! I'll look into that.