October 8, 2005

Asterisk PA System

While lurking on #asterisk on freenode someone asked how to get console audio working with asterisk.  This is something I had experimented with in the past with luck and for the life of me the suggestions I gave to get it working I was not able to get working on my own setup.  Here I will explain how I was able to get this working properly in the hopes it might help others in the future.

{mosimage}

First lets take a look at my setup so you might be able to make educated guesses as to how my configuration might be different than yours as with anything of this nature your millage may vary.
CPU: AMD-K6(tm) 3D 450Mhz
Memory: 256MB
Distro: Fedora Core 4
Asterisk: 1.0.9
Asterisk At Home: 1.3

With this setup and several frustrating hours I was able to get a functional PA system running so I could dial an extension and get audio via the speakers I had setup on the system.  This is very useful for paging in a large office or warehouse type environment.

{mospagebreak heading=Hardware&title=Asterisk conf Files}

The fairly easy part to get setup is asterisk itself so here are the config files.  It should be noted there is some redundancy in this config file mainly due to wanting to ensure the load order of various modules.  Also if unable to get OSS sound working it might be beneficial to swap out the alsa module for the oss module.  Doing this should also require an alsa.conf file I found creating a symlink to the oss.conf file allowed me to test with both.

modules.conf

[modules]
autoload=yes
noload => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
noload => app_intercom.so
load => chan_modem.so
load => res_musiconhold.so
noload => chan_alsa.so
load => chan_oss.so
[global]
chan_modem.so=yes

oss.conf | alsa.conf
 
[general]
context=local
extension=s
silencesuppression = yes
silencethreshold = 1000

It should be noted that you should add the lines for the context from-internal-custom and not just replace the whole file.  If the context does not exist you should be safe to add it.

extensions_custom.conf

[from-internal-custom]               

exten => 45,1,Dial(CONSOLE/dsp)
exten => 45,2,Hangup

With these items setup we are now ready to take a look at getting the os to co-operate with asterisk.

{mospagebreak title=Pam Config}

First I had problems getting the audio device to allow the user asterisk to make user of the dsp device at boot.  Fedora core uses udev, pam, and selinux.  Each of these has hooks to change them permissions of devices at bootup.  I began by looking into udev.

/etc/udev/rules.d/50-udev.rules

The following lines were changed to read the following.

KERNEL=="dsp*",                 MODE="0666"
KERNEL=="audio*",               MODE="0666"
KERNEL=="midi*",                MODE="0666"
KERNEL=="mixer*",               MODE="0666"

Unfortunately after a reboot the device was not accessible by anyone but root.  Running udev_start manually did set the permissions so I began researching why udev was not starting.  Someone on #fedora on freenode was able to tell me where the startup for udev was and I confirmed it was starting.  The same person gave me the hint that Fedora had other items that might reset the permissions on devices at startup.

{mospagebreak title=SELinux Config}

SELinux is a great way to ensure your machine is secure.  However it also makes it a pain in the rear to work with when trying to get something working.  So my next step was the SELinux control files to disable SELinux add or modify the SELINUX line.

/etc/selinux/config

SELINUX=disabled

Once SELinux was disabled I thought life would be good instead I found I was in the same boat.

{mospagebreak title=Conclusion}

Thats when I discovered there are files related to pam that are resetting the permissions on my device files at every boot.  In this file there is a line for sound and alias defined at the beginning of the file and another line that defines the file permissions of the devices aliased under sound.  I changed the read write to user group and world.  Since most asterisk boxes are going to be single user this should not pose a security risk but it will allow you to work with the console audio for use in a PA system.

/etc/security/console.perms.d/50-default.perms

<console>  0660 <sound>      0666 root

Leave a comment

You must be logged in to post a comment.