xfreerdp-server: remove thread tick thread
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 24 Apr 2013 00:01:07 +0000 (20:01 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 24 Apr 2013 00:01:07 +0000 (20:01 -0400)
server/X11/xf_encode.c
server/X11/xf_peer.c
server/X11/xfreerdp.c

index ca10744..3f3096c 100644 (file)
@@ -65,49 +65,6 @@ void xf_xdamage_subtract_region(xfPeerContext* xfp, int x, int y, int width, int
 #endif
 }
 
-void* xf_frame_rate_thread(void* param)
-{
-       xfInfo* xfi;
-       HGDI_RGN region;
-       xfPeerContext* xfp;
-       freerdp_peer* client;
-       UINT32 wait_interval;
-
-       client = (freerdp_peer*) param;
-       xfp = (xfPeerContext*) client->context;
-       xfi = xfp->info;
-
-       region = xfp->hdc->hwnd->invalid;
-       wait_interval = 1000000 / xfp->fps;
-
-       while (1)
-       {
-               /* check if we should terminate */
-               pthread_testcancel();
-
-               if (!region->null)
-               {
-                       UINT32 xy, wh;
-
-                       pthread_mutex_lock(&(xfp->mutex));
-
-                       xy = (region->x << 16) | region->y;
-                       wh = (region->w << 16) | region->h;
-                       region->null = 1;
-
-                       pthread_mutex_unlock(&(xfp->mutex));
-
-                       MessageQueue_Post(xfp->queue, (void*) xfp,
-                                       MakeMessageId(PeerEvent, EncodeRegion),
-                                       (void*) (size_t) xy, (void*) (size_t) wh);
-               }
-
-               USleep(wait_interval);
-       }
-
-       return NULL;
-}
-
 void* xf_monitor_updates(void* param)
 {
        int fds;
@@ -130,8 +87,6 @@ void* xf_monitor_updates(void* param)
        wait_interval = 1000000 / xfp->fps;
        ZeroMemory(&timeout, sizeof(struct timeval));
 
-       pthread_create(&(xfp->frame_rate_thread), 0, xf_frame_rate_thread, (void*) client);
-
        while (1)
        {
                /* check if we should terminate */
index 3cda413..2d5617e 100644 (file)
@@ -431,35 +431,25 @@ BOOL xf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
 BOOL xf_peer_check_fds(freerdp_peer* client)
 {
        xfInfo* xfi;
-       wMessage message;
+       HGDI_RGN region;
        xfPeerContext* xfp;
 
        xfp = (xfPeerContext*) client->context;
        xfi = xfp->info;
 
-       if (xfp->activated == FALSE)
+       if (!xfp->activated)
                return TRUE;
 
-       if (MessageQueue_Peek(xfp->queue, &message, TRUE))
-       {
-               if (message.id == MakeMessageId(PeerEvent, EncodeRegion))
-               {
-                       UINT32 xy, wh;
-                       UINT16 x, y, w, h;
+       region = xfp->hdc->hwnd->invalid;
 
-                       xy = (UINT32) (size_t) message.wParam;
-                       wh = (UINT32) (size_t) message.lParam;
+       pthread_mutex_lock(&(xfp->mutex));
 
-                       x = ((xy & 0xFFFF0000) >> 16);
-                       y = (xy & 0x0000FFFF);
+       if ((region->w * region->h) > 0)
+               xf_peer_rfx_update(client, region->x, region->y, region->w, region->h);
 
-                       w = ((wh & 0xFFFF0000) >> 16);
-                       h = (wh & 0x0000FFFF);
+       region->null = 1;
 
-                       if (w * h > 0)
-                               xf_peer_rfx_update(client, x, y, w, h);
-               }
-       }
+       pthread_mutex_unlock(&(xfp->mutex));
 
        return TRUE;
 }
@@ -583,18 +573,17 @@ static void* xf_peer_main_loop(void* arg)
        rdpSettings* settings;
        freerdp_peer* client = (freerdp_peer*) arg;
        xfPeerContext* xfp;
+       struct timeval timeout;
 
        ZeroMemory(rfds, sizeof(rfds));
+       ZeroMemory(&timeout, sizeof(struct timeval));
 
        fprintf(stderr, "We've got a client %s\n", client->hostname);
 
        xf_peer_init(client);
        xfp = (xfPeerContext*) client->context;
-
        settings = client->settings;
 
-       /* Initialize the real server settings here */
-
        xf_generate_certificate(settings);
 
        settings->RemoteFxCodec = TRUE;
@@ -617,6 +606,7 @@ static void* xf_peer_main_loop(void* arg)
                        fprintf(stderr, "Failed to get FreeRDP file descriptor\n");
                        break;
                }
+
                if (xf_peer_get_fds(client, rfds, &rcount) != TRUE)
                {
                        fprintf(stderr, "Failed to get xfreerdp file descriptor\n");
@@ -639,7 +629,10 @@ static void* xf_peer_main_loop(void* arg)
                if (max_fds == 0)
                        break;
 
-               if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1)
+               timeout.tv_sec = 0;
+               timeout.tv_usec = 100;
+
+               if (select(max_fds + 1, &rfds_set, NULL, NULL, &timeout) == -1)
                {
                        /* these are not really errors */
                        if (!((errno == EAGAIN) ||
@@ -657,6 +650,7 @@ static void* xf_peer_main_loop(void* arg)
                        fprintf(stderr, "Failed to check freerdp file descriptor\n");
                        break;
                }
+
                if ((xf_peer_check_fds(client)) != TRUE)
                {
                        fprintf(stderr, "Failed to check xfreerdp file descriptor\n");
@@ -669,10 +663,8 @@ static void* xf_peer_main_loop(void* arg)
        client->Disconnect(client);
        
        pthread_cancel(xfp->thread);
-       pthread_cancel(xfp->frame_rate_thread);
        
        pthread_join(xfp->thread, NULL);
-       pthread_join(xfp->frame_rate_thread, NULL);
        
        freerdp_peer_context_free(client);
        freerdp_peer_free(client);
index 62bd989..ce89aba 100644 (file)
@@ -33,9 +33,6 @@
 #include "xf_peer.h"
 #include "xfreerdp.h"
 
-char* xf_pcap_file = NULL;
-BOOL xf_pcap_dump_realtime = TRUE;
-
 void xf_server_main_loop(freerdp_listener* instance)
 {
        int i;
@@ -106,12 +103,6 @@ int main(int argc, char* argv[])
        instance = freerdp_listener_new();
        instance->PeerAccepted = xf_peer_accepted;
 
-       if (argc > 1)
-               xf_pcap_file = argv[1];
-
-       if (argc > 2 && !strcmp(argv[2], "--fast"))
-               xf_pcap_dump_realtime = FALSE;
-
        /* Open the server socket and start listening. */
        if (instance->Open(instance, NULL, 3389))
        {