Added comments.
This commit is contained in:
parent
8c3beef69b
commit
64fc2dd968
@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
SFXManager *SFXManager::m_sfx_manager;
|
SFXManager *SFXManager::m_sfx_manager;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
/** Static function to create the singleton sfx manager.
|
/** Static function to create the singleton sfx manager.
|
||||||
*/
|
*/
|
||||||
void SFXManager::create()
|
void SFXManager::create()
|
||||||
@ -83,6 +84,8 @@ SFXManager::SFXManager()
|
|||||||
} // SoundManager
|
} // SoundManager
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Destructor, frees all sound effects.
|
||||||
|
*/
|
||||||
SFXManager::~SFXManager()
|
SFXManager::~SFXManager()
|
||||||
{
|
{
|
||||||
// ---- clear m_all_sfx
|
// ---- clear m_all_sfx
|
||||||
@ -120,7 +123,10 @@ SFXManager::~SFXManager()
|
|||||||
} // ~SFXManager
|
} // ~SFXManager
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
/** Called then sound is globally switched on or off. It either pauses or
|
||||||
|
* resumes all sound effects.
|
||||||
|
* \param on If sound is switched on or off.
|
||||||
|
*/
|
||||||
void SFXManager::soundToggled(const bool on)
|
void SFXManager::soundToggled(const bool on)
|
||||||
{
|
{
|
||||||
// When activating SFX, load all buffers
|
// When activating SFX, load all buffers
|
||||||
@ -148,7 +154,9 @@ void SFXManager::soundToggled(const bool on)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
/** Returns if sfx can be played. This means sfx are enabled and
|
||||||
|
* the manager is correctly initialised.
|
||||||
|
*/
|
||||||
bool SFXManager::sfxAllowed()
|
bool SFXManager::sfxAllowed()
|
||||||
{
|
{
|
||||||
if(!UserConfigParams::m_sfx || !m_initialized)
|
if(!UserConfigParams::m_sfx || !m_initialized)
|
||||||
@ -312,11 +320,6 @@ SFXBase* SFXManager::createSoundSource(SFXBuffer* buffer,
|
|||||||
positional = buffer->isPositional();
|
positional = buffer->isPositional();
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("CREATING %s (%x), positional = %i (race_manager->getNumLocalPlayers() = %i, buffer->isPositional() = %i)\n",
|
|
||||||
// buffer->getFileName().c_str(), (unsigned int)buffer,
|
|
||||||
// positional,
|
|
||||||
// race_manager->getNumLocalPlayers(), buffer->isPositional());
|
|
||||||
|
|
||||||
#if HAVE_OGGVORBIS
|
#if HAVE_OGGVORBIS
|
||||||
//assert( alIsBuffer(buffer->getBufferID()) ); crashes on server
|
//assert( alIsBuffer(buffer->getBufferID()) ); crashes on server
|
||||||
SFXBase* sfx = new SFXOpenAL(buffer, positional, buffer->getGain(), owns_buffer);
|
SFXBase* sfx = new SFXOpenAL(buffer, positional, buffer->getGain(), owns_buffer);
|
||||||
@ -338,7 +341,9 @@ SFXBase* SFXManager::createSoundSource(const std::string &name,
|
|||||||
std::map<std::string, SFXBuffer*>::iterator i = m_all_sfx_types.find(name);
|
std::map<std::string, SFXBuffer*>::iterator i = m_all_sfx_types.find(name);
|
||||||
if ( i == m_all_sfx_types.end() )
|
if ( i == m_all_sfx_types.end() )
|
||||||
{
|
{
|
||||||
Log::error("SFXManager", "SFXManager::createSoundSource could not find the requested sound effect : '%s'\n", name.c_str());
|
Log::error("SFXManager",
|
||||||
|
"SFXManager::createSoundSource could not find the "
|
||||||
|
"requested sound effect : '%s'\n", name.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +371,8 @@ void SFXManager::deleteSFXMapping(const std::string &name)
|
|||||||
|
|
||||||
if (i == m_all_sfx_types.end())
|
if (i == m_all_sfx_types.end())
|
||||||
{
|
{
|
||||||
Log::warn("SFXManager", "SFXManager::deleteSFXMapping : Warning: sfx not found in list.\n");
|
Log::warn("SFXManager",
|
||||||
|
"SFXManager::deleteSFXMapping : Warning: sfx not found in list.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(*i).second->unload();
|
(*i).second->unload();
|
||||||
@ -389,7 +395,8 @@ void SFXManager::deleteSFX(SFXBase *sfx)
|
|||||||
|
|
||||||
if(i==m_all_sfx.end())
|
if(i==m_all_sfx.end())
|
||||||
{
|
{
|
||||||
Log::warn("SFXManager", "SFXManager::deleteSFX : Warning: sfx not found in list.\n");
|
Log::warn("SFXManager",
|
||||||
|
"SFXManager::deleteSFX : Warning: sfx not found in list.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +451,7 @@ bool SFXManager::checkError(const std::string &context)
|
|||||||
|
|
||||||
if(error != AL_NO_ERROR)
|
if(error != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
Log::error("SFXManager", "SFXOpenAL OpenAL error while %s: %s\n",
|
Log::error("SFXManager", "SFXOpenAL OpenAL error while %s: %s",
|
||||||
context.c_str(), SFXManager::getErrorString(error).c_str());
|
context.c_str(), SFXManager::getErrorString(error).c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -503,7 +510,10 @@ const std::string SFXManager::getErrorString(int err)
|
|||||||
} // getErrorString
|
} // getErrorString
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Sets the position and orientation of the listener.
|
||||||
|
* \param position Position of the listener.
|
||||||
|
* \param front Which way the listener is facing.
|
||||||
|
*/
|
||||||
void SFXManager::positionListener(const Vec3 &position, const Vec3 &front)
|
void SFXManager::positionListener(const Vec3 &position, const Vec3 &front)
|
||||||
{
|
{
|
||||||
#if HAVE_OGGVORBIS
|
#if HAVE_OGGVORBIS
|
||||||
|
@ -100,7 +100,10 @@ private:
|
|||||||
/** listener vector (position vector + up vector) */
|
/** listener vector (position vector + up vector) */
|
||||||
float m_listenerVec[6];
|
float m_listenerVec[6];
|
||||||
|
|
||||||
|
/** If the sfx manager has been initialised. */
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
|
|
||||||
|
/** Master gain value, taken from the user config value. */
|
||||||
float m_master_gain;
|
float m_master_gain;
|
||||||
|
|
||||||
void loadSfx();
|
void loadSfx();
|
||||||
@ -154,9 +157,13 @@ public:
|
|||||||
/** Called when sound was muted/unmuted */
|
/** Called when sound was muted/unmuted */
|
||||||
void soundToggled(const bool newValue);
|
void soundToggled(const bool newValue);
|
||||||
|
|
||||||
/** Prints the list of currently loaded sounds to stdout. Useful to debug audio leaks */
|
// ------------------------------------------------------------------------
|
||||||
|
/** Prints the list of currently loaded sounds to stdout. Useful to
|
||||||
|
* debug audio leaks */
|
||||||
void dump();
|
void dump();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Returns the current position of the listener. */
|
||||||
Vec3 getListenerPos() const { return m_position; }
|
Vec3 getListenerPos() const { return m_position; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user