Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I create a lot of sounds, in some cases they are fire-and forget, in other cases they are looping sounds I want to reposition or stop later. My code does this: in cases of looping sounds, I set track = true when calling play. (also loop is true, obviously). In other cases, track is false. In ALL cases, start paused is true, so I can adjust volume. I am assuming that the reference count of all those cases is still one? or two if tracked? Currently, my code calls drop() on all of them, and then later, witht he looped ones, at a time of my choosing I call stop(). is this correct? There is NO way to get the actual refecount value from a sound, and although drop() returns a bool, the docs don't say what it means (in all cases it seems to return false). Am I doing it right or wrong? |
||||
|
Basically, you are doing it right, with the exception that if you plan to call stop() to a sound somewhere, you would want to ensure that the pointer is still valid, by calling drop() only after you called stop(), not before, as it seems you are doing. It's just like COM pointers, but instead of AddRef() and Release(), you are using drop() and grab(). Between drop() and grab(), your pointer is ensured to be valid. If you drop() a pointer, and it is not used anywhere else (it gets deleted then), and then you call something on this pointer, your program could crash. |
|