[Spice-devel] [PATCH spice-protocol v2 1/2] Update enums.h for preferred compression message
Christophe Fergeau
cfergeau at redhat.com
Fri Jul 10 02:39:18 PDT 2015
On Fri, Jul 03, 2015 at 03:59:23PM +0200, Christophe Fergeau wrote:
> Hey,
>
> On Mon, Jun 01, 2015 at 04:47:12PM +0200, Javier Celaya wrote:
> > ---
> > spice/enums.h | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/spice/enums.h b/spice/enums.h
> > index 18e2f74..6a0ab0b 100644
> > --- a/spice/enums.h
> > +++ b/spice/enums.h
> > @@ -181,6 +181,19 @@ typedef enum SpiceImageType {
> > SPICE_IMAGE_TYPE_ENUM_END
> > } SpiceImageType;
> >
> > +typedef enum SpiceImageCompress {
> > + SPICE_IMAGE_COMPRESS_INVALID,
> > + SPICE_IMAGE_COMPRESS_OFF,
> > + SPICE_IMAGE_COMPRESS_AUTO_GLZ,
> > + SPICE_IMAGE_COMPRESS_AUTO_LZ,
> > + SPICE_IMAGE_COMPRESS_QUIC,
> > + SPICE_IMAGE_COMPRESS_GLZ,
> > + SPICE_IMAGE_COMPRESS_LZ,
> > + SPICE_IMAGE_COMPRESS_LZ4,
> > +
> > + SPICE_IMAGE_COMPRESS_ENUM_END
> > +} SpiceImageCompress;
> > +
>
> This turns out to be wrong as someone trying to use an older
> spice-server with a newer spice-protocol will get these enum values
> twice resulting in build errors :(
I've been looking at that, I don't have any better idea than moving
these spice-protocol contants to a different prefix
(SPICE_IMAGE_COMPRESSION_), and adding some compat #defines to
spice-server (see attached patches). Dunno if I should rename
SpiceImageCompress to SpiceImageCompression while I'm at it.
Any better idea?
Christophe
-------------- next part --------------
From 90878ea12f47557d3dbe4410600155aff323dd5c Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri, 10 Jul 2015 11:13:53 +0200
Subject: [PATCH] SpiceImageCompress
---
server/red_dispatcher.c | 2 +-
server/red_worker.c | 68 ++++++++++++++++++++++++-------------------------
server/reds.c | 6 ++---
server/spice-server.h | 8 ++++++
spice-common | 2 +-
5 files changed, 47 insertions(+), 39 deletions(-)
diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index faa0d76..083bf1b 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -747,7 +747,7 @@ static inline int calc_compression_level(void)
{
spice_assert(streaming_video != SPICE_STREAM_VIDEO_INVALID);
if ((streaming_video != SPICE_STREAM_VIDEO_OFF) ||
- (image_compression != SPICE_IMAGE_COMPRESS_QUIC)) {
+ (image_compression != SPICE_IMAGE_COMPRESSION_QUIC)) {
return 0;
} else {
return 1;
diff --git a/server/red_worker.c b/server/red_worker.c
index 1071716..7d7f76e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -6561,10 +6561,10 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
display_channel->common.worker->image_compression;
int quic_compress = FALSE;
- if ((image_compression == SPICE_IMAGE_COMPRESS_OFF) ||
+ if ((image_compression == SPICE_IMAGE_COMPRESSION_OFF) ||
((src->y * src->stride) < MIN_SIZE_TO_COMPRESS)) { // TODO: change the size cond
return FALSE;
- } else if (image_compression == SPICE_IMAGE_COMPRESS_QUIC) {
+ } else if (image_compression == SPICE_IMAGE_COMPRESSION_QUIC) {
if (BITMAP_FMT_IS_PLT[src->format]) {
return FALSE;
} else {
@@ -6576,17 +6576,17 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
of the image in bytes (2) unstable bitmaps
*/
if (_stride_is_extra(src) || (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE)) {
- if ((image_compression == SPICE_IMAGE_COMPRESS_LZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_GLZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_LZ4) ||
+ if ((image_compression == SPICE_IMAGE_COMPRESSION_LZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_GLZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_LZ4) ||
BITMAP_FMT_IS_PLT[src->format]) {
return FALSE;
} else {
quic_compress = TRUE;
}
} else {
- if ((image_compression == SPICE_IMAGE_COMPRESS_AUTO_LZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_AUTO_GLZ)) {
+ if ((image_compression == SPICE_IMAGE_COMPRESSION_AUTO_LZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_AUTO_GLZ)) {
if ((src->x < MIN_DIMENSION_TO_QUIC) || (src->y < MIN_DIMENSION_TO_QUIC)) {
quic_compress = FALSE;
} else {
@@ -6611,8 +6611,8 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
#endif
// if bitmaps is picture-like, compress it using jpeg
if (can_lossy && display_channel->enable_jpeg &&
- ((image_compression == SPICE_IMAGE_COMPRESS_AUTO_LZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_AUTO_GLZ))) {
+ ((image_compression == SPICE_IMAGE_COMPRESSION_AUTO_LZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_AUTO_GLZ))) {
// if we use lz for alpha, the stride can't be extra
if (src->format != SPICE_BITMAP_FMT_RGBA || !_stride_is_extra(src)) {
return red_jpeg_compress_image(dcc, dest,
@@ -6624,14 +6624,14 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
} else {
int glz;
int ret;
- if ((image_compression == SPICE_IMAGE_COMPRESS_AUTO_GLZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_GLZ)) {
+ if ((image_compression == SPICE_IMAGE_COMPRESSION_AUTO_GLZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_GLZ)) {
glz = BITMAP_FMT_HAS_GRADUALITY(src->format) && (
(src->x * src->y) < glz_enc_dictionary_get_size(
dcc->glz_dict->dict));
- } else if ((image_compression == SPICE_IMAGE_COMPRESS_AUTO_LZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_LZ) ||
- (image_compression == SPICE_IMAGE_COMPRESS_LZ4)) {
+ } else if ((image_compression == SPICE_IMAGE_COMPRESSION_AUTO_LZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_LZ) ||
+ (image_compression == SPICE_IMAGE_COMPRESSION_LZ4)) {
glz = FALSE;
} else {
spice_error("invalid image compression type %u", image_compression);
@@ -6653,7 +6653,7 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
if (!glz) {
#ifdef USE_LZ4
- if (image_compression == SPICE_IMAGE_COMPRESS_LZ4 &&
+ if (image_compression == SPICE_IMAGE_COMPRESSION_LZ4 &&
bitmap_fmt_is_rgb(src->format) &&
red_channel_client_test_remote_cap(&dcc->common.base,
SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
@@ -6868,10 +6868,10 @@ static void fill_mask(RedChannelClient *rcc, SpiceMarshaller *m,
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
if (mask_bitmap && m) {
- if (display_channel->common.worker->image_compression != SPICE_IMAGE_COMPRESS_OFF) {
+ if (display_channel->common.worker->image_compression != SPICE_IMAGE_COMPRESSION_OFF) {
SpiceImageCompress save_img_comp =
display_channel->common.worker->image_compression;
- display_channel->common.worker->image_compression = SPICE_IMAGE_COMPRESS_OFF;
+ display_channel->common.worker->image_compression = SPICE_IMAGE_COMPRESSION_OFF;
fill_bits(dcc, m, mask_bitmap, drawable, FALSE);
display_channel->common.worker->image_compression = save_img_comp;
} else {
@@ -8871,8 +8871,8 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
comp_mode = display_channel->common.worker->image_compression;
- if (((comp_mode == SPICE_IMAGE_COMPRESS_AUTO_LZ) ||
- (comp_mode == SPICE_IMAGE_COMPRESS_AUTO_GLZ)) && !_stride_is_extra(&bitmap)) {
+ if (((comp_mode == SPICE_IMAGE_COMPRESSION_AUTO_LZ) ||
+ (comp_mode == SPICE_IMAGE_COMPRESSION_AUTO_GLZ)) && !_stride_is_extra(&bitmap)) {
if (BITMAP_FMT_HAS_GRADUALITY(item->image_format)) {
BitmapGradualType grad_level;
@@ -8902,7 +8902,7 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
worker->mem_slots.internal_groupslot_id);
} else {
#ifdef USE_LZ4
- if (comp_mode == SPICE_IMAGE_COMPRESS_LZ4 &&
+ if (comp_mode == SPICE_IMAGE_COMPRESSION_LZ4 &&
bitmap_fmt_is_rgb(bitmap.format) &&
red_channel_client_test_remote_cap(&dcc->common.base,
SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
@@ -10270,15 +10270,15 @@ static int display_channel_handle_preferred_compression(DisplayChannelClient *dc
SpiceMsgcDisplayPreferredCompression *pc) {
DisplayChannel *display_channel = DCC_TO_DC(dcc);
switch (pc->image_compression) {
- case SPICE_IMAGE_COMPRESS_AUTO_LZ:
- case SPICE_IMAGE_COMPRESS_AUTO_GLZ:
- case SPICE_IMAGE_COMPRESS_QUIC:
+ case SPICE_IMAGE_COMPRESSION_AUTO_LZ:
+ case SPICE_IMAGE_COMPRESSION_AUTO_GLZ:
+ case SPICE_IMAGE_COMPRESSION_QUIC:
#ifdef USE_LZ4
- case SPICE_IMAGE_COMPRESS_LZ4:
+ case SPICE_IMAGE_COMPRESSION_LZ4:
#endif
- case SPICE_IMAGE_COMPRESS_LZ:
- case SPICE_IMAGE_COMPRESS_GLZ:
- case SPICE_IMAGE_COMPRESS_OFF:
+ case SPICE_IMAGE_COMPRESSION_LZ:
+ case SPICE_IMAGE_COMPRESSION_GLZ:
+ case SPICE_IMAGE_COMPRESSION_OFF:
display_channel->common.worker->image_compression = pc->image_compression;
return TRUE;
default:
@@ -11745,27 +11745,27 @@ void handle_dev_set_compression(void *opaque, void *payload)
worker->image_compression = msg->image_compression;
switch (worker->image_compression) {
- case SPICE_IMAGE_COMPRESS_AUTO_LZ:
+ case SPICE_IMAGE_COMPRESSION_AUTO_LZ:
spice_info("ic auto_lz");
break;
- case SPICE_IMAGE_COMPRESS_AUTO_GLZ:
+ case SPICE_IMAGE_COMPRESSION_AUTO_GLZ:
spice_info("ic auto_glz");
break;
- case SPICE_IMAGE_COMPRESS_QUIC:
+ case SPICE_IMAGE_COMPRESSION_QUIC:
spice_info("ic quic");
break;
#ifdef USE_LZ4
- case SPICE_IMAGE_COMPRESS_LZ4:
+ case SPICE_IMAGE_COMPRESSION_LZ4:
spice_info("ic lz4");
break;
#endif
- case SPICE_IMAGE_COMPRESS_LZ:
+ case SPICE_IMAGE_COMPRESSION_LZ:
spice_info("ic lz");
break;
- case SPICE_IMAGE_COMPRESS_GLZ:
+ case SPICE_IMAGE_COMPRESSION_GLZ:
spice_info("ic glz");
break;
- case SPICE_IMAGE_COMPRESS_OFF:
+ case SPICE_IMAGE_COMPRESSION_OFF:
spice_info("ic off");
break;
default:
diff --git a/server/reds.c b/server/reds.c
index 0867edb..bca9e76 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -111,7 +111,7 @@ static int ticketing_enabled = 1; //Ticketing is enabled by default
static pthread_mutex_t *lock_cs;
static long *lock_count;
uint32_t streaming_video = SPICE_STREAM_VIDEO_FILTER;
-SpiceImageCompress image_compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
+SpiceImageCompress 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;
@@ -3556,9 +3556,9 @@ SPICE_GNUC_VISIBLE int spice_server_set_image_compression(SpiceServer *s,
{
spice_assert(reds == s);
#ifndef USE_LZ4
- if (comp == SPICE_IMAGE_COMPRESS_LZ4) {
+ if (comp == SPICE_IMAGE_COMPRESSION_LZ4) {
spice_warning("LZ4 compression not supported, falling back to auto GLZ");
- comp = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
+ comp = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
set_image_compression(comp);
return -1;
}
diff --git a/server/spice-server.h b/server/spice-server.h
index 0c707a7..9b5b99b 100644
--- a/server/spice-server.h
+++ b/server/spice-server.h
@@ -69,6 +69,14 @@ int spice_server_remove_interface(SpiceBaseInstance *sin);
// Needed for backward API compatibility
typedef SpiceImageCompress spice_image_compression_t;
+#define SPICE_IMAGE_COMPRESS_INVALID SPICE_IMAGE_COMPRESSION_INVALID
+#define SPICE_IMAGE_COMPRESS_OFF SPICE_IMAGE_COMPRESSION_OFF
+#define SPICE_IMAGE_COMPRESS_AUTO_GLZ SPICE_IMAGE_COMPRESSION_AUTO_GLZ
+#define SPICE_IMAGE_COMPRESS_AUTO_LZ SPICE_IMAGE_COMPRESSION_AUTO_LZ
+#define SPICE_IMAGE_COMPRESS_QUIC SPICE_IMAGE_COMPRESSION_QUIC
+#define SPICE_IMAGE_COMPRESS_GLZ SPICE_IMAGE_COMPRESSION_GLZ
+#define SPICE_IMAGE_COMPRESS_LZ SPICE_IMAGE_COMPRESSION_LZ
+#define SPICE_IMAGE_COMPRESS_LZ4 SPICE_IMAGE_COMPRESSION_LZ4
int spice_server_set_image_compression(SpiceServer *s,
SpiceImageCompress comp);
diff --git a/spice-common b/spice-common
index dc8c9c4..2453c42 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit dc8c9c4188005cc9f5d3b1c5d7bf9ffc63e24f81
+Subproject commit 2453c42c8d694baeb9e6d3f9223425ef10648e37
--
2.4.3
-------------- next part --------------
From cd93d8902c831052abc69102d1b6c1d5840ebe24 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri, 10 Jul 2015 11:09:05 +0200
Subject: [spice-protocol] Rename SpiceImageCompress constants
Having these constants use the same name as the ones in spice-server
0.12.5 causes compilation issues for spice-server users when using
spice-server 0.12.5 or older, and spice-protocol 0.12.8.
---
spice/enums.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/spice/enums.h b/spice/enums.h
index 6a0ab0b..ae5f28d 100644
--- a/spice/enums.h
+++ b/spice/enums.h
@@ -182,16 +182,16 @@ typedef enum SpiceImageType {
} SpiceImageType;
typedef enum SpiceImageCompress {
- SPICE_IMAGE_COMPRESS_INVALID,
- SPICE_IMAGE_COMPRESS_OFF,
- SPICE_IMAGE_COMPRESS_AUTO_GLZ,
- SPICE_IMAGE_COMPRESS_AUTO_LZ,
- SPICE_IMAGE_COMPRESS_QUIC,
- SPICE_IMAGE_COMPRESS_GLZ,
- SPICE_IMAGE_COMPRESS_LZ,
- SPICE_IMAGE_COMPRESS_LZ4,
+ SPICE_IMAGE_COMPRESSION_INVALID,
+ SPICE_IMAGE_COMPRESSION_OFF,
+ SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
+ SPICE_IMAGE_COMPRESSION_AUTO_LZ,
+ SPICE_IMAGE_COMPRESSION_QUIC,
+ SPICE_IMAGE_COMPRESSION_GLZ,
+ SPICE_IMAGE_COMPRESSION_LZ,
+ SPICE_IMAGE_COMPRESSION_LZ4,
- SPICE_IMAGE_COMPRESS_ENUM_END
+ SPICE_IMAGE_COMPRESSION_ENUM_END
} SpiceImageCompress;
typedef enum SpiceImageFlags {
--
2.4.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150710/7c12f939/attachment-0001.sig>
More information about the Spice-devel
mailing list