OSS
From ArchWiki
| i18n |
|---|
| English |
| 简体中文 |
| Français |
| Türkçe |
Contents |
Introduction
The Open Sound System is a commercially-supported sound architecture that works on several UNIX-like and POSIX-compatible systems, including Linux, FreeBSD, Solaris and BeOS/Haiku.
Please note that this article is not about the old OSS, which is included in the Linux kernel sources and is more than 10 years old by now.
This article is about the new OSS versions (often called OSSv4). These versions were previously proprietary - OSS became open source again in July 2007, and is currently available under GPL, BSD or CDDL licenses.
Advantages and disadvantages vs. ALSA
Advantages over ALSA (for users)
- Includes a transparent software mixer (vmix) in kernel space. This means multiple applications can access the sound device at the same time without problems.
- The vmix mixer controls allow you to adjust the volume of each application individually.
- Better support for some sound card models, for example for the Creative X-Fi.
- Sound quality is usually better. reference needed to validate this statement
- Better support for applications written for the OSS API, of course. The OSS API is widely spread and a lot of applications support it. The ALSA's OSS API emulation, however, is often buggy.
Advantages over ALSA (for developers)
- Cleaner and easier to use API.
- API is much better documented.
- Support for sound drivers in the userspace (oss_userdev).
- Portability across all supported platforms. If the application works using OSS under Linux, it will work under FreeBSD and Solaris too, for example.
- Portability across operating systems. It's easier to port OSS to a new operating system.
Disadvantages vs. ALSA
- USB audio devices support is currently experimental and USB recording is not implemented.
- Bluetooth audio devices are currently not supported.
- AC'97 and HDAudio dial-up soft-modems (for example Si3055) are currently not supported.
- MIDI support is currently not finished. However, you can still use MIDI with a software synthesizer like timidity or fluidsynth.
- Suspend is currently not supported. You need to unload OSS (by using soundoff) before suspending, and to reload OSS (by using soundon) after resuming.
- Automatic jack sensing currently doesn't work properly with some HDAudio-powered motherboards. This means that, depending on your motherboard model, you may have to manually switch off your speakers when plugging your earphone.
Installing
- Disable ALSA by blocking the soundcore module in /etc/rc.conf:
MODULES=(!soundcore ..............
And by rebooting.
If you didn't want to reboot, you could also quit your desktop environment (if any) to free the soundcard, and go to pure console for doing the next steps.
- Install OSS by running:
# pacman -S oss
- Start OSS by running:
# /etc/rc.d/oss start
- Add oss to your DAEMONS variable at /etc/rc.conf, so OSS is loaded automatically at each boot.
- In the case OSS is not able to detect your card when starting it, run :
# ossdetect -v
Then soundoff && soundon to reactivate it.
Testing
You can test OSS by running:
$ osstest
You should be able to hear music during the test process. If there is no audio, try to adjust the mixer as explained in the following sections and/or read the Troubleshooting sections.
The mixer
The command line mixer is called ossmix. It's very like the BSD audio mixer (mixerctl).
A more friendly, graphical mixer, is available too. It's called ossxmix. It needs the optional depend gtk2 to work.
The ossxmix controls are explained in the following example:
______________________________ / High Definition Audio ALC262 \ ----------------------------------> One tab for each sound card /________________________________\_______________________________ | | [x] vmix0-enable [vmix0-rate: 48.000kHz] vmix0-channels \ The vmix (virtual mixer) special configurations | [ Stereo [v] ] |--> appear at the top. These include sampling rate | / and mixer priority. They are provided by OSS. | __codec1______________________________________________________ | | _jack_______________________________________________________ \ | | | _int-speaker____________________ __green_________________ | | | | | | | | These are your sound card configurations. | | | | _mode______ | | | | _mode______ | | | Every mixer control that is shown here is | | | | [ mix [v] ] o o [x] [ ]mute | | [ mix [v] ] o o [x] |--> provided by your sound card. Every sound card | | | | | | | | | | | specific control is shown here. | | | |________________________________| |_______________________ | | | |____________________________________________________________ | | |______________________________________________________________ / | | ___vmix0_______________________________________________________ \ | | __mocp___ O O _firefox_ O O __pcm7___ O O | Here are the vmix mixer controls. These are | | | | O O | | x x | | O O | virtual mixer controls provided by OSS. Each | | | | | | x O | | | | x x | | | | O O | slider is the volume control of a different | | | o o [x] | x x | o o [x] | x x | o o [x] | O O |--> application. When one application uses the | | | | | | x x | | | | x x | | | | O O | sound card, its name is shown in the place of | | |_________| x x |_________| x x |_________| O O | the 'pcm#' labels. There are also sound level | |______________________________________________________________ | meter levels for each application. |________________________________________________________________ /
Saving and restoring mixer settings
If you wish to save your mixer settings manually, run savemixer. You will require to be a user with write permissions to /usr/lib/oss/etc/save.mixer or you'll need to use the -f switch to select another file. savemixer -L restores mixer settings.
Please note that the init scripts run these commands before shutdown/after starting to keep mixer settings across boot, so most users don't need to worry about it.
Configuring Applications for OSS
Skype
The skype package only includes support for ALSA. To get an OSS-capable Skype, install the skype-oss package:
# pacman -S skype-oss
If you are using x86_64, you can get the bin32-skype-oss package from AUR.
Wine
- Run winecfg.
$ winecfg
- Go to the Audio tab.
- Select OSS Driver.
Gajim
By default Gajim uses aplay -q to play a sound. To change this go in Advanced Settings and search for the soundplayer variable. The ossplay program included in the oss package is a good replacement:
ossplay -qq
MOC
To use MOC with OSS v4.1 you must change section OSSMixerDevice to OSSMixerDevice= /dev/ossmix in your config (located in /home/yourusername/.moc). And now MOC should work with OSS v4.1. Or you can compile moc-svn package from AUR (he got support for new vmix).
Applications that use Gstreamer
While the general OSS sink works with OSSv4, better results can be had using the plugins specifically designed for OSSv4.
- Install gstreamer0.10-bad-plugins
# pacman -S gstreamer0.10-bad-plugins
- Set OSSv4 sink
$ gstreamer-properties
OSS4 appears in the drop down menu but choose "Custom" and enter oss4sink.
Other applications
- If you can't get sound from an application not listed here, try looking at the Configuring Applications for OSSv4 page.
- Search OSS specific packages by using pacman -Ss -- '-oss' and in AUR.
Troubleshooting
Troubleshooting HDAudio devices
Understanding why problems arise
If you have a HDAudio sound device, it's very likely that you will have to adjust some mixer settings before your sound works.
HDAudio devices are very powerful in the sense that they can contain a lot of small circuits (called widgets) that can be adjusted by software at any time. These controls are exposed to the mixer, and they can be used, for example, to turn the earphone jack into a sound input jack instead of a sound output jack.
However, there is a side effect, mainly because the HDAudio standard is more flexible than it perhaps should be, and because the vendors often only care to get their official drivers working.
Then, when using HDAudio devices, you often find disorganized mixer controls, that doesn't work at all by default, and you are forced to try every mixer control combination, until it works.
How to solve
Open ossxmix and try to change every mixer control in the middle area, that contains the sound card specific controls, as explained in the previous "The mixer" section.
You'll probably want to setup a program to record/play continously in the background (e.g. ossrecord - for recording or osstest -lV for playing), while changing mixer settings in ossxmix in the foreground.
- Raise every volume control slider.
- In each option box, try to change the selected option, trying all the possible combinations.
- If you get noise, try to lower and/or mute some volume controls, until you find the source of the noise.
Please note again that you do not need to change any controls in the top area nor in the bottom area, as they are virtual vmix-related mixer controls.
Troubleshooting other issues
- If you get distorted sound, try lowering some volume control sliders.
- If you need to change the default sound card, look at here.
- If you have another issues, try searching or asking for help at the 4front forums.
No audio in Banshee or Other Gstreamer Programs
Ensure that you have not inadvertantly installed pulseaudio or gstreamer0.10-pulse. This is easy mistake to make when installing all the gstreamer codecs.
Tips and Tricks
Using multimedia keys with OSS
An easy way to mute/unmute and increase/decrease the volume is to use the ossvol script. It is available in AUR but the package is out of date as of 20 June 2009.
Once you installed it try to toggle the sound:
$ ossvol -t
Type ossvol -h for the other commands.
If you don't know how to assign commands to your multimedia keys, see Extra Keyboard Keys.
ossvol troubleshooting
If you get an error like:
Bad mixer control name(987) 'vol'
you need to edit the script (/usr/bin/ossvol) and change the value of the CHANNEL variable which is at the beginning of the script. For example mine is CHANNEL="vmix0-outvol".
Other tips
Laptop suspend and hibernation
OSS does not automatically support suspend meaning that OSS must be manually stopped prior to suspending or hibernating a laptop.
OSS provides soundon and soundoff to enable and disable OSS, although any processes that use sound must be terminated first.
The following script is a rather basic method of automatically unloading OSS prior to suspending and reloading afterwards. This has been tested with KDE 4.2 but has not tried in other desktop environments.
- Save the contents of this script (as root) into /etc/pm/sleep.d/50ossound:
#!/bin/sh
. "${PM_FUNCTIONS}"
suspend_osssound()
{
/usr/lib/oss/scripts/killprocs.sh
/usr/sbin/soundoff
}
resume_osssound()
{
/usr/sbin/soundon
}
case "$1" in
hibernate|suspend)
suspend_osssound
;;
thaw|resume)
resume_osssound
;;
*) exit $NA
;;
esac
The KDE notify daemon (which provides the system sounds) will automatically reload itself after being terminated by OSS.
ALSA emulation
Introduction
You can instruct alsa-lib to use OSS as its audio output system. This works as a sort of ALSA emulation.
Note, however, that this method may introduce additional latency in your sound output, and that the emulation is not complete and doesn't work with all applications. It doesn't work, for example, with programs that try to detect devices using ALSA.
So, as most applications support OSS directly, use this method only as a last resort.
In the future, more complete methods may be available for emulating ALSA, such as libsalsa and cuckoo.
HOW-TO
- Install the alsa-plugins package.
# pacman -S alsa-plugins
- Edit /etc/asound.conf as follows.
pcm.oss {
type oss
device /dev/dsp
}
pcm.!default {
type oss
device /dev/dsp
}
ctl.oss {
type oss
device /dev/mixer
}
ctl.!default {
type oss
device /dev/mixer
}
Experimental packages
Mercurial repository version
There is a oss-mercurial package in AUR. This package compiles and installs the latest OSS development version direcly from the Mercurial repository.
You can try this package if you want to contribute code to OSS or if only a very recent change in OSS code introduced support to your sound device.