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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -174,6 +174,8 @@ private:
|
||||
bool testForALError(string s);
|
||||
bool testForError(void *p, string s);
|
||||
|
||||
string _refname;
|
||||
|
||||
void update_sample_config( SGSoundSample *sound );
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user