Xine + emu10k1 AC3
How to watch DVD's in Linux with full-fidelity 5.1 sound from a Creative SoundBlaster Live!
By: John Laur
Note: The information in this article is over a decade out of date. It is preserved as a historical curiosity.
Disclaimer: The status of this software is currently:
Hack (3/25/2001) - Got a DVD playing video while AC3 data
sputtered out of the Live! Using Juha Yrjölä's
Kludge (3/26/2001) <-- We are here. I tested a few movies last night and watched The Matrix all the way through in 5.1
Unnecessary! - Xine now includes support for FMT_AC3 on OSS natively and the emu10k1 driver can now auto-load its AC3 passthrough patch when needed!
What this patch currently does:
This software patch can currently allow you to play a DVD using xine and pass the AC3 audio output to an external Dolby 5.1 or DTS decoder.
It also handles switching between AC3 and LPCM audio output in mid stream.
It can correctly reestablish sync on seek (you can drag your slider around with impunity), and you can change the audio stream in xine and it will not lose sync or blip, etc.
What this patch currently
does not do:
First, this patch only passes AC3 audio through the SPDIF connector. It does NOT decode AC3 to four+ channels and output analog to front/rear/other speakers; though, libac3 supports this, xine supports this on ALSA, and it would probably be pretty easy to get xine playing nice with 4 speaker output on the emu10k1 oss driver also. Once documentation can be procured from Creative on the 5.1's extra DAC and possible on-chip AC3 decoding capabilities, then we could have some really fun things going on! But this library exists for another reason.
Since switching to and from AC3 passthrough mode requires loading and unloading patches to the emu10k1 dsp, currently this is handled with (shoot me) system() calls to other programs that handle this. It is a real mess and needs to be rewritten so that xine can do it natively. Since it hasn't yet been established that this is the way that the emu10k1 driver will even support AC3 passthrough, I haven't put a lot of time into fixing it.
As far as sync goes, there are some definate problems. The audio and video seem to keep perfect pace with each other; however, they are not timed correctly with one another. I had to make xine completely skip a sync step when in AC3 mode, so that is probably where this is coming from.
Also the AC3 cuts out sometimes mid-stream and you have to nudge the seek bar to reestablish sync. I think that the AC3 frames are losing sync with the IEC958 frames, and that is where it is all happening.
How to make this work:
First, you will need the latest emu10k1 driver from CVS at opensource.creative.com and Juha Yrjölä's AC3 patches to enable AC3 passthrough. These patches are available at shakti.tky.hut.fi/~odin/patch-ac3.gz You'll have to compile and get all this junk running by yourself. I don't want to write a HOWTO and can't take the time to support this at this stage. Make sure you compile the DSP patch manager tool (mgr_text) and hang onto ac3pass.bin, because you'll need it later!
Second, grab the latest release of xine (Non CVS to be safe) from xine.sourceforge.net This patch was created against xine 0.4.01 It also works against the "complete_xine" package version 0.4.01 with libcss and IFO parsing support. This version of xine can be downloaded at gape.ist.utl.pt/ment00/linuxdvd.html If you want to watch CSS encrypted DVD's with xine then you'll need this version. Anyway, after you have xine, replace the file $XINE/audio_out/audio_oss_out.c with my version here. Then compile and install xine as you normally compile anything. You don't have to give configure any special flags to enable emu10k1 support (though you probably should if this junk is ever merged into xine)
Finally, install xine. Put mgr_text somewhere in your path (/usr/local/bin works nicely) and put ac3pass.bin into /usr/share/xine (I build everything into Debian packages, so that's why it's looking in /usr. Unless you alter the source directly, you can't change this right now. Next, you can test xine by just starting it as you would normally and everything should work as xine always has. To try the AC3 passthrough stuff, start xine with -S (enable spdif output). BTW -S is an existing xine switch to support AC3 passthrough on ALSA cards that support it, so we are really doing nothing new, just enabling it to work with the emu10k1 OSS driver too, since the ALSA one doesnt support the emu10k1's SPDIF interface properly yet... After you do this, you should get 5.1 sound! If xine crashes, debug it. If you just don't get AC3 out, just check that you started with -S, that you are running the correct xine with my patch, that xine isn't using its ALSA interface for some reason, and that your speakers or reciever can decode AC3 or DTS or whatever else you are feeding them from the DVD!
Hopefully this will help somebody. I may not have a lot of time to continue developing this - I'm hoping someone on the xine team has a SBLive! and will want to pick this task up. If you fix something or give me any ideas/patches just drop me a line at email@example.com