Skip to content

OSS4 and gstreamer based player problem

Updated: at 12:30 PM

Sound system on Linux is confusing, both for end users and developers. When I was using Fedora, I used Alsa for all of my sound needs, from listening to music, filming and gaming. Recently, I’ve switched to Arch Linux and installed OSS4 for my sound. The sound quanlity is quite better than Alsa but I’ve got an annoying problem: all the gstreamer-based music player uses CPU too much, about 40%-60% (rhythmbox, totem, exaile) when playing mp3 files. After googling, I found this, try this on my system:

/usr/sbin/vmixctl detach /dev/dsp
/usr/sbin/vmixctl attach -r /dev/dsp

What it does is to detach the virtual mixer and reattach without recording setting. The CPU usage down to 6-10%, cool!
But after reboot, the CPU usage of gstreamer-based music player still high. It seems that our hack is not persisted. So I have to edit the /etc/rc.d/oss to detach and reattach without recording ability, here is my /etc/rc.d/oss:

#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
start)
     stat_busy 'Starting Open Sound System'
     if /usr/sbin/soundon
     then
             add_daemon oss
             /usr/sbin/vmixctl detach /dev/dsp
             /usr/sbin/vmixctl attach -r /dev/dsp
             stat_done
     else
             stat_fail
     fi
     ;;
stop)
     stat_busy 'Stopping Open Sound System'
     if /usr/sbin/soundoff
     then
             rm_daemon oss
             stat_done
     else
             stat_fail
     fi
     ;;
restart)
     $0 stop
     $0 start
     ;;
*)
     echo "Usage: $0 {start|stop|restart}"
esac

Now, all the gstreamer-based applications are now playing nice with my CPU, but my box lost the ability to record sound :(. If you have a better solution, please share with me.