From a67688322da8312917d39bf592e570f596583322 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 15 Oct 2009 17:08:45 +0000 Subject: [PATCH] Initialization was done much earlier than expected resulting in some sample groups not being activated (and sample loading using OpenAL/ALUT functions to be scheduled before OpenAL was initilialized). fix alutInit counter remove left over static declaration fro SGSoundMgr::load --- simgear/sound/sample_group.cxx | 1 - simgear/sound/sample_group.hxx | 1 + simgear/sound/soundmgr_openal.cxx | 14 ++++++++++---- simgear/sound/soundmgr_openal.hxx | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index c85e386f..3d1dd084 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -63,7 +63,6 @@ SGSampleGroup::SGSampleGroup ( SGSoundMgr *smgr, const string &refname ) : _orientation(SGQuatd::zeros()) { _smgr->add(this, refname); - _active = _smgr->is_working(); _samples.clear(); } diff --git a/simgear/sound/sample_group.hxx b/simgear/sound/sample_group.hxx index 5bb504a9..70b844c3 100644 --- a/simgear/sound/sample_group.hxx +++ b/simgear/sound/sample_group.hxx @@ -155,6 +155,7 @@ public: inline void tie_to_listener() { _tied_to_listener = true; } + inline void activate() { _active = true; } protected: SGSoundMgr *_smgr; diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index 450b5714..c8bd635c 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -70,7 +70,6 @@ SGSoundMgr::SGSoundMgr() : testForALUTError("alut initialization"); return; } - _alut_init++; } _alut_init++; #endif @@ -152,6 +151,13 @@ void SGSoundMgr::init() { if (_free_sources.size() == 0) { SG_LOG(SG_GENERAL, SG_ALERT, "Unable to grab any OpenAL sources!"); } + + sample_group_map_iterator sample_grp_current = _sample_groups.begin(); + sample_group_map_iterator sample_grp_end = _sample_groups.end(); + for ( ; sample_grp_current != sample_grp_end; ++sample_grp_current ) { + SGSampleGroup *sgrp = sample_grp_current->second; + sgrp->activate(); + } } // suspend the sound manager @@ -471,9 +477,9 @@ void SGSoundMgr::release_buffer(SGSoundSample *sample) bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt, unsigned int *sz, int *frq ) { - ALenum format = (ALenum)*fmt; - ALsizei size = (ALsizei)*sz; - ALsizei freq = (ALsizei)*frq; + ALenum format; + ALsizei size; + ALsizei freq; ALvoid *data; #if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1 diff --git a/simgear/sound/soundmgr_openal.hxx b/simgear/sound/soundmgr_openal.hxx index 4baad69b..e2e2be40 100644 --- a/simgear/sound/soundmgr_openal.hxx +++ b/simgear/sound/soundmgr_openal.hxx @@ -199,7 +199,7 @@ public: */ inline bool has_changed() { return _changed; } - static bool load(string &samplepath, void **data, int *format, + bool load(string &samplepath, void **data, int *format, unsigned int*size, int *freq ); -- 2.39.5