Fixed multithread crash when loading another game

This commit is contained in:
Souryo 2016-01-06 20:37:52 -05:00
parent 242749971e
commit a96b6229d0
3 changed files with 9 additions and 0 deletions

View file

@ -135,6 +135,8 @@ void VideoDecoder::StartThread()
_stopFlag = false; _stopFlag = false;
_frameChanged = false; _frameChanged = false;
_frameCount = 0; _frameCount = 0;
_waitForFrame.Reset();
_waitForRender.Reset();
Instance->_decodeThread.reset(new thread(&VideoDecoder::DecodeThread, Instance.get())); Instance->_decodeThread.reset(new thread(&VideoDecoder::DecodeThread, Instance.get()));
Instance->_renderThread.reset(new thread(&VideoDecoder::RenderThread, Instance.get())); Instance->_renderThread.reset(new thread(&VideoDecoder::RenderThread, Instance.get()));
} }

View file

@ -25,6 +25,12 @@ void AutoResetEvent::Wait(int timeoutDelay)
_signaled = false; _signaled = false;
} }
void AutoResetEvent::Reset()
{
std::unique_lock<std::mutex> lock(_mutex);
_signaled = false;
}
void AutoResetEvent::Signal() void AutoResetEvent::Signal()
{ {
std::unique_lock<std::mutex> lock(_mutex); std::unique_lock<std::mutex> lock(_mutex);

View file

@ -15,6 +15,7 @@ public:
AutoResetEvent(); AutoResetEvent();
~AutoResetEvent(); ~AutoResetEvent();
void Reset();
void Wait(int timeoutDelay = 0); void Wait(int timeoutDelay = 0);
void Signal(); void Signal();
}; };