0

I am implementing an extension 900 which routes the audio to ALSA device.  I am also using mpd, which plays music through ALSA.

Asterisk 15, OpenWrt 18.06

mpd.conf:

log_file "syslog"

bind_to_address "127.0.0.1"
bind_to_address "192.168.1.18"

input {
    plugin          "curl"
}

audio_output {
    type            "alsa"
    name            "sun4icodec"
    device          "hw:0,0"
    mixer_control   "Power Amplifier"
}

Here is the section of extensions.conf related to the extension:

;SIP 900
exten => 900,1,NoOp(Testing calls to speakers. Dialing ${EXTEN} from ${CALLERID})
same => n,System(kill -9 `pgrep mpg123`)
same => n,System(amixer set 'Power Amplifier' 80%)
same => n,System(/usr/bin/aplay /var/lib/myapp/sounds/tone3.wav &)
same => n,System(sleep(4))
same => n,NoOp(Testing calls to speakers. Dialing ${EXTEN} from ${CALLERID})
same => n,Dial(CONSOLE/ALSA)
same => n,Hangup()
same => n,System(sleep(1))
same => n,System(amixer set 'Power Amplifier' 80%;)
same => n,System(sleep(4))

When chan_alsa is loaded it locks the ALSA device, and when something is played on mpd I get the following error:

aplay: main:722: audio open error: Resource busy

I came across this on VoIP-Info, but I am not sure how to implement this.  Not sure if I need to twiddle software and/or hardware mixing.

  • output_device = <ALSA device name>

    Indicates the name of the ALSA device to use for playing sound, i.e. for listening.  A device name specified here is passed, unchanged, to the ALSA sound layer, so any ALSA device name should work. Warning: Asterisk may lock the ALSA device specified here for the entire duration the Asterisk process is running.  You may have to twiddle software and/or hardware mixing settings to keep Asterisk from hogging your output device.

  • If you quote something/somebody, please identify the source. – G-Man Feb 25 at 5:22
  • @G-Man Noted that. Will follow this in future! Thanks! – dmSherazi Feb 26 at 5:59
0

That mean you need mixer which allow simult access.

But your task is doable much easy way via MOH.

  • can you please explain or provide some links to resources explaining that ? – dmSherazi Feb 25 at 10:37
  • Alsa card/driver blocking your sound path, not asterisk. So you need have mixer AND sound card which can do non-blocking operations. Or you can do using moh. voip-info.org/asterisk-config-musiconholdconf – arheops Feb 25 at 14:04
  • I have gone through this page and was not able to understand how I can route the audio from sip call to the sound card. Can you please help in understanding this ? – dmSherazi Feb 26 at 5:58
  • You not need sound card at all. You should send MPD output to moh, like described – arheops Feb 26 at 7:03
  • I guess we both are not in sync, :). What I need is if I call an extension to suppose 900 from an endpoint, Asterisk will Answer the call and route the incoming voice to the soundcard of the machine /board on which the asterisk is setup. That is why I am using same => n,Dial(CONSOLE/ALSA) . The output of the soundcard in my setup is fed to an audio amplifier which will play the audio on attached speakers. In short the 900 extension will be used as Public address extension – dmSherazi Feb 26 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.