A simple script to change sound system OSS4 <-> ALSA

OSS specific Linux discussion (x86/amd64)

Moderators: cesium, dev, kodachi, hannu

A simple script to change sound system OSS4 <-> ALSA

Postby igorzwx » Sun Sep 05, 2010 8:05 pm

It is not likely to be a practical solution for every day use, but it might be very helpful for testing multi-media applications with OSS4 and ALSA. For example:
1. SIP Communicator (PortAudio) with OSS4 + ALSA emulation
2. SIP Communicator (PortAudio) with ALSA + OSS emulation

Similar tests can be made with GMail voice and video chat
http://gmailblog.blogspot.com/2008/11/s ... -chat.html

There seems to be a great realm for experimenting. For instance, Twinkle SIP Phone works well with OSS4, but it might be interesting to compare its performance OSS4 vs. ALSA on the same computer and on the same system.

WARNING: This method works for Arch Linux only!

It is suggested that you understand rc.conf and you know how to configure applications for ALSA and OSS
http://wiki.archlinux.org/index.php/Beg ... _alsamixer
http://wiki.archlinux.org/index.php/Alsa
http://wiki.archlinux.org/index.php/OSS
http://www.4front-tech.com/wiki/index.p ... _for_OSSv4

Temüjin's script for configuring GSreamer and "gnome-sound-properties" can be downloaded here:
http://www.opensound.com/forum/viewtopic.php?f=3&t=3324

It is suggested that you have Arch Linux with OSS4 installed.

Step 1: Save copies of rc.conf
Code: Select all
$ sudo cp /etc/rc.conf /etc/rc.conf-oss
$ sudo cp /etc/rc.conf /etc/rc.conf-alsa
$ sudo cp /etc/rc.conf /etc/rc.conf-alsa-esd


Step 2: Edit rc.conf-alsa and rc.conf-alsa-esd

rc.conf-oss should look like this:
Code: Select all
# rc.conf for OSS4
# /etc/rc.conf - Main Configuration for Arch Linux
.
.
.
MODULES=(!net-pf-10 !usblp !soundcore !snd_pcsp !pcspkr loop)
.
.
.
DAEMONS=(network @syslog-ng netfs ntpdate ntpd cups @crond @oss dbus hal gdm)


rc.conf-alsa should look like this:
Code: Select all
# rc.conf for ALSA
# /etc/rc.conf - Main Configuration for Arch Linux
.
.
.
MODULES=(!net-pf-10 !usblp soundcore !snd_pcsp !pcspkr loop)
.
.
.
DAEMONS=(network @syslog-ng netfs ntpdate ntpd cups @crond alsa dbus hal gdm)


rc.conf-alsa-esd should look like this:
Code: Select all
# rc.conf for ESound with ALSA
# /etc/rc.conf - Main Configuration for Arch Linux
.
.
.
MODULES=(!net-pf-10 !usblp soundcore !snd_pcsp !pcspkr loop)
.
.
.
DAEMONS=(network @syslog-ng netfs ntpdate ntpd cups @crond alsa esd dbus hal gdm)

Step 3: Install ALSA things:
Code: Select all
# pacman -Syy
# pacman -S alsa-utils alsa-oss esound


Step 4: Install the magic tool from AUR
Code: Select all
$ yaourt -S asoundconf


see:
http://wiki.archlinux.org/index.php/Yaourt
http://wiki.archlinux.org/index.php/ALS ... ound_Cards

Now you can easily switch from OSS4 to ALSA and other way round.

To switch to ALSA, execute two commands:
Code: Select all
$ sudo cp /etc/rc.conf-alsa /etc/rc.conf
$ sudo reboot



To switch to OSS4, execute two commands:
Code: Select all
$ sudo cp /etc/rc.conf-oss /etc/rc.conf
$ sudo reboot


