From 58525ca41538a9a6d76a6550b48657b50f7f51da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 20 Sep 2012 00:22:13 -0400 Subject: [PATCH] wfreerdp-server: fix encoder on Windows 7 --- .gitignore | 1 + server/Windows/wf_info.c | 21 ++++++--------------- server/Windows/wf_peer.c | 12 ++++++++++++ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 1b060b8e9..21444d459 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ client/X11/xfreerdp.1 *.opensdf ipch Debug +RelWithDebInfo # Binaries *.a diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 6adba3fd5..addd7e132 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -125,6 +125,7 @@ wfInfo* wf_info_init() } wfi->updateEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + printf("updateEvent created\n"); wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL); @@ -192,16 +193,12 @@ void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) context->info = wfi; context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - if (wfi->peerCount == 0) - { #ifdef WITH_WIN8 + if (wfi->peerCount == 0) wf_dxgi_init(wfi); +#else + wf_mirror_driver_activate(wfi); #endif - } - else - { - wf_mirror_driver_activate(wfi); - } wfi->peers[wfi->peerCount++] = ((rdpContext*) context)->peer; @@ -220,12 +217,10 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) printf("Unregistering Peer: %d\n", wfi->peerCount); - if(wfi->peerCount == 0) - { #ifdef WITH_WIN8 + if (wfi->peerCount == 0) wf_dxgi_cleanup(wfi); #endif - } wf_info_unlock(wfi); } @@ -248,12 +243,10 @@ void wf_info_update_changes(wfInfo* wfi) #ifdef WITH_WIN8 wf_dxgi_nextFrame(wfi, wfi->framesPerSecond / 1000); #else - GETCHANGESBUF* buf; buf = (GETCHANGESBUF*) wfi->changeBuffer; wfi->nextUpdate = buf->buffer->counter; - #endif } @@ -274,7 +267,7 @@ void wf_info_find_invalid_region(wfInfo* wfi) #endif if (wfi->invalid.left < 0) - wfi->invalid.left = 0; + wfi->invalid.left = 0; if (wfi->invalid.top < 0) wfi->invalid.top = 0; @@ -284,7 +277,6 @@ void wf_info_find_invalid_region(wfInfo* wfi) if (wfi->invalid.bottom >= wfi->height) wfi->invalid.bottom = wfi->height - 1; - } void wf_info_clear_invalid_region(wfInfo* wfi) @@ -323,6 +315,5 @@ void wf_info_getScreenData(wfInfo* wfi, long* width, long* height, uint8** pBits *pBits = ((uint8*) (changes->Userbuffer)) + offset; *pitch = wfi->width * 4; } - #endif } diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index 8cfbdd198..7a18894a8 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -138,6 +138,8 @@ DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) ZeroMemory(rfds, sizeof(rfds)); context = (wfPeerContext*) client->context; + printf("PeerSocketListener\n"); + while (1) { rcount = 0; @@ -220,11 +222,15 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) wfi = context->info; context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + printf("socketEvent created\n"); + context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL); context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL); printf("We've got a client %s\n", client->local ? "(local)" : client->hostname); + printf("Setting Handles\n"); + nCount = 0; handles[nCount++] = context->updateEvent; handles[nCount++] = context->socketEvent; @@ -233,6 +239,12 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) { status = WaitForMultipleObjects(nCount, handles, FALSE, INFINITE); + if ((status == WAIT_FAILED) || (status == WAIT_TIMEOUT)) + { + printf("WaitForMultipleObjects failed\n"); + break; + } + if (WaitForSingleObject(context->updateEvent, 0) == 0) { if (client->activated)