- moved sound system debug into a new debugSound property to lessen the impact of regular debug logging since sound processing is now threaded and therefore logging sound system items may slow down performance

- added texture caching for faction preview textures
This commit is contained in:
Mark Vejvoda 2011-01-26 09:09:59 +00:00
parent 16836c758e
commit d10054f1c3
19 changed files with 141 additions and 175 deletions

View File

@ -44,27 +44,6 @@ Logger::Logger() {
} }
Logger::~Logger() { Logger::~Logger() {
cleanupLoadingTexture();
}
void Logger::cleanupLoadingTexture() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(loadingTexture!=NULL) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//Renderer &renderer= Renderer::getInstance();
//renderer.endTexture(rsGlobal,loadingTexture);
loadingTexture->end();
delete loadingTexture;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//delete loadingTexture;
loadingTexture=NULL;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
Logger & Logger::getInstance() { Logger & Logger::getInstance() {
@ -102,8 +81,6 @@ void Logger::loadLoadingScreen(string filepath) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
cleanupLoadingTexture();
if(filepath=="") if(filepath=="")
{ {
loadingTexture=NULL; loadingTexture=NULL;
@ -111,18 +88,7 @@ void Logger::loadLoadingScreen(string filepath) {
else else
{ {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
loadingTexture = Renderer::findFactionLogoTexture(filepath);
loadingTexture=GraphicsInterface::getInstance().getFactory()->newTexture2D();
//loadingTexture = renderer.newTexture2D(rsGlobal);
loadingTexture->setMipmap(true);
//loadingTexture->getPixmap()->load(filepath);
loadingTexture->load(filepath);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Renderer &renderer= Renderer::getInstance();
renderer.initTexture(rsGlobal,loadingTexture);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
} }
@ -137,7 +103,7 @@ void Logger::renderLoadingScreen() {
renderer.reset2d(); renderer.reset2d();
renderer.clearBuffers(); renderer.clearBuffers();
if(loadingTexture==NULL){ if(loadingTexture == NULL) {
renderer.renderBackground(CoreData::getInstance().getBackgroundTexture()); renderer.renderBackground(CoreData::getInstance().getBackgroundTexture());
} }
else{ else{

View File

@ -50,8 +50,6 @@ private:
Logger(); Logger();
~Logger(); ~Logger();
void cleanupLoadingTexture();
public: public:
static Logger & getInstance(); static Logger & getInstance();

View File

@ -176,6 +176,18 @@ int Game::ErrorDisplayMessage(const char *msg, bool exitApp) {
return 0; return 0;
} }
Texture2D * Game::findFactionLogoTexture(const GameSettings *settings, Logger *logger,string factionLogoFilter, bool useTechDefaultIfFilterNotFound) {
Texture2D *result = NULL;
string logoFilename = Game::findFactionLogoFile(settings, logger,factionLogoFilter);
if(logoFilename == "" && factionLogoFilter != "" && useTechDefaultIfFilterNotFound == true) {
logoFilename = Game::findFactionLogoFile(settings, logger);
}
result = Renderer::findFactionLogoTexture(logoFilename);
return result;
}
string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,string factionLogoFilter) { string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,string factionLogoFilter) {
string result = ""; string result = "";
if(settings == NULL) { if(settings == NULL) {

View File

@ -167,6 +167,7 @@ public:
void endPerformanceTimer(); void endPerformanceTimer();
Vec2i getPerformanceTimerResults(); Vec2i getPerformanceTimerResults();
static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger,string factionLogoFilter="loading_screen.*", bool useTechDefaultIfFilterNotFound=true);
static string findFactionLogoFile(const GameSettings *settings, Logger *logger, string factionLogoFilter="loading_screen.*"); static string findFactionLogoFile(const GameSettings *settings, Logger *logger, string factionLogoFilter="loading_screen.*");
bool getGameOver() { return gameOver; } bool getGameOver() { return gameOver; }

View File

@ -114,6 +114,7 @@ public:
static const char *RANDOMFACTION_SLOTNAME; static const char *RANDOMFACTION_SLOTNAME;
static const char *playerTextureCacheLookupKey; static const char *playerTextureCacheLookupKey;
static const char *factionPreviewTextureCacheLookupKey;
static const char *pathCacheLookupKey; static const char *pathCacheLookupKey;
static const char *path_data_CacheLookupKey; static const char *path_data_CacheLookupKey;
static const char *path_ini_CacheLookupKey; static const char *path_ini_CacheLookupKey;

View File

@ -50,7 +50,8 @@ const char *GameConstants::folder_path_screenshots = "screens/";
const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*"; const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*";
const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*"; const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache"; const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
const char *GameConstants::factionPreviewTextureCacheLookupKey = "factionPreviewTextureCache";
const char *GameConstants::application_name = "MegaGlest"; const char *GameConstants::application_name = "MegaGlest";
const char *GameConstants::pathCacheLookupKey = "pathCache_"; const char *GameConstants::pathCacheLookupKey = "pathCache_";

View File

@ -416,6 +416,9 @@ void Renderer::reset3dMenu() {
// ==================== end ==================== // ==================== end ====================
void Renderer::end() { void Renderer::end() {
std::map<string,Texture2D *> &crcFactionPreviewTextureCache = CacheManager::getCachedItem< std::map<string,Texture2D *> >(GameConstants::factionPreviewTextureCacheLookupKey);
crcFactionPreviewTextureCache.clear();
//delete resources //delete resources
modelManager[rsGlobal]->end(); modelManager[rsGlobal]->end();
textureManager[rsGlobal]->end(); textureManager[rsGlobal]->end();
@ -4798,4 +4801,32 @@ uint64 Renderer::getCurrentPixelByteCount(ResourceScope rs) const {
return result; return result;
} }
Texture2D * Renderer::findFactionLogoTexture(string logoFilename) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
Texture2D *result = NULL;
if(logoFilename != "") {
// Cache faction preview textures
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
std::map<string,Texture2D *> &crcFactionPreviewTextureCache = CacheManager::getCachedItem< std::map<string,Texture2D *> >(GameConstants::factionPreviewTextureCacheLookupKey);
if(crcFactionPreviewTextureCache.find(logoFilename) != crcFactionPreviewTextureCache.end()) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
result = crcFactionPreviewTextureCache[logoFilename];
}
else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
Renderer &renderer= Renderer::getInstance();
result = renderer.newTexture2D(rsGlobal);
result->setMipmap(true);
result->load(logoFilename);
renderer.initTexture(rsGlobal,result);
crcFactionPreviewTextureCache[logoFilename] = result;
}
}
return result;
}
}}//end namespace }}//end namespace

View File

@ -422,6 +422,8 @@ public:
void renderProgressBar(int size, int x, int y, Font2D *font,int customWidth=-1, string prefixLabel=""); void renderProgressBar(int size, int x, int y, Font2D *font,int customWidth=-1, string prefixLabel="");
static Texture2D * findFactionLogoTexture(string logoFilename);
private: private:
//private misc //private misc
float computeSunAngle(float time); float computeSunAngle(float time);

View File

@ -917,6 +917,7 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled = config.getBool("DebugUnitCommands","false"); SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled = config.getBool("DebugUnitCommands","false");
SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled = config.getBool("DebugPathFinder","false"); SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled = config.getBool("DebugPathFinder","false");
SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled = config.getBool("DebugLUA","false"); SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled = config.getBool("DebugLUA","false");
SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled = config.getBool("DebugSound","false");
SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true"); SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true");
string debugLogFile = config.getString("DebugLogFile",""); string debugLogFile = config.getString("DebugLogFile","");
@ -971,6 +972,14 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
debugLUALogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugLUALogFile; debugLUALogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugLUALogFile;
} }
string debugSoundLogFile = config.getString("DebugLogFileSound","");
if(debugSoundLogFile == "") {
debugSoundLogFile = debugLogFile;
}
else {
debugSoundLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugSoundLogFile;
}
string debugErrorLogFile = config.getString("DebugLogFileError",""); string debugErrorLogFile = config.getString("DebugLogFileError","");
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).debugLogFileName = debugLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugSystem).debugLogFileName = debugLogFile;
@ -980,10 +989,11 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).debugLogFileName = debugUnitCommandsLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).debugLogFileName = debugUnitCommandsLogFile;
SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).debugLogFileName = debugPathFinderLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).debugLogFileName = debugPathFinderLogFile;
SystemFlags::getSystemSettingType(SystemFlags::debugLUA).debugLogFileName = debugLUALogFile; SystemFlags::getSystemSettingType(SystemFlags::debugLUA).debugLogFileName = debugLUALogFile;
SystemFlags::getSystemSettingType(SystemFlags::debugSound).debugLogFileName = debugSoundLogFile;
SystemFlags::getSystemSettingType(SystemFlags::debugError).debugLogFileName = debugErrorLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugError).debugLogFileName = debugErrorLogFile;
if(haveSpecialOutputCommandLineOption == false) { if(haveSpecialOutputCommandLineOption == false) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Startup settings are: debugSystem [%d], debugNetwork [%d], debugPerformance [%d], debugWorldSynch [%d], debugUnitCommands[%d], debugPathFinder[%d], debugLUA [%d], debugError [%d]\n", if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Startup settings are: debugSystem [%d], debugNetwork [%d], debugPerformance [%d], debugWorldSynch [%d], debugUnitCommands[%d], debugPathFinder[%d], debugLUA [%d], debugSound [%d], debugError [%d]\n",
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled,
SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled,
SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled,
@ -991,6 +1001,7 @@ void setupLogging(Config &config, bool haveSpecialOutputCommandLineOption) {
SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled,
SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled,
SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled,
SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled,
SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled); SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled);
} }
} }

