Search:  
Gentoo Wiki

HOWTO_ALSA_and_TeamSpeak_on_amd64


Please format this article according to the guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article


Contents

HOWTO setup Teamspeak2 on amd64

The problem is that Teamspeak isn't available for native 64bit, so you have to setup an 32bit environment for TeamSpeak. This is very easy with the existing x86 emulation libraries, however you may run into some problems. TeamSpeak supports only the old sound API (OSS) which allows only one application to access the card (as long as you do not have a sound card that supports hardware mixing!). That makes it impossible to use TeamSpeak while playing other sounds or games. To work around this you can use a sound daemon (esd, arts) or use the alsa-oss emulation (not the one in the kernel, there is also one that works from the user space).

Install packages

First you have to install emul-linux-x86-xlibs and emul-linux-x86-soundlibs:

emerge emul-linux-x86-xlibs
emerge emul-linux-x86-soundlibs

However, these packages SHALL already come up as a dependency of the following:

Then you can install TeamSpeak itself:

emerge teamspeak2-client-bin

If you get an error like "media-libs/jasper could not compile", try to compile without opengl USE-Flag:

USE="-opengl" emerge media-libs/jasper

In some cases TeamSpeak will just work without anyproblems.

Launch TeamSpeak and try it:

TeamSpeak

or

/opt/bin/TeamSpeak

If it doesn't work properly (especially when running a second sound application like a media player or a game), read on.

Setup sound subsystem

