Remove CSoundGroupMgr, since it is unnecessary and broken and leaks memory
This was SVN commit r7442.
This commit is contained in:
parent
27556f4b21
commit
c02771fef2
@ -64,7 +64,6 @@ that of Atlas depending on commandline parameters.
|
||||
#include "simulation/Scheduler.h"
|
||||
#include "simulation2/Simulation2.h"
|
||||
#include "sound/CMusicPlayer.h"
|
||||
#include "sound/SoundGroupMgr.h"
|
||||
#include "gui/GUIManager.h"
|
||||
|
||||
#define LOG_CATEGORY L"main"
|
||||
@ -304,7 +303,6 @@ static void Frame()
|
||||
float down[3] = { -up[0], -up[1], -up[2] };
|
||||
if(snd_update(pos, dir, down) < 0)
|
||||
debug_printf(L"snd_update failed\n");
|
||||
g_soundGroupMgr->UpdateSoundGroups(TimeSinceLastFrame);
|
||||
PROFILE_END( "sound update" );
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "LOSManager.h"
|
||||
#include "graphics/Terrain.h"
|
||||
#include "Stance.h"
|
||||
#include "sound/SoundGroupMgr.h"
|
||||
//#include "sound/SoundGroupMgr.h"
|
||||
|
||||
#include "ps/Game.h"
|
||||
#include "ps/World.h"
|
||||
@ -511,7 +511,7 @@ bool CEntity::ProcessContactActionNoPathing( CEntityOrder* current, int timestep
|
||||
if( ( m_fsm_cyclepos <= action->m_Speed ) && ( nextpos > action->m_Speed ) )
|
||||
{
|
||||
const size_t soundGroupIndex = m_base->m_SoundGroupTable[animation];
|
||||
g_soundGroupMgr->PlayNext(soundGroupIndex, m_position);
|
||||
// g_soundGroupMgr->PlayNext(soundGroupIndex, m_position);
|
||||
|
||||
if(!DispatchEvent( &contactEvent ))
|
||||
{
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "ps/Player.h"
|
||||
#include "scripting/ScriptableComplex.inl"
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
#include "sound/SoundGroupMgr.h"
|
||||
//#include "sound/SoundGroupMgr.h"
|
||||
|
||||
#include "ps/CLogger.h"
|
||||
#define LOG_CATEGORY L"entity"
|
||||
@ -332,6 +332,7 @@ bool CEntityTemplate::LoadXml( const VfsPath& pathname )
|
||||
}
|
||||
else if( ChildName == el_SoundGroups )
|
||||
{
|
||||
#if 0
|
||||
// Read every child element's value into m_SoundGroupTable with its tag as the key
|
||||
XMBElementList children = Child.GetChildNodes();
|
||||
for(int j = 0; j < children.Count; ++j)
|
||||
@ -342,6 +343,7 @@ bool CEntityTemplate::LoadXml( const VfsPath& pathname )
|
||||
const size_t soundGroupIndex = g_soundGroupMgr->AddGroup(soundGroupFilename);
|
||||
m_SoundGroupTable[name] = soundGroupIndex;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
Example usage: (SEE SOUNDGROUPMGR.H)
|
||||
Example usage:
|
||||
|
||||
|
||||
Example SoundGroup.xml
|
||||
|
@ -1,161 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 0 A.D. is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* =========================================================================
|
||||
* File : SoundGroupMgr.h
|
||||
* Project : 0 A.D.
|
||||
* Description : Manages and updates SoundGroups
|
||||
* =========================================================================
|
||||
*/
|
||||
|
||||
// Example usage:
|
||||
|
||||
// size_t index;
|
||||
// CSoundGroupMgr *sgm = CSoundGroupMgr::GetInstance();
|
||||
// index = sgm->AddGroup("SoundGroup.xml");
|
||||
|
||||
// sgm->UpdateSoundGroups(TimeSinceLastFrame); // call in Frame()
|
||||
|
||||
// sgm->PlayNext(index); // wash-rinse-repeat
|
||||
|
||||
|
||||
// sgm->RemoveGroup(index); // Remove the group if you like
|
||||
|
||||
// sgm->DeleteInstance(); // Delete instance in shutdown
|
||||
|
||||
|
||||
#include "precompiled.h"
|
||||
#include "SoundGroupMgr.h"
|
||||
|
||||
typedef std::vector<CSoundGroup*> SoundGroups;
|
||||
typedef SoundGroups::iterator SoundGroupIt;
|
||||
|
||||
|
||||
CSoundGroupMgr *CSoundGroupMgr::m_pInstance = 0;
|
||||
|
||||
CSoundGroupMgr::CSoundGroupMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSoundGroupMgr *CSoundGroupMgr::GetInstance()
|
||||
{
|
||||
if(!m_pInstance)
|
||||
m_pInstance = new CSoundGroupMgr();
|
||||
|
||||
return m_pInstance;
|
||||
|
||||
}
|
||||
|
||||
void CSoundGroupMgr::DeleteInstance()
|
||||
{
|
||||
if(m_pInstance)
|
||||
{
|
||||
SoundGroupIt vIter = m_pInstance->m_Groups.begin();
|
||||
while(vIter != m_pInstance->m_Groups.end())
|
||||
vIter = m_pInstance->RemoveGroup(vIter);
|
||||
|
||||
delete m_pInstance;
|
||||
}
|
||||
m_pInstance = 0;
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// AddGroup()
|
||||
// in: const char *XMLFile - the filename of the SoundGroup.xml to open
|
||||
// out: size_t index into m_Groups
|
||||
// Loads the given XML file and returns an index for later use
|
||||
///////////////////////////////////////////
|
||||
size_t CSoundGroupMgr::AddGroup(const VfsPath& XMLFile)
|
||||
{
|
||||
CSoundGroup* newGroup = new CSoundGroup(XMLFile);
|
||||
m_Groups.push_back(newGroup);
|
||||
|
||||
return m_Groups.size() - 1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// RemoveGroup()
|
||||
// in: size_t index into m_Groups
|
||||
// out: SoundGroupIt - one past the index removed (sometimes useful)
|
||||
// Removes and Releases a given soundgroup
|
||||
///////////////////////////////////////////
|
||||
SoundGroupIt CSoundGroupMgr::RemoveGroup(size_t index)
|
||||
{
|
||||
SoundGroupIt vIter = m_Groups.begin();
|
||||
if(index >= m_Groups.size())
|
||||
return vIter;
|
||||
|
||||
CSoundGroup *temp = (*vIter);
|
||||
(*vIter)->ReleaseGroup();
|
||||
vIter = m_Groups.erase(vIter+index);
|
||||
|
||||
delete temp;
|
||||
|
||||
return vIter;
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// RemoveGroup()
|
||||
// in: SoundGroupIt - item to remove
|
||||
// out: SoundGroupIt - one past the index removed (sometimes useful)
|
||||
// Removes and Releases a given soundgroup
|
||||
///////////////////////////////////////////
|
||||
SoundGroupIt CSoundGroupMgr::RemoveGroup(SoundGroupIt iter)
|
||||
{
|
||||
|
||||
(*iter)->ReleaseGroup();
|
||||
|
||||
CSoundGroup *temp = (*iter);
|
||||
|
||||
iter = m_Groups.erase(iter);
|
||||
|
||||
delete temp;
|
||||
|
||||
return iter;
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// UpdateSoundGroups()
|
||||
// updates all soundgroups, call in Frame()
|
||||
///////////////////////////////////////////
|
||||
void CSoundGroupMgr::UpdateSoundGroups(float TimeSinceLastFrame)
|
||||
{
|
||||
SoundGroupIt vIter = m_Groups.begin();
|
||||
while(vIter != m_Groups.end())
|
||||
{
|
||||
(*vIter)->Update(TimeSinceLastFrame);
|
||||
vIter++;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// PlayNext()
|
||||
// in: size_t index - index into m_Groups
|
||||
// Plays the next queued sound in an indexed group
|
||||
///////////////////////////////////////////
|
||||
void CSoundGroupMgr::PlayNext(size_t index, const CVector3D& position)
|
||||
{
|
||||
if(index < m_Groups.size())
|
||||
m_Groups[index]->PlayNext(position);
|
||||
else
|
||||
debug_printf(L"SND: PlayNext(%lu) invalid, %lu groups defined\n", (unsigned long)index, (unsigned long)m_Groups.size());
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 0 A.D. is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** Manages and updates SoundGroups. */
|
||||
|
||||
#ifndef INCLUDED_SOUNDGROUPMGR
|
||||
#define INCLUDED_SOUNDGROUPMGR
|
||||
|
||||
#include "SoundGroup.h"
|
||||
#include <vector>
|
||||
|
||||
class CSoundGroupMgr
|
||||
{
|
||||
public:
|
||||
std::vector <CSoundGroup *> m_Groups; // a collection of sound groups
|
||||
static CSoundGroupMgr *m_pInstance; // our static instance of the manager
|
||||
static CSoundGroupMgr *GetInstance();
|
||||
static void DeleteInstance();
|
||||
|
||||
///////////////////////////////////////////
|
||||
// UpdateSoundGroups()
|
||||
// updates all soundgroups, call in Frame()
|
||||
///////////////////////////////////////////
|
||||
void UpdateSoundGroups(float TimeSinceLastFrame);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// PlayNext()
|
||||
// in: size_t index - index into m_Groups
|
||||
// Plays the next queued sound in an indexed group
|
||||
///////////////////////////////////////////
|
||||
void PlayNext(size_t index, const CVector3D& position);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// AddGroup()
|
||||
// in: const char *XMLFile - the filename of the SoundGroup.xml to open
|
||||
// out: size_t index into m_Groups
|
||||
// Loads the given XML file and returns an index for later use
|
||||
///////////////////////////////////////////
|
||||
size_t AddGroup(const VfsPath& XMLFile);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// RemoveGroup()
|
||||
// in: size_t index into m_Groups
|
||||
// out: std::vector<CSoundGroup *>::iterator - one past the index removed (sometimes useful)
|
||||
// Removes and Releases a given soundgroup
|
||||
///////////////////////////////////////////
|
||||
std::vector<CSoundGroup *>::iterator RemoveGroup(size_t index);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// RemoveGroup()
|
||||
// in: std::vector<CSoundGroup *>::iterator - item to remove
|
||||
// out: std::vector<CSoundGroup *>::iterator - one past the index removed (sometimes useful)
|
||||
// Removes and Releases a given soundgroup
|
||||
///////////////////////////////////////////
|
||||
std::vector<CSoundGroup *>::iterator RemoveGroup(std::vector<CSoundGroup *>::iterator iter);
|
||||
|
||||
|
||||
private:
|
||||
CSoundGroupMgr();
|
||||
CSoundGroupMgr(const CSoundGroupMgr &ref);
|
||||
CSoundGroupMgr &operator=(const CSoundGroupMgr &ref);
|
||||
|
||||
};
|
||||
|
||||
#define g_soundGroupMgr CSoundGroupMgr::GetInstance()
|
||||
|
||||
#endif // INCLUDED_SOUNDGROUPMGR
|
Loading…
Reference in New Issue
Block a user