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"
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
CSettings * g_settings = nullptr;
|
2016-08-11 10:46:03 +00:00
|
|
|
|
2017-09-14 08:07:12 +00:00
|
|
|
CSettings::CSettings() :
|
2018-12-20 10:19:14 +00:00
|
|
|
m_Set_SyncViaAudioEnabled(0),
|
2017-09-14 08:07:12 +00:00
|
|
|
m_Set_EnableAudio(0),
|
2017-09-28 11:43:58 +00:00
|
|
|
m_Set_SyncAudio(0),
|
|
|
|
m_Set_FullSpeed(0),
|
2017-09-28 19:32:43 +00:00
|
|
|
m_Set_LimitFPS(0),
|
2017-09-14 08:07:12 +00:00
|
|
|
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),
|
2017-09-26 13:57:33 +00:00
|
|
|
m_Volume(100),
|
2019-01-21 05:45:52 +00:00
|
|
|
m_Buffer(4),
|
2017-09-28 11:43:58 +00:00
|
|
|
m_SyncAudio(false),
|
|
|
|
m_FullSpeed(true)
|
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-26 13:57:33 +00:00
|
|
|
ReadSettings();
|
2017-09-25 12:00:04 +00:00
|
|
|
|
2017-09-28 07:48:45 +00:00
|
|
|
if (m_Set_EnableAudio != 0) { SettingsRegisterChange(true, m_Set_EnableAudio, this, stSettingsChanged); }
|
|
|
|
if (m_Set_basic_mode != 0) { SettingsRegisterChange(true, m_Set_basic_mode, this, stSettingsChanged); }
|
|
|
|
if (m_Set_debugger != 0) { SettingsRegisterChange(true, m_Set_debugger, this, stSettingsChanged); }
|
|
|
|
if (m_Set_log_flush != 0) { SettingsRegisterChange(true, m_Set_log_flush, this, stSettingsChanged); }
|
2017-09-28 11:43:58 +00:00
|
|
|
if (m_Set_SyncAudio != 0) { SettingsRegisterChange(true, m_Set_SyncAudio, this, stSettingsChanged); }
|
|
|
|
if (m_Set_FullSpeed != 0) { SettingsRegisterChange(true, m_Set_FullSpeed, this, stSettingsChanged); }
|
2017-09-28 19:32:43 +00:00
|
|
|
if (m_Set_LimitFPS != 0) { SettingsRegisterChange(true, m_Set_LimitFPS, this, stSettingsChanged); }
|
2017-09-25 12:00:04 +00:00
|
|
|
SettingsRegisterChange(false, Set_Volume, this, stSettingsChanged);
|
2019-01-21 05:45:52 +00:00
|
|
|
SettingsRegisterChange(false, Set_Buffer, this, stSettingsChanged);
|
2017-09-25 12:00:04 +00:00
|
|
|
|
|
|
|
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-28 07:48:45 +00:00
|
|
|
if (m_Set_EnableAudio != 0) { SettingsUnregisterChange(true, m_Set_EnableAudio, this, stSettingsChanged); }
|
|
|
|
if (m_Set_basic_mode != 0) { SettingsUnregisterChange(true, m_Set_basic_mode, this, stSettingsChanged); }
|
|
|
|
if (m_Set_debugger != 0) { SettingsUnregisterChange(true, m_Set_debugger, this, stSettingsChanged); }
|
|
|
|
if (m_Set_log_flush != 0) { SettingsUnregisterChange(true, m_Set_log_flush, this, stSettingsChanged); }
|
2017-09-28 11:43:58 +00:00
|
|
|
if (m_Set_SyncAudio != 0) { SettingsUnregisterChange(true, m_Set_SyncAudio, this, stSettingsChanged); }
|
|
|
|
if (m_Set_FullSpeed != 0) { SettingsUnregisterChange(true, m_Set_FullSpeed, this, stSettingsChanged); }
|
2017-09-28 19:32:43 +00:00
|
|
|
if (m_Set_LimitFPS != 0) { SettingsUnregisterChange(true, m_Set_LimitFPS, this, stSettingsChanged); }
|
2017-09-25 12:00:04 +00:00
|
|
|
SettingsUnregisterChange(false, Set_Volume, this, stSettingsChanged);
|
2019-01-21 05:45:52 +00:00
|
|
|
SettingsUnregisterChange(false, Set_Buffer, this, stSettingsChanged);
|
2017-09-25 12:00:04 +00:00
|
|
|
|
|
|
|
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");
|
2019-01-17 04:40:28 +00:00
|
|
|
m_Set_SyncViaAudioEnabled = FindSystemSettingId("SyncViaAudioEnabled");
|
|
|
|
m_Set_EnableAudio = FindSystemSettingId("Enable Audio");
|
2017-09-28 11:43:58 +00:00
|
|
|
m_Set_SyncAudio = FindSystemSettingId("Sync Audio");
|
|
|
|
m_Set_FullSpeed = FindSystemSettingId("Full Speed");
|
2017-09-28 19:32:43 +00:00
|
|
|
m_Set_LimitFPS = FindSystemSettingId("Limit FPS");
|
2017-09-14 08:07:12 +00:00
|
|
|
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");
|
|
|
|
|
2017-09-26 20:55:53 +00:00
|
|
|
SetModuleName("Audio");
|
2021-04-12 11:35:39 +00:00
|
|
|
RegisterSetting(Set_Volume, Data_DWORD_General, "Volume", "Settings", 100, nullptr);
|
|
|
|
RegisterSetting(Set_Logging_MD5, Data_DWORD_General, "MD5", "Logging", g_ModuleLogLevel[TraceMD5], nullptr);
|
|
|
|
RegisterSetting(Set_Logging_Thread, Data_DWORD_General, "Thread", "Logging", g_ModuleLogLevel[TraceThread], nullptr);
|
|
|
|
RegisterSetting(Set_Logging_Path, Data_DWORD_General, "Path", "Logging", g_ModuleLogLevel[TracePath], nullptr);
|
|
|
|
RegisterSetting(Set_Logging_InitShutdown, Data_DWORD_General, "InitShutdown", "Logging", g_ModuleLogLevel[TraceAudioInitShutdown], nullptr);
|
|
|
|
RegisterSetting(Set_Logging_Interface, Data_DWORD_General, "Interface", "Logging", g_ModuleLogLevel[TraceAudioInterface], nullptr);
|
|
|
|
RegisterSetting(Set_Logging_Driver, Data_DWORD_General, "Driver", "Logging", g_ModuleLogLevel[TraceAudioDriver], nullptr);
|
|
|
|
RegisterSetting(Set_Buffer, Data_DWORD_Game, "Buffer", "", 4, nullptr);
|
2017-09-14 08:07:12 +00:00
|
|
|
LogLevelChanged();
|
|
|
|
}
|
|
|
|
|
2018-12-20 10:19:14 +00:00
|
|
|
void CSettings::SetSyncViaAudioEnabled(bool Enabled)
|
|
|
|
{
|
2019-01-17 04:40:28 +00:00
|
|
|
if (m_Set_SyncViaAudioEnabled != 0)
|
|
|
|
{
|
|
|
|
SetSystemSetting(m_Set_SyncViaAudioEnabled, Enabled ? 1 : 0);
|
|
|
|
}
|
2018-12-20 10:19:14 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 05:45:52 +00:00
|
|
|
void CSettings::SetBuffer(uint32_t Buffer)
|
2017-09-26 13:57:33 +00:00
|
|
|
{
|
2019-01-21 05:45:52 +00:00
|
|
|
SetSetting(Set_Buffer, Buffer);
|
2017-09-26 13:57:33 +00:00
|
|
|
}
|
|
|
|
|
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-26 13:57:33 +00:00
|
|
|
void CSettings::ReadSettings(void)
|
2017-09-25 12:00:04 +00:00
|
|
|
{
|
2017-09-28 19:32:43 +00:00
|
|
|
bool bLimitFPS = m_Set_LimitFPS ? GetSystemSetting(m_Set_LimitFPS) != 0 : true;
|
2017-09-25 12:00:04 +00:00
|
|
|
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;
|
2019-01-21 05:45:52 +00:00
|
|
|
m_Buffer = GetSetting(Set_Buffer);
|
2017-09-28 11:43:58 +00:00
|
|
|
m_FullSpeed = m_Set_FullSpeed ? GetSystemSetting(m_Set_FullSpeed) != 0 : false;
|
2019-01-17 04:33:06 +00:00
|
|
|
m_SyncAudio = (!m_advanced_options || bLimitFPS);
|
2017-09-28 19:32:43 +00:00
|
|
|
|
2017-09-25 12:00:04 +00:00
|
|
|
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
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_settings == nullptr)
|
2017-09-14 08:07:12 +00:00
|
|
|
{
|
|
|
|
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;
|
2021-04-12 11:35:39 +00:00
|
|
|
g_settings = nullptr;
|
2016-08-11 10:46:03 +00:00
|
|
|
}
|
2017-10-13 00:57:24 +00:00
|
|
|
}
|