Oss2jack
Contents |
Introduction
Oss2jack allows OSS applications to use the jack sound server with the advantage of being able to start several OSS applications at the same time. With giving jackd some additional options both oss2jack and jackd can also make use of your .asoundrc settings - including software mixing and plugins like Softvol.
Since oss2jack depends on the fusd-kor kernel module, which isn't in portage and versions from several sites don't seem to compile on newer kernels (>= 2.6.19), a few steps are required to get it working.
To get best latencies for your jackd and OSS based applications you should also install a realtime kernel as described below.
ALSA Configuration
To have better control over the ALSA devices and settings that jackd will use, I suggest to create an .asoundrc configuration file for ALSA with some basic settings:
| File: $HOME/.asoundrc |
pcm.!default { ### this will be the standard device for any ALSA based application
type plug
slave.pcm "dmixer"
}
pcm.dmixer { ### defines a new playback device with software mixing enabled
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "hw:0"
channels 2
period_time 0
period_size 1024
buffer_size 4096
rate 48000
}
bindings {
0 0
1 1
}
}
pcm.dsnooper { ### defines a new capturing device with software mixing enabled
type dsnoop
ipc_key 1024
ipc_perm 0666
slave {
pcm "hw:0"
channels 2
period_time 0
period_size 1024
buffer_size 4096
rate 48000
}
bindings {
0 0
1 1
}
}
ctl.!default {
type hw
card 0
}
ctl.dsnooper {
type hw
card 0
}
ctl.dmixer {
type hw
card 0
}
|
If you need more information on setting up ALSA you could try this HOWTO.
Recommended versions
At the time of writing this (04/2008) I only got proper results when using a certain combination of driver and software versions. When using jack-audio-connection-kit-0.109.* for example jackd would crash if an oss2jack application causes xruns. Also using the kernel-alsa driver rather than the alsa-driver ebuild gave me best results. So here is my current list of versions that work fine:
1. Linux Kernel 2.6.22.1-rt9 (vanilla kernel with manually applied realtime patches)
2. media-libs/alsa-lib-1.0.16
3. media-sound/alsa-utils-1.0.16
4. media-sound/alsa-headers-1.0.16
5. media-sound/jack-audio-connection-kit-0.103.0
6. media-sound/oss2jack-0.25
7. media-sound/fusd-kor-1.10.11-r1
Instructions:
The following can be added to /etc/portage/package.keywords; then just follow the rest of this HOWTO:
| File: /etc/portage/package.keywords |
=media-libs/alsa-lib-1.0.16* =media-sound/alsa-utils-1.0.16* =media-sound/alsa-headers-1.0.16* =media-sound/jack-audio-connection-kit-0.103.0 # 0.101.1 or higher is needed for ardour-2.4 =media-sound/oss2jack-0.25 # as found in my ebuild =media-sound/fusd-kor-1.10.11-r1 # as found in my ebuild |
Use this command to update the ALSA packages:
emerge -uav alsa-lib alsa-utils alsa-headers
To install the kernel see this section below.
Preparation
First of all it's important that the standard oss-driver that alsa provides isn't loaded:
rmmod snd-pcm-oss rmmod snd-mixer-oss
If you use the alsasound init script you can disable support for OSS by editing /etc/conf.d/alsasound:
| File: /etc/conf.d/alsasound |
ENABLE_OSS_EMUL="no" |
Next restart alsasound:
/etc/init.d/alsasound restart
There shouldn't be a /dev/dsp and /dev/mixer anymore after this step! Oss2jack will create its own devices with the same name.
Get a realtime-kernel
For best performance you should install a realtime-kernel or at least the deprecated realtime-lsm module (if it still works on newer kernels). You could use the rt-sources ebuilds from the pro-audio overlay (can be installed via layman) but some ebuild versions seem to be broken so it is probably easiest to install the kernel manually:
cd /usr/src rm linux wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.1.tar.bz2 tar xjvf linux-2.6.22.1.tar.bz2 mv linux-2.6.22.1 linux-2.6.22.1-rt9 ln -s linux-2.6.22.1-rt9 linux cd linux wget ftp://ftp.kernel.org/pub/linux/kernel/projects/rt/older/patch-2.6.22.1-rt9 patch -p1 < patch-2.6.22.1-rt9 rm patch-2.6.22.1-rt9 rm ../linux-2.6.22.1.tar.bz2
If you have no kernel from the portage tree installed, you should do the following to inform portage that you provide an own kernel tree (important for packages that install kernel modules):
mkdir -p /etc/portage/profile echo "sys-kernel/gentoo-sources-2.6.22" >> /etc/portage/profile/package.provided
As I mentioned above for me the kernel alsa driver worked better than the alsa-driver ebuild so you might want to enable ALSA support directly in the kernel (i suggest to compile all sound related options as modules where it's possible - the OSS part of ALSA in particular, which would be best to deactivate completely or it could collide with oss2jack). In this case unmerge alsa-driver:
emerge -Ca alsa-driver
Here are some links that might help you with configuring your kernel:
Configuring the Kernel (Gentoo Handbook)
HOWTO Compile a Kernel Manually (Gentoo Wiki)
HOWTO Compile Kernel with ALSA (Gentoo Wiki)
See this and this Howto for more specialized details on setting up a realtime kernel. Don't forget to alter your /etc/security/limits.conf as described on these sites. For example:
| File: /etc/security/limits.conf |
@audio - rtprio 80 @audio - nice -10 @audio - memlock 500000 |
Install the ebuilds
First get jackd from portage:
emerge jack-audio-connection-kit
Now you need to install fusd-kor and oss2jack. Please use the following file. It contains both ebuilds with patches for newer kernels (tested with 2.6.22 - 2.6.25; I found a working patch in a debian source package):
Gentoo ebuilds for fusd-kor and oss2jack (not a direct link)
To install them, go to your portage overlay dir and extract them there. For example:
cd /usr/local/portage tar xfvz $HOME/downloads/fusd-kor_oss2jack-ebuilds.tar.gz
| File: /etc/portage/package.keywords |
media-sound/fusd-kor media-sound/oss2jack |
now emerge them:
emerge -av fusd-kor oss2jack
A new rule for udev will be added so you either have to reboot or run
udevcontrol reload_rules
to reload the rules. After this do
modprobe kfusd
Start jackd and oss2jack
Now run jackd. I use the following configuration, which allows me to use jackd and still be able to run normal alsa-apps (always start jackd and oss2jack as the user your sound-applications are run with - not as root!):
/usr/bin/jackd -R -dalsa -r48000 -p1024 -Pdmixer -Cdsnooper &
Please replace dmixer with an appropriate defined device from your .asoundrc. If you use the Softvol plugin for example the command is sth. like:
/usr/bin/jackd -R -dalsa -r48000 -p1024 -Psoftvol -Cdsnooper &
Don't use -Pdefault or -Cdefault for playback and capturing. Jackd will complain about this and will possibly not run at all.
explanations:
-R make use of realtime -dalsa set alsa as the device -r the sample rate -p frames per period. this must be the same value as you use for period_size in your .asoundrc -P force jackd to use one of your defined devices instead of hw:0 for playback. -C force jackd to use one of your defined devices instead of hw:0 for recording.
Next start oss2jack.
oss2jack &
Now you should have two new devices: /dev/dsp and /dev/mixer
Finally start an OSS-application of your choice - you should now be able to run several OSS applications at the same time. After all this it's even possible for me to start an alsa player, an oss player and record with ardour2 without any xruns (= sound buffer overruns or underruns).
However, if you still get xruns you can easily shut down jackd/oss2jack and start jackd the normal way like
/usr/bin/jackd -R -dalsa -r48000 -p1024 &
while you're working with your jackd application. When you're done, just restart jackd and oss2jack:
stopjack; /usr/bin/jackd -R -dalsa -r48000 -p1024 & ardour2; stopjack; startjack &
I assumed here that you use my scripts below.
If everything works as expected you should make kfusd being loaded at startup:
echo kfusd >> /etc/modules.autoload.d/kernel-2.6
And of course remove anything with oss in the same file.
Autostart scripts
If you like to automatically start (and restart in case of crashes) jackd and oss2jack you could use the following simple bash scripts:
| File: /usr/local/bin/startjack |
#!/bin/bash
while true; do
if [ "`ps x | grep "jackd -R -dalsa" | grep -v grep`" == "" ]; then
jackd -R -dalsa -r 48000 -Pdmixer -Cdsnooper -p1024 1>/dev/null 2>/dev/null &
fi
sleep 1
if [ "`ps x | grep "oss2jack -q" | grep -v grep`" == "" ]; then
oss2jack -q 2>/dev/null 1>/dev/null
fi
sleep 2
done
|
| File: /usr/local/bin/stopjack |
#!/bin/sh killall -q startjack killall -q oss2jack killall -q jackd |
Make them executable:
chmod +x /usr/local/bin/*
Put the following at the end of $HOME/.bashrc (to start jackd and oss2jack with your first console login)
| File: $HOME/.bashrc |
if [ "`ps x | grep "/bin/bash /usr/local/bin/startjack" | grep -v grep`" == "" ];then
startjack 1>/dev/null 2>/dev/null &
fi
|
Or create a new executable file in your window managers autostart directory (e.g. ~/.kde/env/startjack.sh):
| File: $HOME/.kde/env/startjack.sh |
#!/bin/bash
if [ "`ps x | grep "/bin/bash /usr/local/bin/startjack" | grep -v grep`" == "" ];then
startjack 1>/dev/null 2>/dev/null &
fi
|
Now jackd and oss2jack will be started the first time you log in. Use stopjack to kill the jackd processes manually.
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and list their apartments, townhouses and units.
