Memory leaks in `umsoundplay()` if called too frequently
How to reproduce:
- Run the tetris example
- Hit a rotation (Z, X, C) or drop (space) key several times very quickly
- Close the program window
- See memory leak warnings
Looks like the problem is unnecessary increment: https://github.com/marekmaskarinec/tophat/blob/main/src/bindings.c#L352
I can see why it was put there, it creates issue of memory leaks but it solves the problem of the object getting freed after being discarded. The way to solve this is probably to allocate the handle instead
@skejeton Notice that this leak never happens if the function is called not too often (so that the sound plays to the end and stops normally?)
Yeah it seems to only happen when the sound didn't finish playing entirely
Notice that this leak never happens if the function is called not too often (so that the sound plays to the end and stops normally?)
This is weird, since adding more playbacks shouldn't affect other playbacks.
Looks like the problem is unnecessary increment: https://github.com/marekmaskarinec/tophat/blob/main/src/bindings.c#L352
This is since the thg.playbacks own a reference. It is decremented when the sound stop playing.
This is weird, since adding more playbacks shouldn't affect other playbacks.
But what if all those playbacks refer to the same audio.Sound?
Playbacks don't refer to audio.Sounds at all.
@marekmaskarinec prev = pbi; is missing from the for loop in _th_audio_data_callback(), so it cannot process lists longer than one sound.
@marekmaskarinec prev = pbi; is missing from the for loop in _th_audio_data_callback(), so it cannot process lists longer than one sound.
This might have been the problem. I fixed it and now I can't reproduce neither the memory leak warnings or the sound cutting of too early issue.
Great!