snowcone-ltd / libmatoya

Cross-platform application development.
MIT License
578 stars 50 forks source link

Fix android audio flushing #104

Closed Kodikuu closed 1 year ago

Kodikuu commented 1 year ago

In its flushing + playing state, the audio module could get stuck with less data than the callback to play it ever requests, permanently stopping audio playback until the MTY_Audio session is reset or otherwise ended.

I added some functionality to track the smallest request for audio frames, and discard the data left in the buffer if we're flushing, but have less data than the smallest request we've seen.

16/01/23; What this PR actually does;

Tracks the smallest size Android ever requests from the buffer If in the flushing state, and the buffer is smaller than the smallest size, clear whatever data remains to avoid locking up the audio