muting soundcard via system() not working right

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

muting soundcard via system() not working right

Postby quickbeam » Thu Oct 24, 2013 10:23 am

Hi all,
I have FreePBX (Asterisk version 11.4.0) up and running with roughly 20 SIP phones and one outside analog line. I have an extension setup as a paging extension (extension '8'). It works if I manually unmute/mute the soundcard in alsamixer: I can call the extension, hear the beep, and talk through the speakers. I am trying to have the sound card unmuted/muted automatically when the extension is dialed. Here is my extensions_custom.conf file:
Code: Select all
[from-internal-custom]
exten => 8,1,System(/usr/bin/amixer -c 0 sset 'Audigy Analog/Digital Output Jack' unmute)
     same => n,Dial(console/dsp,,gA(beep))
     same => n,System(/usr/bin/amixer -c 0 sset 'Audigy Analog/Digital Output Jack' mute)
     same => n,Hangup

Here is the output of the log file when I dial the extension:
Code: Select all
[date] WARNING[5361][C-0000001e]: chan_oss.c:853 ss_request: oss_request ty <console> data 0x0x7f4478001e90 <dsp>
[date] NOTICE[5361][c-0000001e]: console_video.c:137 console_video_start: voice only, console video support not present

I have tried several variants on the system() call with no significant results. I have tried only muting or only unmuting the card in the extensions_custom.conf file to see if the mute/unmute happened too fast for me to catch it. I can run the same command from the asterisk cli using the ! and it will run fine. I can see it unmute/mute the card in alsamixer. Is there something glaringly obvious that I am missing? Is there a different way to make the system() call? Any help is greatly appreciated!!
quickbeam
Newsterisk
 
Posts: 3
Joined: Thu Oct 24, 2013 10:03 am

Re: muting soundcard via system() not working right

Postby quickbeam » Fri Oct 25, 2013 3:04 pm

I have some updated information. I am currently running this script to unmute the sound card:
Code: Select all
unmute.sh
#!/bin/bash
amixer -c 0 sset 'Audigy Analog/Digital Output Jack' unmute

I can run /etc/asterisk/unmute.sh > /etc/asterisk/tmplog.txt from the bash command prompt and get the results of the command in the tmplog.txt file (i.e. the sound card Audigy channel is unmuted).
However, if I execute the script from the dial plan it fails and all I get in the tmplog.txt file is the output of amixer as if I had run it with no parameters. The parameters seem to be missing when the file is called from within the dial plan. Here is the dial plan call:
Code: Select all
[from-internal-custom]
exten => 8,1,Answer()
exten => 8,2,TrySystem(/etc/asterisk/unmute.sh > /etc/asterisk/tmplog.txt)
exten => 8,3,Dial(console/dsp,,gA(beep))
exten => 8,4,Hangup

I'll post more information as I get it.
quickbeam
Newsterisk
 
Posts: 3
Joined: Thu Oct 24, 2013 10:03 am

Re: muting soundcard via system() not working right

Postby quickbeam » Mon Oct 28, 2013 1:14 pm

More information:
I can run this at the asterisk cli and the sound card is unmuted:
Code: Select all
localhost*CLI>!/etc/asterisk/unmute.sh

This exact same shell script when called from within the dial plan gives me this:
Code: Select all
Usage: amixer <options> [command]

Available options:
-h,--help this help
-c,--card N select the card
-D,--device N select the device, default 'default'
-d,--debug debug mode
-n,--nocheck do not perform range checking
-v,--version print version of this program
-q,--quiet be quiet
-i,--inactive show also inactive controls
-a,--abstract L select abstraction level (none or basic)
-s,--stdin Read and execute commands from stdin sequentially
-R,--raw-volume Use the raw value (default)
-M,--mapped-volume Use the mapped volume

Available commands:
scontrols show all mixer simple controls
scontents    show contents of all mixer simple controls (default command)
sset sID P set contents for one mixer simple control
sget sID get contents for one mixer simple control
controls show all controls for given card
contents show contents of all controls for given card
cset cID P set control contents for one control
cget cID get control contents for one control

...and this is the call
Code: Select all
exten => 8,1,Answer()
     same => n,System(/etc/asterisk/unmute.sh)


It appears that somewhere the System() command does SOMETHING to the call. Otherwise, why would it fail?
quickbeam
Newsterisk
 
Posts: 3
Joined: Thu Oct 24, 2013 10:03 am

Re: muting soundcard via system() not working right

Postby navaismo » Mon Oct 28, 2013 2:33 pm

Freepbx runs as asterisk user so check if asterisk user can use the device.
navaismo
Salt of the Asterisk
 
Posts: 1610
Joined: Mon Dec 07, 2009 1:30 pm
Location: Mexico City, Mexico


Return to Asterisk Support

Who is online

Users browsing this forum: No registered users and 19 guests