AVB to TDM and When to Swap the Receive Buffer in buffer_manager_to_tdm

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
Post Reply
dmclean
Junior Member
Posts: 5
Joined: Mon May 22, 2017 4:01 am

AVB to TDM and When to Swap the Receive Buffer in buffer_manager_to_tdm

Post by dmclean »

I have a few questions about something in the Application Note: AN00203 Gigabit Ethernet AVB endpoint example using TDM master, that I was hoping someone might be able to answer. During the tdm.send() callback in the buffer_manager_to_tdm() task, the receive audio buffer is swapped once the send index is 7 less than the number of receive channels:

if (index == (AVB_NUM_MEDIA_INPUTS-7)) {
tmr :> p_in_frame->timestamp;
audio_frame_t *unsafe new_frame = audio_buffers_swap_active_buffer(*double_buffer);
c_audio <: p_in_frame;
p_in_frame = new_frame;
}


What is the significance of the 7?
Why aren't the buffers swapped in the tdm.receive() callback which seems like a more logical choice given that it knows when the frame is full?


User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

I changed mine to swap the buffers in tdm.receive() and it works perfectly, a lot more logical code.
You just have to keep a count of the samples received, don't use the receive sample index because that doesn't go from 0 to 31 I don't believe. So I just added a new variable called samples_received or something like that and incremented it from 0 to AVB_NUM_MEDIA_INPUTS and then set it back to 0.
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Code: Select all

       
        if( sample_out_count == AVB_NUM_MEDIA_INPUTS )
        {
          tmr :> p_in_frame->timestamp;
          audio_frame_t *unsafe new_frame = audio_buffers_swap_active_buffer(*double_buffer);
          c_audio <: p_in_frame;
          p_in_frame = new_frame;
          sample_out_count = 0;
        }
dmclean
Junior Member
Posts: 5
Joined: Mon May 22, 2017 4:01 am

Post by dmclean »

Thanks akp! I got impatient and tried the same and everything appears to work as it should.
Post Reply