soundprovider_factory.cpp

来自「这是一款2d游戏引擎」· C++ 代码 · 共 64 行

CPP
64
字号
/*  $Id: soundprovider_factory.cpp,v 1.10 2003/11/11 10:13:25 grumbel Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library 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
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#include "Sound/precomp.h"

#ifdef _MSC_VER
#pragma warning(disable : 4786)
#endif

#include "API/Sound/SoundProviders/soundprovider_factory.h"
#include "API/Sound/SoundProviders/soundprovider_type.h"
#include "API/Core/System/error.h"
#include "API/Core/System/clanstring.h"

/////////////////////////////////////////////////////////////////////////////
// CL_SoundProviderFactory attributes:

std::map<std::string, CL_SoundProviderType *> CL_SoundProviderFactory::types;

/////////////////////////////////////////////////////////////////////////////
// CL_SoundProviderFactory operations:

CL_SoundProvider *CL_SoundProviderFactory::load(
	const std::string &filename,
	bool streamed,
	const std::string &type,
	CL_InputSourceProvider *input_provider)
{
	if (type != "")
	{
		if (types.find(type) == types.end()) throw CL_Error("Unknown sound provider type " + type);

		CL_SoundProviderType *factory = types[type];
		return factory->load(filename, input_provider, streamed);
	}

	// Determine file extension and use it to lookup type.
	std::string ext = CL_String::get_extension(filename);
	if (ext.empty()) ext = filename;
	ext = CL_String::to_lower(ext);
	if (types.find(ext) == types.end()) throw CL_Error(std::string("Unknown sound provider type ") + ext.c_str());

	CL_SoundProviderType *factory = types[ext];
	return factory->load(filename, input_provider, streamed);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?