I'm using plain ALSA (no sound daemons) so I had to setup my ALSA devices first. If you have a card that doesn't support hardware mixing (most integrated soundchips don't), you'll have to setup dmix

Compile alsa-lib

UPDATE : To avoid the highly annoying procedure to compile your own 32bit alsa-lib (which is also prone to fault), just update to emul-linux-x86-soundlibs-2.3, which fixes the error below. See Bug #114426

Warning: I have alsa-lib-1.0.10 and emul-linux-x86-soundlibs-2.2, but those are incompatible ! You'll see errors like:
Code: Error message
ALSA lib pcm_dmix.c:788:(snd_pcm_dmix_open) unable to create IPC shm instance
mplayer: pcm_params.c:187: snd_pcm_hw_param_get_min: Assertion `!snd_interval_empty(i)' failed. 

If you start a 32bit and 64bit application at the same time (for example: Wine and MPlayer). The second application will always fail with a similar error because of the incompatibility.

To compile your own alsa-lib for 32bit, extract the alsa-lib archive and run:

Code: Compile alsa-lib for 32bit
./configure --prefix=/home/yourname/root \
   LDFLAGS="-L/emul/linux/x86/usr/lib -m32" \
   CFLAGS="-L/emul/linux/x86/usr/lib -m32" 
make
make install

This will install a 32bit libasound.so.2.0.0 to /home/yourname/root/lib. Copy this library to /emul/linux/x86/usr/lib. Now you should be able to run 32bit and 64bit applications at the same time and both should be able to access the sound card.

Start TeamSpeak

To convince TeamSpeak to use ALSA we'll use aoss32. This comes from the emul-linux-x86-soundlibs package and is a little wrapper script that preloads libaoss.so. This library reroutes all calls to the old OSS sound subsystem to ALSA.

To start TeamSpeak, we use this:

ALSA_OSS_DEBUG=1 aoss32 TeamSpeak

That shows us some debug informations.

If you'll see lots of 'read' 'write' messages, you're fine. But that was not the case here. I got this:

$ ALSA_OSS_DEBUG=1 aoss32 TeamSpeak 
Opened PCM dsp0 for stream 0 (result = -2)
Opened PCM default for stream 0 (result = 0)
Opened PCM default for stream 1 (result = 0)
open("/dev/dsp", 2, 0) -> 18
ioctl(18, SNDCTL_DSP_RESET)
ioctl(18, SNDCTL_DSP_SETDUPLEX)
ioctl(18, SNDCTL_DSP_GETCAPS, 0x590e9168) -> [13056]
ioctl(18, SNDCTL_DSP_SETFRAGMENT, 0x590e916c[3000c])
dsp ioctl error = -22
close(18) -> 0
$

This appears if you have set period_time or period_size in your ~/.asoundrc. If you delete these options TeamSpeak should run just fine. However, after that wine doesn't work, wine needs one of those options.

I haven't found any way around that other than patch alsa-oss and compile it on my own. The good thing is that you only have to comment out a few lines and it compiles just fine for 32bit.

If the output stops after the first 'read' message, that means that snd_pcm_start() hasn't been called by the preloaded library. I've worked around this by adding this call to the read/write functions in the preloaded library.

If TeamSpeak crashes with EAccessViolation or if you see X errors, that means that the preloaded library returned wrong (too big) values in one function.

Compile patched alsa-oss

Copy the alsa-oss archive from your distfiles directory to your home directory, extract it, enter the created directory and run:

Code: Compile patched alsa-oss
./configure \
   --prefix=/home/yourname/root \
   LDFLAGS="-L/emul/linux/x86/usr/lib -m32" \
   CFLAGS="-L/emul/linux/x86/usr/lib -m32"

Because the stupid libtool uses absolute paths, we'll have to edit the ./libtool file.

File: ./libtool

Replace

"/lib64 /usr/lib64" 

with

"/emul/linux/x86/lib /emul/linux/x86/usr/lib"

You should replace that string on a total of 4 lines:

sys_lib_search_path_spec="/emul/linux/x86/lib /emul/linux/x86/usr/lib"
sys_lib_dlsearch_path_spec="/emul/linux/x86/lib /emul/linux/x86/usr/lib"
sys_lib_search_path_spec="/emul/linux/x86/lib /emul/linux/x86/usr/lib"
sys_lib_dlsearch_path_spec="/emul/linux/x86/lib /emul/linux/x86/usr/lib" 

all located towards the end of the file.

Modify files

Open alsa/pcm.c and go to line ~269, You'll see a

if (dsp->maxfrags > 0) {
 ...
}

block around this line. Comment that out.

Next block around lines ~955:

case SNDCTL_DSP_GETBLKSIZE:
   str = &dsp->streams[SND_PCM_STREAM_PLAYBACK];
   if (!str->pcm)
      str = &dsp->streams[SND_PCM_STREAM_CAPTURE];
   pcm = str->pcm;
   *(int *) arg = str->oss.period_size * str->frame_bytes;
   DEBUG("SNDCTL_DSP_GETBLKSIZE, %p) -> [%d]\n", arg, *(int *)arg);
   break;

replace

*(int *) arg = str->oss.period_size * str->frame_bytes;

with a constant number, 4096 works here and 8192 doesn't. This is the place where a too big number is returned.

*(int *) arg = 4096;

Now add the snd_pcm_start() calls:

in the lib_oss_pcm_read() / lib_oss_pcm_write() functions (starting around line 655) add

snd_pcm_start(pcm);

right before the _again: label:

   frames = n / str->frame_bytes;
   snd_pcm_start(pcm);
_again:
   result = snd_pcm_writei(pcm, buf, frames);


Now you can compile it

make
make install

and again, go to /home/yourname/root/lib and copy libaoss.so.0.0.0 and libalsatooss.so.0.0.0 to /emul/linux/x86/usr/lib

Now you should be able to run wine (32bit), TeamSpeak (32bit) and any 64bit alsa-enabled application (mplayer, alsaplayer etc) at the same time.


Links

Related gentoo bug: http://bugs.gentoo.org/show_bug.cgi?id=114426

Retrieved from "http://www.gentoo-wiki.info/HOWTO_ALSA_and_TeamSpeak_on_amd64"

Last modified: Mon, 08 Sep 2008 11:02:00 +0000 Hits: 17,800