VOIP Implementation Audio problems


Hi i have built and packaged linphone for the mango i am working on porting the media pathways to use mango as a sound card the “Mic” thread seems to work ok [only once] the “Speaker” thread fails.

I am starting 2 legato threads in the legacy program [mediastreamer2] that “mange” audio via a pipe one for TX one for RX using either Mic/Recorder Speaker/Player audio connectors GetSamples/PlaySamples is then called reading/writing to the pipe.

The speaker never works it gets a “Invalid Argument” error 22/EINVAL.

Jan 7 01:41:16 swi-mdm9x15 user.err kernel: [ 5205.360719] msm9615_i2s_startup: Error shutdown Tx first
Jan 7 01:41:16 swi-mdm9x15 user.err kernel: [ 5205.365023] ASoC: PRIMARY_I2S_RX startup failed: -22
Jan 7 01:41:16 swi-mdm9x15 user.err kernel: [ 5205.372012] PRIMARY_I2S_RX: ASoC: BE open failed -22
Jan 7 01:41:16 swi-mdm9x15 user.err kernel: [ 5205.376437] MDM9615 Media2: ASoC: failed to start some BEs -22
Jan 7 01:41:16 swi-mdm9x15 user.err Legato: =ERR= | audioDaemon[10519] | cannot open device ‘/dev/snd/pcmC0D1p’, errno 22
Jan 7 01:41:16 swi-mdm9x15 user.err Legato: =ERR= | audioDaemon[10519]/alsa_intf T=Playback-0x10000007 | pa_pcm_alsa.c InitPcmPlaybackCapture() 380 | PCM is not ready (pcm error: )
Jan 7 01:41:16 swi-mdm9x15 user.err Legato: =ERR= | audioDaemon[10519]/audio T=Playback-0x10000007 | le_media.c PlaybackThread() 1539 | PCM cannot be open

I need to restart the audio service on each call attempt to get Mic input data as the pcm device it tries to use changes value.

Jan 7 01:44:45 swi-mdm9x15 user.info Legato: INFO | audioDaemon[10519]/le_pa_audio T=main | pa_audio.c pa_audio_SetDspAudioPath() 3090 | IfaceInUse is now 255
Jan 7 01:44:45 swi-mdm9x15 user.err Legato: =ERR= | audioDaemon[10519] | cannot open device ‘/dev/snd/pcmC0D-c’, errno 2
Jan 7 01:44:45 swi-mdm9x15 user.err Legato: =ERR= | audioDaemon[10519]/alsa_intf T=AudioCapture-0x1000000b | pa_pcm_alsa.c InitPcmPlaybackCapture() 380 | PCM is not ready (pcm error: )
Jan 7 01:44:45 swi-mdm9x15 user.err Legato: =ERR= | audioDaemon[10519]/audio T=AudioCapture-0x1000000b | le_media.c CaptureThread() 1351 | PCM cannot be open

Any ideas will be welcomed.


We have been looking at enhancing and expanding the audio for VOIP use here are some design notes of next generation of board please note we have designed our own board with audio based on the NU8812 audio codec. I have tested this with a CS108B usb dongle plugged into the OTG port it gives full ALSA support via USB Audio v1. we also went for the LAN9500A chip with out extra USB.

The current WP85 has very limited and problematic audio limiting the boards ability to function with VOIP there is a simple solution that will work more efficiently going forward as its separated from the CPU/GSM modem.

A STG3693 high speed 4x 2:1 high speed low resistance switch should allow selecting between GSM/VOIP paths connecting them to the existing audio codec on the board the correct choice in VOIP audio interface will allow for seamless switching via a single GPIO with the default been selected by pull up/down resistor placement or a DNF 0ohm to replace the switch this component is ~1$

Change The Ethernet Chip from a LAN9500Ai to LAN9512 the price goes from ~5$ to ~6.60 for -40c to 85c or stays the same for 0-70c component. The difference is the 9512 adds 2 additional USB interfaces that will allow connecting a USB I2S bridge to allow for VOIP without changing the current device features a alternative is to use only one external USB port changing the connector to a single USB this would potentially drop the cost.

Add a CP2615 USB I2S bridge ~$3.50 to supply a full audio interface that is VOIP capable to the WP the USB will be connected to the LAN9512 chip above or consume one of the external USB ports see notes above i favor using a LAN9512i chip the I2S bus will be connected to the STG3693 switch that will also connect to the audio codec and I2S bus from WP. the I2C should be shared on the i2C mux with the audio chip (3.3v) and the device should be powered from the 3v3 supply a single GPIO is required for programing the device it will be possible to have volume up/down/mute/… buttons the device includes a UART/GPIO bank that can be implemented with adding a kernel driver.