It is very simple, you see. Now you can easily create the scripts you need to automatize the process. You may also try my scripts (in the Attachment).
Attachments
oss-alsa-oss.tar.gz
scripts to change sound system OSS4 <-> ALSA
(1.14 KiB) Downloaded 704 times
igorzwx
Known Member
 
Posts: 1003
Joined: Sun Jun 28, 2009 9:31 pm

Re: A simple script to change sound system OSS4 <-> ALSA

Postby bearson » Wed Sep 08, 2010 3:42 pm

Since it is some work in rc.conf, could "rmmod / modprobe and /etc/rc.d/xxxx stop/ start" do the switch without reboot?
bearson
Member
 
Posts: 12
Joined: Thu Apr 29, 2010 2:04 pm

Re: A simple script to change sound system OSS4 <-> ALSA

Postby igorzwx » Wed Sep 08, 2010 4:07 pm

Yes.
But...

It works perfectly for ALSA -> OSS4

OSS4 -> ALSA might be problematic. Everything was OK, but with Pertrov's resampler, I got sound interruptions. Everything was fixed with reboot.

It would be very nice, if you would find a way to switch without reboot.
I will provide a detail report of my experiments.


--------------------------------------------
You should know the name of ALSA driver for your soundcard

$ lspci -v | grep snd
Kernel modules: snd-via82xx

--------------------------------------------

OSS4 -> ALSA
Code: Select all
1. killall ossxmix   

2. killall mixer_applet2

3. killall gvolwheel 

4. killall knotify4   

5.  ./alsa-gstr.sh

6. mv $HOME/.a-copy-asoundrc $HOME/.asoundrc

7. sudo cp /etc/rc.conf-alsa /etc/rc.conf

8. sudo soundoff

9. sudo modprobe snd-via82xx

10. sudo /etc/rc.d/alsa start

amixer set Master 90% unmute

amixer set PCM 85% unmute

11. gvolwheel

TEST:

speaker-test -c 2

aplay /usr/share/sounds/alsa/Front_Center.wav


ALSA -> OSS4
Code: Select all
1. killall mixer_applet2

2. killall gvolwheel 

3. killall knotify4   

4.  ./oss4gstr.sh

5. mv $HOME/.asoundrc $HOME/.a-copy-asoundrc

6. sudo cp /etc/rc.conf-oss /etc/rc.conf

7. sudo /etc/rc.d/alsa stop

8. sudo modprobe -r snd-via82xx

9. sudo rmmod -f $(lsmod | grep 'snd' | grep -v codec | awk '{print $1}') soundcore

10. sudo soundon

11. gvolwheel

12. ossxmix -b

TEST:

osstest



Underruns with ALSA (they vanished after reboot):
Code: Select all
$ aplay ./Tabla-Tabla_Tarang.wav
Playing WAVE './Tabla-Tabla_Tarang.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

Converter: fftrate (build: Sep  5 2010, 18:37:54)
Input:  44100 Hz, 2 ch, 's16_le' (0x2): dummy = 0, period = 1764
Output: 48000 Hz, 2 ch, 's24_3le' (0x20): dummy = 0, period = 1920
Rates:  44100 --> 48000 (jitter = 0.00%)
Ok.

underrun!!! (at least 326326551.839 ms long)

$ aplay ./Tabla-Tabla_Tarang.wav
Playing WAVE './Tabla-Tabla_Tarang.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

Converter: fftrate (build: Sep  5 2010, 18:37:54)
Input:  44100 Hz, 2 ch, 's16_le' (0x2): dummy = 0, period = 1764
Output: 48000 Hz, 2 ch, 's24_3le' (0x20): dummy = 0, period = 1920
Rates:  44100 --> 48000 (jitter = 0.00%)
Ok.

underrun!!! (at least 326322583.893 ms long)
igorzwx
Known Member
 
Posts: 1003
Joined: Sun Jun 28, 2009 9:31 pm


Return to Linux

Who is online

Users browsing this forum: No registered users and 1 guest

cron