AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 288 forks source link

Fix audio source releasing when stream is empty #661

Closed lukaspirkl closed 6 years ago

lukaspirkl commented 6 years ago

In case that audio stream contains no data (even first call to IAudioStreamProvider.ReadStream(...) returns false) the NativeAudioSource is stuck in streamWorkerQueue. Because of this, the source is never freed up and also the ReadStream method of IAudioStreamProvider is constantly called.

As a fix, I am setting strStopReq to EndOfStream because this is what actually happens. Then I also need to modify condition which is stopping the streaming. I tested this on sample project and also with my custom stream provider. It should handle correctly streams of any lengths (empty, shorter than initial buffers, shorter than one buffer, infinitely long).

ilexp commented 6 years ago

Approved and merged. Thanks! 🙂