[Spice-devel] [PATCH 10/16] display: add update_compression() method

Frediano Ziglio fziglio at redhat.com
Thu Nov 26 08:06:07 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
 server/display-channel.c | 17 +++++++++++++++++
 server/display-channel.h |  2 ++
 server/red_worker.c      | 21 ++++-----------------
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 28fd565..13a14a2 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2088,3 +2088,20 @@ exit:
     red_put_surface_cmd(surface);
     free(surface);
 }
+
+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;
+    } 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;
+    } else {
+        display->enable_zlib_glz_wrap = (dcc->zlib_glz_state == SPICE_WAN_COMPRESSION_ALWAYS);
+    }
+    spice_info("jpeg %s", display->enable_jpeg ? "enabled" : "disabled");
+    spice_info("zlib-over-glz %s", display->enable_zlib_glz_wrap ? "enabled" : "disabled");
+}
diff --git a/server/display-channel.h b/server/display-channel.h
index 5fa17e6..7f3d408 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -305,6 +305,8 @@ void                       display_channel_process_surface_cmd       (DisplayCha
                                                                       RedSurfaceCmd *surface,
                                                                       uint32_t group_id,
                                                                       int loadvm);
+void                       display_channel_update_compression        (DisplayChannel *display,
+                                                                      DisplayChannelClient *dcc);
 
 static inline int validate_surface(DisplayChannel *display, uint32_t surface_id)
 {
diff --git a/server/red_worker.c b/server/red_worker.c
index cf9e41f..2a58052 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -727,34 +727,21 @@ static void handle_new_display_channel(RedWorker *worker, RedClient *client, Red
                                        uint32_t *common_caps, int num_common_caps,
                                        uint32_t *caps, int num_caps)
 {
-    DisplayChannel *display_channel;
+    DisplayChannel *display;
     DisplayChannelClient *dcc;
 
     spice_return_if_fail(worker->display_channel);
 
-    display_channel = worker->display_channel;
+    display = worker->display_channel;
     spice_info("add display channel client");
-    dcc = dcc_new(display_channel, client, stream, migrate,
+    dcc = dcc_new(display, client, stream, migrate,
                   common_caps, num_common_caps, caps, num_caps,
                   worker->image_compression, worker->jpeg_state, worker->zlib_glz_state);
     if (!dcc) {
         return;
     }
 
-    if (dcc->jpeg_state == SPICE_WAN_COMPRESSION_AUTO) {
-        display_channel->enable_jpeg = dcc->common.is_low_bandwidth;
-    } else {
-        display_channel->enable_jpeg = (dcc->jpeg_state == SPICE_WAN_COMPRESSION_ALWAYS);
-    }
-
-    if (dcc->zlib_glz_state == SPICE_WAN_COMPRESSION_AUTO) {
-        display_channel->enable_zlib_glz_wrap = dcc->common.is_low_bandwidth;
-    } else {
-        display_channel->enable_zlib_glz_wrap = (dcc->zlib_glz_state ==
-                                                 SPICE_WAN_COMPRESSION_ALWAYS);
-    }
-    spice_info("jpeg %s", display_channel->enable_jpeg ? "enabled" : "disabled");
-    spice_info("zlib-over-glz %s", display_channel->enable_zlib_glz_wrap ? "enabled" : "disabled");
+    display_channel_update_compression(display, dcc);
 
     guest_set_client_capabilities(worker);
     dcc_start(dcc);
-- 
2.4.3



More information about the Spice-devel mailing list