This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to implement audio duplex with alsa in TLV320AIC3101 codec in DM365

Other Parts Discussed in Thread: TLV320AIC3101

I am implementing an application to capture and playback audio with alsa library at same time in TLV320AIC3101 in DM365 (Linux kernel 2.6.18). 

I use “default” device and open it twice, one for CAPTURE, one for PLAYBACK. The snd_pcm_open function returns fine. And capture function(snd_pcm_readi) works fine too before I start playback.

But I always get “Broken Pipe” error  in capture function when I start playback during capturing. 

I did not find duplex setting in TLV320AIC3101’s datasheet, but I checked its block diagram, looks like it has separate channel for capture and playback.

Is there any special configuration for alsa or any patch for alsa or kernel to implement audio duplex?

 

Thank you very much  for your time and help,

Ivy

  • Hi, Ivy !

    If you want to get capture & playbak without any processing, you can try loopback feature of AIC3101.
    Here is some info
    http://e2e.ti.com/support/embedded/linux/f/354/p/180734/653972.aspx#653972
    It works fine!

    Also, I tried Capture&Playback with ALSA.
    See my profile and click "Files"-tab or use this link
    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-components-userfiles/00-00-05-53-00/simplealsatest.zip

    There are two problems.
    Of course, at first, it's delay between capture & playback. You can pickup data to buf from input and then put buf data to output.
    Sound delay("echo") is always present. This is not a problem, it's a statement of fact.

    The second thing is warning with "BROKEN PIPE". (aka "-EPIPE", aka "overrun").

    Quote from "http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html":
    "The overrun can happen when an application does not take new captured samples in time from alsa-lib."

    Some another concurrent thread takes control for a lot of time and then return it.
    At this moment the sound buffer can be overflowed, because your thread could not make readings in time.

    Solution is dramatically increase buf size or change thread switch logic to spent time more often in your thread.

    My "simplealsatest.zip" example is very old and it has bugs.
    For example, I add "snd_pcm_recover" call and so on.
    ----
      frames_avail = snd_pcm_avail(snd.pPcmC);
      if(frames_avail<0) {
        frames_avail = snd_pcm_recover(snd.pPcmC, frames_avail, 1);
        frames_avail = snd_pcm_avail(snd.pPcmC);
      }
    ---
    and I will plan to update "simplealsatest.zip" example with version-"2" on my profile page.

    If you have any ideas, please write here.

    I will be glad to hear any comments and suggestions of how to make the capture process better.

    Sometimes I still see "BROKEN PIPE" message in my application.

    Best regards,

    Arseniy Platonov ('senchuss').

  • Hi Arseniy,

    Thank you very much for your detailed reply.

    I can not use loopback feature, because I need to playback a specific file.

    I will try your example now.

    And one more question about alsa.conf or asound.rc, do you have any special setting in those two configure files?

    I heard about that I need to change the settings in those two files too to make duplex work. I just have a simple alsa.conf.

     

    Thanks and Best Regards,

    Ivy

  • Hi Arseniy,

    The code works for me.

    Thank you very much.

     

    Best Regards,

    Ivy

  • 6278.1KHz Sine Wave 16KHz sample rate 20 sec.wav

    Dear senchuss,

    I am trying to use your alsa test code for playing wav on DM365 target board, but when I  play 16Khz, 16Bit Wave file

    , I am hear a clicking noise during writing pcm data like as

     normal sound -- clicking noise -- normal sound....

    When I try to play it via aplay, it works fine.

    Do you have any idea what I missed?

    Hear is my test wav file..

    Thanks in advance.

    Aden Yoon