[Spice-devel] [PATCH 17/18] Move image_compression to RedsState struct
Frediano Ziglio
fziglio at redhat.com
Fri Jan 29 04:02:13 PST 2016
From: Jonathon Jongsma <jjongsma at redhat.com>
Removing more global variables
---
server/red-dispatcher.c | 4 ++--
server/red-worker.c | 3 ++-
server/reds-private.h | 1 +
server/reds.c | 14 +++++++-------
server/reds.h | 1 -
5 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 5bc2d87..ac2cc3d 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -707,7 +707,7 @@ static inline int calc_compression_level(void)
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)) {
+ (spice_server_get_image_compression(reds) != SPICE_IMAGE_COMPRESSION_QUIC)) {
return 0;
} else {
return 1;
@@ -722,7 +722,7 @@ void red_dispatcher_on_ic_change(void)
while (now) {
now->qxl->st->qif->set_compression_level(now->qxl, compression_level);
- payload.image_compression = image_compression;
+ payload.image_compression = spice_server_get_image_compression(reds);
dispatcher_send_message(&now->dispatcher,
RED_WORKER_MESSAGE_SET_COMPRESSION,
&payload);
diff --git a/server/red-worker.c b/server/red-worker.c
index dbc57d6..dae5e6b 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1505,7 +1505,8 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
if (worker->record_fd) {
dispatcher_register_universal_handler(dispatcher, worker_dispatcher_record);
}
- worker->image_compression = image_compression;
+
+ worker->image_compression = spice_server_get_image_compression(reds);
worker->jpeg_state = jpeg_state;
worker->zlib_glz_state = zlib_glz_state;
worker->driver_cap_monitors_config = 0;
diff --git a/server/reds-private.h b/server/reds-private.h
index 6a1a11c..7b8159f 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -218,6 +218,7 @@ struct RedsState {
int ticketing_enabled;
uint32_t streaming_video;
+ SpiceImageCompression image_compression;
};
#endif
diff --git a/server/reds.c b/server/reds.c
index 1488522..c6ffd56 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;
-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;
int agent_mouse = TRUE;
@@ -2769,12 +2768,12 @@ static inline void on_activating_ticketing(RedsState *reds)
}
}
-static void set_image_compression(SpiceImageCompression val)
+static void reds_set_image_compression(RedsState *reds, SpiceImageCompression val)
{
- if (val == image_compression) {
+ if (val == reds->image_compression) {
return;
}
- image_compression = val;
+ reds->image_compression = val;
red_dispatcher_on_ic_change();
}
@@ -3435,6 +3434,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
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;
return reds;
}
@@ -3673,18 +3673,18 @@ SPICE_GNUC_VISIBLE int spice_server_set_image_compression(SpiceServer *s,
if (comp == SPICE_IMAGE_COMPRESSION_LZ4) {
spice_warning("LZ4 compression not supported, falling back to auto GLZ");
comp = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
- set_image_compression(comp);
+ reds_set_image_compression(s, comp);
return -1;
}
#endif
- set_image_compression(comp);
+ reds_set_image_compression(s, comp);
return 0;
}
SPICE_GNUC_VISIBLE SpiceImageCompression spice_server_get_image_compression(SpiceServer *s)
{
spice_assert(reds == s);
- return image_compression;
+ return s->image_compression;
}
SPICE_GNUC_VISIBLE int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp)
diff --git a/server/reds.h b/server/reds.h
index fcf1089..5c8a8a5 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -73,7 +73,6 @@ enum {
};
extern struct SpiceCoreInterfaceInternal *core;
-extern SpiceImageCompression image_compression;
extern spice_wan_compression_t jpeg_state;
extern spice_wan_compression_t zlib_glz_state;
--
2.4.3
More information about the Spice-devel
mailing list