View File

@ -420,8 +420,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
} }
MenuStateConnectedGame::~MenuStateConnectedGame() { MenuStateConnectedGame::~MenuStateConnectedGame() {
cleanupFactionTexture();
if(ftpClientThread != NULL) { if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL); ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) { if(ftpClientThread->shutdownAndWait() == true) {
@ -1662,49 +1660,18 @@ void MenuStateConnectedGame::loadFactionTexture(string filepath) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
cleanupFactionTexture();
if(enableFactionTexturePreview == true) { if(enableFactionTexturePreview == true) {
if(filepath == "") { if(filepath == "") {
factionTexture=NULL; factionTexture=NULL;
} }
else { else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
factionTexture = Renderer::findFactionLogoTexture(filepath);
factionTexture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
//loadingTexture = renderer.newTexture2D(rsGlobal);
factionTexture->setMipmap(true);
//loadingTexture->getPixmap()->load(filepath);
factionTexture->load(filepath);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Renderer &renderer= Renderer::getInstance();
renderer.initTexture(rsGlobal,factionTexture);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
} }
} }
void MenuStateConnectedGame::cleanupFactionTexture() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(factionTexture!=NULL) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
factionTexture->end();
delete factionTexture;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//delete loadingTexture;
factionTexture=NULL;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview) { bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview) {
struct MapFileHeader{ struct MapFileHeader{

View File

@ -180,7 +180,6 @@ private:
string getHumanPlayerName(); string getHumanPlayerName();
void setActiveInputLabel(GraphicLabel *newLable); void setActiveInputLabel(GraphicLabel *newLable);
void cleanupFactionTexture();
void loadFactionTexture(string filepath); void loadFactionTexture(string filepath);
bool loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview); bool loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview);
void showMessageBox(const string &text, const string &header, bool toggle); void showMessageBox(const string &text, const string &header, bool toggle);

View File

@ -547,7 +547,6 @@ void MenuStateCustomGame::cleanup() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
cleanupFactionTexture();
cleanupMapPreviewTexture(); cleanupMapPreviewTexture();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -2854,49 +2853,18 @@ void MenuStateCustomGame::loadFactionTexture(string filepath) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
cleanupFactionTexture();
if(enableFactionTexturePreview == true) { if(enableFactionTexturePreview == true) {
if(filepath == "") { if(filepath == "") {
factionTexture=NULL; factionTexture = NULL;
} }
else { else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
factionTexture = Renderer::findFactionLogoTexture(filepath);
factionTexture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
//loadingTexture = renderer.newTexture2D(rsGlobal);
factionTexture->setMipmap(true);
//loadingTexture->getPixmap()->load(filepath);
factionTexture->load(filepath);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Renderer &renderer= Renderer::getInstance();
renderer.initTexture(rsGlobal,factionTexture);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
} }
} }
void MenuStateCustomGame::cleanupFactionTexture() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(factionTexture!=NULL) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
factionTexture->end();
delete factionTexture;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//delete loadingTexture;
factionTexture=NULL;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
void MenuStateCustomGame::cleanupMapPreviewTexture() { void MenuStateCustomGame::cleanupMapPreviewTexture() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -184,7 +184,6 @@ private:
void setActiveInputLabel(GraphicLabel *newLable); void setActiveInputLabel(GraphicLabel *newLable);
string getHumanPlayerName(int index=-1); string getHumanPlayerName(int index=-1);
void cleanupFactionTexture();
void loadFactionTexture(string filepath); void loadFactionTexture(string filepath);
void RestoreLastGameSettings(); void RestoreLastGameSettings();

View File

@ -843,7 +843,7 @@ void MenuStateMasterserver::rebuildServerLines(const string &serverInfo) {
Tokenize(server,serverEntities,"|"); Tokenize(server,serverEntities,"|");
const int MIN_FIELDS_EXPECTED = 14; const int MIN_FIELDS_EXPECTED = 14;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("--------------> server [%s] serverEntities.size() = %d MIN_FIELDS_EXPECTED = %d\n",server.c_str(),serverEntities.size(),MIN_FIELDS_EXPECTED); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("--------------> server [%s] serverEntities.size() = %lu MIN_FIELDS_EXPECTED = %d\n",server.c_str(),serverEntities.size(),MIN_FIELDS_EXPECTED);
if(serverEntities.size() >= MIN_FIELDS_EXPECTED) { if(serverEntities.size() >= MIN_FIELDS_EXPECTED) {
labelTitle.setText(lang.get("AvailableServers")); labelTitle.setText(lang.get("AvailableServers"));

View File

@ -68,8 +68,8 @@ public:
protected: protected:
friend class SoundPlayerOpenAL; friend class SoundPlayerOpenAL;
static const size_t STREAMBUFFERSIZE = 1024 * 500; static const size_t STREAMBUFFERSIZE = 4096 * 500;
static const size_t STREAMFRAGMENTS = 5; static const size_t STREAMFRAGMENTS = 10;
static const size_t STREAMFRAGMENTSIZE static const size_t STREAMFRAGMENTSIZE
= STREAMBUFFERSIZE / STREAMFRAGMENTS; = STREAMBUFFERSIZE / STREAMFRAGMENTS;

View File

@ -44,6 +44,7 @@ public:
debugUnitCommands, debugUnitCommands,
debugPathFinder, debugPathFinder,
debugLUA, debugLUA,
debugSound,
debugError debugError
}; };

View File

@ -22,22 +22,22 @@ using namespace Util;
SoundSource::SoundSource() SoundSource::SoundSource()
{ {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
alGenSources(1, &source); alGenSources(1, &source);
SoundPlayerOpenAL::checkAlError("Couldn't create audio source: "); SoundPlayerOpenAL::checkAlError("Couldn't create audio source: ");
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
SoundSource::~SoundSource() SoundSource::~SoundSource()
{ {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
stop(); stop();
alDeleteSources(1, &source); alDeleteSources(1, &source);
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
bool SoundSource::playing() bool SoundSource::playing()
@ -59,13 +59,13 @@ void SoundSource::unQueueBuffers() {
void SoundSource::stop() void SoundSource::stop()
{ {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
alSourceStop(source); alSourceStop(source);
SoundPlayerOpenAL::checkAlError("Problem stopping audio source: "); SoundPlayerOpenAL::checkAlError("Problem stopping audio source: ");
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
unQueueBuffers(); unQueueBuffers();
@ -73,29 +73,36 @@ void SoundSource::stop()
alSourcei(source, AL_BUFFER, AL_NONE); alSourcei(source, AL_BUFFER, AL_NONE);
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
SoundPlayerOpenAL::checkAlError("Problem stopping audio source: "); SoundPlayerOpenAL::checkAlError("Problem stopping audio source: ");
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
ALenum SoundSource::getFormat(Sound* sound) ALenum SoundSource::getFormat(Sound* sound)
{ {
if(sound->getInfo()->getChannels() == 2) { if(sound->getInfo()->getChannels() == 2) {
if(sound->getInfo()->getBitsPerSample() == 16) if(sound->getInfo()->getBitsPerSample() == 16) {
return AL_FORMAT_STEREO16; return AL_FORMAT_STEREO16;
else if(sound->getInfo()->getBitsPerSample() == 8) }
else if(sound->getInfo()->getBitsPerSample() == 8) {
return AL_FORMAT_STEREO8; return AL_FORMAT_STEREO8;
else }
else {
throw std::runtime_error("[1] Sample format not supported in file: " + sound->getFileName()); throw std::runtime_error("[1] Sample format not supported in file: " + sound->getFileName());
} else if(sound->getInfo()->getChannels() == 1) { }
if(sound->getInfo()->getBitsPerSample() == 16) }
else if(sound->getInfo()->getChannels() == 1) {
if(sound->getInfo()->getBitsPerSample() == 16) {
return AL_FORMAT_MONO16; return AL_FORMAT_MONO16;
else if(sound->getInfo()->getBitsPerSample() == 8) }
else if(sound->getInfo()->getBitsPerSample() == 8) {
return AL_FORMAT_MONO8; return AL_FORMAT_MONO8;
else }
else {
throw std::runtime_error("[2] Sample format not supported in file: " + sound->getFileName()); throw std::runtime_error("[2] Sample format not supported in file: " + sound->getFileName());
}
} }
throw std::runtime_error("[3] Sample format not supported in file: " + sound->getFileName()); throw std::runtime_error("[3] Sample format not supported in file: " + sound->getFileName());
@ -114,8 +121,9 @@ StaticSoundSource::~StaticSoundSource() {
} }
} }
void StaticSoundSource::play(StaticSound* sound) void StaticSoundSource::play(StaticSound* sound) {
{ SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(bufferAllocated) { if(bufferAllocated) {
stop(); stop();
alDeleteBuffers(1, &buffer); alDeleteBuffers(1, &buffer);
@ -125,14 +133,18 @@ void StaticSoundSource::play(StaticSound* sound)
alGenBuffers(1, &buffer); alGenBuffers(1, &buffer);
SoundPlayerOpenAL::checkAlError("Couldn't create audio buffer: "); SoundPlayerOpenAL::checkAlError("Couldn't create audio buffer: ");
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] filename [%s] format = %d, sound->getSamples() = %d, sound->getInfo()->getSize() = %d, sound->getInfo()->getSamplesPerSecond() = %d\n",__FILE__,__FUNCTION__,__LINE__,sound->getFileName().c_str(),format,sound->getSamples(),sound->getInfo()->getSize(),sound->getInfo()->getSamplesPerSecond());
bufferAllocated = true; bufferAllocated = true;
alBufferData(buffer, format, sound->getSamples(), alBufferData(buffer, format, sound->getSamples(),
static_cast<ALsizei> (sound->getInfo()->getSize()), static_cast<ALsizei> (sound->getInfo()->getSize()),
static_cast<ALsizei> (sound->getInfo()->getSamplesPerSecond())); static_cast<ALsizei> (sound->getInfo()->getSamplesPerSecond()));
SoundPlayerOpenAL::checkAlError("Couldn't fill audio buffer: "); SoundPlayerOpenAL::checkAlError("Couldn't fill audio buffer: ");
alSourcei(source, AL_BUFFER, buffer); alSourcei(source, AL_BUFFER, buffer);
alSourcef(source, AL_GAIN, sound->getVolume()); alSourcef(source, AL_GAIN, sound->getVolume());
alSourcePlay(source); alSourcePlay(source);
SoundPlayerOpenAL::checkAlError("Couldn't start audio source: "); SoundPlayerOpenAL::checkAlError("Couldn't start audio source: ");
} }
@ -192,14 +204,14 @@ void StreamSoundSource::play(StrSound* sound, int64 fadeon)
void StreamSoundSource::update() void StreamSoundSource::update()
{ {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(sound == 0) { if(sound == 0) {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
return; return;
} }
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(fadeState == NoFading){ if(fadeState == NoFading){
alSourcef(source, AL_GAIN, sound->getVolume()); alSourcef(source, AL_GAIN, sound->getVolume());
} }
@ -217,18 +229,18 @@ void StreamSoundSource::update()
break; break;
} }
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
// we might have to restart the source if we had a buffer underrun // we might have to restart the source if we had a buffer underrun
if(!playing()) { if(!playing()) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Restarting audio source because of buffer underrun.\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] Restarting audio source because of buffer underrun.\n",__FILE__,__FUNCTION__,__LINE__);
std::cerr << "Restarting audio source because of buffer underrun.\n"; std::cerr << "Restarting audio source because of buffer underrun.\n";
alSourcePlay(source); alSourcePlay(source);
SoundPlayerOpenAL::checkAlError("Couldn't restart audio source: "); SoundPlayerOpenAL::checkAlError("Couldn't restart audio source: ");
} }
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
// handle fading // handle fading
switch(fadeState) { switch(fadeState) {
@ -253,7 +265,7 @@ void StreamSoundSource::update()
break; break;
} }
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
bool StreamSoundSource::fillBufferAndQueue(ALuint buffer) bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
@ -289,21 +301,21 @@ bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
// ================================ // ================================
SoundPlayerOpenAL::SoundPlayerOpenAL() { SoundPlayerOpenAL::SoundPlayerOpenAL() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
device = 0; device = 0;
initOk = false; initOk = false;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
SoundPlayerOpenAL::~SoundPlayerOpenAL() { SoundPlayerOpenAL::~SoundPlayerOpenAL() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
end(); end();
initOk = false; initOk = false;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
void SoundPlayerOpenAL::printOpenALInfo() void SoundPlayerOpenAL::printOpenALInfo()
@ -315,7 +327,7 @@ void SoundPlayerOpenAL::printOpenALInfo()
} }
bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) { bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
initOk = false; initOk = false;
@ -341,11 +353,11 @@ bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) {
checkAlError("Audio error after init: "); checkAlError("Audio error after init: ");
initOk = true; initOk = true;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
catch(const exception &ex) { catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
printOpenALInfo(); printOpenALInfo();
//throw std::runtime_error(ex.what()); //throw std::runtime_error(ex.what());
} }
@ -355,7 +367,7 @@ bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) {
void SoundPlayerOpenAL::end() { void SoundPlayerOpenAL::end() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
for(StaticSoundSources::iterator i = staticSources.begin(); for(StaticSoundSources::iterator i = staticSources.begin();
@ -364,7 +376,7 @@ void SoundPlayerOpenAL::end() {
src->stop(); src->stop();
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
for(StreamSoundSources::iterator i = streamSources.begin(); for(StreamSoundSources::iterator i = streamSources.begin();
i != streamSources.end(); ++i) { i != streamSources.end(); ++i) {
@ -372,32 +384,32 @@ void SoundPlayerOpenAL::end() {
src->stop(); src->stop();
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
for(StaticSoundSources::iterator i = staticSources.begin(); for(StaticSoundSources::iterator i = staticSources.begin();
i != staticSources.end(); ++i) { i != staticSources.end(); ++i) {
delete *i; delete *i;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
for(StreamSoundSources::iterator i = streamSources.begin(); for(StreamSoundSources::iterator i = streamSources.begin();
i != streamSources.end(); ++i) { i != streamSources.end(); ++i) {
delete *i; delete *i;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
alcMakeContextCurrent( NULL ); alcMakeContextCurrent( NULL );
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(context != 0) { if(context != 0) {
alcDestroyContext(context); alcDestroyContext(context);
context = 0; context = 0;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(device != 0) { if(device != 0) {
alcCloseDevice(device); alcCloseDevice(device);
@ -405,7 +417,7 @@ void SoundPlayerOpenAL::end() {
initOk = false; initOk = false;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
void SoundPlayerOpenAL::play(StaticSound* staticSound) { void SoundPlayerOpenAL::play(StaticSound* staticSound) {
@ -415,13 +427,15 @@ void SoundPlayerOpenAL::play(StaticSound* staticSound) {
try { try {
StaticSoundSource* source = findStaticSoundSource(); StaticSoundSource* source = findStaticSoundSource();
if(source == 0)
if(source == 0) {
return; return;
}
source->play(staticSound); source->play(staticSound);
} }
catch(std::exception& e) { catch(std::exception& e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
std::cerr << "Couldn't play static sound: " << e.what() << "\n"; std::cerr << "Couldn't play static sound: [" << e.what() << "]\n";
} }
} }
@ -481,7 +495,7 @@ void SoundPlayerOpenAL::updateStreams() {
source->update(); source->update();
} }
catch(std::exception& e) { catch(std::exception& e) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
std::cerr << "Error while updating sound stream: "<< e.what() << "\n"; std::cerr << "Error while updating sound stream: "<< e.what() << "\n";
@ -491,13 +505,13 @@ void SoundPlayerOpenAL::updateStreams() {
checkAlcError("Error while processing audio context: "); checkAlcError("Error while processing audio context: ");
} }
catch(exception &ex) { catch(exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
printOpenALInfo(); printOpenALInfo();
throw runtime_error(ex.what()); throw runtime_error(ex.what());
} }
catch(...) { catch(...) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
printOpenALInfo(); printOpenALInfo();
throw; throw;
@ -521,12 +535,12 @@ StaticSoundSource* SoundPlayerOpenAL::findStaticSoundSource() {
return 0; return 0;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
StaticSoundSource* source = new StaticSoundSource(); StaticSoundSource* source = new StaticSoundSource();
staticSources.push_back(source); staticSources.push_back(source);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return source; return source;
} }
@ -548,12 +562,12 @@ StreamSoundSource* SoundPlayerOpenAL::findStreamSoundSource() {
throw std::runtime_error("Too many stream sounds played at once"); throw std::runtime_error("Too many stream sounds played at once");
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
StreamSoundSource* source = new StreamSoundSource(); StreamSoundSource* source = new StreamSoundSource();
streamSources.push_back(source); streamSources.push_back(source);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return source; return source;
} }

View File

@ -159,30 +159,24 @@ void OggSoundFileLoader::open(const string &path, SoundInfo *soundInfo){
throw runtime_error("Can't read ogg header info for file: "+path); throw runtime_error("Can't read ogg header info for file: "+path);
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] vi->version = %d, vi->channels = %d, vi->rate = %ld, vi->bitrate_upper = %ld, vi->bitrate_nominal = %ld, vi->bitrate_lower = %ld, vi->bitrate_window = %ld\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),vi->version,vi->channels,vi->rate,vi->bitrate_upper,vi->bitrate_nominal,vi->bitrate_lower,vi->bitrate_window); uint32 samples = static_cast<uint32>(ov_pcm_total(vf, -1));
SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s Line: %d] path = [%s] vi->version = %d, vi->channels = %d, vi->rate = %ld, vi->bitrate_upper = %ld, vi->bitrate_nominal = %ld, vi->bitrate_lower = %ld, vi->bitrate_window = %ld, samples = %lu\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),vi->version,vi->channels,vi->rate,vi->bitrate_upper,vi->bitrate_nominal,vi->bitrate_lower,vi->bitrate_window,samples);
soundInfo->setChannels(vi->channels); soundInfo->setChannels(vi->channels);
soundInfo->setsamplesPerSecond(vi->rate); soundInfo->setsamplesPerSecond(vi->rate);
soundInfo->setBitsPerSample(16); soundInfo->setBitsPerSample(16);
soundInfo->setSize(samples * 2);
uint32 samples = static_cast<uint32>(ov_pcm_total(vf, -1));
//if(vi->channels == 1) {
soundInfo->setSize(samples * 2);
//}
//else {
// soundInfo->setSize(samples * 4);
//}
} }
uint32 OggSoundFileLoader::read(int8 *samples, uint32 size){ uint32 OggSoundFileLoader::read(int8 *samples, uint32 size){
int section; int section;
int totalBytesRead= 0; int totalBytesRead= 0;
while(size>0){ while(size>0) {
int bytesRead= ov_read(vf, reinterpret_cast<char*> (samples), size, int bytesRead= ov_read(vf, reinterpret_cast<char*> (samples), size,
0, 2, 1, &section); 0, 2, 1, &section);
if(bytesRead==0){ if(bytesRead==0) {
break; break;
} }
size-= bytesRead; size-= bytesRead;

View File

@ -186,13 +186,14 @@ void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
if(SystemFlags::debugLogFileList == NULL) { if(SystemFlags::debugLogFileList == NULL) {
SystemFlags::debugLogFileList = new std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>(); SystemFlags::debugLogFileList = new std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>();
(*SystemFlags::debugLogFileList)[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem); (*SystemFlags::debugLogFileList)[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
(*SystemFlags::debugLogFileList)[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork); (*SystemFlags::debugLogFileList)[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork);
(*SystemFlags::debugLogFileList)[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance); (*SystemFlags::debugLogFileList)[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance);
(*SystemFlags::debugLogFileList)[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch); (*SystemFlags::debugLogFileList)[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch);
(*SystemFlags::debugLogFileList)[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands); (*SystemFlags::debugLogFileList)[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
(*SystemFlags::debugLogFileList)[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA); (*SystemFlags::debugLogFileList)[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA);
(*SystemFlags::debugLogFileList)[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError); (*SystemFlags::debugLogFileList)[SystemFlags::debugSound] = SystemFlags::SystemFlagsType(SystemFlags::debugSound);
(*SystemFlags::debugLogFileList)[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
} }
if(threadLogger == NULL) { if(threadLogger == NULL) {