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.

SK-AM62A-LP: Continuous Audio Playback Fails

Part Number: SK-AM62A-LP

Hello,

We have been having problems playing consecutive audio files on the AM62 platform.  This occurs on our custom hardware as well as the TI EVM.

For example, using the TI AM62A EVM:

root@am62axx-evm:/opt/edgeai-gst-apps# aplay /usr/share/sounds/alsa/Noise.wav /usr/share/sounds/alsa/Noise.wav /usr/share/sounds/alsa/Noise.wav /usr/share/sounds/alsa/Noise.wav
Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
[   73.356455] davinci-mcasp 2b10000.audio-controller: Transmit buffer underflow underrun!!! (at least 1.508 ms long)
[   73.387715] davinci-mcasp 2b10000.audio-controller: Transmit buffer underflow underrun!!! (at least 0.028 ms long)
[   73.416359] davinci-mcasp 2b10000.audio-controller: Transmit buffer underflow

Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
aplay: set_params:1416: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: 48000
PERIOD_TIME: 125000
PERIOD_SIZE: 6000
PERIOD_BYTES: 12000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 24000
BUFFER_BYTES: 48000
TICK_TIME: 0
[   74.440187] ti-udma 485c0100.dma-controller: chan1 teardown timeout!
root@am62axx-evm:/opt/edgeai-gst-apps# uname -a
Linux am62axx-evm 6.1.46-gf8110d9ce8 #1 SMP PREEMPT Mon Sep  4 04:45:34 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

I should note that in this example with three files on the command line, the audio file does play once before printing those errrors. In addition, if you call aplay multiple times in a row with a single WAV file it does seem to work.

Our customer was unable to play consecutive sound files in a Qt application, which led to this testing with the aplay application.

