Nicolas Quijano wrote:

> Also, I see you replaced delete[], by delete in the sound sample destructor.
> Shouldn't we just be setting to NULL, and not delete, leaving it to the 
> original creator of the data, since the original allocation is done 
> somewhere else ?
> e.g _data never allocates, just points to data allocated somewhere else.
> The allocator should be the one deallocating, to make sure we don't have 
> dangling pointers.

It's not as easy as you might think;

Many sounds are created using SGSoundSample(<path>, <filename>) and the 
calling code has no clue about _data.

Also, the SoundManager is requested to take this sample into account. 
The caller never knows when the data is actually turned into an OpenAL 
buffer, meaning it could destroy the data before it is handed over to 
OpenAL if you're not careful.

And finally if the data is kept resident than all sound samples are 
resident in memory twice; once in the _data pointer and once in an 
OpenAL buffer. I like to keep that under control in case AI models also 
start producing sound effect.

All in all it's best to leave it to the SoundManager when to free up the 
data.

Erik

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to