-
Hello. I have a game engine uses miniaudio as sound engine. I have a sound class with ma_sound object, but I don't know how to cache an existing sound, so that when the sound is re-loaded, it does not reload the file again, but loads it from an existing object. Since this is C++, I tried std::map<std::string, ma_sound> sounds;, where string is the filename, however this was throwing exceptions. Is there some way to cache sounds using mimiaudio? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
miniaudio supports reference counting. You can just initialize a However, your map is wrong. You need to remember this trip hazard from the documentation:
So any time you add a new entry to your |
Beta Was this translation helpful? Give feedback.
miniaudio supports reference counting. You can just initialize a
ma_sound
object and hold onto it for as long as you need. That way the reference count will never hit 0 and will never be unloaded.However, your map is wrong. You need to remember this trip hazard from the documentation: