From c942e3aaca441fa0c83abc6914771a3574c18a2a Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Mon, 16 Nov 2009 17:14:10 +0000 Subject: [PATCH] * Implemented more support for on-the-fly CDVD source changes (not well tested, probably need work). * Fix Reelease mode compilation errors. * More misc bugfixes to the UI. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2207 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/src/Utilities/Windows/WinThreads.cpp | 2 +- pcsx2/CDVD/CDVDaccess.cpp | 5 ++++ pcsx2/CDVD/CDVDaccess.h | 1 + pcsx2/System/SysCoreThread.cpp | 26 +++++++++++++++------ pcsx2/System/SysThreads.h | 1 + pcsx2/gui/App.h | 1 + pcsx2/gui/AppCoreThread.cpp | 9 +++++++ pcsx2/gui/AppRes.cpp | 4 ++-- pcsx2/gui/IsoDropTarget.cpp | 4 +++- pcsx2/gui/MainMenuClicks.cpp | 7 +----- plugins/spu2-x/src/PS2E-spu2.cpp | 3 ++- 11 files changed, 45 insertions(+), 18 deletions(-) diff --git a/common/src/Utilities/Windows/WinThreads.cpp b/common/src/Utilities/Windows/WinThreads.cpp index 744008b49c..513714349d 100644 --- a/common/src/Utilities/Windows/WinThreads.cpp +++ b/common/src/Utilities/Windows/WinThreads.cpp @@ -32,7 +32,7 @@ __forceinline void Threading::SpinWait() __forceinline void Threading::EnableHiresScheduler() { - // This improves accuracy of Sleep() by some amount, and only adds a negligable amount of + // This improves accuracy of Sleep() by some amount, and only adds a negligible amount of // overhead on modern CPUs. Typically desktops are already set pretty low, but laptops in // particular may have a scheduler Period of 15 or 20ms to extend battery life. diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index da91b2e959..e4b592fddb 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -268,6 +268,11 @@ void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile ) m_SourceFilename[srctype] = newfile; } +CDVD_SourceType CDVDsys_GetSourceType() +{ + return m_CurrentSourceType; +} + void CDVDsys_ChangeSource( CDVD_SourceType type ) { GetPluginManager().Close( PluginId_CDVD ); diff --git a/pcsx2/CDVD/CDVDaccess.h b/pcsx2/CDVD/CDVDaccess.h index 48f47556d3..142034da11 100644 --- a/pcsx2/CDVD/CDVDaccess.h +++ b/pcsx2/CDVD/CDVDaccess.h @@ -69,6 +69,7 @@ extern const wxChar* CDVD_SourceLabels[]; extern void CDVDsys_ChangeSource( CDVD_SourceType type ); extern void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile ); +extern CDVD_SourceType CDVDsys_GetSourceType(); extern bool DoCDVDopen(); extern void DoCDVDclose(); diff --git a/pcsx2/System/SysCoreThread.cpp b/pcsx2/System/SysCoreThread.cpp index f9810805ef..19ea5751be 100644 --- a/pcsx2/System/SysCoreThread.cpp +++ b/pcsx2/System/SysCoreThread.cpp @@ -35,13 +35,13 @@ static __threadlocal SysCoreThread* tls_coreThread = NULL; // (Called from outside the context of this thread) // -------------------------------------------------------------------------------------- -SysCoreThread::SysCoreThread() : - m_resetRecompilers( true ) -, m_resetProfilers( true ) -, m_resetVirtualMachine( true ) -, m_hasValidState( false ) +SysCoreThread::SysCoreThread() { - m_name = L"EE Core"; + m_name = L"EE Core"; + m_resetRecompilers = true; + m_resetProfilers = true; + m_resetVirtualMachine = true; + m_hasValidState = false; } SysCoreThread::~SysCoreThread() throw() @@ -119,8 +119,20 @@ void SysCoreThread::ApplySettings( const Pcsx2Config& src ) if( resumeWhenDone ) Resume(); } +void SysCoreThread::ChangeCdvdSource( CDVD_SourceType type ) +{ + if( type == CDVDsys_GetSourceType() ) return; + + // Fast change of the CDVD source only -- a Pause will suffice. + + bool resumeWhenDone = Pause(); + GetPluginManager().Close( PluginId_CDVD ); + CDVDsys_ChangeSource( type ); + if( resumeWhenDone ) Resume(); +} + // -------------------------------------------------------------------------------------- -// EECoreThread *Worker* Implementations +// SysCoreThread *Worker* Implementations // (Called from the context of this thread only) // -------------------------------------------------------------------------------------- SysCoreThread& SysCoreThread::Get() diff --git a/pcsx2/System/SysThreads.h b/pcsx2/System/SysThreads.h index 44e9625317..cc28f6cee6 100644 --- a/pcsx2/System/SysThreads.h +++ b/pcsx2/System/SysThreads.h @@ -220,6 +220,7 @@ public: virtual const wxString& GetElfOverride() const { return m_elf_override; } virtual void SetElfOverride( const wxString& elf ); + virtual void ChangeCdvdSource( CDVD_SourceType type ); protected: void CpuInitializeMess(); diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 0b18316380..38a046981c 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -534,6 +534,7 @@ public: virtual void Reset(); virtual void StateCheckInThread(); virtual void ApplySettings( const Pcsx2Config& src ); + virtual void ChangeCdvdSource( CDVD_SourceType type ); protected: virtual void OnResumeReady(); diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 74029837b9..ee2abc1877 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -100,6 +100,15 @@ void AppCoreThread::Resume() resume_tries = 0; } +void AppCoreThread::ChangeCdvdSource( CDVD_SourceType type ) +{ + g_Conf->CdvdSource = type; + _parent::ChangeCdvdSource( type ); + sMainFrame.UpdateIsoSrcSelection(); + + // TODO: Add a listener for CDVDsource changes? Or should we bother? +} + void AppCoreThread::OnResumeReady() { ApplySettings( g_Conf->EmuOptions ); diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 47053f61c6..f36f9882d1 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -74,13 +74,13 @@ pxAppResources::pxAppResources() wxMenu& Pcsx2App::GetRecentIsoMenu() { - pxAssert( m_Resources->RecentIsoMenu ); + pxAssert( !!m_Resources->RecentIsoMenu ); return *m_Resources->RecentIsoMenu; } RecentIsoManager& Pcsx2App::GetRecentIsoList() { - pxAssert( m_Resources->RecentIsoList ); + pxAssert( !!m_Resources->RecentIsoList ); return *m_Resources->RecentIsoList; } diff --git a/pcsx2/gui/IsoDropTarget.cpp b/pcsx2/gui/IsoDropTarget.cpp index 6a555a5db9..825656b6bb 100644 --- a/pcsx2/gui/IsoDropTarget.cpp +++ b/pcsx2/gui/IsoDropTarget.cpp @@ -121,7 +121,9 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen { SysUpdateIsoSrcFile( filenames[0] ); if( result != wxID_RESET ) - CDVDsys_ChangeSource( CDVDsrc_Iso ); + { + CoreThread.ChangeCdvdSource( CDVDsrc_Iso ); + } else { sApp.SysExecute( CDVDsrc_Iso ); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 51a4ff6356..f21de7a1a6 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -61,12 +61,7 @@ void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event ) jNO_DEFAULT } - - if( g_Conf->CdvdSource == newSource ) return; - - bool resume = CoreThread.Suspend(); - CDVDsys_ChangeSource( g_Conf->CdvdSource = newSource ); - if( resume ) CoreThread.Resume(); + CoreThread.ChangeCdvdSource( newSource ); } // Returns FALSE if the user cancelled the action. diff --git a/plugins/spu2-x/src/PS2E-spu2.cpp b/plugins/spu2-x/src/PS2E-spu2.cpp index d686cc2204..7700ac9f96 100644 --- a/plugins/spu2-x/src/PS2E-spu2.cpp +++ b/plugins/spu2-x/src/PS2E-spu2.cpp @@ -140,7 +140,8 @@ EXPORT_C_(s32) SPU2test() return -1; } - if( !SndBuffer::Test() ) + ReadSettings(); + if( SndBuffer::Test() == 0 ) { // TODO : Implement a proper dialog that allows the user to test different audio out drivers. SysMessage( L"The '%s' driver test failed. Please configure\ndifferent SoundOut module and try again.", mods[OutputModule]->GetIdent() );