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.

audio data recv buffer design discussion



I am writing a audio player program, which audio data recv from the network. So my program needs to do two tasks, one is to recv audio data, the other is to play audio data. I've try 3 design mode. Listing as following:

1. The simplest one, recv() and play() in the same thread.  This model has some problem. That's when the sender showdown, there is no data arrive, program will block on recv(). So no data write to CODEC DA, it plays the last data and occur noise.

2. Using select to do a timeout check. If there is no data recv, write the mute data to CODEC DA.

3. Using two threads.  One thread is to recv data and write it to an FIFO file, The other thread is to read data from the FIFO file and write it to CODEC DA.  Read FIFO does not block when FIFO is empty, so I can write the mute audio data to CODEC DA.

I use Mode 3. I am wonder what kind of recv buffer do you use ? 

How do you deal with package lost because of UDP transmit?

Audio data is PCM format.

Thank you !

Regards,

yuan