[audio] sgtl5000: RTP and audio loop

  • Hello,


    we have an issue with an interrupted RTP stream: sending and receiving an RTP strem (MU_LAW 8KHz) between two armStone boards works fine.
    The problem occurs on network interruption or the sender died: approximately the last 500ms audio samples are repeated for about 180 seconds.


    sender test code: <!-- m --><a class="postlink" href="http://pastebin.com/fKaSJJ3h">http://pastebin.com/fKaSJJ3h</a><!-- m -->
    receiver test code: <!-- m --><a class="postlink" href="http://pastebin.com/d8nnBbLp">http://pastebin.com/d8nnBbLp</a><!-- m -->


    You should compile with -lortp -lasound and add multicast route to your system:

    Code
    1. # route add -net 224.0/4 dev eth0
    2. # ./sender <card_name> <port>
    3. or
    4. # ./receiver <card_name> <port>
    5. where <card_name> could be "default"


    Best regards,


    Marco Bascetta

  • Hello,


    as mentioned in the email, the problem comes from the mediastreamer2 library in the "mediastreamer-2.8.2/src/alsa.c"-file -> "alsa_set_params()"-function. The calculation of the "stop_threshold"-variable is wrong because of reading back the wrong exact set value (exact_ulvalue)
    after setting the periods in "snd_pcm_hw_params_set_periods_near()"-function. The stop_threshold variable is used by ALSA for automatic stop after reading a buffer.


    Due to a wrong assignment the "periods"-variable gets the value of periodsize, which for example can be 1024 or 2048. The "stop_threshold"-variable is calculated with "periods * periodsize" in the "snd_pcm_sw_params_set_stop_threshold()"-call.
    This normally would be the buffersize (for example 8192 bytes if periods would be 8). In this case "stop_threshold" would be calculated up to 1048576.
    Divided by buffersize you would get the duration of the loop playing after a interruption (about 128sec). This values are just a example. In some cases (if periodsize would be for example 2048 bytes) the audio loop would be longer (>8min).


    Enclosed is a patch for this problem.


    Best regards,


    Andreas Zeiler

    Files

    • ms_alsa_c.patch

      (467 Byte, downloaded 408 times, last: )

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.