xfreerdp-server: move update thread to new source files
This commit is contained in:
parent
9383892d16
commit
d46dfabcfb
@ -28,6 +28,8 @@ set(${MODULE_PREFIX}_SRCS
|
||||
xf_input.h
|
||||
xf_encode.c
|
||||
xf_encode.h
|
||||
xf_update.c
|
||||
xf_update.h
|
||||
xf_interface.c
|
||||
xf_interface.h
|
||||
xfreerdp.h)
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <sys/signal.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#include "xf_encode.h"
|
||||
|
||||
@ -64,52 +63,3 @@ void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int
|
||||
XDamageSubtract(xfi->display, xfi->xdamage, xfi->xdamage_region, None);
|
||||
#endif
|
||||
}
|
||||
|
||||
void* xf_monitor_thread(void* param)
|
||||
{
|
||||
xfInfo* xfi;
|
||||
HANDLE event;
|
||||
XEvent xevent;
|
||||
xfPeerContext* xfp;
|
||||
freerdp_peer* client;
|
||||
UINT32 wait_interval;
|
||||
struct timeval timeout;
|
||||
int x, y, width, height;
|
||||
XDamageNotifyEvent* notify;
|
||||
|
||||
client = (freerdp_peer*) param;
|
||||
xfp = (xfPeerContext*) client->context;
|
||||
xfi = xfp->info;
|
||||
|
||||
wait_interval = 1000000 / xfp->fps;
|
||||
ZeroMemory(&timeout, sizeof(struct timeval));
|
||||
|
||||
event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds);
|
||||
|
||||
while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0)
|
||||
{
|
||||
while (XPending(xfi->display) > 0)
|
||||
{
|
||||
ZeroMemory(&xevent, sizeof(xevent));
|
||||
XNextEvent(xfi->display, &xevent);
|
||||
|
||||
if (xevent.type == xfi->xdamage_notify_event)
|
||||
{
|
||||
notify = (XDamageNotifyEvent*) &xevent;
|
||||
|
||||
x = notify->area.x;
|
||||
y = notify->area.y;
|
||||
width = notify->area.width;
|
||||
height = notify->area.height;
|
||||
|
||||
WaitForSingleObject(xfp->mutex, INFINITE);
|
||||
gdi_InvalidateRegion(xfp->hdc, x, y, width, height);
|
||||
ReleaseMutex(xfp->mutex);
|
||||
|
||||
xf_xdamage_subtract_region(xfp, x, y, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -20,13 +20,11 @@
|
||||
#ifndef __XF_ENCODE_H
|
||||
#define __XF_ENCODE_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include "xfreerdp.h"
|
||||
|
||||
#include "xf_peer.h"
|
||||
|
||||
XImage* xf_snapshot(xfPeerContext* xfp, int x, int y, int width, int height);
|
||||
void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int height);
|
||||
void* xf_monitor_thread(void* param);
|
||||
|
||||
#endif /* __XF_ENCODE_H */
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
#include "xf_input.h"
|
||||
#include "xf_encode.h"
|
||||
#include "xf_update.h"
|
||||
|
||||
#include "makecert.h"
|
||||
|
||||
@ -279,6 +280,7 @@ xfInfo* xf_info_init()
|
||||
printf("Using X Shared Memory Extension (XShm)\n");
|
||||
|
||||
xfi->bytesPerPixel = 4;
|
||||
xfi->activePeerCount = 0;
|
||||
|
||||
freerdp_keyboard_init(0);
|
||||
|
||||
@ -343,7 +345,7 @@ void xf_peer_live_rfx(freerdp_peer* client)
|
||||
xfPeerContext* xfp = (xfPeerContext*) client->context;
|
||||
|
||||
xfp->monitorThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) xf_monitor_thread, (void*) client, 0, NULL);
|
||||
(LPTHREAD_START_ROUTINE) xf_update_thread, (void*) client, 0, NULL);
|
||||
}
|
||||
|
||||
void xf_peer_rfx_update(freerdp_peer* client, int x, int y, int width, int height)
|
||||
@ -521,6 +523,8 @@ BOOL xf_peer_activate(freerdp_peer* client)
|
||||
rfx_context_reset(xfp->rfx_context);
|
||||
xfp->activated = TRUE;
|
||||
|
||||
xfp->info->activePeerCount++;
|
||||
|
||||
xf_peer_live_rfx(client);
|
||||
|
||||
return TRUE;
|
||||
|
87
server/X11/xf_update.c
Normal file
87
server/X11/xf_update.c
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* X11 Server Graphical Updates
|
||||
*
|
||||
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/synch.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
|
||||
#include "xf_peer.h"
|
||||
#include "xf_encode.h"
|
||||
|
||||
#include "xf_update.h"
|
||||
|
||||
void* xf_update_thread(void* param)
|
||||
{
|
||||
xfInfo* xfi;
|
||||
HANDLE event;
|
||||
XEvent xevent;
|
||||
DWORD beg, end;
|
||||
DWORD diff, rate;
|
||||
xfPeerContext* xfp;
|
||||
freerdp_peer* client;
|
||||
int x, y, width, height;
|
||||
XDamageNotifyEvent* notify;
|
||||
|
||||
client = (freerdp_peer*) param;
|
||||
xfp = (xfPeerContext*) client->context;
|
||||
xfi = xfp->info;
|
||||
|
||||
rate = 1000 / xfp->fps;
|
||||
|
||||
event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds);
|
||||
|
||||
while (WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0)
|
||||
{
|
||||
beg = GetTickCount();
|
||||
|
||||
while (XPending(xfi->display) > 0)
|
||||
{
|
||||
ZeroMemory(&xevent, sizeof(xevent));
|
||||
XNextEvent(xfi->display, &xevent);
|
||||
|
||||
if (xevent.type == xfi->xdamage_notify_event)
|
||||
{
|
||||
notify = (XDamageNotifyEvent*) &xevent;
|
||||
|
||||
x = notify->area.x;
|
||||
y = notify->area.y;
|
||||
width = notify->area.width;
|
||||
height = notify->area.height;
|
||||
|
||||
WaitForSingleObject(xfp->mutex, INFINITE);
|
||||
gdi_InvalidateRegion(xfp->hdc, x, y, width, height);
|
||||
ReleaseMutex(xfp->mutex);
|
||||
|
||||
xf_xdamage_subtract_region(xfp, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
end = GetTickCount();
|
||||
diff = end - beg;
|
||||
|
||||
if (diff < rate)
|
||||
Sleep(rate - diff);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
28
server/X11/xf_update.h
Normal file
28
server/X11/xf_update.h
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* X11 Server Graphical Updates
|
||||
*
|
||||
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __XF_UPDATE_H
|
||||
#define __XF_UPDATE_H
|
||||
|
||||
#include "xfreerdp.h"
|
||||
|
||||
void* xf_update_thread(void* param);
|
||||
|
||||
#endif /* __XF_UPDATE_H */
|
||||
|
@ -60,6 +60,7 @@ struct xf_info
|
||||
int bytesPerPixel;
|
||||
HCLRCONV clrconv;
|
||||
BOOL use_xshm;
|
||||
int activePeerCount;
|
||||
|
||||
XImage* fb_image;
|
||||
Pixmap fb_pixmap;
|
||||
|
Loading…
Reference in New Issue
Block a user