From a3b59f684575086f233233fbae04fb7eabfd1f46 Mon Sep 17 00:00:00 2001 From: skidau Date: Wed, 15 Sep 2010 12:30:56 +0000 Subject: [PATCH] Change Disc functionality: * Fixed the "Change disc..." command. The filename of the disc was being lost between functions. * Split the ChangeDisc function into two functions: EjectDisc and InsertDisc * Moved the "Change disc..." command to the File menu. * Removed some log messages that caused the debug build to crash when loaded with release build plug-ins. Fixes issue 3036. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6206 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/OpenCL.cpp | 1 - Source/Core/Core/Src/HW/DVDInterface.cpp | 64 +++++++++---------- Source/Core/DolphinWX/Src/FrameTools.cpp | 2 +- .../Plugins/Plugin_VideoDX11/Src/D3DBase.cpp | 4 -- .../Plugins/Plugin_VideoDX9/Src/D3DBase.cpp | 1 - 5 files changed, 30 insertions(+), 42 deletions(-) diff --git a/Source/Core/Common/Src/OpenCL.cpp b/Source/Core/Common/Src/OpenCL.cpp index 8fad808f18..2d7b684074 100644 --- a/Source/Core/Common/Src/OpenCL.cpp +++ b/Source/Core/Common/Src/OpenCL.cpp @@ -122,7 +122,6 @@ bool Initialize() return false; } - NOTICE_LOG(COMMON, "Initialized OpenCL!"); g_bInitialized = true; return true; #else diff --git a/Source/Core/Core/Src/HW/DVDInterface.cpp b/Source/Core/Core/Src/HW/DVDInterface.cpp index b37f2a5237..e64645051e 100644 --- a/Source/Core/Core/Src/HW/DVDInterface.cpp +++ b/Source/Core/Core/Src/HW/DVDInterface.cpp @@ -208,8 +208,10 @@ static unsigned char media_buffer[0x40]; // (both requests can happen at the same time, audio takes precedence) Common::CriticalSection dvdread_section; -static int changeDisc; -void ChangeDiscCallback(u64 userdata, int cyclesLate); +static int ejectDisc; +void EjectDiscCallback(u64 userdata, int cyclesLate); +static int insertDisc; +void InsertDiscCallback(u64 userdata, int cyclesLate); void UpdateInterrupts(); void GenerateDIInterrupt(DI_InterruptType _DVDInterrupt); @@ -253,7 +255,8 @@ void Init() AudioPos = 0; AudioLength = 0; - changeDisc = CoreTiming::RegisterEvent("ChangeDisc", ChangeDiscCallback); + ejectDisc = CoreTiming::RegisterEvent("EjectDisc", EjectDiscCallback); + insertDisc = CoreTiming::RegisterEvent("InsertDisc", InsertDiscCallback); } void Shutdown() @@ -274,44 +277,35 @@ bool IsDiscInside() // We want this in the "backend", NOT the gui // any !empty string will be deleted to ensure // that the userdata string exists when called -void ChangeDiscCallback(u64 userdata, int cyclesLate) +void EjectDiscCallback(u64 userdata, int cyclesLate) { - std::string FileName((const char*)userdata); + // Empty the drive SetDiscInside(false); SetLidOpen(); - - std::string& SavedFileName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename; - - if (FileName.empty()) - { - // Empty the drive - VolumeHandler::EjectVolume(); - } - else - { - if (VolumeHandler::SetVolumeName(FileName)) - { - // Save the new ISO file name - SavedFileName = FileName; - } - else - { - PanicAlert("Invalid file \n %s", FileName.c_str()); - - // Put back the old one - VolumeHandler::SetVolumeName(SavedFileName); - } - } - - SetLidOpen(false); - SetDiscInside(VolumeHandler::IsValid()); + VolumeHandler::EjectVolume(); } -void ChangeDisc(const char* _FileName) +void InsertDiscCallback(u64 userdata, int cyclesLate) { - const char* NoDisc = ""; - CoreTiming::ScheduleEvent_Threadsafe(0, changeDisc, (u64)NoDisc); - CoreTiming::ScheduleEvent_Threadsafe(500000000, changeDisc, (u64)_FileName); + std::string& SavedFileName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename; + std::string *_FileName = (std::string *)userdata; + + if (!VolumeHandler::SetVolumeName(*_FileName)) + { + // Put back the old one + VolumeHandler::SetVolumeName(SavedFileName); + PanicAlert("Invalid file"); + } + SetLidOpen(false); + SetDiscInside(VolumeHandler::IsValid()); + delete _FileName; +} + +void ChangeDisc(const char* _newFileName) +{ + std::string* _FileName = new std::string(_newFileName); + CoreTiming::ScheduleEvent_Threadsafe(0, ejectDisc); + CoreTiming::ScheduleEvent_Threadsafe(500000000, insertDisc, (u64)_FileName); } void SetLidOpen(bool _bOpen) diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 8d718ae44f..f64be6e570 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -105,6 +105,7 @@ void CFrame::CreateMenu() // file menu wxMenu* fileMenu = new wxMenu; fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O")); + fileMenu->Append(IDM_CHANGEDISC, _T("Change &Disc...")); wxMenu *externalDrive = new wxMenu; fileMenu->Append(IDM_DRIVES, _T("&Boot from DVD Drive..."), externalDrive); @@ -135,7 +136,6 @@ void CFrame::CreateMenu() emulationMenu->Append(IDM_PLAYRECORD, _T("P&lay Recording...")); emulationMenu->Append(IDM_RECORDEXPORT, _T("Export Recording...")); emulationMenu->AppendSeparator(); - emulationMenu->Append(IDM_CHANGEDISC, _T("Change &Disc")); emulationMenu->Append(IDM_FRAMESTEP, _T("&Frame Stepping"), wxEmptyString, wxITEM_CHECK); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp index 1aaed516df..471b374bd9 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp @@ -80,10 +80,6 @@ HRESULT Create(HWND wnd) NOTICE_LOG(VIDEO, "Successfully loaded d3dx11_42.dll. If you're having trouble, try updating your DX runtime first."); } } - else - { - NOTICE_LOG(VIDEO, "Successfully loaded %s.", StringFromFormat("d3dx11_%d.dll", D3DX11_SDK_VERSION).c_str()); - } PD3DX11CompileFromMemory = (D3DX11COMPILEFROMMEMORYTYPE)GetProcAddress(hD3DXDll, "D3DX11CompileFromMemory"); if (PD3DX11CompileFromMemory == NULL) MessageBoxA(NULL, "GetProcAddress failed for D3DX11CompileFromMemory!", "Critical error", MB_OK | MB_ICONERROR); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp index 2d1f4b2413..3a7c827478 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp @@ -265,7 +265,6 @@ HRESULT LoadD3DX9() hD3DXDll = LoadLibraryA(StringFromFormat("d3dx9_%d.dll", D3DX_SDK_VERSION).c_str()); if (hD3DXDll != NULL) { - NOTICE_LOG(VIDEO, "Successfully loaded %s.", StringFromFormat("d3dx9_%d.dll", D3DX_SDK_VERSION).c_str()); hr = S_OK; } else