Google
 

Open Sound System
OSS 4.x Programmer's Guide

Do you have problems with sound/audio application development? Don't panic! Click here for help!

Device types supported by OSS

Open Sound System supports three kind of devices:

A typical computer sound card (or the motherboard sound subsystem) has one or more of these devices. The cheapest ones have just an audio device and a mixer. A typical system supports all of the types. Finally there are some highly sophisticated professional devices that have only MIDI or only digital audio without the other features.

OSS Supports several sound cards (in addition to the motherboard sound) which means that in the best case there may be tens of independent audio devices, few mixers and few MIDI ports.

All OSS devices are numbered. To find out the available device numbers you can execute the ossinfo utility. For example ossinfo -v1 prints something like following:


Version info: OSS 4.0 (build 158/200606290716 (0x00040000)

Number of audio devices: 38
Number of MIDI devices: 2
Number of mixer devices: 4

MIDI devices (/dev/midi*)
0: Terratec DMX6fire 24/96 #1 (MIDI port 1 of device object 3)
Device file /dev/envy241_midi0
Modes: IN/OUT , Available for use
1: Terratec DMX6fire 24/96 #2 (MIDI port 2 of device object 3)
Device file /dev/envy241_midi1
Modes: IN/OUT , Available for use

Mixer devices (/dev/mixer*)
0: ICH AC97 Mixer (ALC658) (Mixer 0 of device object 1)
Device file /dev/ich0_mixer0
Priority: 10
Caps:
1: M Audio Delta TDIF (Mixer 0 of device object 2)
Device file /dev/envy240_mixer0
Priority: 0
Caps:
2: Terratec DMX6fire 24/96 (Mixer 0 of device object 3)
Device file /dev/envy241_mixer0
Priority: 0
Caps:
3: Virtual Mixer (Mixer 0 of device object 4)
Device file /dev/softoss0_mixer0
Priority: 1
Caps: VIRTUAL

Audio devices (/dev/dsp*)
0: Intel ICH5 (24D5) (audio port 0 of device object 1)
Device file /dev/ich0_dsp0, Legacy device /dev/dsp24
Caps: DUPLEX TRIGGER MMAP
Modes: IN/OUT , Available for use
1: Intel ICH5 (24D5) (shadow) (audio port 1 of device object 1)
Device file /dev/ich0_dsp1, Legacy device /dev/dsp25
Caps: DUPLEX TRIGGER MMAP SHADOW
Modes: IN/OUT , Available for use
2: M Audio Delta TDIF out1/2 (audio port 0 of device object 2)
Device file /dev/envy240_dsp0, Legacy device /dev/dsp0
Caps: TRIGGER MMAP
Modes: OUTPUT , Available for use
3: M Audio Delta TDIF out3/4 (audio port 2 of device object 2)
Device file /dev/envy240_dsp1, Legacy device /dev/dsp1
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
4: M Audio Delta TDIF out5/6 (audio port 4 of device object 2)
Device file /dev/envy240_dsp2, Legacy device /dev/dsp2
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
5: M Audio Delta TDIF out7/8 (audio port 6 of device object 2)
Device file /dev/envy240_dsp3, Legacy device /dev/dsp3
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
6: M Audio Delta TDIF S/PDIF out (audio port 8 of device object 2)
Device file /dev/envy240_dsp4, Legacy device /dev/dsp4
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
7: M Audio Delta TDIF in1/2 (audio port 10 of device object 2)
Device file /dev/envy240_dsp5, Legacy device /dev/dsp5
Caps: TRIGGER MMAP
Modes: INPUT , Available for use
8: M Audio Delta TDIF in3/4 (audio port 12 of device object 2)
Device file /dev/envy240_dsp6, Legacy device /dev/dsp6
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
9: M Audio Delta TDIF in5/6 (audio port 14 of device object 2)
Device file /dev/envy240_dsp7, Legacy device /dev/dsp7
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
10: M Audio Delta TDIF in7/8 (audio port 16 of device object 2)
Device file /dev/envy240_dsp8, Legacy device /dev/dsp8
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
11: M Audio Delta TDIF S/PDIF in (audio port 18 of device object 2)
Device file /dev/envy240_dsp9, Legacy device /dev/dsp9
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
12: M Audio Delta TDIF input from mon. mixer (audio port 20 of device object 2)
Device file /dev/envy240_dsp10, Legacy device /dev/dsp10
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
13: M Audio Delta TDIF (all outputs) (audio port 0 of device object 2)
Device file /dev/envy240_dsp11, Legacy device /dev/dsp11
Caps: TRIGGER MMAP
Modes: OUTPUT , Available for use
14: M Audio Delta TDIF (all inputs) (audio port 10 of device object 2)
Device file /dev/envy240_dsp12, Legacy device /dev/dsp12
Caps: TRIGGER MMAP
Modes: INPUT , Available for use
15: Terratec DMX6fire 24/96 out1/2 (audio port 0 of device object 3)
Device file /dev/envy241_dsp0, Legacy device /dev/dsp13
Caps: TRIGGER MMAP
Modes: OUTPUT , Available for use
16: Terratec DMX6fire 24/96 out3/4 (audio port 2 of device object 3)
Device file /dev/envy241_dsp1, Legacy device /dev/dsp14
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
17: Terratec DMX6fire 24/96 out5/6 (audio port 4 of device object 3)
Device file /dev/envy241_dsp2, Legacy device /dev/dsp15
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
18: Terratec DMX6fire 24/96 S/PDIF out (audio port 8 of device object 3)
Device file /dev/envy241_dsp3, Legacy device /dev/dsp16
Caps: TRIGGER MMAP SLAVE
Modes: OUTPUT , Available for use
19: Terratec DMX6fire 24/96 in1/2 (audio port 10 of device object 3)
Device file /dev/envy241_dsp4, Legacy device /dev/dsp17
Caps: TRIGGER MMAP
Modes: INPUT , Available for use
20: Terratec DMX6fire 24/96 in3/4 (audio port 12 of device object 3)
Device file /dev/envy241_dsp5, Legacy device /dev/dsp18
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
21: Terratec DMX6fire 24/96 in5/6 (audio port 14 of device object 3)
Device file /dev/envy241_dsp6, Legacy device /dev/dsp19
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
22: Terratec DMX6fire 24/96 S/PDIF in (audio port 18 of device object 3)
Device file /dev/envy241_dsp7, Legacy device /dev/dsp20
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
23: Terratec DMX6fire 24/96 input from mon. mixer (audio port 20 of device object 3)
Device file /dev/envy241_dsp8, Legacy device /dev/dsp21
Caps: TRIGGER MMAP SLAVE
Modes: INPUT , Available for use
24: Terratec DMX6fire 24/96 (all outputs) (audio port 0 of device object 3)
Device file /dev/envy241_dsp9, Legacy device /dev/dsp22
Caps: TRIGGER MMAP
Modes: OUTPUT , Available for use
25: Terratec DMX6fire 24/96 (all inputs) (audio port 10 of device object 3)
Device file /dev/envy241_dsp10, Legacy device /dev/dsp23
Caps: TRIGGER MMAP
Modes: INPUT , Available for use
26: OSS Virtual Mixer v3.0 Playback CH #1 (audio port 0 of device object 4)
Device file /dev/softoss0_dsp0, Legacy device /dev/dsp26
Caps: TRIGGER MMAP VIRTUAL
Modes: OUTPUT , Available for use
27: OSS Virtual Mixer v3.0 Playback CH #2 (audio port 1 of device object 4)
Device file /dev/softoss0_dsp1, Legacy device /dev/dsp27
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
28: OSS Virtual Mixer v3.0 Playback CH #3 (audio port 2 of device object 4)
Device file /dev/softoss0_dsp2, Legacy device /dev/dsp28
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
29: OSS Virtual Mixer v3.0 Playback CH #4 (audio port 3 of device object 4)
Device file /dev/softoss0_dsp3, Legacy device /dev/dsp29
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
30: OSS Virtual Mixer v3.0 Playback CH #5 (audio port 4 of device object 4)
Device file /dev/softoss0_dsp4, Legacy device /dev/dsp30
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
31: OSS Virtual Mixer v3.0 Playback CH #6 (audio port 5 of device object 4)
Device file /dev/softoss0_dsp5, Legacy device /dev/dsp31
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
32: OSS Virtual Mixer v3.0 Playback CH #7 (audio port 6 of device object 4)
Device file /dev/softoss0_dsp6, Legacy device /dev/dsp32
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
33: OSS Virtual Mixer v3.0 Playback CH #8 (audio port 7 of device object 4)
Device file /dev/softoss0_dsp7, Legacy device /dev/dsp33
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: OUTPUT , Available for use
34: Virtual Mixer Loopback Record CH #1 (audio port 8 of device object 4)
Device file /dev/softoss0_dsp8, Legacy device /dev/dsp34
Caps: TRIGGER MMAP VIRTUAL
Modes: INPUT , Available for use
35: Virtual Mixer Loopback Record CH #2 (audio port 9 of device object 4)
Device file /dev/softoss0_dsp9, Legacy device /dev/dsp35
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: INPUT , Available for use
36: Virtual Mixer Loopback Record CH #3 (audio port 10 of device object 4)
Device file /dev/softoss0_dsp10, Legacy device /dev/dsp36
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: INPUT , Available for use
37: Virtual Mixer Loopback Record CH #4 (audio port 11 of device object 4)
Device file /dev/softoss0_dsp11, Legacy device /dev/dsp37
Caps: TRIGGER MMAP VIRTUAL SHADOW
Modes: INPUT , Available for use

It's important to unserstand that there is no logic in the way how the numberings of these three device types are related with each other. It's common that the first mixer and audio devices belong together but this is often not the case. This is even more unlikely with the higher device numbers.

There is a method for matching the device numbers together but doing that doesn't make any sense. The audio API of OSS now has official ways for doing things like recording source selection and recording/playback volume control without accessing the mixer.

About device numbering

OSS device files have traditionally been named like /dev/dsp0, /dev/dsp1, ..., /dev/dspN with sequantial numbers. There have been no holes in the device numbering. Also the device numbers have been relatively static so it has been possible to save the numbers in application config files.

Due to modern technologies like device hot plugging/unplugging this is no longer true. This "legacy" device naming scheme is still supported by OSS but it's no longer reliable. For this reason the legacy naming should only be used by applications written for earlier OSS versions. It can also be used in scripts that use hardcoded device names.

Advanced device naming

Starting from OSS 4.0 the device numbering used by OSS is no longer static. Devices will be numbered in whatever order the operating system decides to initialize the devices. This means that device numbers may change every time OSS is restarted or the system is rebooted. In particular hot-pluggable devices such as USB or FireWire rarely get assigned the same numbers.

To solve the problems with initialization order OSS now uses device names which contain the device name. For example /dev/sblive0_pcm2 is the third audio device of the first SB Live!/Audigy card found in the system. This naming is completely static. The easiest way to find out the new style device names is to run ossinfo with verbosity level of -v1 or higher.

The exact naming scheme depends on the operating system. There is no guarantee that any given naming scheme will be used. For example the same device may be called as /dev/sblive0_pcm0 in some systems and /dev/sblive0/pcm0 or /dev/oss/sblive0/pcm0 in some others. Applications should not make any assumptions about the device naming system.

To maintain compatibility with older applications the ossdevlinks(1) utility is used to maintain "legacy" device numbers for the devices. The legacy device files (such as /dev/dsp0) are now symbolic links to the actual device file. OSS stores these links in /usr/lib/oss/etc/legacy_devices and they will be restored every time when OSS is restarted. When new devices are added to the system they will be given legacy device numbers after the previously installed devices. In this way the legacy device numbering will be relatively stable but system administrator may reset it by running ossdevlinks -r. For example /dev/dsp5 may be a symbolic link to /dev/sblive0_pcm2.

The /dev/sndstat file shows the devices in their legacy device order to maintain compatibility with some older applications. However new applications should not use /dev/sndstat to find out the device names. Instead they should use the programmatic method described below.

Obtaining device names programmatically

Applications should use the SNDCTL_SYSINFO ioctl call to find out how many audio, mixer or MIDI devices there are in the system. Then they can use SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO or SNDCTL_MIDIINFO to obtain the device name and the device node (devnode field) for each device. The device fila name returned in the devnode field can then be stored in the application config files. It is not recommended to try to guess the device names because future OSS versions may use different naming schemes. Please look at the ossinfo.c for an example of using the ioctl calls mentioned above.

Default devices

OSS provides default devices names for applications that don't have any config files. This makes using the applications very easy but the default files are not suitable for all kind of applications. The default device files supported by current OSS are the following (more names may be introduced in future OSS versions):

The most common default devices such as /dev/dsp, /dev/mixer and /dev/midi) will be available in all systems. However the remaining ones will only be created if there is a suitable device in the system.

It is recommended that applications using /dev/dsp check the OSS_AUDIODEV environment variable. If this variable is set then applications should use the device name specified by it instead of /dev/dsp. However device names given on command line or in the application setup should have priority over this. The same is true for OSS_MIXERDEV and /dev/mixer. Use of these environment variables makes it the applications to work better in many kind of virtualized environments where different users/sessions can have their private device sets.



Copyright (C) 4Front Technologies, 2007. All rights reserved.
Back to index OSS web site