PDA

View Full Version : HowTo ALSA/Dmix/OSS



Seyyapc
02-26-2007, 03:44 AM
I use ALSA since knoppix v3.7 & kernel 2.4.27, it still works perfectly but many guides-wikis-howto are too old to use in actual days, many things are the some others are different. This Howto is to make a standard system-sound-ready (prefer kernel > 2.6.16) for programs/games, no taking in consideration latency,quality and other sound Specifications like 5.1 sound or jack.

---
1_Identify Your Card
# lspci | grep -i audio
00:01.4 Multimedia audio controller: Silicon Integrated Systems [SiS] SiS PCI Audio Accelerator (rev 02)
2_Building Support from Kernel Source (2.6.x)
ALSA modules can be built from your kernel source, in my case I used 'make xconfig' and choose the next modules (I prefer modules and not build all in the kernel)
http://img180.imageshack.us/img180/8306/config1xh9.th.jpg (http://img180.imageshack.us/my.php?image=config1xh9.jpg) - http://img504.imageshack.us/img504/5950/config2ei9.th.jpg (http://img504.imageshack.us/my.php?image=config2ei9.jpg) - http://img180.imageshack.us/img180/3769/config3ud3.th.jpg (http://img180.imageshack.us/my.php?image=config3ud3.jpg)
Compile the new kernel with your sound modules.
Known Issues Kernel 2.6.16

There is currently a problem with the alsa-driver package and kernel 2.6.16, either vanilla, Gentoo, or -ck. Please note that upgrading to ALSA 1.0.11_rc3 or newer should solve the problem for some. Yet for others, this option might create modules that cannot load into your new kernel. Be aware that as of right now, you should only run 2.6.16 with Alsa built into the kernel. This issue is resolved in kernels 2.6.17 and above.

If you choose to compile sound card support directly into the kernel and have alsa-sound on video capture cards there may be problems starting with 2.6.16. Compiling as modules solved this problem. This is also resolved in 2.6.17 and up.
3_Utils
You still need some utils to make use of your new kernel with alsa support
#apt-get update
#apt-get alsa-lib alsa-oss alsa-utils
4_ Dmix & Asoundrc
There are many configurations files (/home/username/.asoundrc & /etc/asound.conf) on the net to make use of the plugin:dmix, but this configurations are from the old days on kernel 2.4.x. Today (for general use) you don't need to spec dmix on the configuration files, the kernel with the alsa modules already use dmix automatically for alsa-sound.

The dmix virtual sound mixing device is a plugin to ALSA which takes multiple sound streams and mixes them into one virtual stream which a lower-end card can handle. Any card which does not support multiple streams or hardware mixing of sounds must use this plugin to take full advantage of ALSA and its capabilities.
You still need the configuration files for the ALSA OSS emulation (example aoss for Simcity 3000 Unlimited or realplayer) bellow a common .asoundrc which only control the ALSA OSS emulation with the line pcm.dsp0
#nano /home/username/.asoundrc
pcm.ossmix {
type dmix
ipc_key 1024 # must be unique!
# ipc_key_add_uid false # let multiple users share
# ipc_perm 0666 # IPC permissions for multi-user sharing (octal, default 0600)
slave {
pcm "hw:0,0" # you cannot use a "plug" device here, darn.
period_time 0
period_size 1024 # must be power of 2
buffer_size 8192 # dito. It
#format "S32_LE"
#periods 128 # dito.
rate 44100 # with rate 8000 you *will* hear,
# if ossmix is used :)
}
# bindings are cool. This says, that only the first
# two channels are to be used by dmix, which is
# enough for (most) oss apps and also lets
# multichannel chios work much faster:
bindings {
0 0 # from 0 => to 0
1 1 # from 1 => to 1
}
}
pcm.dsp0 {
type plug
slave.pcm "ossmix" # use our new PCM here
}
# mixer0 like above
ctl.mixer0 {
type hw
card 0
}
5_ Common Applications with alsa support
Mplayer
#nano ~./mplayer/config
# Write your default config options here!
vo=xv
#Use alsa device for audio
ao=alsa
#Activated soft volume control
softvol=1
Mplayer-plugin
nano ~/.mplayer/mplayerplug-in.conf
vo=xv
#Use ALSA device for sound
ao=alsa
cachesize=512
cache-percent=20
...
XMMS
Options -> Preferences -> Audio
* Select Alsa Plugin
* Output Plugins Preferences
1. Audio Device: default (which is NOT the same as "ossmix")
2. Use software volume control
3. Advanced Settings (these settings may be for a particular sound card)
o buffer time: 750ms
o period time: 75ms
o uncheck mmap mode, if present
6_ Reset and enjoy your new kernel with alsa support

I hope it help others, with this steps I can hear at the same time (for testing, not for common use) demo on skype, movie on mplayer, song on xmms and play simcity 3000 unlimited.
----
Bibliography
HOWTO ALSA Complete (includes dmix) (http://gentoo-wiki.com/HOWTO_ALSA_sound_mixer_aka_dmix#XMMS)
Advanced Linux Sound Architecture (http://www.alsa-project.org/)
ALSA Soundcard MATRIX (http://www.alsa-project.org/alsa-doc/)