the cost of these changes will be ~$6.10


root@swi-mdm9x15:~# /lib/ld-linux.so.3 --list /usr/bin/linphonec
liblinphone.so.9 => /usr/lib/liblinphone.so.9 (0xb6ed3000)
libbctoolbox.so.1 => /usr/lib/libbctoolbox.so.1 (0x43440000)
libortp.so.13 => /usr/lib/libortp.so.13 (0x432f0000)
libmediastreamer_base.so.10 => /usr/lib/libmediastreamer_base.so.10 (0xb6ebb000)
libc.so.6 => /lib/libc.so.6 (0x43108000)
libbellesip.so.0 => /usr/lib/libbellesip.so.0 (0xb6c1d000)
libmediastreamer_voip.so.10 => /usr/lib/libmediastreamer_voip.so.10 (0xb6bae000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb6a87000)
libbelr.so.1 => /usr/lib/libbelr.so.1 (0xb6a20000)
libbzrtp.so.0 => /usr/lib/libbzrtp.so.0 (0xb6a08000)
libz.so.1 => /lib/libz.so.1 (0xb69ee000)
libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x43578000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x43680000)
libm.so.6 => /lib/libm.so.6 (0x43470000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x43638000)
libpthread.so.0 => /lib/libpthread.so.0 (0x43240000)
librt.so.1 => /lib/librt.so.1 (0x43560000)
libdl.so.2 => /lib/libdl.so.2 (0x432e0000)
libpolarssl.so.7 => /usr/lib/libpolarssl.so.7 (0x43268000)
/lib/ld-linux.so.3 (0x430d8000)
libantlr3c.so.1 => /usr/lib/libantlr3c.so.1 (0xb69d0000)
libsrtp.so.1 => /usr/lib/libsrtp.so.1 (0xb69b3000)
libgsm.so => /usr/lib/libgsm.so (0xb69a4000)
libopus.so.0 => /usr/lib/libopus.so.0 (0xb695b000)
libspeex.so.1 => /usr/lib/libspeex.so.1 (0xb693e000)
libspeexdsp.so.1 => /usr/lib/libspeexdsp.so.1 (0xb6924000)
libasound.so.2 => /usr/lib/libasound.so.2 (0xb6860000)
libavcodec.so.53 => /usr/lib/libavcodec.so.53 (0xb5de5000)
libavutil.so.51 => /usr/lib/libavutil.so.51 (0xb5dc0000)
libswscale.so.2 => /usr/lib/libswscale.so.2 (0xb5d97000)
libtheora.so.0 => /usr/lib/libtheora.so.0 (0xb5d4d000)
libvpx.so.1 => /usr/lib/libvpx.so.1 (0xb5bd0000)
libtheoraenc.so.1 => /usr/lib/libtheoraenc.so.1 (0xb5b93000)
libtheoradec.so.1 => /usr/lib/libtheoradec.so.1 (0xb5b79000)
libogg.so.0 => /usr/lib/libogg.so.0 (0xb5b6c000)

root@swi-mdm9x15:~# linphonec
Warning: video is disabled in linphonec, use -V or -C or -D to enable.
linphonec> help
Commands are:
      help	Print commands help.
    answer	Answer a call
autoanswer	Show/set auto-answer mode
      call	Call a SIP uri or number
     calls	Show all the current calls with their id and status.
 call-logs	Calls history
    camera	Send camera output for current call.
      chat	Chat with a SIP uri
conference	Create and manage an audio conference.
  duration	Print duration in seconds of the last call.
  firewall	Set firewall policy
    friend	Manage friends
      ipv6	Use IPV6
      mute	Mute microphone and suspend voice transmission.
       nat	Set nat address
     pause	pause a call
      play	play a wav file
playbackga	Adjust playback gain.
     proxy	Manage proxies
    record	record to a wav file
    resume	resume a call
 soundcard	Manage soundcards
      stun	Set stun server address
 terminate	Terminate a call
  transfer	Transfer a call to a specified destination.
    unmute	Unmute microphone and resume voice transmission.
    webcam	Manage webcams
      quit	Exit linphonec
Type 'help <command>' for more details or
     'help advanced' to list additional commands.