AUDIO: Use SeekableSubReadStream instead of reallocating streams #2786
This cleans up audio code that mallocs raw audio data just to discard format headers, instead of just wrapping the stream. This reduces redundant reallocations since a lot of engines/decoders already do this anyways, and makes it easier to add WAV decoders since the extra headers are always discarded now.
One downside of this change is some engines have edge cases freeing sounds that are still being played (eg. closing the game mid-sound), which now crashes. I tried to fix the engines I ran across, but obviously I can't test every engine using raw WAVs, so I'd appreciate extra testing (and engine fixes) for this.
@mgerhardy The base Engine destructor already stops the mixer, but by then it's too late. You could change it to happen before the destruction instead, or just let the mixer free the resources.
Since this is a rare edge case (most audio decoders assume the resources won't be freed while in use), I think it's better to fix any problematic engines than try to cover it up in the common code.