* Constructor
* @param path Path name to sound
* @param file File name of sound
- should usually be true unless you want to manipulate the data
- later.)
+ Buffer data is freed by the sample group
*/
SGSoundSample( const char *path, const char *file );
/**
* Constructor.
* @param data Pointer to a memory buffer containing this audio sample data
- buffer data is freed by this audio sample manager.
+ The application may free the data by calling free_data(), otherwise it
+ will be resident untill the class is destroyed.
* @param len Byte length of array
* @param freq Frequency of the provided data (bytes per second)
* @param format OpenAL format id of the data
ALsizei size = sample->get_size();
ALsizei freq = sample->get_frequency();
alBufferData( buffer, format, data, size, freq );
- sample->free_data();
+
+ // If this sample was read from a file we have all the information
+ // needed to read it again. For data buffers provided by the
+ // program we don't; so don't delete it's data.
+ if (sample->is_file()) sample->free_data();
if ( !testForALError("buffer add data") ) {
sample->set_buffer(buffer);