From c59b7dedad7fabd71884b31cc85856bd70745230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Fri, 7 Sep 2012 18:01:36 +0200 Subject: [PATCH] wfreerdp-server: add registry key for framerate --- server/Windows/wf_info.c | 27 +++++++++++++++++++++++++++ server/Windows/wf_info.h | 3 ++- server/Windows/wf_peer.c | 21 ++------------------- server/Windows/wf_update.c | 7 ++++--- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index b7f207a68..94a5aa25d 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -27,6 +27,7 @@ #include #include "wf_info.h" +#include "wf_update.h" #include "wf_mirage.h" static wfInfo* wfInfoInstance = NULL; @@ -103,6 +104,12 @@ wfInfo* wf_info_init() if (wfi != NULL) { + HKEY hKey; + LONG status; + DWORD dwType; + DWORD dwSize; + DWORD dwValue; + wfi->mutex = CreateMutex(NULL, FALSE, NULL); if (wfi->mutex == NULL) @@ -112,7 +119,27 @@ wfInfo* wf_info_init() wfi->updateEvent = CreateEvent(0, 1, 0, 0); + wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL); + + if (!wfi->updateThread) + { + _tprintf(_T("Failed to create update thread\n")); + } + wfi->peers = (wfPeerContext**) malloc(sizeof(wfPeerContext*) * 32); + + wfi->framesPerSecond = 24; + + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), 0, KEY_READ | KEY_WOW64_64KEY, &hKey); + + if (status == ERROR_SUCCESS) + { + if (RegQueryValueEx(hKey, _T("FramesPerSecond"), NULL, &dwType, (BYTE*) &dwValue, &dwSize) == ERROR_SUCCESS) + wfi->framesPerSecond = dwValue; + + } + + RegCloseKey(hKey); } return wfi; diff --git a/server/Windows/wf_info.h b/server/Windows/wf_info.h index 85404feb1..6eb995798 100644 --- a/server/Windows/wf_info.h +++ b/server/Windows/wf_info.h @@ -36,6 +36,7 @@ struct wf_info int peerCount; BOOL activated; void* changeBuffer; + int framesPerSecond; LPTSTR deviceKey; TCHAR deviceName[32]; wfPeerContext** peers; @@ -66,4 +67,4 @@ void wf_info_find_invalid_region(wfInfo* wfi); void wf_info_clear_invalid_region(wfInfo* wfi); BOOL wf_info_have_invalid_region(wfInfo* wfi); -#endif +#endif /* WF_INFO_H */ diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index e8dc2bde0..5d8b15c53 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -46,24 +46,6 @@ void wf_peer_context_free(freerdp_peer* client, wfPeerContext* context) wf_info_peer_unregister(context->info, context); } -void wf_peer_start_encoder_thread(freerdp_peer* client) -{ - wfInfo* wfi; - - wfi = ((wfPeerContext*) client->context)->info; - - wf_info_lock(wfi); - - wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, 0, NULL); - - if (!wfi->updateThread) - { - _tprintf(_T("Failed to create update thread\n")); - } - - wf_info_unlock(wfi); -} - void wf_peer_init(freerdp_peer* client) { client->context_size = sizeof(wfPeerContext); @@ -99,9 +81,10 @@ boolean wf_peer_post_connect(freerdp_peer* client) settings->color_depth = wfi->bitsPerPixel; client->update->DesktopResize(client->update->context); + client->activated = false; } - wf_peer_start_encoder_thread(client); + ResumeThread(wfi->updateThread); return true; } diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index a0be67fd5..c4ca0f2cb 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -38,10 +38,11 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) DWORD beg, end; DWORD diff, rate; - fps = 24; - rate = 1000 / fps; wfi = (wfInfo*) lpParam; - + + fps = wfi->framesPerSecond; + rate = 1000 / fps; + while (1) { beg = GetTickCount();