From 4ca084b9ada2b7c7a322bf25876a0462e4a04370 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Jun 2013 16:06:24 -0700 Subject: [PATCH 1/2] Add a bit more space for the smoothness hackery. Prevents a buffer overflow error I was getting randomly. --- Core/HW/SasAudio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index f5a468bbaf..3323315335 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -316,8 +316,8 @@ void SasInstance::SetGrainSize(int newGrainSize) { delete [] resampleBuffer; // 2 samples padding at the start, that's where we copy the two last samples from the channel - // so that we can do bicubic resampling if necessary. - resampleBuffer = new s16[grainSize * 4 + 2]; + // so that we can do bicubic resampling if necessary. Plus 1 for smoothness hackery. + resampleBuffer = new s16[grainSize * 4 + 3]; } static inline s16 clamp_s16(int i) { @@ -509,7 +509,7 @@ void SasInstance::DoState(PointerWrap &p) { p.DoArray(sendBuffer, grainSize * 2); } if (resampleBuffer != NULL && grainSize > 0) { - p.DoArray(resampleBuffer, grainSize * 4 + 2); + p.DoArray(resampleBuffer, grainSize * 4 + 3); } int n = PSP_SAS_VOICES_MAX; From f5178e769ab17269493a5f8b5d1a5c81d5e7d666 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Jun 2013 17:47:09 -0700 Subject: [PATCH 2/2] Fix crash on File -> Exit in some cases. Fixes #2537. --- Windows/OpenGLBase.cpp | 7 ++++++- Windows/main.cpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Windows/OpenGLBase.cpp b/Windows/OpenGLBase.cpp index 34092506a6..80964fa85e 100644 --- a/Windows/OpenGLBase.cpp +++ b/Windows/OpenGLBase.cpp @@ -17,6 +17,8 @@ static int xres, yres; // TODO: Make config? static bool enableGLDebug = false; +#pragma optimize("", off) + void GL_SetVSyncInterval(int interval=1) { if( wglSwapIntervalEXT ) @@ -219,7 +221,10 @@ void GL_Shutdown() { } if (hDC && !ReleaseDC(hWnd,hDC)) { - MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + DWORD err = GetLastError(); + if (err != ERROR_DC_NOT_FOUND) { + MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + } hDC = NULL; } hWnd = NULL; diff --git a/Windows/main.cpp b/Windows/main.cpp index 948cd46e60..94c049e65c 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -154,6 +154,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin VFSShutdown(); + EmuThread_Stop(); + DialogManager::DestroyAll(); timeEndPeriod(1); delete host;