2016-06-05 01:33:35 +00:00
|
|
|
/****************************************************************************
|
2017-09-11 11:57:21 +00:00
|
|
|
* *
|
|
|
|
* Project64-audio - A Nintendo 64 audio plugin. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2017 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2017-09-14 08:07:12 +00:00
|
|
|
#include <Settings/Settings.h>
|
|
|
|
#include <Project64-audio/trace.h>
|
2017-09-11 22:37:32 +00:00
|
|
|
#include "SettingsID.h"
|
2016-06-05 01:33:35 +00:00
|
|
|
#include "AudioSettings.h"
|
|
|
|
|
2017-09-14 08:07:12 +00:00
|
|
|
CSettings * g_settings = NULL;
|
2016-08-11 10:46:03 +00:00
|
|
|
|
2017-09-14 08:07:12 +00:00
|
|
|
CSettings::CSettings() :
|
|
|
|
m_Set_EnableAudio(0),
|
|
|
|
m_Set_basic_mode(0),
|
|
|
|
m_Set_debugger(0),
|
|
|
|
m_Set_log_dir(0),
|
|
|
|
m_Set_log_flush(0),
|
|
|
|
m_FlushLogs(false),
|
|
|
|
m_AudioEnabled(true),
|
|
|
|
m_advanced_options(false),
|
2017-09-25 12:00:04 +00:00
|
|
|
m_debugger_enabled(false),
|
|
|
|
m_Volume(100)
|
2016-08-11 10:46:03 +00:00
|
|
|
{
|
2017-09-14 08:07:12 +00:00
|
|
|
memset(m_log_dir, 0, sizeof(m_log_dir));
|
|
|
|
RegisterSettings();
|
2017-09-25 12:00:04 +00:00
|
|
|
SettingsChanged();
|
|
|
|
|
|
|
|
if (m_Set_EnableAudio != 0) { SettingsRegisterChange(false, m_Set_EnableAudio, this, stSettingsChanged); }
|
|
|
|
if (m_Set_basic_mode != 0) { SettingsRegisterChange(false, m_Set_basic_mode, this, stSettingsChanged); }
|
|
|
|
if (m_Set_debugger != 0) { SettingsRegisterChange(false, m_Set_debugger, this, stSettingsChanged); }
|
|
|
|
if (m_Set_log_flush != 0) { SettingsRegisterChange(false, m_Set_log_flush, this, stSettingsChanged); }
|
|
|
|
SettingsRegisterChange(false, Set_Volume, this, stSettingsChanged);
|
|
|
|
|
|
|
|
SettingsRegisterChange(false, Set_Logging_MD5, this, stLogLevelChanged);
|
|
|
|
SettingsRegisterChange(false, Set_Logging_Thread, this, stLogLevelChanged);
|
|
|
|
SettingsRegisterChange(false, Set_Logging_Path, this, stLogLevelChanged);
|
|
|
|
SettingsRegisterChange(false, Set_Logging_InitShutdown, this, stLogLevelChanged);
|
|
|
|
SettingsRegisterChange(false, Set_Logging_Interface, this, stLogLevelChanged);
|
|
|
|
SettingsRegisterChange(false, Set_Logging_Driver, this, stLogLevelChanged);
|
2017-09-14 08:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSettings::~CSettings()
|
|
|
|
{
|
2017-09-25 12:00:04 +00:00
|
|
|
if (m_Set_EnableAudio != 0) { SettingsUnregisterChange(false, m_Set_EnableAudio, this, stSettingsChanged); }
|
|
|
|
if (m_Set_basic_mode != 0) { SettingsUnregisterChange(false, m_Set_basic_mode, this, stSettingsChanged); }
|
|
|
|
if (m_Set_debugger != 0) { SettingsUnregisterChange(false, m_Set_debugger, this, stSettingsChanged); }
|
|
|
|
if (m_Set_log_flush != 0) { SettingsUnregisterChange(false, m_Set_log_flush, this, stSettingsChanged); }
|
|
|
|
SettingsUnregisterChange(false, Set_Volume, this, stSettingsChanged);
|
|
|
|
|
|
|
|
SettingsUnregisterChange(false, Set_Logging_MD5, this, stLogLevelChanged);
|
|
|
|
SettingsUnregisterChange(false, Set_Logging_Thread, this, stLogLevelChanged);
|
|
|
|
SettingsUnregisterChange(false, Set_Logging_Path, this, stLogLevelChanged);
|
|
|
|
SettingsUnregisterChange(false, Set_Logging_InitShutdown, this, stLogLevelChanged);
|
|
|
|
SettingsUnregisterChange(false, Set_Logging_Interface, this, stLogLevelChanged);
|
|
|
|
SettingsUnregisterChange(false, Set_Logging_Driver, this, stLogLevelChanged);
|
2017-09-14 08:07:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSettings::RegisterSettings(void)
|
|
|
|
{
|
|
|
|
SetModuleName("default");
|
|
|
|
m_Set_EnableAudio = FindSystemSettingId("Enable Audio");
|
|
|
|
m_Set_basic_mode = FindSystemSettingId("Basic Mode");
|
|
|
|
m_Set_debugger = FindSystemSettingId("Debugger");
|
|
|
|
m_Set_log_flush = FindSystemSettingId("Log Auto Flush");
|
|
|
|
m_Set_log_dir = FindSystemSettingId("Dir:Log");
|
|
|
|
|
|
|
|
SetModuleName("Project64-Audio");
|
2017-09-25 12:00:04 +00:00
|
|
|
RegisterSetting(Set_Volume, Data_DWORD_General, "Volume", "Settings", 100, NULL);
|
2017-09-14 08:07:12 +00:00
|
|
|
RegisterSetting(Set_Logging_MD5, Data_DWORD_General, "MD5", "Logging", g_ModuleLogLevel[TraceMD5], NULL);
|
|
|
|
RegisterSetting(Set_Logging_Thread, Data_DWORD_General, "Thread", "Logging", g_ModuleLogLevel[TraceThread], NULL);
|
|
|
|
RegisterSetting(Set_Logging_Path, Data_DWORD_General, "Path", "Logging", g_ModuleLogLevel[TracePath], NULL);
|
|
|
|
RegisterSetting(Set_Logging_InitShutdown, Data_DWORD_General, "InitShutdown", "Logging", g_ModuleLogLevel[TraceAudioInitShutdown], NULL);
|
|
|
|
RegisterSetting(Set_Logging_Interface, Data_DWORD_General, "Interface", "Logging", g_ModuleLogLevel[TraceAudioInterface], NULL);
|
|
|
|
RegisterSetting(Set_Logging_Driver, Data_DWORD_General, "Driver", "Logging", g_ModuleLogLevel[TraceAudioDriver], NULL);
|
|
|
|
LogLevelChanged();
|
|
|
|
}
|
|
|
|
|
2017-09-25 12:00:04 +00:00
|
|
|
void CSettings::SetAudioEnabled(bool Enabled)
|
2017-09-14 08:07:12 +00:00
|
|
|
{
|
2017-09-25 12:00:04 +00:00
|
|
|
if (m_Set_EnableAudio != 0)
|
|
|
|
{
|
|
|
|
SetSystemSetting(m_Set_EnableAudio, Enabled ? 1 : 0);
|
|
|
|
}
|
|
|
|
}
|
2017-09-14 08:07:12 +00:00
|
|
|
|
2017-09-25 12:00:04 +00:00
|
|
|
void CSettings::SetVolume(uint32_t Volume)
|
|
|
|
{
|
|
|
|
if (m_Set_EnableAudio != 0)
|
2017-09-14 08:07:12 +00:00
|
|
|
{
|
2017-09-25 12:00:04 +00:00
|
|
|
SetSetting(Set_Volume, Volume);
|
2017-09-14 08:07:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSettings::LogLevelChanged(void)
|
|
|
|
{
|
|
|
|
g_ModuleLogLevel[TraceMD5] = GetSetting(Set_Logging_MD5);
|
|
|
|
g_ModuleLogLevel[TraceThread] = GetSetting(Set_Logging_Thread);
|
|
|
|
g_ModuleLogLevel[TracePath] = GetSetting(Set_Logging_Path);
|
|
|
|
g_ModuleLogLevel[TraceAudioInitShutdown] = GetSetting(Set_Logging_InitShutdown);
|
|
|
|
g_ModuleLogLevel[TraceAudioInterface] = GetSetting(Set_Logging_Interface);
|
|
|
|
g_ModuleLogLevel[TraceAudioDriver] = GetSetting(Set_Logging_Driver);
|
2016-08-11 10:46:03 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 12:00:04 +00:00
|
|
|
void CSettings::SettingsChanged(void)
|
|
|
|
{
|
|
|
|
m_Volume = GetSetting(Set_Volume);
|
|
|
|
m_AudioEnabled = m_Set_EnableAudio ? GetSystemSetting(m_Set_EnableAudio) != 0 : true;
|
|
|
|
m_advanced_options = m_Set_basic_mode ? GetSystemSetting(m_Set_basic_mode) == 0 : false;
|
|
|
|
m_debugger_enabled = m_advanced_options && m_Set_debugger ? GetSystemSetting(m_Set_debugger) == 1 : false;
|
|
|
|
|
|
|
|
if (m_Set_log_dir != 0)
|
|
|
|
{
|
|
|
|
GetSystemSettingSz(m_Set_log_dir, m_log_dir, sizeof(m_log_dir));
|
|
|
|
}
|
|
|
|
m_FlushLogs = m_Set_log_flush != 0 ? GetSystemSetting(m_Set_log_flush) != 0 : false;
|
|
|
|
}
|
|
|
|
|
2016-08-11 10:46:03 +00:00
|
|
|
void SetupAudioSettings(void)
|
2016-06-05 01:33:35 +00:00
|
|
|
{
|
2017-09-14 08:07:12 +00:00
|
|
|
if (g_settings == NULL)
|
|
|
|
{
|
|
|
|
g_settings = new CSettings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CleanupAudioSettings(void)
|
|
|
|
{
|
|
|
|
if (g_settings)
|
2016-08-11 10:46:03 +00:00
|
|
|
{
|
2017-09-14 08:07:12 +00:00
|
|
|
delete g_settings;
|
|
|
|
g_settings = NULL;
|
2016-08-11 10:46:03 +00:00
|
|
|
}
|
2016-06-05 01:33:35 +00:00
|
|
|
}
|