Clownacy / clownaudio

Sound engine that is suitable for video games and other multimedia applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use a memory pool for sound objects?

Clownacy opened this issue · comments

Using free in the middle of the mixer isn't a great idea: there's no guarantee free isn't super slow and won't stall the audio thread. Rather, it might be worth looking into allocating sound objects from a memory pool. The size of this memory pool can be specified by the user during initialisation.

However, there is the issue of multiple threads accessing the pool at once, so mutexes might be needed. But as I went over in #1, mutexes are bad. I'll have to come up with a mutex-less solution.

I just realised I'm a complete idiot: every stage of the pipeline has its own malloc and free, so this would require much more extensive modification than I had in mind.

Not to mention... much of the time, the decoder backends themselves allocate and deallocate too, which cannot be worked around. I suppose I'll never be able to completely eliminate memory allocation. So much for this issue.