Is there a workaround or fix? Previous e2e issues mentioned that a similar problem should be fixed in Processor SDK 9.0 (<e2e.ti.com/.../processor-sdk-am62x-audio-playback-dma-teardown-complete-not-seen-after-dma-teardown-requested> , but this test was performed with the 9.x SDK SD card image. The teardown timeout message still exists.

If I missed something, please let me know.

Thanks,

-Bob

  • Hi Bob,

    I apologize for the delay in responding to your query.

    It's not possible to play multiple audio files at the same time on the same ALSA PCM device (i.e. using aplay command). If the expectation was to have those audio files mixed together before rendering, then you have to use another component in charge of mixing the streams beforehand (i.e. ALSA dmix plugin).

    Either of these two things you can do:

    1. You have to edit your ~/.asoundrc or etc/asound.conf file to create a virtual device, see "1.5 5. The simple approach" here.

    2. It seems that gstreamer has its own audiomixer/adder element to mix two or more streams.

    I have verified both on my board:

    Added this on /etc/asound.conf

    pcm.!default {
            type plug
            slave.pcm "dmixer"
    }
    
    pcm.dmixer  {
            type dmix
            ipc_key 1024
            slave {
                    pcm "hw:0,0"
                    period_time 0
                    period_size 64
                    buffer_size 9600
                    rate 48000
            }
            bindings {
                    0 0
                    1 1
            }
    }
    
    ctl.dmixer {
            type hw
            card 0
    }
    

    and ran this command: 

    amixer sset PCM 90%

    Simple mixer control 'PCM',0
    Capabilities: pvolume
    Playback channels: Front Left - Front Right
    Limits: Playback 0 - 127
    Mono:
    Front Left: Playback 114 [90%] [-6.50dB]
    Front Right: Playback 114 [90%] [-6.50dB]

    aplay 16_48k_PerfectTest.wav & aplay -Ddmixer piano2.wav


    [1] 1495
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE '16_48k_PerfectTest.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    root@am62axx-evm:/home# aplay 16_48k_PerfectTest.wav & aplay -Ddmixer piano2.wav
    [2] 1497
    Playing WAVE '16_48k_PerfectTest.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    [1]- Done aplay 16_48k_PerfectTest.wav

    Using Gstreamer: 

    gst-launch-1.0 -v filesrc location=16_48k_PerfectTest.wav ! wavparse ! adder name=m ! audioconvert ! autoaudiosink filesrc location=piano2.wav ! wavparse ! audioconvert ! m.

    The chan1 error timeout warning can be ignored.

    Let me know if this helps.

    Best Regards,

    Suren

  • Hello Suren. Thank you for your help, but we are not trying to play sound files at the same time. We are trying to play one file and then immediately play the next one. 

    That is what the aplay example is doing. It plays one file and then immediately plays the next one using the same device.  This fails on the AM62x with the 6.1 kernel.

    You should be able to reproduce this error on your EVM.  My expectation is that it would play the sound and then play it again without the underflow error.

    -Bob

  • Hi Bob,

    Are you testing with the latest SDK 9.1 release for AM62A?

    I just ran this command on my AM62A board and didn't see any issues playing files one after the other with a single aplay command.

    root@am62axx-evm:/home# aplay piano2.wav piano2.wav piano2.wav piano2.wav 16_48k_PerfectTest.wav piano2.wav 16_48k_PerfectTest.wav piano2.wav
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE '16_48k_PerfectTest.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE '16_48k_PerfectTest.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Playing WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    [ 9980.643752] ti-udma 485c0100.dma-controller: chan1 teardown timeout!
    root@am62axx-evm:/home#

    Best Regards,

    Suren

  • Suren,

    Testing on the AM62A evm (SK-AM62A-LP) with a freshly flashed SDK 9.1 image.

    Note that i'm using the alsa Noise.wav since it's already on the filesystem. Not sure where to get your piano2.wav or 16_48k_PerfectTest.wav

    root@am62axx-evm:/opt/edgeai-gst-apps# uname -a
    Linux am62axx-evm 6.1.46-g247b2535b2 #1 SMP PREEMPT Wed Dec  6 17:54:04 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
    root@am62axx-evm:/opt/edgeai-gst-apps# aplay /usr/share/sounds/alsa/Noise.wav /usr/share/sounds/alsa/Noise.wav /usr/share/sounds/alsa/Noise.wav /usr/share/sounds/alsa/Noise.wav
    Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
    Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
    [   82.906866] davinci-mcasp 2b10000.audio-controller: Transmit buffer underflow
    underrun!!! (at least 0.349 ms long)
    [   82.936810] davinci-mcasp 2b10000.audio-controller: Transmit buffer underflow
    underrun!!! (at least 0.029 ms long)
    [   82.978049] davinci-mcasp 2b10000.audio-controller: Transmit buffer underflow
    Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
    aplay: set_params:1416: Unable to install hw params:
    ACCESS:  RW_INTERLEAVED
    FORMAT:  S16_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 16
    FRAME_BITS: 16
    CHANNELS: 1
    RATE: 48000
    PERIOD_TIME: 125000
    PERIOD_SIZE: 6000
    PERIOD_BYTES: 12000
    PERIODS: 4
    BUFFER_TIME: 500000
    BUFFER_SIZE: 24000
    BUFFER_BYTES: 48000
    TICK_TIME: 0
    [   84.005417] ti-udma 485c0100.dma-controller: chan1 teardown timeout!
    

  • Hi Jonathan,

    I was able to reproduce the issue when I removed my /etc/asound.conf file. Just to let you know if I have the /etc/asound.conf with these details, I can run any number of times without any issues. 

    Contents of the /etc/asound.conf:

    pcm.!default {
            type plug
            slave.pcm "dmixer"
    }
    
    pcm.dmixer  {
            type dmix
            ipc_key 1024
            slave {
                    pcm "hw:0,0"
                    period_time 0
                    period_size 64
                    buffer_size 9600
                    rate 48000
            }
            bindings {
                    0 0
                    1 1
            }
    }
    
    ctl.dmixer {
            type hw
            card 0
    }
    

    Best Regards,

    Suren

  • Suren, thank you for your additional attention. We will do some tests with the asound.conf change and I will follow-up here.

  • I was able to reproduce the issue when I removed my /etc/asound.conf file. Just to let you know if I have the /etc/asound.conf with these details, I can run any number of times without any issues. 

    Contents of the /etc/asound.conf:

    Thanks, adding the asound.conf does make the command succeed.  Above you mentioned something about having the files mixed together before playing. What does this mean and why is this necessary?  I would have thought aplay should be able to stop and start playing a different file without having to mix them.

    Any idea if the asound.conf will have any effect on audio played through QT, we will dig into it ourselves but curious if you knew. My grasp on alsa and pulseaudio is pretty rusty.

  • Hi Jonathan,

    If you don't want to use the asound.conf approach to specify the period-size and buffer-size, you can apply the below patch in the linux kernel, compile and rebuild the kernel Image. 

    I have verified with the below patch, I was able to run multiple files without any issues.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/1581.underrun_5F00_crash_5F00_fix.patch

    Hope this helps.

    Best Regards,

    Suren

  • I tested the patch and it does allow aplay to play multiple files in a row.

    The patch is nice and simple, though I wonder why it's in common code and why this issue doesn't crop up with other platforms like the 57x. I suppose there could be a regression in the kernel, since I don't have a 5.10/6.1 kernel to test on my 57x right at this moment.

  • Jonathan, 

    DMA is not the same as it used to be for 57x with newer K3 Sitara SoCs. 

    Since, the issue is resolved with the patch that I provided, I am going to close this thread. Please feel free to reach out for any further assistance.

    Best Regards,

    Suren