ASL with no OSS Kernel Module (since it’s now marked as broken and has been deprecated for 10 years)
This is the process that I used to facilitate the “emulation” of OSS /dev/dsp1
using ALSA, PulseAudio and OSSPD.
Below you will find basic guidelines and what I edited in order to allow ASL to function with a CURRENT kernel on raspbian. This document makes a few assumptions:
- You know how to use an editor, of your choice, in the shell of your choice.
- You have ASL in a state where it will at least start up with the CURRENT kernel.. i.e. you built and installed the required dahdi modules from source
- You know how to install applications on whatever distribution that you happen to be running
Again, the good news here is that you can run current kernels without trudging through and trying to enable broken.. so that means security fixes and performance patches etc… Just a little more admin overhead for now.
Caveats
Before we dive into it to far, I want to make note of a few current caveats. Firstly I have not found a way to make OSSPD work properly with pulse running as a system wide service (if you don’t know what I’m talking about, I suggest RTFM or move on). Secondly, I have not been able to successfully get Pulse to run as a daemon using systemctl, there are issues because when you do it this way pulse expects a window manager and we don’t want that overhead on the system IMHO…. So what this means is that unfortunately at this time (I’m working on a solution) when a system reboots the user needs to ssh into the box and manually do a few things.
If anyone gets pulse running correctly at startup, I’m all ears and will happily publish the info!
Yes, I did try fairly exhaustively to use AOSS and ALSA-OSPD but was never able to make it work, so if you are so inclined please feel free because if we can eliminate Pulse from the equation it would simplify things a bit. Of course having pulse in there gives us a lot of other capabilities.. so there is a tradeoff I suppose.
Basic Steps Outline
- OPTIONAL Disable the onboard audio (for Pi 3 etc…) unless you have an explicit reason to have it..
* Edit /lib/modprobe.d/raspi-blacklist.conf and addblacklist snd_bcm2835
* reboot - Determine hardware location(s) (run all as root or sudo unless otherwise noted)
* lsusb (look for C-Media Electronics, Inc) to be sure it’s even listed (your URI)
* aplay -l (make note of the card # associated with the USB PnP Sound Device) - Edit /usr/share/alsa/alsa.conf to make the URI (USB Device) the default
- find defaults.ctl.card and defaults.pcm.card
- their default value is 0, change this to the # value identified in step 1 using the aplay -l command
- find defaults.ctl.card and defaults.pcm.card
- Reboot
- Install OSSPD
- A few more edits
- Service restarts
- Audio should now work via alsa, pulse and aoss
Slightly more detail
These are the exact steps that I took to emulate OSS. Please remember to check logs files if you are experiencing things that you don’t expect, they usually contain information that will help with the troubleshooting process.
- edit /etc/pulse/daemon.conf changing the following lines to read as noted
default-sample-rate = 48000 default-fragments = 5 default-fragment-size-msec = 2
- edit /usr/share/alsa/alsa.conf changing the following lines to read as noted
defaults.ctl.card 1 #card number from aplay -l defaults.pcm.card 1 #card number from aplay -l
- edit /etc/pulse/default.pa changing the following lines to read as noted
load-module module-alsa-source device=hw:1,0 #device number specified in alsa.conf from aplay -l load-module module-udev-detect tsched=0 ignore_dB=1
-
reboot
- install osspd and execute the following after install
sudo systemctl stop osspd.service
- edit /lib/systemd/system/osspd.service and change the ExecStart line as noted
ExecStart=/usr/sbin/osspd -f --dsp-slave=/usr/lib/osspd/ossp-padsp --adsp=dsp1
- execute the following commands to restart services etc…
sudo systemctl daemon-reload sudo pulseaudio --start sudo systemctl start osspd.service sudo systemctl restart asterisk.service
- You should now have audio using the above method.. if not, check logs and retrace your steps. Note that you have to manually start pulseaudio every time for now.. and that you need to start osspd.service and asterisk.service AFTER starting pulse, but you dont’ have to stay logged in…
To-Do
My short list of outstanding things… and in no specific order
- Systemize pulseaudio
- Benchtest audio levels of this setup vs OSS on the same hardware
- Benchtest CTCSS output of this setup vs OSS on the same hardware (it all sounds super clean but I need science)
- Produce some more examples of using pulse to pipe the audio stream out to other sources for recording/monitoring etc etc… (this gives us so many more capabilities than OSS ever dreamed of)