[Spice-devel] [PATCH v2] Move streaming_video to RedsState struct

Jonathon Jongsma jjongsma at redhat.com
Wed Feb 3 22:10:56 CET 2016


Also requires adding reds_get_streaming_video() accessor so that other
files can check this value.
---

 - Changed back to assert

 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 fa2a42c..374d5a9 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_assert(reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_INVALID);
+
+    if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
         (spice_server_get_image_compression(reds) != 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 f6c4f45..0549047 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1541,7 +1541,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 504cb27..6f9bbaf 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -216,6 +216,7 @@ struct RedsState {
     uint8_t spice_uuid[16];
 
     gboolean ticketing_enabled;
+    uint32_t streaming_video;
     SpiceImageCompression image_compression;
     spice_wan_compression_t jpeg_state;
 };
diff --git a/server/reds.c b/server/reds.c
index 91550ed..f50690c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -146,7 +146,6 @@ static SpiceCoreInterfaceInternal core_interface_adapter = {
 
 static pthread_mutex_t *lock_cs;
 static long *lock_count;
-uint32_t streaming_video = SPICE_STREAM_VIDEO_FILTER;
 spice_wan_compression_t zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
 int agent_mouse = TRUE;
 int agent_copypaste = TRUE;
@@ -3426,6 +3425,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;
     reds->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
     reds->jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
     return reds;
@@ -3782,11 +3782,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 97b08b5..e62f0ba 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -73,7 +73,6 @@ enum {
 };
 
 extern struct SpiceCoreInterfaceInternal *core;
-extern uint32_t streaming_video;
 extern spice_wan_compression_t zlib_glz_state;
 
 // Temporary measures to make splitting reds.c to inputs-channel.c easier
@@ -111,6 +110,7 @@ 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);
 spice_wan_compression_t reds_get_jpeg_state(const RedsState *reds);
 
 #endif
-- 
2.4.3



More information about the Spice-devel mailing list