[Project64] Try to fix sync to audio

This commit is contained in:
zilmar 2018-12-20 20:49:14 +10:30
parent 9ab7a83c26
commit eddd90bbeb
7 changed files with 36 additions and 12 deletions

View File

@ -65,6 +65,10 @@ EXPORT void CALL PluginLoaded(void)
{
PluginInit();
WriteTrace(TraceAudioInterface, TraceDebug, "Called");
if (g_settings != NULL)
{
g_settings->SetSyncViaAudioEnabled(true);
}
}
EXPORT void CALL AiDacrateChanged(int SystemType)

View File

@ -16,6 +16,7 @@
CSettings * g_settings = NULL;
CSettings::CSettings() :
m_Set_SyncViaAudioEnabled(0),
m_Set_EnableAudio(0),
m_Set_FixedAudio(0),
m_Set_SyncAudio(0),
@ -81,11 +82,7 @@ CSettings::~CSettings()
void CSettings::RegisterSettings(void)
{
SetModuleName("default");
short Set_SyncViaAudioEnabled = FindSystemSettingId("SyncViaAudioEnabled");
if (Set_SyncViaAudioEnabled != 0)
{
SetSystemSetting(Set_SyncViaAudioEnabled, 1);
}
m_Set_SyncViaAudioEnabled = FindSystemSettingId("SyncViaAudioEnabled");
m_Set_EnableAudio = FindSystemSettingId("Enable Audio");
m_Set_FixedAudio = FindSystemSettingId("Fixed Audio");
m_Set_SyncAudio = FindSystemSettingId("Sync Audio");
@ -109,6 +106,14 @@ void CSettings::RegisterSettings(void)
LogLevelChanged();
}
void CSettings::SetSyncViaAudioEnabled(bool Enabled)
{
if (m_Set_SyncViaAudioEnabled != 0)
{
SetSystemSetting(m_Set_SyncViaAudioEnabled, Enabled ? 1 : 0);
}
}
void CSettings::SetAudioEnabled(bool Enabled)
{
if (m_Set_EnableAudio != 0)

View File

@ -26,6 +26,7 @@ public:
inline bool FlushLogs(void) const { return m_FlushLogs; }
inline const char * log_dir(void) const { return m_log_dir; }
void SetSyncViaAudioEnabled(bool Enabled);
void SetAudioEnabled(bool Enabled);
void SetVolume(uint32_t Volume);
void SetTinyBuffer(bool TinyBuffer);
@ -45,6 +46,7 @@ private:
void RegisterSettings(void);
void LogLevelChanged(void);
short m_Set_SyncViaAudioEnabled;
short m_Set_EnableAudio;
short m_Set_FixedAudio;
short m_Set_SyncAudio;

View File

@ -37,6 +37,8 @@ CAudioPlugin::~CAudioPlugin()
bool CAudioPlugin::LoadFunctions(void)
{
g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false);
// Find entries for functions in DLL
void(CALL *InitiateAudio)(void);
LoadFunction(InitiateAudio);
@ -62,7 +64,6 @@ bool CAudioPlugin::LoadFunctions(void)
bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
{
g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false);
struct AUDIO_INFO
{
void * hwnd;

View File

@ -363,6 +363,11 @@ bool CPlugins::Reset(CN64System * System)
if (!m_RSP->Initiate(this, System)) { return false; }
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done");
}
if (System)
{
System->RefreshSyncToAudio();
}
WriteTrace(TracePlugins, TraceDebug, "Done");
return true;
}

View File

@ -57,7 +57,6 @@ 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) && g_Settings->LoadBool(Setting_SyncViaAudioEnabled);
m_FullSpeed = g_Settings->LoadBool(Game_FullSpeed);
m_b32Bit = g_Settings->LoadBool(Game_32Bit);
#ifdef ANDROID
@ -79,6 +78,7 @@ void CGameSettings::RefreshGameSettings()
}
if (m_OverClockModifier < 1) { m_OverClockModifier = 1; }
if (m_OverClockModifier > 20) { m_OverClockModifier = 20; }
RefreshSyncToAudio();
WriteTrace(TraceN64System, TraceDebug, "Done");
}
@ -87,3 +87,8 @@ void CGameSettings::SpeedChanged(int SpeedLimit)
m_FullSpeed = (g_System->m_SystemType == SYSTEM_PAL ? 50 : 60) == SpeedLimit;
g_Settings->SaveBool(Game_FullSpeed, m_FullSpeed);
}
void CGameSettings::RefreshSyncToAudio(void)
{
m_bSyncToAudio = g_Settings->LoadBool(Game_SyncViaAudio) && g_Settings->LoadBool(Setting_SyncViaAudioEnabled);
}

View File

@ -45,6 +45,8 @@ public:
inline static CPU_TYPE CpuType(void) { return m_CpuType; }
inline static uint32_t OverClockModifier(void) { return m_OverClockModifier; }
void RefreshSyncToAudio(void);
protected:
static void SpeedChanged(int32_t SpeedLimit);