mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 06:47:19 +00:00
[host] switch to fast polling mode, fixes stuttering issues
This commit is contained in:
parent
afff50dfde
commit
e379f70784
@ -69,6 +69,7 @@ KVMFRFrame;
|
|||||||
#define KVMFR_HEADER_FLAG_FRAME 1 // frame update available
|
#define KVMFR_HEADER_FLAG_FRAME 1 // frame update available
|
||||||
#define KVMFR_HEADER_FLAG_CURSOR 2 // cursor update available
|
#define KVMFR_HEADER_FLAG_CURSOR 2 // cursor update available
|
||||||
#define KVMFR_HEADER_FLAG_RESTART 4 // restart signal from client
|
#define KVMFR_HEADER_FLAG_RESTART 4 // restart signal from client
|
||||||
|
#define KVMFR_HEADER_FLAG_READY 8 // ready signal from client
|
||||||
|
|
||||||
typedef struct KVMFRHeader
|
typedef struct KVMFRHeader
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ Service * Service::m_instance = NULL;
|
|||||||
Service::Service() :
|
Service::Service() :
|
||||||
m_initialized(false),
|
m_initialized(false),
|
||||||
m_memory(NULL),
|
m_memory(NULL),
|
||||||
m_readyEvent(INVALID_HANDLE_VALUE),
|
m_timer(NULL),
|
||||||
m_capture(NULL),
|
m_capture(NULL),
|
||||||
m_header(NULL),
|
m_header(NULL),
|
||||||
m_frameIndex(0)
|
m_frameIndex(0)
|
||||||
@ -73,11 +73,10 @@ bool Service::Initialize(ICapture * captureDevice)
|
|||||||
if (!InitPointers())
|
if (!InitPointers())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_readyEvent = m_ivshmem->CreateVectorEvent(0);
|
m_timer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||||
if (m_readyEvent == INVALID_HANDLE_VALUE)
|
if (!m_timer)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to get event for vector 0");
|
DEBUG_ERROR("Failed to create waitable timer");
|
||||||
DeInitialize();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,10 +116,10 @@ bool Service::InitPointers()
|
|||||||
|
|
||||||
void Service::DeInitialize()
|
void Service::DeInitialize()
|
||||||
{
|
{
|
||||||
if (m_readyEvent != INVALID_HANDLE_VALUE)
|
if (m_timer)
|
||||||
{
|
{
|
||||||
CloseHandle(m_readyEvent);
|
CloseHandle(m_timer);
|
||||||
m_readyEvent = INVALID_HANDLE_VALUE;
|
m_timer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_header = NULL;
|
m_header = NULL;
|
||||||
@ -153,8 +152,7 @@ bool Service::Process()
|
|||||||
frame.bufferSize = m_frameSize;
|
frame.bufferSize = m_frameSize;
|
||||||
|
|
||||||
// wait for the host to notify that is it is ready to proceed
|
// wait for the host to notify that is it is ready to proceed
|
||||||
bool eventDone = false;
|
while (true)
|
||||||
while (!eventDone)
|
|
||||||
{
|
{
|
||||||
// check if the client has flagged a restart
|
// check if the client has flagged a restart
|
||||||
if (m_header->flags & KVMFR_HEADER_FLAG_RESTART)
|
if (m_header->flags & KVMFR_HEADER_FLAG_RESTART)
|
||||||
@ -164,29 +162,23 @@ bool Service::Process()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (WaitForSingleObject(m_readyEvent, 200))
|
// check if the client has flagged it's ready
|
||||||
|
if (m_header->flags & KVMFR_HEADER_FLAG_READY)
|
||||||
{
|
{
|
||||||
case WAIT_ABANDONED:
|
InterlockedAnd8((char *)&m_header->flags, ~(KVMFR_HEADER_FLAG_READY));
|
||||||
DEBUG_ERROR("Wait abandoned");
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case WAIT_OBJECT_0:
|
|
||||||
eventDone = true;
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WAIT_TIMEOUT:
|
// wait for 100ns before polling again
|
||||||
continue;
|
LARGE_INTEGER timeout;
|
||||||
|
timeout.QuadPart = -100;
|
||||||
case WAIT_FAILED:
|
if (!SetWaitableTimer(m_timer, &timeout, 0, NULL, NULL, FALSE))
|
||||||
DEBUG_ERROR("Wait failed");
|
{
|
||||||
return false;
|
DEBUG_ERROR("Failed to set waitable timer");
|
||||||
|
|
||||||
default:
|
|
||||||
DEBUG_ERROR("Unknown error");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
WaitForSingleObject(m_timer, INFINITE);
|
||||||
}
|
}
|
||||||
ResetEvent(m_readyEvent);
|
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
bool cursorOnly = false;
|
bool cursorOnly = false;
|
||||||
|
@ -51,7 +51,7 @@ private:
|
|||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
uint8_t * m_memory;
|
uint8_t * m_memory;
|
||||||
IVSHMEM * m_ivshmem;
|
IVSHMEM * m_ivshmem;
|
||||||
HANDLE m_readyEvent;
|
HANDLE m_timer;
|
||||||
ICapture * m_capture;
|
ICapture * m_capture;
|
||||||
|
|
||||||
KVMFRHeader * m_header;
|
KVMFRHeader * m_header;
|
||||||
|
Loading…
Reference in New Issue
Block a user