Thanks for the reply! I changed the code and it worked. there is still some issues
consider, I choose data rate as 5.689 Ks/s and sample per channel as 5 KS/ch. one issue is that the elements in the queue starts to grow, and when I stop the code, I have to wait for the queue to save the remaining data one by one.
I think I have to use flush queue, when pressing stop buttom. I tried it but wasn't successfull. could please help me with that too?
also, I have to increase the depth of buffer on host side, the predefined size was 3 times the total block size, and I changed it 10 times because, I was getting buffer overflow error. Is this okay or there is still something worng with code that cause the overflow to occur.
I attached the modified code to the post.