Re: [spice-server 3/3] dcc: Add debug log when setting compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Without this it's not obvious that a compression setting took effect.

We spoke about, there was also a request for this debug line.

> ---
>  server/dcc.c   |  3 +++
>  server/utils.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  server/utils.h |  3 +++
>  3 files changed, 48 insertions(+)
> 
> diff --git a/server/dcc.c b/server/dcc.c
> index 826dd28fe..e27d3dcad 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -1093,6 +1093,9 @@ static bool
> dcc_handle_preferred_compression(DisplayChannelClient *dcc,
>      default:
>          spice_warning("preferred-compression: unsupported image compression
>          setting");
>      }
> +    g_debug("Setting preferred compression to %s",
> +            spice_util_genum_get_nick(SPICE_TYPE_SPICE_IMAGE_COMPRESSION_T,
> +                                      dcc->priv->image_compression));
>      return TRUE;
>  }
>  
> diff --git a/server/utils.c b/server/utils.c
> index b8a40b1d9..4b53aa290 100644
> --- a/server/utils.c
> +++ b/server/utils.c
> @@ -114,3 +114,45 @@ int red_channel_name_to_type(const char *name)
>      }
>      return -1;
>  }
> +
> +/* These 2 functions come from
> + * libvirt-glib/libvirt-gconfig/libvirt-gconfig-helpers.c
> + * Copyright (C) 2010, 2011 Red Hat, Inc.
> + * LGPLv2.1+ licensed */

the license is the same, no reason to state here, if it was different
I would prefer to put these in another new file.

> +G_GNUC_INTERNAL const char *

We don't use G_GNUC_INTERNAL in spice-server and spice-common, not
that hurts but is more coherent without.

OT: maybe these would be also useful in spice-common? I remember
Victor once try to write something like this for spice-gtk.

> +spice_util_genum_get_nick(GType enum_type, gint value)

I don't like much the name:
- in spice-server we tend to use spice_ prefix for public function
  (with some old function name exception);
- the function is not dependent to spice, just gobject;
- don't like much the _util_ in the name.

Maybe just genum_get_nick? Or just use the classic prefix, being
red_genum_get_nick.

> +{
> +    GEnumClass *enum_class;
> +    GEnumValue *enum_value;
> +
> +    g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);

spaces style

> +
> +    enum_class = g_type_class_ref(enum_type);
> +    enum_value = g_enum_get_value(enum_class, value);
> +    g_type_class_unref(enum_class);
> +
> +    if (enum_value != NULL)
> +        return enum_value->value_nick;

missing brackets

> +
> +    g_return_val_if_reached(NULL);
> +}
> +
> +G_GNUC_INTERNAL int
> +spice_util_genum_get_value(GType enum_type, const char *nick,

similar comments for this function

> +                           gint default_value)
> +{
> +    GEnumClass *enum_class;
> +    GEnumValue *enum_value;
> +
> +    g_return_val_if_fail(G_TYPE_IS_ENUM(enum_type), default_value);
> +    g_return_val_if_fail(nick != NULL, default_value);
> +
> +    enum_class = g_type_class_ref(enum_type);
> +    enum_value = g_enum_get_value_by_nick(enum_class, nick);
> +    g_type_class_unref(enum_class);
> +
> +    if (enum_value != NULL)
> +        return enum_value->value;

missing brackets

> +
> +    g_return_val_if_reached(default_value);
> +}
> diff --git a/server/utils.h b/server/utils.h
> index 5cb0eb0ee..52b7f5b3e 100644
> --- a/server/utils.h
> +++ b/server/utils.h
> @@ -21,6 +21,7 @@
>  
>  #include <stdint.h>
>  #include <glib.h>
> +#include <glib-object.h>
>  
>  #define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
>  
> @@ -55,5 +56,7 @@ int rgb32_data_has_alpha(int width, int height, size_t
> stride,
>  
>  const char *red_channel_type_to_str(int type);
>  int red_channel_name_to_type(const char *name);
> +int spice_util_genum_get_value(GType enum_type, const char *nick, gint
> default_value);
> +const char *spice_util_genum_get_nick(GType enum_type, gint value);
>  
>  #endif /* UTILS_H_ */

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]