move is_low_bandwidth to DisplayChannelClient

The field is only used by DisplayChannelClient, not by CursorChannelClient

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-05-06 22:24:38 +01:00 committed by Jonathon Jongsma
parent 5d61659bba
commit cbc86e7a1f
8 changed files with 35 additions and 17 deletions

View File

@ -25,6 +25,7 @@
struct DisplayChannelClient {
CommonGraphicsChannelClient common;
int is_low_bandwidth;
uint32_t id;
SpiceImageCompression image_compression;
spice_wan_compression_t jpeg_state;

View File

@ -1845,7 +1845,7 @@ static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
MIGRATE_DATA_DISPLAY_MAX_CACHE_CLIENTS == MAX_CACHE_CLIENTS);
display_data.message_serial = red_channel_client_get_message_serial(rcc);
display_data.low_bandwidth_setting = dcc->common.is_low_bandwidth;
display_data.low_bandwidth_setting = dcc->is_low_bandwidth;
display_data.pixmap_cache_freezer = pixmap_cache_freeze(dcc->pixmap_cache);
display_data.pixmap_cache_id = dcc->pixmap_cache->id;

View File

@ -1107,7 +1107,7 @@ int dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mess
spice_critical("restoring global lz dictionary failed");
}
dcc->common.is_low_bandwidth = migrate_data->low_bandwidth_setting;
dcc->is_low_bandwidth = migrate_data->low_bandwidth_setting;
if (migrate_data->low_bandwidth_setting) {
red_channel_client_ack_set_client_window(RED_CHANNEL_CLIENT(dcc), WIDE_CLIENT_ACK_WINDOW);
@ -1176,3 +1176,18 @@ void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate)
{
dcc->streams_max_bit_rate = rate;
}
int dcc_config_socket(RedChannelClient *rcc)
{
RedClient *client = red_channel_client_get_client(rcc);
MainChannelClient *mcc = red_client_get_main(client);
RCC_TO_DCC(rcc)->is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);
return common_channel_config_socket(rcc);
}
gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc)
{
return dcc->is_low_bandwidth;
}

View File

@ -170,5 +170,7 @@ uint32_t dcc_get_max_stream_latency(DisplayChannelClient *dcc);
void dcc_set_max_stream_latency(DisplayChannelClient *dcc, uint32_t latency);
uint64_t dcc_get_max_stream_bit_rate(DisplayChannelClient *dcc);
void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate);
int dcc_config_socket(RedChannelClient *rcc);
gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc);
#endif /* DCC_H_ */

View File

