[Openal] Openal, S/PDIF and surround [Almost SOLVED]

Alfredo Pironti alfredo.pironti at gmail.com
Thu May 22 00:24:57 PDT 2008


> 
> If you need more instructions, I'll be happy to go into detail. :)

You were very clear. Thank you for teaching me! I'll try to stick with 
the OpenAL, mostly for package reasons. Nevertheless, at
http://ubuntuforums.org/showthread.php?t=725727
they give some info about compiling OpenAL Soft for Ubuntu.

> 
> 
>> I documented in a text file the steps I performed in order to have my
>> setup working. Nothing extremely difficult, but at least a couple of
>> tricks that is worth documenting about. Shall I post documentation on
>> this mailing list, or there is a better place where to put documentation?
> 
> It may help for future people, and I am a bit interested, so I wouldn't mind 
> you posting it here.

OK, here's my brief report. It is essentially a collection of snippets 
found on different web pages, plus my comments/experience.

I am running Ubuntu Linux 8.04. Unfortunately, the libasound2-plugins 
package does not ship the a52 plugin, so you will have to compile it 
from source. Fortunately, compiling from source in Ubuntu (and Debian) 
is rather simple. On the console type:

apt-get source libasound2-plugins
sudo apt-get build-dep libasound2-plugins
sudo apt-get install libavcodec-dev
cd alsa-plugins-1.0.15
./configure
make
sudo make install

Make sure that the "./configure" output indicates that a52 will be compiled.

I didn't switch to OpenAl Soft by now, because I don't want to break 
Ubuntu package manager. If I find some Ubuntu way, I'll let you know.

 From now on, the documentation is distribution independent.

Edit the file ~/.asoundrc adding the following lines

pcm.a52encode {
	rate 44100
	channels 4
	type a52
	}

I don't know if order of the devices matter; I put these lines at the 
bottom of the file. The "channels 4" option is specifying that this 
device will only accept 4-channel inputs. Since OpenAL is only capable 
of outputting 4 channels (and not 6), you have to select this option.
The "rate 44100" specified the input rate. Again, OpenAL will output 
sound with this bitrate, so you have to specify it. Should you use 
OpenAL Soft, you can specify "channels 6", since it can output true 5.1 
audio. Please refer to doc/a52.txt for more options and default values.

Then, edit the ~/.openalrc file, putting the following lines

(define devices '(alsa))
(define speaker-num 4)
(define alsa-out-device "a52encode")

You are specifying the you will use alsa, and in particular the 
a52encode device. You are also stating that the output should be on 4 
channels (matching the a52encode device configuration). Note that, with 
OpenAL, if you specify "speaker-num 6" it will revert to 2 channels, so 
it will not work. It should work with OpenAL Soft instead. Always 
remember to match the "speaker-num" option in .openalrc with the 
"channels" option in .asoundrc.

Note: some games (tremulous for instance) allow to chose the output 
bitrate. When you can choose 11, 22 or 44KHz, you should select 44KHz, 
so that it matches with the "rate 44100" option in .asoundrc. Other KHz 
will likely not work. Also note that the a52 plugin supports 48000KHz 
too, but it seems not to be supported by some games.

Open problems:
- After playing a bit in tremulous, when there were many sound being 
produced at the same moment, audio started clipping very noisely, and I
could see on my audio receiver that s/pdif signal was being sent 
intermittently. I don't know if it's game or OpenAL fault. If it's 
OpenAL fault, maybe switching to OpenAL Soft can do the trick.
- After any output is produced by the a52 plugin, stereo applications 
(like music player) stop emitting audio (even if restarted). I have to 
use the "speaker-test -Dspdif -c2" program to let s/pdif emit audio, 
then stereo applications restart working. Seems to be a problem with my 
configuration.

Your mileage may wary, hopefully not too much ;-)

Thank you very much again!
Cheers,
Alfredo


More information about the Openal mailing list