mirror of
https://github.com/libretro/Play-.git
synced 2025-01-09 18:10:57 +00:00
PsfPlayer: Added saving of selected SoundHandler.
git-svn-id: http://svn.purei.org/purei/trunk@648 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
parent
48cb333dac
commit
ade6b91dcd
@ -1,17 +1,56 @@
|
||||
#include "AppConfig.h"
|
||||
|
||||
#define DEFAULT_CONFIG_PATH L"config.xml"
|
||||
|
||||
using namespace Framework;
|
||||
using namespace boost;
|
||||
|
||||
CAppConfig::CAppConfig() :
|
||||
CConfig(CConfig::PathType(DEFAULT_CONFIG_PATH))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAppConfig::~CAppConfig()
|
||||
{
|
||||
|
||||
}
|
||||
#include "AppConfig.h"
|
||||
#include "PathUtils.h"
|
||||
#include "Utf8.h"
|
||||
#if !defined(WIN32)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#define BASE_DATA_PATH L"PsfPlayer Data Files"
|
||||
#define DEFAULT_CONFIG_PATH (L"config.xml")
|
||||
|
||||
CAppConfig::CAppConfig() :
|
||||
CConfig(BuildConfigPath())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAppConfig::~CAppConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Framework::CConfig::PathType CAppConfig::GetBasePath()
|
||||
{
|
||||
#if defined(WIN32)
|
||||
return (Framework::PathUtils::GetPersonalDataPath() / BASE_DATA_PATH);
|
||||
#elif defined(MACOSX)
|
||||
return (Utf8ToPath(Framework::PathUtils::GetHomePath().string().c_str()) / BASE_DATA_PATH);
|
||||
#else
|
||||
return CConfig::PathType();
|
||||
#endif
|
||||
}
|
||||
|
||||
Framework::CConfig::PathType CAppConfig::Utf8ToPath(const char* path)
|
||||
{
|
||||
return CConfig::PathType(Framework::Utf8::ConvertFrom(path));
|
||||
}
|
||||
|
||||
std::string CAppConfig::PathToUtf8(const CConfig::PathType& path)
|
||||
{
|
||||
return Framework::Utf8::ConvertTo(path.string());
|
||||
}
|
||||
|
||||
Framework::CConfig::PathType CAppConfig::BuildConfigPath()
|
||||
{
|
||||
#if defined(MACOSX)
|
||||
passwd* userInfo = getpwuid(getuid());
|
||||
if(userInfo == NULL) return DEFAULT_CONFIG_PATH;
|
||||
return wstring(Utf8::ConvertFrom(userInfo->pw_dir)) + L"/Library/Preferences/com.vapps.Purei.xml";
|
||||
#elif defined(WIN32)
|
||||
CConfig::PathType userPath(GetBasePath());
|
||||
Framework::PathUtils::EnsurePathExists(userPath);
|
||||
return (userPath / L"config.xml");
|
||||
#else
|
||||
return DEFAULT_CONFIG_PATH;
|
||||
#endif
|
||||
}
|
||||
|
@ -9,9 +9,16 @@ class CAppConfig : public Framework::CConfig, public CSingleton<CAppConfig>
|
||||
public:
|
||||
friend class CSingleton<CAppConfig>;
|
||||
|
||||
static CConfig::PathType GetBasePath();
|
||||
|
||||
static CConfig::PathType Utf8ToPath(const char*);
|
||||
static std::string PathToUtf8(const CConfig::PathType&);
|
||||
|
||||
private:
|
||||
CAppConfig();
|
||||
virtual ~CAppConfig();
|
||||
|
||||
static CConfig::PathType BuildConfigPath();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -27,7 +27,10 @@
|
||||
#define PSF2_FILTER _T("PlayStation2 Sound Files (*.psf2; *.minipsf2)\0*.psf2; *.minipsf2\0")
|
||||
#define PSFP_FILTER _T("PlayStation Portable Sound Files (*.psfp; *.minipsfp)\0*.psfp; *.minipsfp\0")
|
||||
|
||||
CMainWindow::SPUHANDLER_INFO CMainWindow::m_handlerInfo[] =
|
||||
#define PREF_SOUNDHANDLER_ID ("soundhandler.id")
|
||||
#define DEFAULT_SOUND_HANDLER_ID (1)
|
||||
|
||||
CMainWindow::SOUNDHANDLER_INFO CMainWindow::m_handlerInfo[] =
|
||||
{
|
||||
{ 1, _T("Win32 WaveOut"), _T("SH_WaveOut.dll") },
|
||||
{ 2, _T("OpenAL"), _T("SH_OpenAL.dll") },
|
||||
@ -41,7 +44,7 @@ CMainWindow::CMainWindow(CPsfVm& virtualMachine) :
|
||||
m_virtualMachine(virtualMachine),
|
||||
m_ready(false),
|
||||
m_frames(0),
|
||||
m_selectedAudioHandler(0),
|
||||
m_selectedAudioPlugin(DEFAULT_SOUND_HANDLER_ID),
|
||||
m_ejectButton(NULL),
|
||||
m_pauseButton(NULL),
|
||||
m_repeatButton(NULL),
|
||||
@ -56,7 +59,10 @@ m_repeatMode(PLAYLIST_ONCE),
|
||||
m_trackLength(0),
|
||||
m_accel(CreateAccelerators())
|
||||
{
|
||||
for(unsigned int i = 0; i < MAX_PANELS; i++)
|
||||
CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_SOUNDHANDLER_ID, DEFAULT_SOUND_HANDLER_ID);
|
||||
LoadAudioPluginPreferences();
|
||||
|
||||
for(unsigned int i = 0; i < MAX_PANELS; i++)
|
||||
{
|
||||
m_panels[i] = NULL;
|
||||
}
|
||||
@ -79,7 +85,7 @@ m_accel(CreateAccelerators())
|
||||
|
||||
m_virtualMachine.OnNewFrame.connect(std::tr1::bind(&CMainWindow::OnNewFrame, this));
|
||||
|
||||
ChangeAudioPlugin(0);
|
||||
ChangeAudioPlugin(FindAudioPlugin(m_selectedAudioPlugin));
|
||||
|
||||
m_timerLabel = new Win32::CStatic(m_hWnd, _T(""), SS_CENTER);
|
||||
m_titleLabel = new Win32::CStatic(m_hWnd, _T(""), SS_CENTER | SS_NOPREFIX);
|
||||
@ -523,14 +529,38 @@ void CMainWindow::UpdateAudioPluginMenu()
|
||||
for(unsigned int i = 0; m_handlerInfo[i].name != NULL; i++)
|
||||
{
|
||||
Win32::CMenuItem pluginSubMenuEntry(Win32::CMenuItem::FindById(m_popupMenu, ID_FILE_AUDIOPLUGIN_PLUGIN_0 + i));
|
||||
pluginSubMenuEntry.Check(m_handlerInfo[i].id == m_selectedAudioHandler);
|
||||
pluginSubMenuEntry.Check(m_handlerInfo[i].id == m_selectedAudioPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
void CMainWindow::LoadAudioPluginPreferences()
|
||||
{
|
||||
int audioHandlerId = CAppConfig::GetInstance().GetPreferenceInteger(PREF_SOUNDHANDLER_ID);
|
||||
int audioHandlerIdx = FindAudioPlugin(audioHandlerId);
|
||||
if(audioHandlerIdx == -1)
|
||||
{
|
||||
m_selectedAudioPlugin = DEFAULT_SOUND_HANDLER_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_selectedAudioPlugin = audioHandlerId;
|
||||
}
|
||||
}
|
||||
|
||||
int CMainWindow::FindAudioPlugin(unsigned int pluginId)
|
||||
{
|
||||
for(unsigned int i = 0; m_handlerInfo[i].name != NULL; i++)
|
||||
{
|
||||
if(m_handlerInfo[i].id == pluginId) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CMainWindow::ChangeAudioPlugin(unsigned int pluginIdx)
|
||||
{
|
||||
SPUHANDLER_INFO* handlerInfo = m_handlerInfo + pluginIdx;
|
||||
m_selectedAudioHandler = handlerInfo->id;
|
||||
SOUNDHANDLER_INFO* handlerInfo = m_handlerInfo + pluginIdx;
|
||||
m_selectedAudioPlugin = handlerInfo->id;
|
||||
CAppConfig::GetInstance().SetPreferenceInteger(PREF_SOUNDHANDLER_ID, m_selectedAudioPlugin);
|
||||
m_virtualMachine.SetSpuHandler(std::tr1::bind(&CMainWindow::CreateHandler, this, handlerInfo->dllName));
|
||||
UpdateAudioPluginMenu();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
TRACK_REPEAT,
|
||||
};
|
||||
|
||||
struct SPUHANDLER_INFO
|
||||
struct SOUNDHANDLER_INFO
|
||||
{
|
||||
int id;
|
||||
const TCHAR* name;
|
||||
@ -90,6 +90,8 @@ private:
|
||||
void Reset();
|
||||
void ActivatePanel(unsigned int);
|
||||
|
||||
void LoadAudioPluginPreferences();
|
||||
int FindAudioPlugin(unsigned int);
|
||||
void ChangeAudioPlugin(unsigned int);
|
||||
|
||||
HACCEL CreateAccelerators();
|
||||
@ -130,10 +132,10 @@ private:
|
||||
uint64 m_trackLength;
|
||||
uint64 m_fadePosition;
|
||||
float m_volumeAdjust;
|
||||
int m_selectedAudioHandler;
|
||||
int m_selectedAudioPlugin;
|
||||
REPEAT_MODE m_repeatMode;
|
||||
|
||||
static SPUHANDLER_INFO m_handlerInfo[];
|
||||
static SOUNDHANDLER_INFO m_handlerInfo[];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user