diff --git a/plugins/spu2-x/src/Linux/CfgHelpers.cpp b/plugins/spu2-x/src/Linux/CfgHelpers.cpp index 8dd6825b53..28ed9e4c4e 100644 --- a/plugins/spu2-x/src/Linux/CfgHelpers.cpp +++ b/plugins/spu2-x/src/Linux/CfgHelpers.cpp @@ -16,15 +16,91 @@ */ #include "Dialogs.h" + #include + + wxConfigBase *oldConfig; + wxString path; + + wxFileConfig *setIni(const wchar_t* Section) + { + wxConfig *tempConfig; + + oldConfig = wxConfigBase::Get(false); + + tempConfig = new wxFileConfig(L"", L"", path, L"", wxCONFIG_USE_LOCAL_FILE); + wxConfigBase::Set(tempConfig); + tempConfig->SetPath(L"/"); + tempConfig->SetPath(Section); + return tempConfig; + } + + void writeIni(wxFileConfig *tempConfig) + { + tempConfig->Flush(); + + if (oldConfig != NULL) wxConfigBase::Set(oldConfig); + delete tempConfig; + } void CfgSetSettingsDir(const char* dir) { + path = wxString::FromAscii(dir) + L"spu2-x.ini"; + +} + +void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value) +{ + wxConfig *config = setIni(Section); + config->Write(Name, Value); + writeIni(config); +} + +void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value) +{ + wxConfig *config = setIni(Section); + config->Write(Name, Value); + writeIni(config); } void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data) { + wxConfig *config = setIni(Section); + config->Write(Name, Data); + writeIni(config); +} + +bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default) +{ + bool ret; + + wxConfig *config = setIni(Section); + config->Read(Name, &ret, Default); + writeIni(config); + + return ret; +} + +int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default) +{ + int ret; + + wxConfig *config = setIni(Section); + config->Read(Name, &ret, Default); + writeIni(config); + + return ret; +} + +void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, int DataSize, const wchar_t* Default) +{ + wxConfig *config = setIni(Section); + Data = config->Read(Name, Default); + writeIni(config); } void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default) { + wxString temp; + CfgReadStr(Section, Name, temp, DataSize, Default); + Data = temp.c_str(); } diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 4082370269..e411d27a4a 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -87,19 +87,67 @@ bool StereoExpansionEnabled = false; /*****************************************************************************/ void ReadSettings() -{ +{ + Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 1 ); + ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 ); + + timeStretchDisabled = CfgReadBool( L"OUTPUT", L"Disable_Timestretch", false ); + EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); + + StereoExpansionEnabled = CfgReadBool( L"OUTPUT", L"Enable_StereoExpansion", false ); + SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 150); + + wchar_t omodid[128]; + //CfgReadStr( L"OUTPUT", L"Output_Module", omodid, 127, PortaudioOut->GetIdent() ); + + // find the driver index of this module: + //OutputModule = FindOutputModuleById( omodid ); + + // Read DSOUNDOUT and WAVEOUT configs: + CfgReadStr( L"WAVEOUT", L"Device", Config_WaveOut.Device, 254, L"default" ); + Config_WaveOut.NumBuffers = CfgReadInt( L"WAVEOUT", L"Buffer_Count", 4 ); + + PortaudioOut->ReadSettings(); + + SoundtouchCfg::ReadSettings(); + //DebugConfig::ReadSettings(); + + // Sanity Checks + // ------------- + + Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX ); + + WriteSettings(); } /*****************************************************************************/ void WriteSettings() -{ +{ + CfgWriteInt(L"MIXING",L"Interpolation",Interpolation); + CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost); + + CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled); + + CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() ); + CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS); + CfgWriteBool(L"OUTPUT",L"Disable_Timestretch", timeStretchDisabled); + CfgWriteBool(L"OUTPUT",L"Enable_StereoExpansion", StereoExpansionEnabled); + + if( Config_WaveOut.Device.empty() ) Config_WaveOut.Device = L"default"; + CfgWriteStr(L"WAVEOUT",L"Device",Config_WaveOut.Device); + CfgWriteInt(L"WAVEOUT",L"Buffer_Count",Config_WaveOut.NumBuffers); + + PortaudioOut->WriteSettings(); + SoundtouchCfg::WriteSettings(); + //DebugConfig::WriteSettings(); } void configure() { - ReadSettings(); + ReadSettings(); + WriteSettings(); } void MessageBox(char const*, ...) diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index e99757b7b7..1efd4efbb3 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -96,9 +96,10 @@ namespace SoundtouchCfg static int SeekWindowMS = 16; static int OverlapMS = 7; - static void ReadSettings(); - static void WriteSettings(); - static void OpenDialog( uptr hWnd ); + /*static*/ void ReadSettings(); + /*static*/ void WriteSettings(); + /*static*/ void OpenDialog( uptr hWnd ); + static void ClampValues(); }; diff --git a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp index f81694d880..5a90ca0666 100644 --- a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp +++ b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp @@ -42,18 +42,19 @@ void ApplySettings( soundtouch::SoundTouch& sndtouch ) void ReadSettings() { - //SequenceLenMS = CfgReadInt( L"SOUNDTOUCH", L"SequenceLengthMS", 63 ); - //SeekWindowMS = CfgReadInt( L"SOUNDTOUCH", L"SeekWindowMS", 16 ); - //OverlapMS = CfgReadInt( L"SOUNDTOUCH", L"OverlapMS", 7 ); + SequenceLenMS = CfgReadInt( L"SOUNDTOUCH", L"SequenceLengthMS", 63 ); + SeekWindowMS = CfgReadInt( L"SOUNDTOUCH", L"SeekWindowMS", 16 ); + OverlapMS = CfgReadInt( L"SOUNDTOUCH", L"OverlapMS", 7 ); - ClampValues(); + ClampValues(); + WriteSettings(); } void WriteSettings() { - //CfgWriteInt( L"SOUNDTOUCH", L"SequenceLengthMS", SequenceLenMS ); - //CfgWriteInt( L"SOUNDTOUCH", L"SeekWindowMS", SeekWindowMS ); - //CfgWriteInt( L"SOUNDTOUCH", L"OverlapMS", OverlapMS ); + CfgWriteInt( L"SOUNDTOUCH", L"SequenceLengthMS", SequenceLenMS ); + CfgWriteInt( L"SOUNDTOUCH", L"SeekWindowMS", SeekWindowMS ); + CfgWriteInt( L"SOUNDTOUCH", L"OverlapMS", OverlapMS ); } /*bool CALLBACK SoundtouchCfg::DialogProc(uptr hWnd,u32 uMsg,uptr wParam,uptr lParam) @@ -62,5 +63,7 @@ void WriteSettings() void OpenDialog( uptr hWnd ) { + ReadSettings(); + WriteSettings(); } } diff --git a/plugins/spu2-x/src/Linux/Dialogs.h b/plugins/spu2-x/src/Linux/Dialogs.h index 6e3b3970b2..20e62c5662 100644 --- a/plugins/spu2-x/src/Linux/Dialogs.h +++ b/plugins/spu2-x/src/Linux/Dialogs.h @@ -23,13 +23,13 @@ extern void CfgSetSettingsDir(const char* dir); -//extern void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value); -//extern void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value); +extern void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value); +extern void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value); extern void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data); -//extern bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default); +extern bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default); extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default); //extern void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, int DataSize, const wchar_t* Default); -//extern int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default); +extern int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default); #endif