Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Clarifying use of drop()

cliffski
Registered User
Quote
2012-07-25 22:44:52

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?


niko
Moderator
Quote
2012-07-26 06:10:45

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.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact