From 2ca97f0b377a13d969856a1d653b7c4fe42099b4 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 3 Dec 2018 05:23:45 +1030 Subject: [PATCH 1/2] [Audio] Change timer resolution to 1ms --- Source/Project64-audio/AudioMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64-audio/AudioMain.cpp b/Source/Project64-audio/AudioMain.cpp index c9b1fbfd1..f0fa1cefb 100644 --- a/Source/Project64-audio/AudioMain.cpp +++ b/Source/Project64-audio/AudioMain.cpp @@ -284,7 +284,7 @@ void SetTimerResolution(void) typedef LONG(NTAPI* tNtSetTimerResolution)(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution); tNtSetTimerResolution NtSetTimerResolution = (tNtSetTimerResolution)GetProcAddress(hMod, "NtSetTimerResolution"); ULONG CurrentResolution = 0; - NtSetTimerResolution(5000, TRUE, &CurrentResolution); + NtSetTimerResolution(10000, TRUE, &CurrentResolution); } } #endif From 88386600ed6f9bfd0e8d898d05099a7e9a37c7ac Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 8 Dec 2018 21:23:06 +1030 Subject: [PATCH 2/2] [Audio] Have sync audio only if plugin enables it --- Source/Project64-audio/AudioSettings.cpp | 7 ++++++- Source/Project64-core/Plugins/AudioPlugin.cpp | 1 + Source/Project64-core/Settings.cpp | 1 + Source/Project64-core/Settings/GameSettings.cpp | 2 +- .../Settings/SettingType/SettingsType-TempBool.cpp | 12 ++++++++++-- Source/Project64-core/Settings/SettingsID.h | 1 + .../UserInterface/Settings/SettingsPage-Defaults.cpp | 4 ++++ .../Settings/SettingsPage-Game-General.cpp | 5 +++++ 8 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Source/Project64-audio/AudioSettings.cpp b/Source/Project64-audio/AudioSettings.cpp index a2ac8c26a..cef5a25ef 100644 --- a/Source/Project64-audio/AudioSettings.cpp +++ b/Source/Project64-audio/AudioSettings.cpp @@ -81,7 +81,12 @@ CSettings::~CSettings() void CSettings::RegisterSettings(void) { SetModuleName("default"); - m_Set_EnableAudio = FindSystemSettingId("Enable Audio"); + short Set_SyncViaAudioEnabled = FindSystemSettingId("SyncViaAudioEnabled"); + if (Set_SyncViaAudioEnabled != 0) + { + SetSystemSetting(Set_SyncViaAudioEnabled, 1); + } + m_Set_EnableAudio = FindSystemSettingId("Enable Audio"); m_Set_FixedAudio = FindSystemSettingId("Fixed Audio"); m_Set_SyncAudio = FindSystemSettingId("Sync Audio"); m_Set_FullSpeed = FindSystemSettingId("Full Speed"); diff --git a/Source/Project64-core/Plugins/AudioPlugin.cpp b/Source/Project64-core/Plugins/AudioPlugin.cpp index 537067f98..df7f879e7 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.cpp +++ b/Source/Project64-core/Plugins/AudioPlugin.cpp @@ -62,6 +62,7 @@ bool CAudioPlugin::LoadFunctions(void) bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) { + g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false); struct AUDIO_INFO { void * hwnd; diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index dd61177a8..247ae70e7 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -127,6 +127,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Setting_EnableDisk, new CSettingTypeTempBool(false)); AddHandler(Setting_LanguageDirDefault, new CSettingTypeRelativePath("Lang", "")); AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Lang Directory", "Directory", Setting_LanguageDirDefault)); + AddHandler(Setting_SyncViaAudioEnabled, new CSettingTypeTempBool(false, "SyncViaAudioEnabled")); AddHandler(Default_RDRamSize, new CSettingTypeApplication("Defaults", "RDRAM Size", 0x400000u)); AddHandler(Default_UseHleGfx, new CSettingTypeApplication("Defaults", "HLE GFX", true)); diff --git a/Source/Project64-core/Settings/GameSettings.cpp b/Source/Project64-core/Settings/GameSettings.cpp index cddb68ab2..6ee003245 100644 --- a/Source/Project64-core/Settings/GameSettings.cpp +++ b/Source/Project64-core/Settings/GameSettings.cpp @@ -57,7 +57,7 @@ void CGameSettings::RefreshGameSettings() m_DelaySI = g_Settings->LoadBool(Game_DelaySI); m_DelayDP = g_Settings->LoadBool(Game_DelayDP); m_bFixedAudio = g_Settings->LoadBool(Game_FixedAudio); - m_bSyncToAudio = g_Settings->LoadBool(Game_SyncViaAudio); + m_bSyncToAudio = g_Settings->LoadBool(Game_SyncViaAudio) && g_Settings->LoadBool(Setting_SyncViaAudioEnabled); m_FullSpeed = g_Settings->LoadBool(Game_FullSpeed); m_b32Bit = g_Settings->LoadBool(Game_32Bit); #ifdef ANDROID diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp index 89c86c420..494908a7b 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp @@ -62,9 +62,17 @@ void CSettingTypeTempBool::Save(uint32_t /*Index*/, bool Value) m_changed = true; } -void CSettingTypeTempBool::Save(uint32_t /*Index*/, uint32_t /*Value*/) +void CSettingTypeTempBool::Save(uint32_t /*Index*/, uint32_t Value) { - g_Notify->BreakPoint(__FILE__, __LINE__); + if (Value == 0 || Value != 0) + { + m_value = Value != 0; + m_changed = true; + } + else + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } void CSettingTypeTempBool::Save(uint32_t /*Index*/, const std::string & /*Value*/) diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index af221c4d7..974a19bae 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -60,6 +60,7 @@ enum SettingID Setting_LanguageDirDefault, Setting_CurrentLanguage, Setting_EnableDisk, + Setting_SyncViaAudioEnabled, //Default Settings Default_RDRamSize, diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp index bb082f785..e26846f07 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp @@ -61,6 +61,10 @@ CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay) AddModCheckBox(GetDlgItem(IDC_SYNC_AUDIO), Default_SyncViaAudio); AddModCheckBox(GetDlgItem(IDC_ROM_FIXEDAUDIO), Default_FixedAudio); + if (!g_Settings->LoadBool(Setting_SyncViaAudioEnabled)) + { + GetDlgItem(IDC_SYNC_AUDIO).EnableWindow(false); + } UpdatePageSettings(); } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp index 78c413e54..5eddabfc8 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp @@ -89,6 +89,11 @@ CGameGeneralPage::CGameGeneralPage(HWND hParent, const RECT & rcDispay) TxtBox = AddModTextBox(GetDlgItem(IDC_OVER_CLOCK_MODIFIER), Game_OverClockModifier, false); TxtBox->SetTextField(GetDlgItem(IDC_OVER_CLOCK_MODIFIER_TEXT)); + if (!g_Settings->LoadBool(Setting_SyncViaAudioEnabled)) + { + GetDlgItem(IDC_SYNC_AUDIO).EnableWindow(false); + } + UpdatePageSettings(); }