element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum PJSIP/PJSUA with Wolfson audio card
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 15 replies
  • Subscribers 677 subscribers
  • Views 3415 views
  • Users 0 members are here
  • raspberry
  • audio
  • wolfson_pi
  • pi
  • raspberry_pi
  • raspeberry_pi_accessories
  • pjsip
  • pjsua
Related

PJSIP/PJSUA with Wolfson audio card

Former Member
Former Member over 11 years ago

I am trying to get a SIP client running on my PI with Wolfson audio card.

 

I can use aplay and arecord, work great but when I set up a call with PJSUA I get the following errors:

 

07:14:34.698pjsua_app.c  ..Turning sound device ON
07:14:34.698pjsua_aud.c  ..Opening sound device PCM@16000/1/20ms
07:14:34.707 alsa_dev.c  ...ALSA lib pcm_hw.c:326:(snd_pcm_hw_hw_params) SNDRV_PCM_IOCTL_HW_PARAMS failed (-22): Invalid argument
07:14:34.707pjsua_app.c  ..Turning sound device ON
07:14:34.707pjsua_aud.c  ..Opening sound device PCM@44100/1/20ms
07:14:35.292ec0x14005a8  ...Echo suppressor created, clock_rate=44100, channel=1, samples per frame=882, tail length=200 ms, latency=100 ms

07:14:35.293  pjsua_media.c  .Call 0: initializing media..

07:14:35.297 alsa_dev.c  ALSA lib pcm_hw.c:587:(snd_pcm_hw_start) SNDRV_PCM_IOCTL_START failed (-12): Cannot allocate memory

 

Anyone that can guide me in the right direction on how to get this running?

 

