From: ehofman Date: Sat, 24 Oct 2009 12:57:11 +0000 (+0000) Subject: Use shared pointers for any reference to SGSoundSample, fix the constructor of SGSoun... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a06a15e769bccda83ac904f524e20f73da10b1a6;p=simgear.git Use shared pointers for any reference to SGSoundSample, fix the constructor of SGSoundSample where data is supplied by the calling program. --- diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index 44dabc1f..f9813fec 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -202,7 +202,7 @@ void SGSampleGroup::update( double dt ) { } // add a sound effect, return true if successful -bool SGSampleGroup::add( SGSoundSample *sound, const string& refname ) { +bool SGSampleGroup::add( SGSharedPtr sound, const string& refname ) { sample_map_iterator sample_it = _samples.find( refname ); if ( sample_it != _samples.end() ) { diff --git a/simgear/sound/sample_group.hxx b/simgear/sound/sample_group.hxx index 7a3dff70..af85e312 100644 --- a/simgear/sound/sample_group.hxx +++ b/simgear/sound/sample_group.hxx @@ -56,8 +56,7 @@ using std::map; using std::string; -typedef SGSharedPtr SGSoundSample_ptr; -typedef map < string, SGSoundSample_ptr > sample_map; +typedef map < string, SGSharedPtr > sample_map; typedef sample_map::iterator sample_map_iterator; typedef sample_map::const_iterator const_sample_map_iterator; @@ -106,7 +105,7 @@ public: * @param refname Name of this audio sample for reference purposes * @return return true if successful */ - bool add( SGSoundSample *sound, const string& refname ); + bool add( SGSharedPtr sound, const string& refname ); /** * Remove an audio sample from this group. @@ -225,7 +224,7 @@ private: SGGeod _position; sample_map _samples; - std::vector _removed_samples; + std::vector< SGSharedPtr > _removed_samples; bool testForALError(string s); bool testForError(void *p, string s); diff --git a/simgear/sound/sample_openal.cxx b/simgear/sound/sample_openal.cxx index 96581b8b..307b2385 100644 --- a/simgear/sound/sample_openal.cxx +++ b/simgear/sound/sample_openal.cxx @@ -150,7 +150,7 @@ SGSoundSample::SGSoundSample( const unsigned char** data, _is_file(false) { SG_LOG( SG_GENERAL, SG_DEBUG, "In memory sounds sample" ); - _data = (unsigned char*)data; *data = NULL; + _data = (unsigned char*)*data; *data = NULL; } // constructor @@ -185,7 +185,7 @@ SGSoundSample::SGSoundSample( void** data, int len, int freq, int format ) : _is_file(false) { SG_LOG( SG_GENERAL, SG_DEBUG, "In memory sounds sample" ); - _data = (unsigned char*)data; *data = NULL; + _data = (unsigned char*)*data; *data = NULL; } diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index 0e52d5c5..37b138c5 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -377,6 +377,8 @@ unsigned int SGSoundMgr::request_source() _free_sources.pop_back(); _sources_in_use.push_back(source); } + else + SG_LOG( SG_GENERAL, SG_INFO, "No more free sources available\n"); return source; } @@ -453,8 +455,9 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample) } } } - else + else { buffer = sample->get_buffer(); +} return buffer; }