Stay in handle_messages for 30ms max (per frame).
This commit is contained in:
parent
dfe454f484
commit
21420aaf5c
@ -51,6 +51,10 @@
|
||||
#include "rdp_keymap.h"
|
||||
#include "rdp_settings.h"
|
||||
|
||||
/**
|
||||
* The maximum duration of a frame in milliseconds.
|
||||
*/
|
||||
#define GUAC_RDP_FRAME_DURATION 30
|
||||
|
||||
/**
|
||||
* Client data that will remain accessible through the guac_client.
|
||||
|
@ -198,8 +198,12 @@ int rdp_guac_client_handle_messages(guac_client* client) {
|
||||
|
||||
/* Wait for messages */
|
||||
int wait_result = rdp_guac_client_wait_for_messages(client, 250000);
|
||||
guac_timestamp frame_start = guac_timestamp_current();
|
||||
while (wait_result > 0) {
|
||||
|
||||
guac_timestamp frame_end;
|
||||
int frame_remaining;
|
||||
|
||||
pthread_mutex_lock(&(guac_client_data->rdp_lock));
|
||||
|
||||
/* Check the libfreerdp fds */
|
||||
@ -247,9 +251,18 @@ int rdp_guac_client_handle_messages(guac_client* client) {
|
||||
if (guac_client_data->audio != NULL)
|
||||
guac_socket_flush(guac_client_data->audio->stream->socket);
|
||||
|
||||
/* Wait again */
|
||||
pthread_mutex_unlock(&(guac_client_data->rdp_lock));
|
||||
wait_result = rdp_guac_client_wait_for_messages(client, 0);
|
||||
|
||||
/* Calculate time remaining in frame */
|
||||
frame_end = guac_timestamp_current();
|
||||
frame_remaining = frame_start + GUAC_RDP_FRAME_DURATION - frame_end;
|
||||
|
||||
/* Wait again if frame remaining */
|
||||
if (frame_remaining > 0)
|
||||
wait_result = rdp_guac_client_wait_for_messages(client,
|
||||
frame_remaining*1000);
|
||||
else
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,11 @@
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
/**
|
||||
* The maximum duration of a frame in milliseconds.
|
||||
*/
|
||||
#define GUAC_VNC_FRAME_DURATION 30
|
||||
|
||||
extern char* __GUAC_CLIENT;
|
||||
|
||||
typedef struct vnc_guac_client_data {
|
||||
|
@ -53,21 +53,31 @@
|
||||
|
||||
int vnc_guac_client_handle_messages(guac_client* client) {
|
||||
|
||||
int wait_result;
|
||||
rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client;
|
||||
|
||||
/* Initially wait for messages */
|
||||
wait_result = WaitForMessage(rfb_client, 1000000);
|
||||
int wait_result = WaitForMessage(rfb_client, 1000000);
|
||||
guac_timestamp frame_start = guac_timestamp_current();
|
||||
while (wait_result > 0) {
|
||||
|
||||
guac_timestamp frame_end;
|
||||
int frame_remaining;
|
||||
|
||||
/* Handle any message received */
|
||||
if (!HandleRFBServerMessage(rfb_client)) {
|
||||
guac_client_log_error(client, "Error handling VNC server message\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check for additional messages */
|
||||
wait_result = WaitForMessage(rfb_client, 0);
|
||||
/* Calculate time remaining in frame */
|
||||
frame_end = guac_timestamp_current();
|
||||
frame_remaining = frame_start + GUAC_VNC_FRAME_DURATION - frame_end;
|
||||
|
||||
/* Wait again if frame remaining */
|
||||
if (frame_remaining > 0)
|
||||
wait_result = WaitForMessage(rfb_client, frame_remaining*1000);
|
||||
else
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user