Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Package:Open Sound System (OSS)"

From Funtoo
Jump to navigation Jump to search
(Added content)
Line 5: Line 5:
|Homepage=http://www.opensound.com/oss.html
|Homepage=http://www.opensound.com/oss.html
}}
}}
__toc__
The [[Wikipedia:Open Sound System|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 [http://www.alsa-project.org Advanced Linux Sound Architecture] (or '''ALSA''') in 2002 when OSS version 4 became proprietary software. OSSv4 became free software again in 2007 when [http://www.opensound.com/ 4Front Technologies] released its source code and provided it under the GPL license.


{{PageNeedsUpdates}}
== Installation ==
=== 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 <code>OSS_CARDS</code> setting in <code>make.conf</code>.
 
E.g. for an HD Audio card use:
{{file|name=/etc/make.conf| file|body=
OSS_CARDS="hd_audio"
}}
You can visit the [http://manuals.opensound.com/usersguide/ OSS documentation] for a driver reference.
 
{{fancyimportant|Make sure that your ''current'' kernel sources directory are symlinked to <code>/usr/src/linux</code>, 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 <code>/etc/init.d/oss</code> to the default runlevel:
<console>
# ##i##emerge oss
# ##i##rc-update add oss default
</console>
 
== Basic Configuration ==
=== USE Flags ===
To compile Applications with OSS support you need to set the <code>oss</code> USE flag, however you will mostly want the <code>alsa</code> flag there too as a fallback (OSS will create ALSA devices for those applications):
{{file|name=/etc/make.conf| file|body=
USE="oss alsa"
}}
{{fancytip|See how to set up an [[#ALSA_emulation| 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:
*[http://www.4front-tech.com/wiki/index.php/Configuring_Applications_for_OSSv4 ArchWiki]
*[https://wiki.archlinux.org/index.php/Open_Sound_System#Configuring_Applications_for_OSS OpenSound Wiki]
 
== ALSA emulation ==
You can instruct <code>alsa-lib</code> 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 <code>libsalsa</code> and <code>cuckoo</code>. See [http://www.4front-tech.com/wiki/index.php/Tips_And_Tricks#ALSA_Emulation].
 
==== Instructions ====
 
* Install the <code>alsa-plugins</code> package, available in the Funtoo Overlay.
 
* Creare and edit <code>/etc/asound.conf</code> as follows:
{{file|name=/etc/asound.conf|body=
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
}
}}
 
{{fancynote|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 <code>mixerctl</code>.
* '''ossxmix''': a GTK+-based graphical mixer.
 
The basic <code>ossxmix</code> controls look like:
 
<pre>
/ 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            | |
| |_____________________________________________________________| |
|_________________________________________________________________|
</pre>
 
# One tab for each sound card
# The <code>vmix</code> (virtual mixer) special configurations appear at the top. These include sampling rate and mixer priority.
# These are your sound card jack configurations (input and output). Every mixer control that is shown here is provided by your sound card.
# Application <code>vmix</code> mixer controls and sound meters. If the application is not actively playing a sound it will be labeled as <code>pcm08</code>, <code>pcm09</code>... and when the application is playing the application name will be shown.
 
=== Color Definitions ===
For high definition (HD) audio, <code>ossxmix</code> will color jack configurations by their pre-defined jack colors:
 
{| class="wikitable"
! Color
! Type
! Connector
|- style="color:black;background:lightgreen"
|green
| front channels (stereo output)
| 3.5mm TRS
|- style="color:white;background:black"
|black
| rear channels (stereo output)
| 3.5mm TRS
|- style="color:white;background:gray"
|grey
| side channels (stereo output)
|3.5mm TRS
|- style="color:black;background:gold"
|gold
| center and subwoofer (dual output)
|3.5mm TRS
|- style="color:black;background:lightblue"
|blue
| line level (stereo input)
|3.5mm TRS
|- style="color:black;background:pink"
|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:
<console># ##i##savemixer</console>
 
<code>savemixer</code> can be used to write mixer levels to a file with the <code>-f</code> switch and restore by the <code>-L</code> switch.
 
=== Other Mixers ===
Other mixers that have support for OSS:
* '''Gnome Volume Control''' - for [[GNOME_First_Steps| 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'': <code>OSS</code>.
:* ''Default Channel'': <code>vmix0-outvol</code> (find out what channel to use with <code>ossmix</code>).
:* ''Default Mixer'': <code>ossxmix</code>.
:* In the ''MiniMixer'' tab (optional), add <code>vmix0-outvol</code> 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 <code>soundon</code> and <code>soundoff</code> 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:
{{file|name=/etc/pm/sleep.d/50osssound|body=
#!/bin/sh
. "${PM_FUNCTIONS}"
suspend_osssound()
{
    /usr/lib/oss/scripts/killprocs.sh
    /usr/sbin/soundoff
}
resume_osssound()
{
    /usr/sbin/soundon
}
case "$1" in
    hibernate<nowiki>|</nowiki>suspend)
        suspend_osssound
;;
    thaw<nowiki>|</nowiki>resume)
resume_osssound
;;
    *) exit $NA
;;
esac
}}
 
Save the contents of this script (as root) into <code>/etc/pm/sleep.d/50osssound</code> and make it executable:
<console># ##i##chmod a+x /etc/pm/sleep.d/50osssound</console>
 
{{fancywarning|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 <code>ossxmix</code> 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. <code>ossrecord - | ossplay -</code> for recording or <code>osstest -lV</code> for playing), while changing mixer settings in <code>ssxmix</code> 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 <code>/usr/lib/oss/conf/oss_hdaudio.conf</code>, uncommenting and changing <code>1=hdaudio_noskip=0</code> to a value from '''0-7''' can give you more jack options in <code>ossxmix</code>.
{{fancynote|If you modify this file, restart the '''oss''' service for the changes to take effect.}}
 
== See also ==
* [http://www.opensound.com/ Official Website]
* [http://www.opensound.com/wiki OSS Wiki]
* [http://www.opensound.com/forum/index.php OSS Forum]
* [http://www.opensound.com/developer/index.html Developer Information]
* [http://sourceforge.net/p/opensound/git/ Git repository]
* [http://sourceforge.net/p/opensound/mailman/opensound-devel/ opensound-devel mailing list]
{{EbuildFooter}}
{{EbuildFooter}}

Revision as of 21:36, September 19, 2014

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

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