Best Regards

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 11 years ago

    I too have been bitten by the sample rate bug...

    I have modified my ~/.asoundrc quite a bit in order to be able to record 1-channel at 8kHz and 16kHz.

    I'm using ALSA's built-in re-sampling capabilities.

     

    This is not for those who like to enjoy HD audio! The sound card operates at 48kHz/16bit at all times.

    Everything is re-sampled and converted up or down as needed.

    --

    Ragnar

     

    #######################################################################
    #
    # Use libsamplerate instead of internal resampler.
    # You might have to: sudo apt-get install libasound2-plugins
    # Or just comment out the next line if the internal one is good enough for your needs.
    defaults.pcm.rate_converter "samplerate"
    
    ######################################################################
    #
    # Wolfson Audio Card for Raspberry Pi
    #
    pcm.wolfson_pi_soundcard {
        type hw
        card sndrpiwsp
        device 0
    }
    # Create a Master volume control
    pcm.softvol {
        type            softvol
        slave {
            pcm         "pduplex"
        }
        control {
            name        "Master"
            card        0
        }
    }
    
    pcm.!default  {
        type           asym
        playback.pcm   "plug:softvol"
        capture.pcm    "pduplex"
    }
    
    #####################################################################
    #
    # Mixing and resampling goodness :-)
    #
    # Several clients can record and play back simultaneously.
    # The dmix and dsnoop plugins operate at 48kHz by default, i.e. the sound card will be kept at 48kHz at all times.
    # All playback streams are converted to 2 channels/48kHz/16bit.
    # All recording streams are converted from the card's 2 channels/48kHz/16bit
    # to the requested number of channels, sample rate and bit depth.
    
    # We define one pcm device called "playmixer" for playback.
    pcm.playmixer {
            ipc_key 140324  # Any number will do, as long as it's unique in the system.
            ipc_key_add_uid true
            type dmix
            slave.pcm "wolfson_pi_soundcard"
    }
    
    # Define another one called "recmixer" for capture.
    # The sound card will run at 48kHz and input is resampled to the requested rate.
    pcm.recmixer {
            ipc_key 140325
            ipc_key_add_uid true
            type dsnoop
            slave.pcm "wolfson_pi_soundcard"
    }
    
    # Define a duplex device, with both in- and outputs.
    pcm.duplex {
            type asym
            playback.pcm "playmixer"
            capture.pcm "recmixer"
    }
    
    # Add a "plug" plugin for the above "duplex" device.
    # This is where all the converting takes place.
    # Sample rate, number of channels, bit depth.
    # By the way, who thought that "plug" was a good name for a plugin?
    #
    # Use this device for all your playback and recording resampling needs.
    pcm.pduplex {
            type plug
            slave.pcm "duplex"
    }
    
    # A ctl device to keep xmms happy
    ctl.pduplex {
            type hw
            card 0
    }
    
    # A DSP to keep the alsa-oss layer happy:
    pcm.dsp0 {
            type plug
            slave.pcm "duplex"
    }
    
    ctl.mixer0 {
            type hw
            card 0
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • nuntipat
    0 nuntipat over 10 years ago in reply to Former Member

    Hi Ragnar,

     

    I'm using your ~/.asoundrc file above and get this error

     

    ALSA lib pcm_direct.c:877:(snd1_pcm_direct_initialize_slave) slave plugin does not support mmap interleaved or mmap noninterleaved access

    ALSA lib pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize slave

    aplay: main:682: audio open error: Invalid argument

     

    Any help would be really appreciate.

     

    Thank you,

    Palm

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to nuntipat

    Is that with the 3.12 kernel? It needs a patch to enable memory mapped I/O.

    georgpi has made a patched kernel available at https://blog.georgmill.de/2015/02/18/update-for-wolfson-audio-card-on-raspberry-pi/

    Full discussion: http://www.element14.com/community/message/141324/l/cirrus-audio-b-and-jack#141324

    --

    Ragnar

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • nuntipat
    0 nuntipat over 10 years ago in reply to Former Member

    Hi Ragnar,

     

    No, I'm using the 3.18 kernel on raspberry pi with my custom build kernel to include support for WM8731 codec board from Mikroe. The driver is missing from 3.18 kernel so I copied the code from the older kernel. I've loaded these kernel modules (snd_soc_wm8731, snd_soc_rpi_proto) according to koalo's blog: I²S Audio Support for Raspberry Pi. It work perfectly and I can play and record sound but at 48kHz stereo (2ch) only. My task is to perform speech recognition using the HTK toolkit or Julius. These software only support mono sound input and at 16kHz or 8kHz sampling rate. Thus I think of using alsa plugin dsnooped to split sound from stereo to mono and to convert the sample rate in software. I've tried using mamp_emul plugin but it said the dsnooped can't work with mmap emulator. Can I just apply your patch here http://www.element14.com/community/message/141324/l/cirrus-audio-b-and-jack#141324 (http://www.element14.com/community/servlet/JiveServlet/download/141528-167303/cirrus_logic_mmap.patch.zip) or do I need to do other thing too?

     

    Thank you,

    Palm

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to nuntipat

    Not a Wolfson/Cirrus Logic card, then...

     

    The patch is meant for the already heavily patched 3.12 kernel sources from Cirrus Logic.

    On the other hand, it's a very small patch. It does apply cleanly to the 3.18 source (if using the "patch" command's -l switch) and I have been able build a 3.18 kernel with it.

    It was the only thing I needed to do to get mmap going in the 3.12 bcm2708-i2s driver.

    But I don't have any hardware to test it on 3.18.

     

    So, the definite answer is: maybe image

    --

    Ragnar

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 10 years ago in reply to nuntipat

    Not a Wolfson/Cirrus Logic card, then...

     

    The patch is meant for the already heavily patched 3.12 kernel sources from Cirrus Logic.

    On the other hand, it's a very small patch. It does apply cleanly to the 3.18 source (if using the "patch" command's -l switch) and I have been able build a 3.18 kernel with it.

    It was the only thing I needed to do to get mmap going in the 3.12 bcm2708-i2s driver.

    But I don't have any hardware to test it on 3.18.

     

    So, the definite answer is: maybe image

    --

    Ragnar

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube