[Spice-devel] [PATCH 4/5] move is_low_bandwidth to DisplayChannelClient

Frediano Ziglio fziglio at redhat.com
Sat May 7 13:49:54 UTC 2016


The field is only used by DisplayChannelClient, not by CursorChannelClient

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/dcc-send.c        |  2 +-
 server/dcc.c             |  2 +-
 server/dcc.h             |  1 +
 server/display-channel.c | 17 ++++++++++++++---
 server/red-worker.c      | 14 +++++++-------
 server/red-worker.h      |  5 ++---
 server/stream.c          |  4 ++--
 7 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/server/dcc-send.c b/server/dcc-send.c
index fcec8d3..3dfe604 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1831,7 +1831,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;
diff --git a/server/dcc.c b/server/dcc.c
index 32cb5c2..8a79f89 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -1585,7 +1585,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);
diff --git a/server/dcc.h b/server/dcc.h
index 1dd53bd..ae60eb7 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -56,6 +56,7 @@ typedef struct FreeList {
 
 struct DisplayChannelClient {
     CommonGraphicsChannelClient common;
+    int is_low_bandwidth;
     uint32_t id;
     SpiceImageCompression image_compression;
     spice_wan_compression_t jpeg_state;
diff --git a/server/display-channel.c b/server/display-channel.c
index 1f4d66f..a037e88 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2019,6 +2019,16 @@ static SpiceCanvas *image_surfaces_get(SpiceImageSurfaces *surfaces, uint32_t su
     return display->surfaces[surface_id].context.canvas;
 }
 
+static int display_channel_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);
+}
+
 DisplayChannel* display_channel_new(SpiceServer *reds, RedWorker *worker, 
                                     int migrate, int stream_video,
                                     uint32_t n_surfaces)
@@ -2031,7 +2041,8 @@ DisplayChannel* display_channel_new(SpiceServer *reds, RedWorker *worker,
         .release_item = release_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 = display_channel_config_socket
     };
     static SpiceImageSurfacesOps image_surfaces_ops = {
         image_surfaces_get,
@@ -2131,13 +2142,13 @@ void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd
 void display_channel_update_compression(DisplayChannel *display, DisplayChannelClient *dcc)
 {
     if (dcc->jpeg_state == SPICE_WAN_COMPRESSION_AUTO) {
-        display->enable_jpeg = dcc->common.is_low_bandwidth;
+        display->enable_jpeg = dcc->is_low_bandwidth;
     } else {
         display->enable_jpeg = (dcc->jpeg_state == SPICE_WAN_COMPRESSION_ALWAYS);
     }
 
     if (dcc->zlib_glz_state == SPICE_WAN_COMPRESSION_AUTO) {
-        display->enable_zlib_glz_wrap = dcc->common.is_low_bandwidth;
+        display->enable_zlib_glz_wrap = dcc->is_low_bandwidth;
     } else {
         display->enable_zlib_glz_wrap = (dcc->zlib_glz_state == SPICE_WAN_COMPRESSION_ALWAYS);
     }
diff --git a/server/red-worker.c b/server/red-worker.c
index c5830aa..e9430a7 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -395,14 +395,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));
@@ -415,8 +415,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
@@ -431,7 +431,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;
 }
@@ -447,11 +447,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;
 
diff --git a/server/red-worker.h b/server/red-worker.h
index e1ed5a7..3798186 100644
--- a/server/red-worker.h
+++ b/server/red-worker.h
@@ -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
diff --git a/server/stream.c b/server/stream.c
index 8884480..0b676c1 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -339,7 +339,7 @@ static void before_reattach_stream(DisplayChannel *display,
         agent = &dcc->stream_agents[index];
 
         if (!dcc->use_video_encoder_rate_control &&
-            !dcc->common.is_low_bandwidth) {
+            !dcc->is_low_bandwidth) {
             continue;
         }
 
@@ -638,7 +638,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 = dcc->common.is_low_bandwidth ?
+            bit_rate = dcc->is_low_bandwidth ?
                 RED_STREAM_DEFAULT_LOW_START_BIT_RATE :
                 RED_STREAM_DEFAULT_HIGH_START_BIT_RATE;
         }
-- 
2.5.5



More information about the Spice-devel mailing list