a8d7419732
The LGP issue is caused by the device drivers returning two or more packets in a single segment of audio data. This fixes it by detecting that and decoding subsequent packets. When the FFmpeg audio decoder returns, it returns how many bytes of data was decoded. To have it decode multiple packets in a single segment, just subtract the return value from the expected size, and if that size is still larger than zero, then there are more packets in the segment to decode. Otherwise, stop.