diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj b/Source/Core/AudioCommon/AudioCommon.vcxproj index a983005318..abb5dbf505 100644 --- a/Source/Core/AudioCommon/AudioCommon.vcxproj +++ b/Source/Core/AudioCommon/AudioCommon.vcxproj @@ -191,7 +191,6 @@ - @@ -204,7 +203,6 @@ - diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters index af5fe12220..30ff35a073 100644 --- a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters +++ b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters @@ -3,7 +3,6 @@ - @@ -26,7 +25,6 @@ - diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index 0e610bd847..3b6d0cea4d 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -1,5 +1,4 @@ set(SRCS Src/AudioCommon.cpp - Src/AudioCommonConfig.cpp Src/DPL2Decoder.cpp Src/Mixer.cpp Src/WaveFile.cpp diff --git a/Source/Core/AudioCommon/Src/AudioCommon.cpp b/Source/Core/AudioCommon/Src/AudioCommon.cpp index 99ae42b93a..e14b9ac45e 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.cpp +++ b/Source/Core/AudioCommon/Src/AudioCommon.cpp @@ -27,6 +27,10 @@ #include "OpenALStream.h" #include "PulseAudioStream.h" #include "../../Core/Src/Movie.h" +#include "../../Core/Src/ConfigManager.h" + +// This shouldn't be a global, at least not here. +SoundStream *soundStream; namespace AudioCommon { @@ -34,7 +38,7 @@ namespace AudioCommon { // TODO: possible memleak with mixer - std::string backend = ac_Config.sBackend; + std::string backend = SConfig::GetInstance().sBackend; if (backend == BACKEND_OPENAL && OpenALStream::isValid()) soundStream = new OpenALStream(mixer); else if (backend == BACKEND_NULLSOUND && NullSound::isValid()) @@ -54,10 +58,10 @@ namespace AudioCommon if (soundStream != NULL) { - ac_Config.Update(); + UpdateSoundStream(); if (soundStream->Start()) { - if (ac_Config.m_DumpAudio) + if (SConfig::GetInstance().m_DumpAudio) { std::string audio_file_name = File::GetUserPath(D_DUMPAUDIO_IDX) + "audiodump.wav"; File::CreateFullPath(audio_file_name); @@ -82,7 +86,7 @@ namespace AudioCommon if (soundStream) { soundStream->Stop(); - if (ac_Config.m_DumpAudio) + if (SConfig::GetInstance().m_DumpAudio) soundStream->GetMixer()->StopLogAudio(); //soundStream->StopLogAudio(); delete soundStream; @@ -122,7 +126,7 @@ namespace AudioCommon { return true; } - return ac_Config.m_EnableJIT; + return SConfig::GetInstance().m_EnableJIT; } void PauseAndLock(bool doLock, bool unpauseOnUnlock) @@ -143,4 +147,12 @@ namespace AudioCommon } } } + void UpdateSoundStream() + { + if (soundStream) + { + soundStream->GetMixer()->SetThrottle(SConfig::GetInstance().m_Framelimit == 2); + soundStream->SetVolume(SConfig::GetInstance().m_Volume); + } + } } diff --git a/Source/Core/AudioCommon/Src/AudioCommon.h b/Source/Core/AudioCommon/Src/AudioCommon.h index e7a111b0a1..b7b32e7498 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.h +++ b/Source/Core/AudioCommon/Src/AudioCommon.h @@ -19,14 +19,12 @@ #define _AUDIO_COMMON_H_ #include "Common.h" -#include "AudioCommonConfig.h" #include "SoundStream.h" class CMixer; extern SoundStream *soundStream; -extern AudioCommonConfig ac_Config; // UDSPControl union UDSPControl @@ -60,6 +58,7 @@ namespace AudioCommon std::vector GetSoundBackends(); bool UseJIT(); void PauseAndLock(bool doLock, bool unpauseOnUnlock=true); + void UpdateSoundStream(); } #endif // _AUDIO_COMMON_H_ diff --git a/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp b/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp deleted file mode 100644 index 49f50b6880..0000000000 --- a/Source/Core/AudioCommon/Src/AudioCommonConfig.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include "AudioCommon.h" -#include "CommonPaths.h" -#include "FileUtil.h" -#include "../../Core/Src/ConfigManager.h" - -AudioCommonConfig ac_Config; - -// This shouldn't be a global, at least not here. -SoundStream *soundStream; - -// Load from given file -void AudioCommonConfig::Load() -{ - IniFile file; - file.Load(File::GetUserPath(F_DSPCONFIG_IDX)); - - file.Get("Config", "EnableJIT", &m_EnableJIT, true); - file.Get("Config", "DumpAudio", &m_DumpAudio, false); -#if defined __linux__ && HAVE_ALSA - file.Get("Config", "Backend", &sBackend, BACKEND_ALSA); -#elif defined __APPLE__ - file.Get("Config", "Backend", &sBackend, BACKEND_COREAUDIO); -#elif defined _WIN32 - file.Get("Config", "Backend", &sBackend, BACKEND_DIRECTSOUND); -#else - file.Get("Config", "Backend", &sBackend, BACKEND_NULLSOUND); -#endif - file.Get("Config", "Volume", &m_Volume, 100); -} - -// Set the values for the file -void AudioCommonConfig::SaveSettings() -{ - IniFile file; - file.Load(File::GetUserPath(F_DSPCONFIG_IDX)); - - file.Set("Config", "EnableJIT", m_EnableJIT); - file.Set("Config", "DumpAudio", m_DumpAudio); - file.Set("Config", "Backend", sBackend); - file.Set("Config", "Volume", m_Volume); - - file.Save(File::GetUserPath(F_DSPCONFIG_IDX)); -} - -// Update according to the values (stream/mixer) -void AudioCommonConfig::Update() { - if (soundStream) { - soundStream->GetMixer()->SetThrottle(SConfig::GetInstance().m_Framelimit == 2); - soundStream->SetVolume(m_Volume); - } -} diff --git a/Source/Core/AudioCommon/Src/AudioCommonConfig.h b/Source/Core/AudioCommon/Src/AudioCommonConfig.h deleted file mode 100644 index 48807b3ffd..0000000000 --- a/Source/Core/AudioCommon/Src/AudioCommonConfig.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef _AUDIO_COMMON_CONFIG_H_ -#define _AUDIO_COMMON_CONFIG_H_ - -#include -#include "IniFile.h" - -// Backend Types -#define BACKEND_NULLSOUND "No audio output" -#define BACKEND_ALSA "ALSA" -#define BACKEND_AOSOUND "AOSound" -#define BACKEND_COREAUDIO "CoreAudio" -#define BACKEND_DIRECTSOUND "DSound" -#define BACKEND_OPENAL "OpenAL" -#define BACKEND_PULSEAUDIO "Pulse" -#define BACKEND_XAUDIO2 "XAudio2" - -struct AudioCommonConfig -{ - bool m_EnableJIT; - bool m_DumpAudio; - int m_Volume; - std::string sBackend; - - // Load from given file - void Load(); - - // Self explanatory - void SaveSettings(); - - // Update according to the values (stream/mixer) - void Update(); -}; - -#endif //AUDIO_COMMON_CONFIG diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index c39056a946..9e14d7cf7e 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -94,7 +94,6 @@ // Filenames // Files in the directory returned by GetUserPath(D_CONFIG_IDX) #define DOLPHIN_CONFIG "Dolphin.ini" -#define DSP_CONFIG "DSP.ini" #define DEBUGGER_CONFIG "Debugger.ini" #define LOGGER_CONFIG "Logger.ini" diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index acd4588126..d7b248a722 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -681,7 +681,6 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath) paths[D_THEMES_IDX] = paths[D_USER_IDX] + THEMES_DIR DIR_SEP; paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP; paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG; - paths[F_DSPCONFIG_IDX] = paths[D_CONFIG_IDX] + DSP_CONFIG; paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 0947db4f5c..451b1b6929 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -52,7 +52,6 @@ enum { D_WIISYSCONF_IDX, D_THEMES_IDX, F_DOLPHINCONFIG_IDX, - F_DSPCONFIG_IDX, F_DEBUGGERCONFIG_IDX, F_LOGGERCONFIG_IDX, F_MAINLOG_IDX, diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index a4f45f4ffc..9cd768992f 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -256,6 +256,12 @@ void SConfig::SaveSettings() ini.Set("Movie", "PauseMovie", m_PauseMovie); ini.Set("Movie", "Author", m_strMovieAuthor); + // DSP + ini.Set("DSP", "EnableJIT", m_EnableJIT); + ini.Set("DSP", "DumpAudio", m_DumpAudio); + ini.Set("DSP", "Backend", sBackend); + ini.Set("DSP", "Volume", m_Volume); + ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); m_SYSCONF->Save(); } @@ -404,6 +410,20 @@ void SConfig::LoadSettings() // Movie ini.Get("General", "PauseMovie", &m_PauseMovie, false); ini.Get("Movie", "Author", &m_strMovieAuthor, ""); + + // DSP + ini.Get("Config", "EnableJIT", &m_EnableJIT, true); + ini.Get("Config", "DumpAudio", &m_DumpAudio, false); + #if defined __linux__ && HAVE_ALSA + ini.Get("Config", "Backend", &sBackend, BACKEND_ALSA); + #elif defined __APPLE__ + ini.Get("Config", "Backend", &sBackend, BACKEND_COREAUDIO); + #elif defined _WIN32 + ini.Get("Config", "Backend", &sBackend, BACKEND_DIRECTSOUND); + #else + ini.Get("Config", "Backend", &sBackend, BACKEND_NULLSOUND); + #endif + ini.Get("Config", "Volume", &m_Volume, 100); } m_SYSCONF = new SysConf(); diff --git a/Source/Core/Core/Src/ConfigManager.h b/Source/Core/Core/Src/ConfigManager.h index cbe1b4d1cb..e92d29ee65 100644 --- a/Source/Core/Core/Src/ConfigManager.h +++ b/Source/Core/Core/Src/ConfigManager.h @@ -26,6 +26,16 @@ #include "HW/SI_Device.h" #include "SysConf.h" +// DSP Backend Types +#define BACKEND_NULLSOUND "No audio output" +#define BACKEND_ALSA "ALSA" +#define BACKEND_AOSOUND "AOSound" +#define BACKEND_COREAUDIO "CoreAudio" +#define BACKEND_DIRECTSOUND "DSound" +#define BACKEND_OPENAL "OpenAL" +#define BACKEND_PULSEAUDIO "Pulse" +#define BACKEND_XAUDIO2 "XAudio2" + struct SConfig : NonCopyable { // Wii Devices @@ -83,6 +93,12 @@ struct SConfig : NonCopyable bool m_ShowLag; std::string m_strMovieAuthor; + // DSP settings + bool m_EnableJIT; + bool m_DumpAudio; + int m_Volume; + std::string sBackend; + SysConf* m_SYSCONF; // save settings diff --git a/Source/Core/Core/Src/DSPEmulator.cpp b/Source/Core/Core/Src/DSPEmulator.cpp index 2f1c7649a7..907eb225b3 100644 --- a/Source/Core/Core/Src/DSPEmulator.cpp +++ b/Source/Core/Core/Src/DSPEmulator.cpp @@ -22,8 +22,6 @@ DSPEmulator *CreateDSPEmulator(bool HLE) { - ac_Config.Load(); - if (HLE) { return new DSPHLE(); diff --git a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp index 7981c677a8..b22be91104 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp @@ -26,6 +26,7 @@ #include "DSPHLE.h" #include "UCodes/UCodes.h" #include "../AudioInterface.h" +#include "ConfigManager.h" DSPHLE::DSPHLE() { m_InitMixer = false; diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index db5f76b684..ae07eb78b8 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -321,9 +321,6 @@ void CConfigMain::InitializeGUIValues() { const SCoreStartupParameter& startup_params = SConfig::GetInstance().m_LocalCoreStartupParameter; - // Load DSP Settings. - ac_Config.Load(); - // General - Basic CPUThread->SetValue(startup_params.bCPUThread); SkipIdle->SetValue(startup_params.bSkipIdle); @@ -354,17 +351,17 @@ void CConfigMain::InitializeGUIValues() if (startup_params.bDSPHLE) DSPEngine->SetSelection(0); else - DSPEngine->SetSelection(ac_Config.m_EnableJIT ? 1 : 2); + DSPEngine->SetSelection(SConfig::GetInstance().m_EnableJIT ? 1 : 2); // Audio - VolumeSlider->Enable(SupportsVolumeChanges(ac_Config.sBackend)); - VolumeSlider->SetValue(ac_Config.m_Volume); - VolumeText->SetLabel(wxString::Format(wxT("%d %%"), ac_Config.m_Volume)); + VolumeSlider->Enable(SupportsVolumeChanges(SConfig::GetInstance().sBackend)); + VolumeSlider->SetValue(SConfig::GetInstance().m_Volume); + VolumeText->SetLabel(wxString::Format(wxT("%d %%"), SConfig::GetInstance().m_Volume)); DSPThread->SetValue(startup_params.bDSPThread); - DumpAudio->SetValue(ac_Config.m_DumpAudio ? true : false); - DPL2Decoder->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL); + DumpAudio->SetValue(SConfig::GetInstance().m_DumpAudio ? true : false); + DPL2Decoder->Enable(std::string(SConfig::GetInstance().sBackend) == BACKEND_OPENAL); DPL2Decoder->SetValue(startup_params.bDPL2Decoder); - Latency->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL); + Latency->Enable(std::string(SConfig::GetInstance().sBackend) == BACKEND_OPENAL); Latency->SetValue(startup_params.iLatency); // add backends to the list AddAudioBackends(); @@ -858,9 +855,6 @@ void CConfigMain::OnOk(wxCommandEvent& WXUNUSED (event)) // Save the config. Dolphin crashes to often to save the settings on closing only SConfig::GetInstance().SaveSettings(); - - // Save Audio settings - ac_Config.SaveSettings(); } // Core settings @@ -880,7 +874,7 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event) break; case ID_FRAMELIMIT: SConfig::GetInstance().m_Framelimit = Framelimit->GetSelection(); - ac_Config.Update(); + AudioCommon::UpdateSoundStream(); break; case ID_FRAMELIMIT_USEFPSFORLIMITING: SConfig::GetInstance().b_UseFPS = UseFPSForLimiting->IsChecked(); @@ -938,13 +932,13 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event) case ID_DSPENGINE: SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = DSPEngine->GetSelection() == 0; if (!DSPEngine->GetSelection() == 0) - ac_Config.m_EnableJIT = DSPEngine->GetSelection() == 1; - ac_Config.Update(); + SConfig::GetInstance().m_EnableJIT = DSPEngine->GetSelection() == 1; + AudioCommon::UpdateSoundStream(); break; case ID_VOLUME: - ac_Config.m_Volume = VolumeSlider->GetValue(); - ac_Config.Update(); + SConfig::GetInstance().m_Volume = VolumeSlider->GetValue(); + AudioCommon::UpdateSoundStream(); VolumeText->SetLabel(wxString::Format(wxT("%d %%"), VolumeSlider->GetValue())); break; @@ -960,8 +954,8 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event) VolumeSlider->Enable(SupportsVolumeChanges(std::string(BackendSelection->GetStringSelection().mb_str()))); Latency->Enable(std::string(BackendSelection->GetStringSelection().mb_str()) == BACKEND_OPENAL); DPL2Decoder->Enable(std::string(BackendSelection->GetStringSelection().mb_str()) == BACKEND_OPENAL); - ac_Config.sBackend = BackendSelection->GetStringSelection().mb_str(); - ac_Config.Update(); + SConfig::GetInstance().sBackend = BackendSelection->GetStringSelection().mb_str(); + AudioCommon::UpdateSoundStream(); break; case ID_LATENCY: @@ -969,7 +963,7 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event) break; default: - ac_Config.m_DumpAudio = DumpAudio->GetValue(); + SConfig::GetInstance().m_DumpAudio = DumpAudio->GetValue(); break; } } @@ -983,7 +977,7 @@ void CConfigMain::AddAudioBackends() { BackendSelection->Append(wxString::FromAscii((*iter).c_str())); int num = BackendSelection->\ - FindString(wxString::FromAscii(ac_Config.sBackend.c_str())); + FindString(wxString::FromAscii(SConfig::GetInstance().sBackend.c_str())); BackendSelection->SetSelection(num); } }