Fixed one of the two remaining crash on Stop (issue 600), and removed some setup defines which are now useless anyway.

There's an attempt to implement Peek_Color too, probably done wrong :P

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3799 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s
2009-07-15 15:09:20 +00:00
parent 15de161f95
commit 3bc8eb7eaf
17 changed files with 92 additions and 384 deletions

View File

@ -32,28 +32,6 @@
// This may remove sound artifacts in Wario Land Shake It and perhaps other games
//#define SETUP_AVOID_SOUND_ARTIFACTS
/* This may fix a problem with Stop and Start that I described in the comments to revision 2,139,
and in the comments in the File Description for PluginManager.cpp */
//#define SETUP_FREE_VIDEO_PLUGIN_ON_BOOT
//#define SETUP_FREE_DSP_PLUGIN_ON_BOOT
//#define SETUP_DONT_FREE_PLUGIN_ON_STOP
/* This will avoid deleting the g_EmuThread after Stop, that may hang when we are rendering to a child
window, however, I didn't seem to need this any more */
//#define SETUP_AVOID_CHILD_WINDOW_RENDERING_HANG
// Build with playback rerecording options
//#define SETUP_AVOID_OPENGL_SCREEN_MESSAGE_HANG
// Use a timer to wait for threads for stop instead of WaitForEternity()
/* I tried that this worked with these options
SETUP_FREE_VIDEO_PLUGIN_ON_BOOT
SETUP_DONT_FREE_PLUGIN_ON_STOP
then the Confirm on Close message box doesn't hang, and we have a controlled Shutdown process
without any hanged threads. The downside is a few error messages in the ShutDown() of the
OpenGL plugin, so I still need FreeLibrary() to clean it, even with this option. */
//#define SETUP_TIMER_WAITING
// Build with playback rerecording options
//#define RERECORDING

View File

@ -23,12 +23,6 @@
#include <process.h>
#endif
#ifdef SETUP_TIMER_WAITING
#include <windows.h>
#include "ConsoleWindow.h"
EventCallBack FunctionPointer[10];
#endif
namespace Common
{
@ -110,12 +104,6 @@ void Thread::SetCurrentThreadAffinity(int mask)
Event::Event()
{
m_hEvent = 0;
#ifdef SETUP_TIMER_WAITING
DoneWaiting = false;
StartWait = false;
hTimer = NULL;
hTimerQueue = NULL;
#endif
}
void Event::Init()
@ -183,96 +171,6 @@ void Event::MsgWait()
}
}
/* Separate thread timer based waiting, instead of same thread loop waiting. The downside with this
is that it's less convenient to use because we can't stall any threads with a loop. The positive
is that we don't cause these incredibly annoying WaitForEternity() hangings. */
#ifdef SETUP_TIMER_WAITING
/* I could not figure out how to place this in the class to, CreateTimerQueueTimer() would complain
about some kind of type casting, anyone have any ideas about how to do it? */
VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired)
{
if (lpParam == NULL)
{
DEBUG_LOG(CONSOLE, "TimerRoutine lpParam is NULL\n");
}
else
{
// lpParam points to the argument; in this case it is an int
//DEBUG_LOG(CONSOLE, "Timer[%i] will call back\n", *(int*)lpParam);
}
// Call back
int Id = *(int*)lpParam;
if (FunctionPointer[Id]) FunctionPointer[Id]();
}
// Create a timer that will call back to the calling function
bool Event::TimerWait(EventCallBack WaitCB, int _Id, bool OptCondition)
{
Id = _Id;
//DEBUG_LOG(CONSOLE, "TimerWait[%i]: %i %i %i\n", Id, StartWait, DoneWaiting, OptCondition);
FunctionPointer[Id] = WaitCB;
// This means we are done waiting, so we wont call back again, and we also reset the variables for this Event
if (DoneWaiting && OptCondition)
{
StartWait = false;
DoneWaiting = false;
FunctionPointer[Id] = NULL;
// Delete all timers in the timer queue.
if (!DeleteTimerQueue(hTimerQueue))
DEBUG_LOG(CONSOLE, "DeleteTimerQueue failed (%d)\n", GetLastError());
hTimer = NULL;
hTimerQueue = NULL;
return true;
}
// Else start a new callback timer
StartWait = true;
// Create the timer queue if needed
if (!hTimerQueue)
{
hTimerQueue = CreateTimerQueue();
if (NULL == hTimerQueue)
{
DEBUG_LOG(CONSOLE, "CreateTimerQueue failed (%d)\n", GetLastError());
return false;
}
}
// Set a timer to call the timer routine in 10 seconds.
if (!CreateTimerQueueTimer( &hTimer, hTimerQueue,
(WAITORTIMERCALLBACK)TimerRoutine, &Id , 10, 0, 0))
{
DEBUG_LOG(CONSOLE, "CreateTimerQueueTimer failed (%d)\n", GetLastError());
return false;
}
return false;
}
// Check if we are done or not
bool Event::DoneWait()
{
if (StartWait && DoneWaiting)
return true;
else
return false;
}
// Tells the timer that we are done waiting
void Event::SetTimer()
{
// We can not be done before we have started waiting
if (StartWait) DoneWaiting = true;
}
#endif
// Supporting functions
void SleepCurrentThread(int ms)
{

View File

@ -60,14 +60,6 @@
#endif
#endif
// -----------------------------------------
#ifdef SETUP_TIMER_WAITING
// -----------------
typedef void (*EventCallBack)(void);
#endif
// ----------------------
///////////////////////////////////
namespace Common
{
@ -156,16 +148,6 @@ public:
void MsgWait() {Wait();}
#endif
#ifdef SETUP_TIMER_WAITING
bool TimerWait(EventCallBack WaitCB, int Id = 0, bool OptCondition = true);
bool DoneWait();
void SetTimer();
bool DoneWaiting;
bool StartWait;
int Id;
HANDLE hTimer;
HANDLE hTimerQueue;
#endif
private:
#ifdef _WIN32