Package:Open Sound System (OSS)

From Funtoo
Jump to navigation Jump to search

Open Sound System (OSS)

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.


The Open Sound System (or OSS) is an alternative sound architecture for Unix-like and POSIX-compatible systems. OSS version 3 was the original sound system for Linux, but was superseded by the Advanced Linux Sound Architecture (or ALSA) in 2002 when OSS version 4 became proprietary software. OSSv4 became free software again in 2007 when 4Front Technologies released its source code and provided it under the GPL license.

Installation

Configuring the kernel

Under Device Drivers:

<M> Sound card support  --->
         --- Sound card support
         [ ]   Preclaim OSS device numbers
         <M>   Advanced Linux Sound Architecture --->
         < >   Open Sound System (DEPRECATED)  ---
   Note

Don't confuse the deprecated OSS module (OSSv3) module with todays OSSv4.

Preparation

The first task is to to make sure that you build OSS with the correct soundcard drivers. To specify them, you can use the OSS_CARDS setting in make.conf.

E.g. for an HD Audio card use:

   /etc/make.conf
OSS_CARDS="hd_audio"

You can visit the OSS documentation for a driver reference.

   Important

Make sure that your current kernel sources directory are symlinked to /usr/src/linux, since the OSS compilation relies on the kernel headers. You can use eselect kernel to verify or set your kernel. See eselect#kernel for a reference guide.

Install

Now build the OSS modules and add /etc/init.d/oss to the default runlevel:

root # emerge oss
root # rc-update add oss default

Basic Configuration

USE Flags

To compile Applications with OSS support you need to set the oss USE flag, however you will mostly want the alsa flag there too as a fallback (OSS will create ALSA devices for those applications):

   /etc/make.conf
USE="oss alsa"
   Tip

See how to set up an ALSA emulation for unsupported Applications below.

Configuring Applications for OSS

Since ALSA is the mostly default configuration for application, you might sometimes need to configure them properly before OSS output/input works.

There are two good resources which guide you through the steps for most applications:

ALSA emulation

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 does not work with all applications. It does not 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. See [1].

Instructions

  • Install the alsa-plugins package, available in the Funtoo Overlay.
  • Creare and edit /etc/asound.conf as follows:
   /etc/asound.conf
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
}
   Note

Do not forget to revert the changes after uninstalling.

Volume Control Mixer

To control the volume of various devices, mixers levels will need to be set. There are two mixers:

  • ossmix: a command-line mixer, similar to the BSD audio mixer mixerctl.
  • ossxmix: a GTK+-based graphical mixer.

The basic ossxmix controls look like:

 / High Definition Audio ALC262 \    --------------------------------> 1
/________________________________\________________________________
|                                                                 \
| [x] vmix0-enable [vmix0-rate: 48.000kHz]      vmix0-channels    |--> 2
|                                               [ Stereo [v] ]    |
|                                                                 |
|  __codec1______________________________________________________ |
| |  _jack______________________________________________________ ||--> 3
| | |  _int-speaker_________________   _green_________________  |||
| | | |                             | |                       | |||
| | | |  _mode_____ | |             | |  _mode_____   | |     | |||
| | | | [ mix [v] ] o o [x] [ ]mute | | [ mix  [v] ]  o o [x] | |||
| | | |             | |             | |               | |     | |||
| | | |_____________________________| |_______________________| |||
| | |___________________________________________________________|||
| |______________________________________________________________||
| ___vmix0______________________________________________________  |
| |  __mocp___  O O   _firefox_  O O  __pcm7___  O O            | |--> 4
| | |         | O O  |         | x x |         | O O            | |
| | | | |     | x O  | | |     | x x | | |     | O O            | |
| | | o o [x] | x x  | o o [x] | x x | o o [x] | O O            | |
| | | | |     | x x  | | |     | x x | | |     | O O            | |
| | |_________| x x  |_________| x x |_________| O O            | |
| |_____________________________________________________________| |
|_________________________________________________________________|
  1. One tab for each sound card
  2. The vmix (virtual mixer) special configurations appear at the top. These include sampling rate and mixer priority.
  3. These are your sound card jack configurations (input and output). Every mixer control that is shown here is provided by your sound card.
  4. Application vmix mixer controls and sound meters. If the application is not actively playing a sound it will be labeled as pcm08, pcm09... and when the application is playing the application name will be shown.

Color Definitions

For high definition (HD) audio, ossxmix will color jack configurations by their pre-defined jack colors:

Color Type Connector
green front channels (stereo output) 3.5mm TRS
black rear channels (stereo output) 3.5mm TRS
grey side channels (stereo output) 3.5mm TRS
gold center and subwoofer (dual output) 3.5mm TRS
blue line level (stereo input) 3.5mm TRS
pink microphone (mono input) 3.5mm TS

Saving Mixer Levels

Mixer levels are saved when you shut off your computer. If you want to save the mixer level immediately, execute:

root # savemixer

savemixer can be used to write mixer levels to a file with the -f switch and restore by the -L switch.

Other Mixers

Other mixers that have support for OSS:

  • Gnome Volume Control - for GNOME.
  • Kmix - for KDE.
  • VolWheel - After the installation, set it to autostart as needed, then enable OSS support by right-clicking on the system tray icon, choosing Preferences and then changing:
  • Driver: OSS.
  • Default Channel: vmix0-outvol (find out what channel to use with ossmix).
  • Default Mixer: ossxmix.
  • In the MiniMixer tab (optional), add vmix0-outvol and optionally others.

Suspend & Hibernation

OSS does not automatically support suspend, it must be manually stopped prior to suspending or hibernating and restarted afterwards.

OSS provides soundon and soundoff to enable and disable OSS, although they only stop OSS if all processes that use sound are terminated first.

The following script is a rather basic method of automatically unloading OSS prior to suspending and reloading afterwards:

   /etc/pm/sleep.d/50osssound
#!/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

Save the contents of this script (as root) into /etc/pm/sleep.d/50osssound and make it executable:

root # chmod a+x /etc/pm/sleep.d/50osssound
   Warning

This script is rather basic and will terminate any application directly accessing OSS. Save your work prior to suspending/hibernating.

Troubleshooting

Troubleshooting HD Audio devices

Understanding the problem

If you have a HD Audio sound device, it is very likely that you will have to adjust some mixer settings before your sound works.

HD Audio 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 are also bad side effects, mainly because the HD Audio standard is more flexible than it perhaps should be, and because the vendors often only care to get their official drivers working.

When using HD Audio devices, you often find disorganized mixer controls, that do not work at all by default, and you are forced to try every mixer control combination possible, until it works.

Solution

Open ossxmix and try to change every mixer control in the middle area, that contains the sound card specific controls, as explained in the #Volume Control Mixer section.

You will probably want to setup a program to record/play continuously in the background (e.g. ossrecord - | ossplay - for recording or osstest -lV for playing), while changing mixer settings in ssxmix 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.
  • Editing /usr/lib/oss/conf/oss_hdaudio.conf, uncommenting and changing 1=hdaudio_noskip=0 to a value from 0-7 can give you more jack options in ossxmix.
   Note

If you modify this file, restart the oss service for the changes to take effect.

See also