From: ehofman Date: Mon, 5 Oct 2009 08:56:40 +0000 (+0000) Subject: Rename update() to update_late() for the sound manager to be able to initialize it... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=579d384c04d441b9b49a7e55fbb0591e0a590ac6;p=simgear.git Rename update() to update_late() for the sound manager to be able to initialize it before any other class that uses it. This will allow the SoundManager to be safely accessed in the constructor of those classes. --- diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index ffa23e68..c01b0cbb 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -62,6 +62,7 @@ SGSampleGroup::SGSampleGroup ( SGSoundMgr *smgr, const string &refname ) : { _smgr->add(this, refname); _active = _smgr->is_working(); + _refname = refname; _samples.clear(); } @@ -434,7 +435,7 @@ bool SGSampleGroup::testForALError(string s) { ALenum error = alGetError(); if (error != AL_NO_ERROR) { - SG_LOG( SG_GENERAL, SG_ALERT, "AL Error (sample group): " + SG_LOG( SG_GENERAL, SG_ALERT, "AL Error (" << _refname << "): " << alGetString(error) << " at " << s); return true; } diff --git a/simgear/sound/sample_group.hxx b/simgear/sound/sample_group.hxx index 3e277014..d9c27922 100644 --- a/simgear/sound/sample_group.hxx +++ b/simgear/sound/sample_group.hxx @@ -174,6 +174,8 @@ private: bool testForALError(string s); bool testForError(void *p, string s); + string _refname; + void update_sample_config( SGSoundSample *sound ); }; diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index 543960e0..ac2d8352 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -194,9 +194,15 @@ void SGSoundMgr::unbind () _sources_in_use.clear(); } +void SGSoundMgr::update( double dt ) +{ + // nothing to do in the regular update,e verything is done on the following + // function +} + // run the audio scheduler -void SGSoundMgr::update( double dt ) { +void SGSoundMgr::update_late( double dt ) { if (_working) { sample_group_map_iterator sample_grp_current = _sample_groups.begin(); sample_group_map_iterator sample_grp_end = _sample_groups.end(); @@ -334,7 +340,7 @@ void SGSoundMgr::release_source( unsigned int source ) if ( result == AL_PLAYING ) { alSourceStop( source ); } - testForALError("free_source"); + testForALError("release source"); _free_sources.push_back(source); _sources_in_use.erase(_sources_in_use.begin()+i, diff --git a/simgear/sound/soundmgr_openal.hxx b/simgear/sound/soundmgr_openal.hxx index 96109057..2c40eeca 100644 --- a/simgear/sound/soundmgr_openal.hxx +++ b/simgear/sound/soundmgr_openal.hxx @@ -80,6 +80,7 @@ public: void bind(); void unbind(); void update(double dt); + void update_late(double dt); void suspend(); void resume(); @@ -157,8 +158,8 @@ public: */ void release_source( unsigned int source ); - bool load(string &samplepath, void **data, int *format, unsigned int*size, - int *freq ); + static bool load(string &samplepath, void **data, int *format, + unsigned int*size, int *freq ); private: