hfujita / pulseaudio-raop2

Experimental RAOP2 (Apple AirPlay2) support for PulseAudio
http://hfujita.github.io/pulseaudio-raop2/
Other
138 stars 19 forks source link

Client should move index (discard data) when "Discarding UDP packet due to EAGAIN" #32

Open karlstav opened 9 years ago

karlstav commented 9 years ago

I have encountered an issue with the client suddenly throwing out a lot of " Discarding UDP packet due to EAGAIN" messages (about 4 pr ms and up to a couple of thousand at the time).

I don't know exactly why this happens but i suspect it happens when there are a lot of traffic on my WiFi or other WiFis on the same channel in the vicinity (2.4GHz). So if my WiFi adapter is in collision avoidance mode (waiting to transmit) the buffer will fill up and therefore the socket throws out the EAGAIN message. I also notice from wireshark dumps that the last packet before the EAGAIN messages is neither transmitted nor reported as discarded.

After a series of these EAGAIN message the audio becomes glitchy and sometimes never recover. I suspect that the client tries to write the same audio packet to the socket over and over while at the same time incrementing the sequence number.

I was able to solve the issue by adding the lines: block->index += block->length; block->length = 0; after the udp packet has been discarded in the send udp audio packet function. But I don't know if that's the best way to solve it.

hfujita commented 9 years ago

@karlstav Thank you for reporting and sorry for the delay -- I made a patch based on your suggestion and pushed it. Hope this works.