[Spice-devel] [PATCH 16/18] Move streaming_video to RedsState struct

Frediano Ziglio fziglio at redhat.com
Fri Jan 29 04:02:12 PST 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Also requires adding reds_get_streaming_video() accessor so that other
files can check this value.
---
 server/red-dispatcher.c | 7 ++++---
 server/red-worker.c     | 2 +-
 server/reds-private.h   | 1 +
 server/reds.c           | 9 +++++++--
 server/reds.h           | 2 +-
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index b4bbe85..5bc2d87 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -704,8 +704,9 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
 
 static inline int calc_compression_level(void)
 {
-    spice_assert(streaming_video != SPICE_STREAM_VIDEO_INVALID);
-    if ((streaming_video != SPICE_STREAM_VIDEO_OFF) ||
+    spice_return_val_if_fail(reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_INVALID, -1);
+
+    if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
         (image_compression != SPICE_IMAGE_COMPRESSION_QUIC)) {
         return 0;
     } else {
@@ -736,7 +737,7 @@ void red_dispatcher_on_sv_change(void)
     RedDispatcher *now = dispatchers;
     while (now) {
         now->qxl->st->qif->set_compression_level(now->qxl, compression_level);
-        payload.streaming_video = streaming_video;
+        payload.streaming_video = reds_get_streaming_video(reds);
         dispatcher_send_message(&now->dispatcher,
                                 RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
                                 &payload);
diff --git a/server/red-worker.c b/server/red-worker.c
index 560d172..dbc57d6 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1540,7 +1540,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
 
     worker->cursor_channel = cursor_channel_new(worker);
     // TODO: handle seemless migration. Temp, setting migrate to FALSE
-    worker->display_channel = display_channel_new(worker, FALSE, streaming_video,
+    worker->display_channel = display_channel_new(worker, FALSE, reds_get_streaming_video(reds),
                                                   init_info.n_surfaces);
 
     return worker;
diff --git a/server/reds-private.h b/server/reds-private.h
index 15cf636..6a1a11c 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -217,6 +217,7 @@ struct RedsState {
     uint8_t spice_uuid[16];
 
     int ticketing_enabled;
+    uint32_t streaming_video;
 };
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index b23ec30..1488522 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -145,7 +145,6 @@ static SpiceCoreInterfaceInternal core_interface_adapter = {
 
 static pthread_mutex_t *lock_cs;
 static long *lock_count;
-uint32_t streaming_video = SPICE_STREAM_VIDEO_FILTER;
 SpiceImageCompression image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
 spice_wan_compression_t jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
 spice_wan_compression_t zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
@@ -3435,6 +3434,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
     reds->spice_uuid_is_set = FALSE;
     memset(reds->spice_uuid, 0, sizeof(reds->spice_uuid));
     reds->ticketing_enabled = TRUE; /* ticketing enabled by default */
+    reds->streaming_video = SPICE_STREAM_VIDEO_FILTER;
     return reds;
 }
 
@@ -3790,11 +3790,16 @@ SPICE_GNUC_VISIBLE int spice_server_set_streaming_video(SpiceServer *s, int valu
         value != SPICE_STREAM_VIDEO_ALL &&
         value != SPICE_STREAM_VIDEO_FILTER)
         return -1;
-    streaming_video = value;
+    s->streaming_video = value;
     red_dispatcher_on_sv_change();
     return 0;
 }
 
+uint32_t reds_get_streaming_video(RedsState *reds)
+{
+    return reds->streaming_video;
+}
+
 SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *s, int enable)
 {
     spice_assert(reds == s);
diff --git a/server/reds.h b/server/reds.h
index 24fb2a6..fcf1089 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -73,7 +73,6 @@ enum {
 };
 
 extern struct SpiceCoreInterfaceInternal *core;
-extern uint32_t streaming_video;
 extern SpiceImageCompression image_compression;
 extern spice_wan_compression_t jpeg_state;
 extern spice_wan_compression_t zlib_glz_state;
@@ -113,5 +112,6 @@ void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc);
 void reds_on_char_device_state_destroy(RedsState *reds, SpiceCharDeviceState *dev);
 
 void reds_set_client_mm_time_latency(RedsState *reds, RedClient *client, uint32_t latency);
+uint32_t reds_get_streaming_video(RedsState *reds);
 
 #endif
-- 
2.4.3



More information about the Spice-devel mailing list