@ -1897,7 +1897,8 @@ DisplayChannel* display_channel_new(SpiceServer *reds, RedWorker *worker,
.send_item = dcc_send_item,
.handle_migrate_flush_mark = handle_migrate_flush_mark,
.handle_migrate_data = handle_migrate_data,
.handle_migrate_data_get_serial = handle_migrate_data_get_serial
.handle_migrate_data_get_serial = handle_migrate_data_get_serial,
.config_socket = dcc_config_socket
};
static SpiceImageSurfacesOps image_surfaces_ops = {
image_surfaces_get,
@ -1992,13 +1993,13 @@ void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd
void display_channel_update_compression(DisplayChannel *display, DisplayChannelClient *dcc)
{
if (dcc_get_jpeg_state(dcc) == SPICE_WAN_COMPRESSION_AUTO) {
display->enable_jpeg = ((CommonGraphicsChannelClient*)dcc)->is_low_bandwidth;
display->enable_jpeg = dcc_is_low_bandwidth(dcc);
} else {
display->enable_jpeg = (dcc_get_jpeg_state(dcc) == SPICE_WAN_COMPRESSION_ALWAYS);
}
if (dcc_get_zlib_glz_state(dcc) == SPICE_WAN_COMPRESSION_AUTO) {
display->enable_zlib_glz_wrap = ((CommonGraphicsChannelClient*)dcc)->is_low_bandwidth;
display->enable_zlib_glz_wrap = dcc_is_low_bandwidth(dcc);
} else {
display->enable_zlib_glz_wrap = (dcc_get_zlib_glz_state(dcc) == SPICE_WAN_COMPRESSION_ALWAYS);
}

View File

@ -400,14 +400,14 @@ static void flush_all_qxl_commands(RedWorker *worker)
flush_cursor_commands(worker);
}
static int common_channel_config_socket(RedChannelClient *rcc)
int common_channel_config_socket(RedChannelClient *rcc)
{
RedClient *client = red_channel_client_get_client(rcc);
MainChannelClient *mcc = red_client_get_main(client);
RedsStream *stream = red_channel_client_get_stream(rcc);
CommonGraphicsChannelClient *ccc = COMMON_GRAPHICS_CHANNEL_CLIENT(rcc);
int flags;
int delay_val;
gboolean is_low_bandwidth;
if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
spice_warning("accept failed, %s", strerror(errno));
@ -420,8 +420,8 @@ static int common_channel_config_socket(RedChannelClient *rcc)
}
// TODO - this should be dynamic, not one time at channel creation
ccc->is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);
delay_val = ccc->is_low_bandwidth ? 0 : 1;
is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);
delay_val = is_low_bandwidth ? 0 : 1;
/* FIXME: Using Nagle's Algorithm can lead to apparent delays, depending
* on the delayed ack timeout on the other side.
* Instead of using Nagle's, we need to implement message buffering on
@ -436,7 +436,7 @@ static int common_channel_config_socket(RedChannelClient *rcc)
}
// TODO: move wide/narrow ack setting to red_channel.
red_channel_client_ack_set_client_window(rcc,
ccc->is_low_bandwidth ?
is_low_bandwidth ?
WIDE_CLIENT_ACK_WINDOW : NARROW_CLIENT_ACK_WINDOW);
return TRUE;
}
@ -452,11 +452,11 @@ CommonGraphicsChannel *red_worker_new_channel(RedWorker *worker, int size,
spice_return_val_if_fail(worker, NULL);
spice_return_val_if_fail(channel_cbs, NULL);
spice_return_val_if_fail(!channel_cbs->config_socket, NULL);
spice_return_val_if_fail(!channel_cbs->alloc_recv_buf, NULL);
spice_return_val_if_fail(!channel_cbs->release_recv_buf, NULL);
channel_cbs->config_socket = common_channel_config_socket;
if (!channel_cbs->config_socket)
channel_cbs->config_socket = common_channel_config_socket;
channel_cbs->alloc_recv_buf = common_alloc_recv_buf;
channel_cbs->release_recv_buf = common_release_recv_buf;

View File

@ -26,11 +26,10 @@ typedef struct RedWorker RedWorker;
typedef struct CommonGraphicsChannelClient {
RedChannelClient base;
int is_low_bandwidth;
} CommonGraphicsChannelClient;
#define COMMON_GRAPHICS_CHANNEL_CLIENT(Client) ((CommonGraphicsChannelClient*)(Client))
int common_channel_config_socket(RedChannelClient *rcc);
#define COMMON_CLIENT_TIMEOUT (NSEC_PER_SEC * 30)
#define CHANNEL_RECEIVE_BUF_SIZE 1024

View File

@ -355,7 +355,7 @@ static void before_reattach_stream(DisplayChannel *display,
agent = dcc_get_stream_agent(dcc, index);
if (!dcc_use_video_encoder_rate_control(dcc) &&
!((CommonGraphicsChannelClient*)dcc)->is_low_bandwidth) {
!dcc_is_low_bandwidth(dcc)) {
continue;
}
@ -646,7 +646,7 @@ static uint64_t get_initial_bit_rate(DisplayChannelClient *dcc, Stream *stream)
* If the network info is not initialized due to another reason,
* the low_bandwidth flag is FALSE.
*/
bit_rate = ((CommonGraphicsChannelClient*)dcc)->is_low_bandwidth ?
bit_rate = dcc_is_low_bandwidth(dcc) ?
RED_STREAM_DEFAULT_LOW_START_BIT_RATE :
RED_STREAM_DEFAULT_HIGH_START_BIT_RATE;
}