2012-04-10 13:24:35 +00:00
|
|
|
/**
|
|
|
|
* \file group_controller_root.cpp
|
|
|
|
* \brief CGroupControllerRoot
|
|
|
|
* \date 2012-04-10 09:44GMT
|
|
|
|
* \author Jan Boon (Kaetemi)
|
|
|
|
* CGroupControllerRoot
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 by authors
|
|
|
|
*
|
|
|
|
* This file is part of RYZOM CORE.
|
|
|
|
* RYZOM CORE is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RYZOM CORE 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
|
|
|
|
* Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with RYZOM CORE. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdsound.h"
|
|
|
|
#include <nel/sound/group_controller_root.h>
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
|
|
|
|
// NeL includes
|
|
|
|
// #include <nel/misc/debug.h>
|
|
|
|
#include <nel/misc/algo.h>
|
|
|
|
|
|
|
|
// Project includes
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
// using namespace NLMISC;
|
|
|
|
|
2012-04-13 09:54:20 +00:00
|
|
|
#define NLSOUND_GROUP_CONTROLLER_ROOT_PATH "sound"
|
|
|
|
|
2012-04-10 13:24:35 +00:00
|
|
|
namespace NLSOUND {
|
|
|
|
|
|
|
|
CGroupControllerRoot::CGroupControllerRoot() : CGroupController(NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CGroupControllerRoot::~CGroupControllerRoot()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-10 14:32:04 +00:00
|
|
|
std::string CGroupControllerRoot::getPath()
|
|
|
|
{
|
2012-04-13 09:54:20 +00:00
|
|
|
// The root node is always called sound
|
|
|
|
return NLSOUND_GROUP_CONTROLLER_ROOT_PATH;
|
2012-04-10 14:32:04 +00:00
|
|
|
}
|
|
|
|
|
2012-04-10 13:24:35 +00:00
|
|
|
void CGroupControllerRoot::calculateFinalGain()
|
|
|
|
{
|
|
|
|
m_FinalGain = calculateTotalGain();
|
|
|
|
}
|
|
|
|
|
2012-04-10 14:32:04 +00:00
|
|
|
void CGroupControllerRoot::increaseSources()
|
2012-04-10 13:24:35 +00:00
|
|
|
{
|
|
|
|
++m_NbSourcesInclChild;
|
|
|
|
|
|
|
|
// Update source gain when this controller was inactive before.
|
|
|
|
if (m_NbSourcesInclChild == 1)
|
|
|
|
updateSourceGain();
|
|
|
|
}
|
|
|
|
|
2012-04-10 14:32:04 +00:00
|
|
|
void CGroupControllerRoot::decreaseSources()
|
2012-04-10 13:24:35 +00:00
|
|
|
{
|
|
|
|
--m_NbSourcesInclChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGroupController *CGroupControllerRoot::getGroupController(const std::string &path)
|
|
|
|
{
|
|
|
|
std::vector<std::string> pathNodes;
|
2012-04-13 09:54:20 +00:00
|
|
|
NLMISC::splitString(NLMISC::toLower(path), ":", pathNodes);
|
2012-04-10 13:24:35 +00:00
|
|
|
CGroupController *active = this;
|
2012-04-13 09:54:20 +00:00
|
|
|
if (pathNodes[0] != NLSOUND_GROUP_CONTROLLER_ROOT_PATH)
|
|
|
|
{
|
|
|
|
nlerror("Root node for group controller must always be 'sound', invalid group '%s' requested", path.c_str());
|
|
|
|
}
|
|
|
|
for (std::vector<std::string>::iterator it(pathNodes.begin() + 1), end(pathNodes.end()); it != end; ++it)
|
2012-04-10 13:24:35 +00:00
|
|
|
{
|
|
|
|
if (!(*it).empty())
|
|
|
|
{
|
|
|
|
std::map<std::string, CGroupController *>::iterator found = active->m_Children.find(*it);
|
|
|
|
if (found == active->m_Children.end())
|
|
|
|
{
|
|
|
|
active = new CGroupController(active);
|
|
|
|
active->m_Parent->m_Children[*it] = active;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
active = (*found).second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace NLSOUND */
|
|
|
|
|
|
|
|
/* end of file */
|