static void* rdpei_schedule_thread(void* arg) { DWORD status; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) arg; RdpeiClientContext* context = (RdpeiClientContext*) rdpei->iface.pInterface; HANDLE hdl[] = {rdpei->event, rdpei->stopEvent}; assert(NULL != rdpei); assert(NULL != context); while (1) { status = WaitForMultipleObjects(2, hdl, FALSE, 20); if (status == WAIT_OBJECT_0 + 1) break; EnterCriticalSection(&rdpei->lock); rdpei_add_frame(context); if (rdpei->frame.contactCount > 0) rdpei_send_frame(context); if (status == WAIT_OBJECT_0) ResetEvent(rdpei->event); LeaveCriticalSection(&rdpei->lock); } ExitThread(0); return NULL; }
int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact) { RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; if (rdpei->frame.contactCount < MAX_CONTACTS) { CopyMemory(&(rdpei->contacts[rdpei->frame.contactCount]), contact, sizeof(RDPINPUT_CONTACT_DATA)); rdpei->frame.contactCount++; } rdpei_send_frame(context); return 1; }
static void* rdpei_schedule_thread(void* arg) { DWORD status; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) arg; RdpeiClientContext* context = (RdpeiClientContext*) rdpei->iface.pInterface; HANDLE hdl[] = {rdpei->event, rdpei->stopEvent}; UINT error = CHANNEL_RC_OK; if (!rdpei) { error = ERROR_INVALID_PARAMETER; goto out; } if (!context) { error = ERROR_INVALID_PARAMETER; goto out; } while (1) { status = WaitForMultipleObjects(2, hdl, FALSE, 20); if (status == WAIT_FAILED) { error = GetLastError(); WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error); break; } if (status == WAIT_OBJECT_0 + 1) break; EnterCriticalSection(&rdpei->lock); if ((error = rdpei_add_frame(context))) { WLog_ERR(TAG, "rdpei_add_frame failed with error %lu!", error); break; } if (rdpei->frame.contactCount > 0) { if ((error = rdpei_send_frame(context))) { WLog_ERR(TAG, "rdpei_send_frame failed with error %lu!", error); break; } } if (status == WAIT_OBJECT_0) ResetEvent(rdpei->event); LeaveCriticalSection(&rdpei->lock); } out: if (error && rdpei->rdpcontext) setChannelError(rdpei->rdpcontext, error, "rdpei_schedule_thread reported an error"); ExitThread(0); return NULL; }