Compare commits

...

3 Commits

Author SHA1 Message Date
hiker
9ef1b65eba Fixed compilation ... again :P 2015-06-25 23:03:55 +10:00
hiker
4d10a680c1 Fixed non-debug compilation. 2015-06-25 22:11:52 +10:00
hiker
b8e4aa589d Added a very rough logging feature for SFXs to debug bug #2169. 2015-06-25 16:54:47 +10:00
5 changed files with 93 additions and 0 deletions

View File

@ -71,6 +71,13 @@ void SFXManager::destroy()
*/
SFXManager::SFXManager()
{
#ifdef DEBUG
// These need to be initialised, even if no --log-sfx flag is specified,
// since at this stage the command line has not been handled.
m_sfx_log_data.resize(100000);
m_sfx_log_data_index = 0;
m_currently_dumping = false;
#endif
// The sound manager initialises OpenAL
m_initialized = music_manager->initialized();
@ -233,8 +240,38 @@ void SFXManager::queue(SFXCommands command, MusicInformation *mi, float f)
* sfx manager to wake up.
* \param command Pointer to the command to queue up.
*/
void SFXManager::queueCommand(SFXCommand *command)
{
#ifdef DEBUG
// Don't accept any commands while data is being dumped, since the
// updates will arrive faster than the data is written, so the
// dumping will never end
if (m_currently_dumping)
return;
if (UserConfigParams::m_sfx_logging && command->m_command!=SFX_EXIT)
{
SFXLogData *p = &(m_sfx_log_data[m_sfx_log_data_index]);
p->m_command = command->m_command;
if (command->m_command < SFX_MUSIC_START)
{
p->m_sfx_base = command->m_sfx;
if (command->m_sfx)
{
p->m_normal_filename = command->m_sfx->getBuffer()->getFileName();
p->m_sfx_buffer = command->m_sfx->getBuffer();
}
}
else
{
p->m_normal_filename = command->m_music_information->getNormalFilename();
}
m_sfx_log_data_index++;
if (m_sfx_log_data_index >= (int)m_sfx_log_data.size())
m_sfx_log_data_index = 0;
}
#endif
m_sfx_commands.lock();
if(World::getWorld() &&
m_sfx_commands.getData().size() > 20*race_manager->getNumberOfKarts()+20 &&
@ -259,6 +296,31 @@ void SFXManager::queueCommand(SFXCommand *command)
m_sfx_commands.unlock();
} // queueCommand
//----------------------------------------------------------------------------
#ifdef DEBUG
void SFXManager::dumpLogData()
{
// Don't bother locking m_currently_dumping, only the main thread sets it
m_currently_dumping = true;
for (unsigned int i = 0; i < m_sfx_log_data_index; i++)
{
const SFXLogData &p = m_sfx_log_data[i];
if (p.m_command <= SFX_MUSIC_START)
{
if (p.m_sfx_base)
Log::info("SFX", "SFX %d %s sfx %lx buffer %lx",
p.m_command, p.m_normal_filename.c_str(),
p.m_sfx_base, p.m_sfx_buffer);
else
Log::info("SFX", "NoSFX %d", p.m_command);
}
else
Log::info("SFX", "Music %d %s", p.m_command, p.m_normal_filename.c_str());
}
m_currently_dumping = false;
} // dumpLogData
#endif
//----------------------------------------------------------------------------
/** Puts a NULL request into the queue, which will trigger the thread to
* exit.

View File

@ -57,6 +57,22 @@ private:
/** Singleton pointer. */
static SFXManager *m_sfx_manager;
#ifdef DEBUG
struct SFXLogData
{
int m_command;
std::string m_normal_filename;
const SFXBase *m_sfx_base;
const SFXBuffer *m_sfx_buffer;
};
std::vector<SFXLogData> m_sfx_log_data;
unsigned int m_sfx_log_data_index;
bool m_currently_dumping;
public:
void dumpLogData();
#endif
public:
/** The various commands to be executed by the sfx manager thread

View File

@ -490,6 +490,9 @@ namespace UserConfigParams
/** If gamepad debugging is enabled. */
PARAM_PREFIX bool m_unit_testing PARAM_DEFAULT(false);
/** If sfx logging is enabled. */
PARAM_PREFIX bool m_sfx_logging PARAM_DEFAULT(false);
/** If gamepad debugging is enabled. */
PARAM_PREFIX bool m_gamepad_debug PARAM_DEFAULT( false );

View File

@ -737,6 +737,8 @@ int handleCmdLine()
if (CommandLine::has("--unit-testing"))
UserConfigParams::m_unit_testing = true;
if (CommandLine::has("--log-sfx"))
UserConfigParams::m_sfx_logging = true;
if (CommandLine::has("--gamepad-debug"))
UserConfigParams::m_gamepad_debug=true;
if (CommandLine::has("--keyboard-debug"))

View File

@ -18,6 +18,7 @@
#include "debug.hpp"
#include "audio/sfx_manager.hpp"
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/irr_driver.hpp"
@ -104,6 +105,7 @@ enum DebugMenuCommand
DEBUG_THROTTLE_FPS,
DEBUG_VISUAL_VALUES,
DEBUG_PRINT_START_POS,
DEBUG_SFX_LOG,
DEBUG_ADJUST_LIGHTS,
DEBUG_SCRIPT_CONSOLE
}; // DebugMenuCommand
@ -267,6 +269,8 @@ bool onEvent(const SEvent &event)
mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY);
mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY);
mnu->addItem(L"Print position", DEBUG_PRINT_START_POS);
if(UserConfigParams::m_sfx_logging)
mnu->addItem(L"Dump sfx data", DEBUG_SFX_LOG);
mnu->addItem(L"Adjust Lights", DEBUG_ADJUST_LIGHTS);
mnu->addItem(L"Scripting console", DEBUG_SCRIPT_CONSOLE);
@ -557,6 +561,12 @@ bool onEvent(const SEvent &event)
);
}
}
#ifdef DEBUG
else if (cmdID == DEBUG_SFX_LOG && UserConfigParams::m_sfx_logging)
{
SFXManager::get()->dumpLogData();
}
#endif
else if (cmdID == DEBUG_VISUAL_VALUES)
{
#if !defined(__APPLE__)