요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
=============================
Notes on Kernel OSS-Emulation
=============================
Jan. 22, 2004 Takashi Iwai <tiwai@suse.de>
Modules
=======
ALSA provides a powerful OSS emulation on the kernel.
The OSS emulation for PCM, mixer and sequencer devices is implemented
as add-on kernel modules, snd-pcm-oss, snd-mixer-oss and snd-seq-oss.
When you need to access the OSS PCM, mixer or sequencer devices, the
corresponding module has to be loaded.
These modules are loaded automatically when the corresponding service
is called. The alias is defined ``sound-service-x-y``, where x and y are
the card number and the minor unit number. Usually you don't have to
define these aliases by yourself.
Only necessary step for auto-loading of OSS modules is to define the
card alias in ``/etc/modprobe.d/alsa.conf``, such as::
alias sound-slot-0 snd-emu10k1
As the second card, define ``sound-slot-1`` as well.
Note that you can't use the aliased name as the target name (i.e.
``alias sound-slot-0 snd-card-0`` doesn't work any more like the old
modutils).
The currently available OSS configuration is shown in
/proc/asound/oss/sndstat. This shows in the same syntax of
/dev/sndstat, which is available on the commercial OSS driver.
On ALSA, you can symlink /dev/sndstat to this proc file.
Please note that the devices listed in this proc file appear only
after the corresponding OSS-emulation module is loaded. Don't worry
even if "NOT ENABLED IN CONFIG" is shown in it.
Device Mapping
==============
ALSA supports the following OSS device files:
::
PCM:
/dev/dspX
/dev/adspX
Mixer:
/dev/mixerX
MIDI:
/dev/midi0X
/dev/amidi0X
Sequencer:
/dev/sequencer
/dev/sequencer2 (aka /dev/music)
where X is the card number from 0 to 7.
(NOTE: Some distributions have the device files like /dev/midi0 and
/dev/midi1. They are NOT for OSS but for tclmidi, which is
a totally different thing.)
Unlike the real OSS, ALSA cannot use the device files more than the
assigned ones. For example, the first card cannot use /dev/dsp1 or
/dev/dsp2, but only /dev/dsp0 and /dev/adsp0.
As seen above, PCM and MIDI may have two devices. Usually, the first
PCM device (``hw:0,0`` in ALSA) is mapped to /dev/dsp and the secondary
device (``hw:0,1``) to /dev/adsp (if available). For MIDI, /dev/midi and
/dev/amidi, respectively.
You can change this device mapping via the module options of
snd-pcm-oss and snd-rawmidi. In the case of PCM, the following
options are available for snd-pcm-oss:
dsp_map
PCM device number assigned to /dev/dspX
(default = 0)
adsp_map
PCM device number assigned to /dev/adspX
(default = 1)
For example, to map the third PCM device (``hw:0,2``) to /dev/adsp0,
define like this:
::
options snd-pcm-oss adsp_map=2
The options take arrays. For configuring the second card, specify
two entries separated by comma. For example, to map the third PCM
device on the second card to /dev/adsp1, define like below:
::
options snd-pcm-oss adsp_map=0,2
To change the mapping of MIDI devices, the following options are
available for snd-rawmidi:
midi_map
MIDI device number assigned to /dev/midi0X
(default = 0)
amidi_map
MIDI device number assigned to /dev/amidi0X
(default = 1)
For example, to assign the third MIDI device on the first card to
/dev/midi00, define as follows:
::
options snd-rawmidi midi_map=2
PCM Mode
========
As default, ALSA emulates the OSS PCM with so-called plugin layer,
i.e. tries to convert the sample format, rate or channels
automatically when the card doesn't support it natively.
This will lead to some problems for some applications like quake or
wine, especially if they use the card only in the MMAP mode.
In such a case, you can change the behavior of PCM per application by
writing a command to the proc file. There is a proc file for each PCM
stream, ``/proc/asound/cardX/pcmY[cp]/oss``, where X is the card number
(zero-based), Y the PCM device number (zero-based), and ``p`` is for
playback and ``c`` for capture, respectively. Note that this proc file
exists only after snd-pcm-oss module is loaded.
The command sequence has the following syntax:
::
app_name fragments fragment_size [options]
``app_name`` is the name of application with (higher priority) or without
path.
``fragments`` specifies the number of fragments or zero if no specific
number is given.
``fragment_size`` is the size of fragment in bytes or zero if not given.
``options`` is the optional parameters. The following options are
available:
disable
the application tries to open a pcm device for
this channel but does not want to use it.
direct
don't use plugins
block
force block open mode
non-block
force non-block open mode
partial-frag
write also partial fragments (affects playback only)
no-silence
do not fill silence ahead to avoid clicks
The ``disable`` option is useful when one stream direction (playback or
capture) is not handled correctly by the application although the
hardware itself does support both directions.
The ``direct`` option is used, as mentioned above, to bypass the automatic
conversion and useful for MMAP-applications.
For example, to playback the first PCM device without plugins for
quake, send a command via echo like the following:
::
% echo "quake 0 0 direct" > /proc/asound/card0/pcm0p/oss
While quake wants only playback, you may append the second command
to notify driver that only this direction is about to be allocated:
::
% echo "quake 0 0 disable" > /proc/asound/card0/pcm0c/oss
The permission of proc files depend on the module options of snd.
As default it's set as root, so you'll likely need to be superuser for
sending the command above.
The block and non-block options are used to change the behavior of
opening the device file.
As default, ALSA behaves as original OSS drivers, i.e. does not block
the file when it's busy. The -EBUSY error is returned in this case.
This blocking behavior can be changed globally via nonblock_open
module option of snd-pcm-oss. For using the blocking mode as default
for OSS devices, define like the following:
::
options snd-pcm-oss nonblock_open=0
The ``partial-frag`` and ``no-silence`` commands have been added recently.
Both commands are for optimization use only. The former command
specifies to invoke the write transfer only when the whole fragment is
filled. The latter stops writing the silence data ahead
automatically. Both are disabled as default.
You can check the currently defined configuration by reading the proc
file. The read image can be sent to the proc file again, hence you
can save the current configuration
::
% cat /proc/asound/card0/pcm0p/oss > /somewhere/oss-cfg
and restore it like
::
% cat /somewhere/oss-cfg > /proc/asound/card0/pcm0p/oss
Also, for clearing all the current configuration, send ``erase`` command
as below:
::
% echo "erase" > /proc/asound/card0/pcm0p/oss
Mixer Elements
==============
Since ALSA has completely different mixer interface, the emulation of
OSS mixer is relatively complicated. ALSA builds up a mixer element
from several different ALSA (mixer) controls based on the name
string. For example, the volume element SOUND_MIXER_PCM is composed
from "PCM Playback Volume" and "PCM Playback Switch" controls for the
playback direction and from "PCM Capture Volume" and "PCM Capture
Switch" for the capture directory (if exists). When the PCM volume of
OSS is changed, all the volume and switch controls above are adjusted
automatically.
As default, ALSA uses the following control for OSS volumes:
==================== ===================== =====
OSS volume ALSA control Index
==================== ===================== =====
SOUND_MIXER_VOLUME Master 0
SOUND_MIXER_BASS Tone Control - Bass 0
SOUND_MIXER_TREBLE Tone Control - Treble 0
SOUND_MIXER_SYNTH Synth 0
SOUND_MIXER_PCM PCM 0
SOUND_MIXER_SPEAKER PC Speaker 0
SOUND_MIXER_LINE Line 0
SOUND_MIXER_MIC Mic 0
SOUND_MIXER_CD CD 0
SOUND_MIXER_IMIX Monitor Mix 0
SOUND_MIXER_ALTPCM PCM 1
SOUND_MIXER_RECLEV (not assigned)
SOUND_MIXER_IGAIN Capture 0
SOUND_MIXER_OGAIN Playback 0
SOUND_MIXER_LINE1 Aux 0
SOUND_MIXER_LINE2 Aux 1
SOUND_MIXER_LINE3 Aux 2
SOUND_MIXER_DIGITAL1 Digital 0
SOUND_MIXER_DIGITAL2 Digital 1
SOUND_MIXER_DIGITAL3 Digital 2
SOUND_MIXER_PHONEIN Phone 0
SOUND_MIXER_PHONEOUT Phone 1
SOUND_MIXER_VIDEO Video 0
SOUND_MIXER_RADIO Radio 0
SOUND_MIXER_MONITOR Monitor 0
==================== ===================== =====
The second column is the base-string of the corresponding ALSA
control. In fact, the controls with ``XXX [Playback|Capture]
[Volume|Switch]`` will be checked in addition.
The current assignment of these mixer elements is listed in the proc
file, /proc/asound/cardX/oss_mixer, which will be like the following
::
VOLUME "Master" 0
BASS "" 0
TREBLE "" 0
SYNTH "" 0
PCM "PCM" 0
...
where the first column is the OSS volume element, the second column
the base-string of the corresponding ALSA control, and the third the
control index. When the string is empty, it means that the
corresponding OSS control is not available.
For changing the assignment, you can write the configuration to this
proc file. For example, to map "Wave Playback" to the PCM volume,
send the command like the following:
::
% echo 'VOLUME "Wave Playback" 0' > /proc/asound/card0/oss_mixer
The command is exactly as same as listed in the proc file. You can
change one or more elements, one volume per line. In the last
example, both "Wave Playback Volume" and "Wave Playback Switch" will
be affected when PCM volume is changed.
Like the case of PCM proc file, the permission of proc files depend on
the module options of snd. you'll likely need to be superuser for
sending the command above.
As well as in the case of PCM proc file, you can save and restore the
current mixer configuration by reading and writing the whole file
image.
Duplex Streams
==============
Note that when attempting to use a single device file for playback and
capture, the OSS API provides no way to set the format, sample rate or
number of channels different in each direction. Thus
::
io_handle = open("device", O_RDWR)
will only function correctly if the values are the same in each direction.
To use different values in the two directions, use both
::
input_handle = open("device", O_RDONLY)
output_handle = open("device", O_WRONLY)
and set the values for the corresponding handle.
Unsupported Features
====================
MMAP on ICE1712 driver
----------------------
ICE1712 supports only the unconventional format, interleaved
10-channels 24bit (packed in 32bit) format. Therefore you cannot mmap
the buffer as the conventional (mono or 2-channels, 8 or 16bit) format
on OSS.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
OSS 에뮬레이션 모듈과 자동 적재
1-40이 문서는 2004년 1월 22일 Takashi Iwai가 작성한 커널 OSS 에뮬레이션 참고 사항이다. ALSA는 커널에서 PCM, 믹서, 시퀀서용 OSS 호환 계층을 제공하며, 각각 `snd-pcm-oss`, `snd-mixer-oss`, `snd-seq-oss` 추가 모듈로 구현된다. 해당 OSS 장치에 접근하려면 대응 모듈이 적재되어 있어야 한다.
서비스가 호출되면 모듈은 보통 자동으로 적재된다. 별칭 형식은 `sound-service-x-y`이고 `x`는 카드 번호, `y`는 minor unit 번호이므로 일반적으로 사용자가 이 별칭을 직접 정의할 필요는 없다.
자동 적재에 필요한 설정은 `/etc/modprobe.d/alsa.conf`에 카드 별칭을 두는 것이다. 첫 번째 카드는 다음과 같이 지정하고, 두 번째 카드에는 `sound-slot-1`을 정의한다.
alias sound-slot-0 snd-emu10k1
별칭으로 정의된 이름을 다시 대상 이름으로 쓸 수는 없다. 따라서 예전 modutils에서 쓰던 `alias sound-slot-0 snd-card-0` 형식은 더 이상 동작하지 않는다.
현재 OSS 구성은 `/proc/asound/oss/sndstat`에서 확인한다. 출력 문법은 상용 OSS 드라이버의 `/dev/sndstat`과 같으며, ALSA에서는 `/dev/sndstat`을 이 proc 파일에 심볼릭 링크할 수 있다.
proc 파일의 장치 목록은 해당 OSS 에뮬레이션 모듈이 적재된 뒤에만 나타난다. 그러므로 모듈 적재 전 `NOT ENABLED IN CONFIG`가 표시되어도 실제 커널 설정이 반드시 잘못된 것은 아니다.
장치 접근이 카드 별칭과 서비스 별칭을 거쳐 대응 에뮬레이션 모듈을 적재하는 흐름이다.
=============================
Notes on Kernel OSS-Emulation
=============================
Jan. 22, 2004 Takashi Iwai <tiwai@suse.de>
Modules
=======
ALSA provides a powerful OSS emulation on the kernel.
The OSS emulation for PCM, mixer and sequencer devices is implemented
as add-on kernel modules, snd-pcm-oss, snd-mixer-oss and snd-seq-oss.
When you need to access the OSS PCM, mixer or sequencer devices, the
corresponding module has to be loaded.
These modules are loaded automatically when the corresponding service
is called. The alias is defined ``sound-service-x-y``, where x and y are
the card number and the minor unit number. Usually you don't have to
define these aliases by yourself.
Only necessary step for auto-loading of OSS modules is to define the
card alias in ``/etc/modprobe.d/alsa.conf``, such as::
alias sound-slot-0 snd-emu10k1
As the second card, define ``sound-slot-1`` as well.
Note that you can't use the aliased name as the target name (i.e.
``alias sound-slot-0 snd-card-0`` doesn't work any more like the old
modutils).
The currently available OSS configuration is shown in
/proc/asound/oss/sndstat. This shows in the same syntax of
/dev/sndstat, which is available on the commercial OSS driver.
On ALSA, you can symlink /dev/sndstat to this proc file.
Please note that the devices listed in this proc file appear only
after the corresponding OSS-emulation module is loaded. Don't worry
even if "NOT ENABLED IN CONFIG" is shown in it.
OSS 장치 파일과 카드별 매핑
41-77ALSA가 지원하는 OSS 장치 파일은 PCM의 `/dev/dspX`, `/dev/adspX`, 믹서의 `/dev/mixerX`, MIDI의 `/dev/midi0X`, `/dev/amidi0X`, 시퀀서의 `/dev/sequencer`, `/dev/sequencer2`이다. `/dev/sequencer2`는 `/dev/music`이라는 이름으로도 알려져 있다. `X`는 0부터 7까지의 카드 번호다.
일부 배포판의 `/dev/midi0`, `/dev/midi1`은 OSS용 장치가 아니라 전혀 다른 tclmidi용 장치이므로 이름만 보고 혼동하면 안 된다.
실제 OSS와 달리 ALSA는 카드에 배정된 장치 파일만 사용할 수 있다. 예를 들어 첫 번째 카드는 `/dev/dsp1`이나 `/dev/dsp2`를 사용할 수 없고 `/dev/dsp0`과 `/dev/adsp0`만 사용한다.
PCM과 MIDI에는 각각 기본 장치와 보조 장치가 있다. 보통 첫 PCM 장치 `hw:0,0`은 `/dev/dsp`, 두 번째 `hw:0,1`은 사용 가능한 경우 `/dev/adsp`에 매핑된다. MIDI도 같은 순서로 `/dev/midi`와 `/dev/amidi`에 대응한다.
카드 번호 X를 포함하는 장치와 전역 시퀀서 장치를 구분한다.
Device Mapping
==============
ALSA supports the following OSS device files:
::
PCM:
/dev/dspX
/dev/adspX
Mixer:
/dev/mixerX
MIDI:
/dev/midi0X
/dev/amidi0X
Sequencer:
/dev/sequencer
/dev/sequencer2 (aka /dev/music)
where X is the card number from 0 to 7.
(NOTE: Some distributions have the device files like /dev/midi0 and
/dev/midi1. They are NOT for OSS but for tclmidi, which is
a totally different thing.)
Unlike the real OSS, ALSA cannot use the device files more than the
assigned ones. For example, the first card cannot use /dev/dsp1 or
/dev/dsp2, but only /dev/dsp0 and /dev/adsp0.
As seen above, PCM and MIDI may have two devices. Usually, the first
PCM device (``hw:0,0`` in ALSA) is mapped to /dev/dsp and the secondary
device (``hw:0,1``) to /dev/adsp (if available). For MIDI, /dev/midi and
/dev/amidi, respectively.
PCM과 MIDI 매핑 모듈 옵션
78-117PCM 장치 매핑은 `snd-pcm-oss`의 `dsp_map`과 `adsp_map` 옵션으로 바꾼다. `dsp_map`은 `/dev/dspX`에 배정할 PCM 장치 번호이며 기본값은 0이다. `adsp_map`은 `/dev/adspX`에 배정할 번호이며 기본값은 1이다.
첫 번째 카드의 세 번째 PCM 장치 `hw:0,2`를 `/dev/adsp0`에 매핑하려면 다음과 같이 지정한다.
options snd-pcm-oss adsp_map=2
이 옵션은 카드별 배열을 받는다. 두 번째 카드의 세 번째 PCM 장치를 `/dev/adsp1`에 매핑하려면 첫 번째와 두 번째 카드 값을 쉼표로 나열한다.
options snd-pcm-oss adsp_map=0,2
MIDI 매핑은 `snd-rawmidi`의 `midi_map`과 `amidi_map` 옵션으로 바꾼다. 각각 `/dev/midi0X`와 `/dev/amidi0X`에 배정할 MIDI 장치 번호이며 기본값은 0과 1이다.
첫 번째 카드의 세 번째 MIDI 장치를 `/dev/midi00`에 배정하는 설정은 다음과 같다.
options snd-rawmidi midi_map=2
옵션 배열의 각 원소는 같은 위치의 카드에 적용된다.
You can change this device mapping via the module options of
snd-pcm-oss and snd-rawmidi. In the case of PCM, the following
options are available for snd-pcm-oss:
dsp_map
PCM device number assigned to /dev/dspX
(default = 0)
adsp_map
PCM device number assigned to /dev/adspX
(default = 1)
For example, to map the third PCM device (``hw:0,2``) to /dev/adsp0,
define like this:
::
options snd-pcm-oss adsp_map=2
The options take arrays. For configuring the second card, specify
two entries separated by comma. For example, to map the third PCM
device on the second card to /dev/adsp1, define like below:
::
options snd-pcm-oss adsp_map=0,2
To change the mapping of MIDI devices, the following options are
available for snd-rawmidi:
midi_map
MIDI device number assigned to /dev/midi0X
(default = 0)
amidi_map
MIDI device number assigned to /dev/amidi0X
(default = 1)
For example, to assign the third MIDI device on the first card to
/dev/midi00, define as follows:
::
options snd-rawmidi midi_map=2
애플리케이션별 PCM 모드
118-161기본적으로 ALSA는 plugin 계층으로 OSS PCM을 에뮬레이션한다. 카드가 요청 형식, 샘플률 또는 채널 수를 직접 지원하지 않으면 이를 자동 변환한다. 그러나 MMAP만 사용하는 quake나 wine 같은 일부 애플리케이션에서는 이 동작이 문제를 일으킬 수 있다.
PCM 스트림별 proc 파일 `/proc/asound/cardX/pcmY[cp]/oss`에 명령을 써서 애플리케이션별 동작을 바꿀 수 있다. `X`는 0부터 시작하는 카드 번호, `Y`는 0부터 시작하는 PCM 장치 번호, `p`는 재생, `c`는 캡처다. 이 파일은 `snd-pcm-oss`가 적재된 뒤에만 존재한다.
명령 형식은 다음과 같다. `app_name`에는 경로를 포함한 애플리케이션 이름을 쓰면 우선순위가 더 높고, 경로 없이 이름만 쓸 수도 있다. `fragments`는 fragment 수이며 지정하지 않을 때 0, `fragment_size`는 바이트 단위 크기이며 지정하지 않을 때 0이다.
app_name fragments fragment_size [options]
`disable`은 해당 방향을 애플리케이션이 열려고 하지만 실제로 사용하지 않는다고 알린다. `direct`는 plugin 자동 변환을 우회한다. `block`과 `non-block`은 열기 동작을 각각 blocking과 non-blocking으로 강제한다. `partial-frag`는 재생에서 부분 fragment도 쓰게 하고, `no-silence`는 클릭을 피하기 위한 선행 무음 채우기를 하지 않게 한다.
스트림별 proc 설정에서 사용할 수 있는 선택 사항이다.
PCM Mode
========
As default, ALSA emulates the OSS PCM with so-called plugin layer,
i.e. tries to convert the sample format, rate or channels
automatically when the card doesn't support it natively.
This will lead to some problems for some applications like quake or
wine, especially if they use the card only in the MMAP mode.
In such a case, you can change the behavior of PCM per application by
writing a command to the proc file. There is a proc file for each PCM
stream, ``/proc/asound/cardX/pcmY[cp]/oss``, where X is the card number
(zero-based), Y the PCM device number (zero-based), and ``p`` is for
playback and ``c`` for capture, respectively. Note that this proc file
exists only after snd-pcm-oss module is loaded.
The command sequence has the following syntax:
::
app_name fragments fragment_size [options]
``app_name`` is the name of application with (higher priority) or without
path.
``fragments`` specifies the number of fragments or zero if no specific
number is given.
``fragment_size`` is the size of fragment in bytes or zero if not given.
``options`` is the optional parameters. The following options are
available:
disable
the application tries to open a pcm device for
this channel but does not want to use it.
direct
don't use plugins
block
force block open mode
non-block
force non-block open mode
partial-frag
write also partial fragments (affects playback only)
no-silence
do not fill silence ahead to avoid clicks
PCM 예외 설정, 저장과 복원
162-220`disable`은 하드웨어가 재생과 캡처를 모두 지원하더라도 애플리케이션이 한 방향을 올바르게 다루지 못할 때 유용하다. `direct`는 자동 변환을 우회하므로 MMAP 애플리케이션에 적합하다.
quake가 첫 PCM 장치를 plugin 없이 재생하도록 하려면 재생 proc 파일에 다음 명령을 보낸다. quake가 재생만 필요로 한다면 캡처 방향에는 `disable`을 추가해 그 방향을 할당하지 않을 것임을 드라이버에 알린다.
% echo "quake 0 0 direct" > /proc/asound/card0/pcm0p/oss
% echo "quake 0 0 disable" > /proc/asound/card0/pcm0c/oss
proc 파일 권한은 `snd` 모듈 옵션에 좌우되며 기본 소유자는 root이므로, 이런 명령은 대개 관리자 권한으로 실행해야 한다.
`block`과 `non-block`은 장치 파일을 여는 동작을 바꾼다. ALSA의 기본값은 원래 OSS 드라이버처럼 사용 중인 장치에서 기다리지 않고 `-EBUSY`를 반환하는 것이다. 모든 OSS 장치의 기본값을 blocking으로 바꾸려면 다음 모듈 옵션을 사용한다.
options snd-pcm-oss nonblock_open=0
`partial-frag`와 `no-silence`는 최적화 전용이며 기본적으로 꺼져 있다. 전자는 전체 fragment가 채워졌을 때만 쓰기 전송을 호출하도록 지정하고, 후자는 무음 데이터를 미리 자동 기록하는 동작을 중지한다.
proc 파일을 읽은 결과는 같은 파일에 다시 쓸 수 있으므로 현재 구성을 저장하고 복원할 수 있다. 모든 설정을 지우려면 `erase` 명령을 보낸다.
% cat /proc/asound/card0/pcm0p/oss > /somewhere/oss-cfg
% cat /somewhere/oss-cfg > /proc/asound/card0/pcm0p/oss
% echo "erase" > /proc/asound/card0/pcm0p/oss
proc 파일의 현재 이미지를 저장·복원하거나 erase로 비운다.
The ``disable`` option is useful when one stream direction (playback or
capture) is not handled correctly by the application although the
hardware itself does support both directions.
The ``direct`` option is used, as mentioned above, to bypass the automatic
conversion and useful for MMAP-applications.
For example, to playback the first PCM device without plugins for
quake, send a command via echo like the following:
::
% echo "quake 0 0 direct" > /proc/asound/card0/pcm0p/oss
While quake wants only playback, you may append the second command
to notify driver that only this direction is about to be allocated:
::
% echo "quake 0 0 disable" > /proc/asound/card0/pcm0c/oss
The permission of proc files depend on the module options of snd.
As default it's set as root, so you'll likely need to be superuser for
sending the command above.
The block and non-block options are used to change the behavior of
opening the device file.
As default, ALSA behaves as original OSS drivers, i.e. does not block
the file when it's busy. The -EBUSY error is returned in this case.
This blocking behavior can be changed globally via nonblock_open
module option of snd-pcm-oss. For using the blocking mode as default
for OSS devices, define like the following:
::
options snd-pcm-oss nonblock_open=0
The ``partial-frag`` and ``no-silence`` commands have been added recently.
Both commands are for optimization use only. The former command
specifies to invoke the write transfer only when the whole fragment is
filled. The latter stops writing the silence data ahead
automatically. Both are disabled as default.
You can check the currently defined configuration by reading the proc
file. The read image can be sent to the proc file again, hence you
can save the current configuration
::
% cat /proc/asound/card0/pcm0p/oss > /somewhere/oss-cfg
and restore it like
::
% cat /somewhere/oss-cfg > /proc/asound/card0/pcm0p/oss
Also, for clearing all the current configuration, send ``erase`` command
as below:
::
% echo "erase" > /proc/asound/card0/pcm0p/oss
OSS 믹서 요소와 ALSA control 매핑
221-269ALSA의 믹서 인터페이스는 OSS와 완전히 다르므로 OSS 믹서 에뮬레이션은 비교적 복잡하다. ALSA는 control 이름 문자열을 기준으로 여러 ALSA mixer control을 하나의 OSS 믹서 요소로 묶는다.
예를 들어 `SOUND_MIXER_PCM`은 재생 방향의 `PCM Playback Volume`, `PCM Playback Switch`와, 존재하는 경우 캡처 방향의 `PCM Capture Volume`, `PCM Capture Switch`로 구성된다. OSS PCM 볼륨을 바꾸면 이 volume과 switch control이 모두 자동 조정된다.
아래 표는 기본 OSS 볼륨 요소에 대응하는 ALSA base string과 index다. 실제 검색에서는 두 번째 열의 `XXX`에 `[Playback|Capture]`와 `[Volume|Switch]` 조합을 붙인 control도 함께 확인한다.
OSS volume 요소를 ALSA control base string과 index에 연결한다.
Mixer Elements
==============
Since ALSA has completely different mixer interface, the emulation of
OSS mixer is relatively complicated. ALSA builds up a mixer element
from several different ALSA (mixer) controls based on the name
string. For example, the volume element SOUND_MIXER_PCM is composed
from "PCM Playback Volume" and "PCM Playback Switch" controls for the
playback direction and from "PCM Capture Volume" and "PCM Capture
Switch" for the capture directory (if exists). When the PCM volume of
OSS is changed, all the volume and switch controls above are adjusted
automatically.
As default, ALSA uses the following control for OSS volumes:
==================== ===================== =====
OSS volume ALSA control Index
==================== ===================== =====
SOUND_MIXER_VOLUME Master 0
SOUND_MIXER_BASS Tone Control - Bass 0
SOUND_MIXER_TREBLE Tone Control - Treble 0
SOUND_MIXER_SYNTH Synth 0
SOUND_MIXER_PCM PCM 0
SOUND_MIXER_SPEAKER PC Speaker 0
SOUND_MIXER_LINE Line 0
SOUND_MIXER_MIC Mic 0
SOUND_MIXER_CD CD 0
SOUND_MIXER_IMIX Monitor Mix 0
SOUND_MIXER_ALTPCM PCM 1
SOUND_MIXER_RECLEV (not assigned)
SOUND_MIXER_IGAIN Capture 0
SOUND_MIXER_OGAIN Playback 0
SOUND_MIXER_LINE1 Aux 0
SOUND_MIXER_LINE2 Aux 1
SOUND_MIXER_LINE3 Aux 2
SOUND_MIXER_DIGITAL1 Digital 0
SOUND_MIXER_DIGITAL2 Digital 1
SOUND_MIXER_DIGITAL3 Digital 2
SOUND_MIXER_PHONEIN Phone 0
SOUND_MIXER_PHONEOUT Phone 1
SOUND_MIXER_VIDEO Video 0
SOUND_MIXER_RADIO Radio 0
SOUND_MIXER_MONITOR Monitor 0
==================== ===================== =====
The second column is the base-string of the corresponding ALSA
control. In fact, the controls with ``XXX [Playback|Capture]
[Volume|Switch]`` will be checked in addition.
oss_mixer 조회와 사용자 지정
270-305현재 믹서 요소 할당은 `/proc/asound/cardX/oss_mixer`에 나열된다. 첫 번째 열은 OSS volume 요소, 두 번째 열은 대응 ALSA control의 base string, 세 번째 열은 control index다. 문자열이 비어 있으면 해당 OSS control을 사용할 수 없다는 뜻이다.
VOLUME "Master" 0
BASS "" 0
TREBLE "" 0
SYNTH "" 0
PCM "PCM" 0
...
할당을 바꾸려면 같은 형식의 구성을 proc 파일에 쓴다. 예를 들어 `Wave Playback`을 PCM 볼륨에 매핑하려면 다음 명령을 사용한다.
% echo 'VOLUME "Wave Playback" 0' > /proc/asound/card0/oss_mixer
명령 문법은 proc 파일에 표시되는 문법과 정확히 같다. 한 줄에 volume 하나씩 여러 요소를 바꿀 수 있다. 이 예에서는 PCM 볼륨을 바꿀 때 `Wave Playback Volume`과 `Wave Playback Switch`가 함께 영향을 받는다.
PCM proc 파일과 마찬가지로 권한은 `snd` 모듈 옵션에 따라 정해지므로 보통 관리자 권한이 필요하다. 파일 전체 이미지를 읽고 다시 써서 현재 믹서 구성도 저장하고 복원할 수 있다.
OSS 요소가 base string과 index를 통해 실제 ALSA volume·switch control에 연결된다.
The current assignment of these mixer elements is listed in the proc
file, /proc/asound/cardX/oss_mixer, which will be like the following
::
VOLUME "Master" 0
BASS "" 0
TREBLE "" 0
SYNTH "" 0
PCM "PCM" 0
...
where the first column is the OSS volume element, the second column
the base-string of the corresponding ALSA control, and the third the
control index. When the string is empty, it means that the
corresponding OSS control is not available.
For changing the assignment, you can write the configuration to this
proc file. For example, to map "Wave Playback" to the PCM volume,
send the command like the following:
::
% echo 'VOLUME "Wave Playback" 0' > /proc/asound/card0/oss_mixer
The command is exactly as same as listed in the proc file. You can
change one or more elements, one volume per line. In the last
example, both "Wave Playback Volume" and "Wave Playback Switch" will
be affected when PCM volume is changed.
Like the case of PCM proc file, the permission of proc files depend on
the module options of snd. you'll likely need to be superuser for
sending the command above.
As well as in the case of PCM proc file, you can save and restore the
current mixer configuration by reading and writing the whole file
image.
이중 방향 스트림의 형식 제약
306-327재생과 캡처에 하나의 장치 파일을 함께 사용할 때 OSS API에는 방향마다 서로 다른 형식, 샘플률 또는 채널 수를 설정할 방법이 없다. 따라서 `O_RDWR`로 연 단일 handle은 두 방향의 값이 모두 같을 때만 올바르게 동작한다.
io_handle = open("device", O_RDWR)
두 방향에서 서로 다른 값을 사용하려면 읽기 전용 입력 handle과 쓰기 전용 출력 handle을 각각 열고, 각 handle에 해당 값을 설정해야 한다.
input_handle = open("device", O_RDONLY)
output_handle = open("device", O_WRONLY)
방향별 PCM 매개변수가 같은지에 따라 handle 구성을 선택한다.
Duplex Streams
==============
Note that when attempting to use a single device file for playback and
capture, the OSS API provides no way to set the format, sample rate or
number of channels different in each direction. Thus
::
io_handle = open("device", O_RDWR)
will only function correctly if the values are the same in each direction.
To use different values in the two directions, use both
::
input_handle = open("device", O_RDONLY)
output_handle = open("device", O_WRONLY)
and set the values for the corresponding handle.
지원되지 않는 ICE1712 MMAP
328-336ICE1712 드라이버의 MMAP은 OSS 에뮬레이션에서 지원되지 않는다. ICE1712가 지원하는 형식은 일반적이지 않은 interleaved 10채널 24bit 형식이며, 각 sample은 32bit에 packed된다.
따라서 OSS에서 통상적인 mono 또는 2채널, 8bit 또는 16bit 형식으로 buffer를 mmap할 수 없다.
하드웨어 native 형식과 OSS 애플리케이션이 기대하는 일반 형식이 일치하지 않는다.
Unsupported Features
====================
MMAP on ICE1712 driver
----------------------
ICE1712 supports only the unconventional format, interleaved
10-channels 24bit (packed in 32bit) format. Therefore you cannot mmap
the buffer as the conventional (mono or 2-channels, 8 or 16bit) format
on OSS.
요약·해설
oss-emulation.rst:1-336ALSA의 커널 OSS 호환 계층에서 PCM·믹서·MIDI·시퀀서 장치 매핑, 애플리케이션별 PCM 동작, mixer control 연결, duplex 제약과 ICE1712 MMAP 제한을 설명합니다.