From 3bc6f29dc35edf69f9978e0192e20beb389faa7d Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 28 Nov 2017 15:18:22 +1100 Subject: [PATCH] [host] syncronization improvements --- host/Service.cpp | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/host/Service.cpp b/host/Service.cpp index 60274c47..80c4bdd6 100644 --- a/host/Service.cpp +++ b/host/Service.cpp @@ -145,34 +145,6 @@ bool Service::Process() return false; } - // wait for the host to notify that is it is ready to proceed - bool eventDone = false; - while (!eventDone) - { - switch (WaitForSingleObject(m_readyEvent, 1000)) - { - case WAIT_ABANDONED: - DEBUG_ERROR("Wait abandoned"); - return false; - - case WAIT_OBJECT_0: - eventDone = true; - break; - - // if we timed out we just continue to ring until we get an answer or we are stopped - case WAIT_TIMEOUT: - continue; - - case WAIT_FAILED: - DEBUG_ERROR("Wait failed"); - return false; - - default: - DEBUG_ERROR("Unknown error"); - return false; - } - } - // copy the frame details into the header header->width = frame.width; header->height = frame.height; @@ -193,6 +165,33 @@ bool Service::Process() return false; } + // wait for the host to notify that is it is ready to proceed + bool eventDone = false; + while (!eventDone) + { + switch (WaitForSingleObject(m_readyEvent, 1000)) + { + case WAIT_ABANDONED: + DEBUG_ERROR("Wait abandoned"); + return false; + + case WAIT_OBJECT_0: + eventDone = true; + break; + + case WAIT_TIMEOUT: + continue; + + case WAIT_FAILED: + DEBUG_ERROR("Wait failed"); + return false; + + default: + DEBUG_ERROR("Unknown error"); + return false; + } + } + if (++m_frameIndex == 2) m_frameIndex = 0;