[Spice-devel] [PATCH] vdagent-virtio-port: fix two -Werror=pointer-sign

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 src/vdagent-virtio-port.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vdagent-virtio-port.c b/src/vdagent-virtio-port.c
index bacfa42..a5da35f 100644
--- a/src/vdagent-virtio-port.c
+++ b/src/vdagent-virtio-port.c
@@ -359,7 +359,7 @@ static void vdagent_virtio_port_do_chunk(struct 
vdagent_virtio_port **vportp)
 }
 }
 
-static int vport_read(struct vdagent_virtio_port *vport, char *buf, int len)
+static int vport_read(struct vdagent_virtio_port *vport, uint8_t *buf, int len)
 {
 if (vport-is_uds) {
 return recv(vport-fd, buf, len, 0);
@@ -447,7 +447,7 @@ static void vdagent_virtio_port_do_read(struct 
vdagent_virtio_port **vportp)
 }
 }
 
-static int vport_write(struct vdagent_virtio_port *vport, char *buf, int len)
+static int vport_write(struct vdagent_virtio_port *vport, uint8_t *buf, int 
len)
 {
 if (vport-is_uds) {
 return send(vport-fd, buf, len, 0);
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] vdagent-virtio-port: fix two -Werror=pointer-sign

2013-09-08 Thread Uri Lublin

On 09/08/2013 11:24 AM, Alon Levy wrote:

Signed-off-by: Alon Levy al...@redhat.com
---
  src/vdagent-virtio-port.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vdagent-virtio-port.c b/src/vdagent-virtio-port.c
index bacfa42..a5da35f 100644
--- a/src/vdagent-virtio-port.c
+++ b/src/vdagent-virtio-port.c
@@ -359,7 +359,7 @@ static void vdagent_virtio_port_do_chunk(struct 
vdagent_virtio_port **vportp)
  }
  }
  
-static int vport_read(struct vdagent_virtio_port *vport, char *buf, int len)

+static int vport_read(struct vdagent_virtio_port *vport, uint8_t *buf, int len)
  {
  if (vport-is_uds) {
  return recv(vport-fd, buf, len, 0);
@@ -447,7 +447,7 @@ static void vdagent_virtio_port_do_read(struct 
vdagent_virtio_port **vportp)
  }
  }
  
-static int vport_write(struct vdagent_virtio_port *vport, char *buf, int len)

+static int vport_write(struct vdagent_virtio_port *vport, uint8_t *buf, int 
len)
  {
  if (vport-is_uds) {
  return send(vport-fd, buf, len, 0);


Ack.
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl] fix a bunch of warnings - unused variables, lables, code

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 src/qxl_kms.c | 27 ---
 src/qxl_surface.c |  7 +--
 2 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/src/qxl_kms.c b/src/qxl_kms.c
index b091a12..32859cc 100644
--- a/src/qxl_kms.c
+++ b/src/qxl_kms.c
@@ -83,7 +83,6 @@ static Bool qxl_open_drm_master(ScrnInfoPtr pScrn)
return FALSE;
 }
 
- out:
 qxl-drmmode.fd = qxl-drm_fd;
 return TRUE;
 }
@@ -181,7 +180,6 @@ qxl_create_screen_resources_kms(ScreenPtr pScreen)
 Bool   ret;
 PixmapPtr  pPixmap;
 qxl_surface_t *surf;
-inti;
 
 pScreen-CreateScreenResources = qxl-create_screen_resources;
 ret = pScreen-CreateScreenResources (pScreen);
@@ -257,7 +255,6 @@ Bool qxl_screen_init_kms(SCREEN_INIT_ARGS_DECL)
 ScrnInfoPtrpScrn = xf86ScreenToScrn (pScreen);
 qxl_screen_t * qxl = pScrn-driverPrivate;
 VisualPtr  visual;
-uint64_t n_surf;
 
 miClearVisualTypes ();
 if (!miSetVisualTypes (pScrn-depth, miGetDefaultVisualMask (pScrn-depth),
@@ -369,7 +366,6 @@ static struct qxl_bo *qxl_bo_alloc(qxl_screen_t *qxl,
 return NULL; // an invalid handle
 }
 
- out:
 bo-name = name;
 bo-size = size;
 bo-type = QXL_BO_DATA;
@@ -383,8 +379,6 @@ static struct qxl_bo *qxl_cmd_alloc(qxl_screen_t *qxl,
unsigned long size, const char *name)
 {
 struct qxl_kms_bo *bo;
-struct drm_qxl_alloc alloc;
-int ret;
 
 bo = calloc(1, sizeof(struct qxl_kms_bo));
 if (!bo)
@@ -500,27 +494,6 @@ static void qxl_bo_output_bo_reloc(qxl_screen_t *qxl, 
uint32_t dst_offset,
 qxl-cmds.n_relocs++;
 }
 
-static void qxl_bo_output_cmd_reloc(qxl_screen_t *qxl, QXLCommand *command,
-   struct qxl_bo *_src_bo)
-{
-struct qxl_kms_bo *src_bo = (struct qxl_kms_bo *)_src_bo;
-struct drm_qxl_reloc *r = qxl-cmds.relocs[qxl-cmds.n_relocs];
-
-if (qxl-cmds.n_reloc_bos = MAX_RELOCS || qxl-cmds.n_relocs = 
MAX_RELOCS)
-  assert(0);
-
-qxl-cmds.reloc_bo[qxl-cmds.n_reloc_bos] = _src_bo;
-qxl-cmds.n_reloc_bos++;
-src_bo-refcnt++;
-/* fix the kernel names */
-r-reloc_type = QXL_RELOC_TYPE_BO;
-r-dst_handle = 0;
-r-src_handle = src_bo-handle;
-r-dst_offset = 0;
-r-src_offset = 0;
-qxl-cmds.n_relocs++;
-}
-
 static void qxl_bo_write_command(qxl_screen_t *qxl, uint32_t cmd_type, struct 
qxl_bo *_bo)
 {
 struct qxl_kms_bo *bo = (struct qxl_kms_bo *)_bo;
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 5e6737a..685d09f 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -471,10 +471,8 @@ image_from_surface_internal(qxl_screen_t *qxl,
 return image_bo;
 }
 
-struct qxl_bo *image_from_surface(qxl_screen_t *qxl, qxl_surface_t *dest)
+static struct qxl_bo *image_from_surface(qxl_screen_t *qxl, qxl_surface_t 
*dest)
 {
-struct QXLImage *image_bo;
-
 if (!dest-image_bo)
   dest-image_bo = image_from_surface_internal(qxl, dest);
 
@@ -520,7 +518,6 @@ qxl_surface_copy (qxl_surface_t *dest,
 else
 {
struct qxl_bo *image_bo;
-   struct QXLImage *image;
 
dest-u.copy_src-ref_count++;
 
@@ -590,8 +587,6 @@ image_from_picture (qxl_screen_t *qxl,
qxl_surface_t *surface,
int *force_opaque)
 {
-struct qxl_bo *image_bo;
-
 if (picture-format == PICT_x8r8g8b8)
*force_opaque = TRUE;
 else
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 01/11] xspice: support sending monitors config

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
v2: fixed the introduces warnings, and handled read errors in uinput.

 src/qxl_io.c   |  9 +++--
 src/spiceqxl_display.c | 10 ++
 src/spiceqxl_display.h |  2 ++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/qxl_io.c b/src/qxl_io.c
index 37bdc24..8fa90b6 100644
--- a/src/qxl_io.c
+++ b/src/qxl_io.c
@@ -29,6 +29,12 @@
 #include errno.h
 #include time.h
 #include qxl.h
+
+#ifdef XSPICE
+#include spiceqxl_display.h
+#endif
+
+
 #ifndef XSPICE
 static void
 qxl_wait_for_io_command (qxl_screen_t *qxl)
@@ -175,11 +181,10 @@ qxl_io_monitors_config_async (qxl_screen_t *qxl)
 #ifndef XSPICE
 if (qxl-pci-revision  4)
return;
-
 ioport_write (qxl, QXL_IO_MONITORS_CONFIG_ASYNC, 0);
 qxl_wait_for_io_command (qxl);
 #else
-fprintf (stderr, UNIMPLEMENTED!\n);
+spiceqxl_display_monitors_config(qxl);
 #endif
 }
 
diff --git a/src/spiceqxl_display.c b/src/spiceqxl_display.c
index b1ce557..9c42d84 100644
--- a/src/spiceqxl_display.c
+++ b/src/spiceqxl_display.c
@@ -307,6 +307,9 @@ static int interface_flush_resources(QXLInstance *sin)
 return ret;
 }
 
+static void interface_async_complete(QXLInstance *sin, uint64_t cookie_token)
+{
+}
 
 static const QXLInterface qxl_interface = {
 .base.type   = SPICE_INTERFACE_QXL,
@@ -327,6 +330,7 @@ static const QXLInterface qxl_interface = {
 .req_cursor_notification = interface_req_cursor_notification,
 .notify_update   = interface_notify_update,
 .flush_resources = interface_flush_resources,
+.async_complete  = interface_async_complete,
 };
 
 void qxl_add_spice_display_interface(qxl_screen_t *qxl)
@@ -342,3 +346,9 @@ void qxl_add_spice_display_interface(qxl_screen_t *qxl)
 qxl-display_sin.st = (struct QXLState*)qxl;
 spice_server_add_interface(qxl-spice_server, qxl-display_sin.base);
 }
+
+void spiceqxl_display_monitors_config(qxl_screen_t *qxl)
+{
+spice_qxl_monitors_config_async(qxl-display_sin, 
(QXLPHYSICAL)qxl-monitors_config,
+MEMSLOT_GROUP, 0);
+}
diff --git a/src/spiceqxl_display.h b/src/spiceqxl_display.h
index 1113f6a..0b17b78 100644
--- a/src/spiceqxl_display.h
+++ b/src/spiceqxl_display.h
@@ -30,4 +30,6 @@ void qxl_add_spice_display_interface(qxl_screen_t *qxl);
 /* spice-server to device, now spice-server to xspice */
 void qxl_send_events(qxl_screen_t *qxl, int events);
 
+void spiceqxl_display_monitors_config(qxl_screen_t *qxl);
+
 #endif // QXL_SPICE_DISPLAY_H
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 02/11] qxl_driver: fix build for Xspice

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 src/qxl_driver.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index ac5408e..731a71a 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1214,10 +1214,14 @@ qxl_init_scrn (ScrnInfoPtr pScrn, Bool kms)
 pScrn-name = driver_name;
 
 if (kms) {
+#ifndef XSPICE
pScrn-PreInit  = qxl_pre_init_kms;
pScrn-ScreenInit   = qxl_screen_init_kms;
pScrn-EnterVT  = qxl_enter_vt_kms;
pScrn-LeaveVT  = qxl_leave_vt_kms;
+#else
+abort();
+#endif
 } else {
pScrn-PreInit  = qxl_pre_init;
pScrn-ScreenInit   = qxl_screen_init;
@@ -1228,7 +1232,7 @@ qxl_init_scrn (ScrnInfoPtr pScrn, Bool kms)
 pScrn-ValidMode= NULL;
 }
 
-#ifdef XF86DRM_MODE
+#if defined(XF86DRM_MODE)  !defined(XSPICE)
 static char *
 CreatePCIBusID(const struct pci_device *dev)
 {
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 06/11] xspice: add vdagent support

2013-09-08 Thread Alon Levy
Adds a configurable virtio path used to communicate with the vdagentd,
and a configuration variable for enabling the thing.

With this you can have multiple monitors, but due to usage of a tablet
you cannot generate pointer events on and monitors besides the first.

clipboard already works.

The next patch adds uinput emulation to let vdagentd generate uinput
events and fix this glitch.

Signed-off-by: Alon Levy al...@redhat.com
---
 src/Makefile.am|   2 +
 src/qxl.h  |   2 +
 src/qxl_driver.c   |   7 +++
 src/spiceqxl_vdagent.c | 168 +
 src/spiceqxl_vdagent.h |   8 +++
 5 files changed, 187 insertions(+)
 create mode 100644 src/spiceqxl_vdagent.c
 create mode 100644 src/spiceqxl_vdagent.h

diff --git a/src/Makefile.am b/src/Makefile.am
index c237618..c6e6dcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -89,6 +89,8 @@ spiceqxl_drv_la_SOURCES = \
spiceqxl_main_loop.h\
spiceqxl_display.c  \
spiceqxl_display.h  \
+   spiceqxl_vdagent.c  \
+   spiceqxl_vdagent.h  \
spiceqxl_audio.c\
spiceqxl_audio.h\
spiceqxl_inputs.c   \
diff --git a/src/qxl.h b/src/qxl.h
index c026b63..b1ba2e9 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -134,6 +134,8 @@ enum {
 OPTION_SPICE_DH_FILE,
 OPTION_SPICE_EXIT_ON_DISCONNECT,
 OPTION_SPICE_PLAYBACK_FIFO_DIR,
+OPTION_SPICE_VDAGENT_ENABLED,
+OPTION_SPICE_VDAGENT_VIRTIO_PATH,
 #endif
 OPTION_COUNT,
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index d5ad45f..00736a2 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -55,6 +55,7 @@
 #include spiceqxl_io_port.h
 #include spiceqxl_spice_server.h
 #include spiceqxl_audio.h
+#include spiceqxl_vdagent.h
 #endif /* XSPICE */
 
 #include dfps.h
@@ -67,6 +68,7 @@ extern void compat_init_scrn (ScrnInfoPtr);
 static char filter_str[] = filter;
 static char auto_str[]   = auto;
 static char auto_glz_str[]   = auto_glz;
+static char spice_vdagent_virtio_path_default[] = /tmp/xspice-virtio;
 #endif
 static char driver_name[] = QXL_DRIVER_NAME;
 const OptionInfoRec DefaultOptions[] =
@@ -133,6 +135,10 @@ const OptionInfoRec DefaultOptions[] =
   SpiceExitOnDisconnect,OPTV_BOOLEAN,   {0}, FALSE},
 { OPTION_SPICE_PLAYBACK_FIFO_DIR,
   SpicePlaybackFIFODir, OPTV_STRING,{0}, FALSE},
+{ OPTION_SPICE_VDAGENT_ENABLED,
+  SpiceVdagentEnabled,  OPTV_BOOLEAN,   {0}, FALSE},
+{ OPTION_SPICE_VDAGENT_VIRTIO_PATH,
+  SpiceVdagentVirtioPath,   OPTV_STRING,{.str = 
spice_vdagent_virtio_path_default}, FALSE},
 #endif
 
 { -1, NULL, OPTV_NONE, {0}, FALSE }
@@ -639,6 +645,7 @@ spiceqxl_screen_init (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
spice_server_init (qxl-spice_server, qxl-core);
qxl_add_spice_display_interface (qxl);
qxl_add_spice_playback_interface (qxl);
+   spiceqxl_vdagent_init (qxl);
 }
 else
 {
diff --git a/src/spiceqxl_vdagent.c b/src/spiceqxl_vdagent.c
new file mode 100644
index 000..4b029bd
--- /dev/null
+++ b/src/spiceqxl_vdagent.c
@@ -0,0 +1,168 @@
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include errno.h
+#include sys/socket.h
+#include sys/un.h
+#include fcntl.h
+#include unistd.h
+
+#include qxl_option_helpers.h
+
+#include spiceqxl_vdagent.h
+
+static const char *vdagent_virtio_filename;
+static int virtio_fd;
+static int virtio_client_fd = -1;
+static SpiceWatch *virtio_client_watch;
+
+typedef struct XSpiceVdagentCharDeviceInstance {
+SpiceCharDeviceInstance base;
+qxl_screen_t *qxl;
+} XSpiceVdagentCharDeviceInstance;
+
+XSpiceVdagentCharDeviceInstance vdagent_sin = {
+.base = {
+.subtype = vdagent
+}
+};
+
+static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
+{
+int written;
+
+if (virtio_client_fd == -1) {
+return 0;
+}
+written = send(virtio_client_fd, buf, len, 0);
+if (written != len) {
+fprintf(stderr, %s: ERROR: short write to vdagentd - TODO 
buffering\n, __func__);
+}
+return written;
+}
+
+static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
+{
+int read;
+
+if (virtio_client_fd == -1) {
+return 0;
+}
+read = recv(virtio_client_fd, buf, len, 0);
+if (read = 0) {
+if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+return 0;
+}
+fprintf(stderr, ERROR: vdagentd died\n);
+close(virtio_client_fd);
+virtio_client_fd = -1;
+vdagent_sin.qxl-core-watch_remove(virtio_client_watch);
+virtio_client_watch = NULL;
+}
+return read;
+}
+
+static void on_read_available(int fd, int event, void *opaque)
+{
+if (virtio_client_fd == -1) {
+return;
+}
+ 

[Spice-devel] [PATCH xf86-video-qxl v2 05/11] qxl_option_helpers: add required includes

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 src/qxl_option_helpers.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qxl_option_helpers.h b/src/qxl_option_helpers.h
index 12a14ff..7c54c72 100644
--- a/src/qxl_option_helpers.h
+++ b/src/qxl_option_helpers.h
@@ -1,6 +1,8 @@
 #ifndef OPTION_HELPERS_H
 #define OPTION_HELPERS_H
 
+#include xf86Crtc.h
+#include xf86Opt.h
 
 int get_int_option(OptionInfoPtr options, int option_index,
const char *env_name);
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 04/11] spiceqxl_inputs: expose buttons position api for agent usage

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 src/spiceqxl_inputs.c | 41 +
 src/spiceqxl_inputs.h |  2 ++
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/spiceqxl_inputs.c b/src/spiceqxl_inputs.c
index 2b8a15e..b39eeae 100644
--- a/src/spiceqxl_inputs.c
+++ b/src/spiceqxl_inputs.c
@@ -270,6 +270,8 @@ typedef struct XSpicePointer {
 InputInfoPtr pInfo; /* xf86 device handle to post events */
 } XSpicePointer;
 
+static XSpicePointer *g_xspice_pointer;
+
 static void mouse_motion(SpiceMouseInstance *sin, int dx, int dy, int dz,
  uint32_t buttons_state)
 {
@@ -304,22 +306,35 @@ static void tablet_set_logical_size(SpiceTabletInstance* 
sin, int width, int hei
 spice_pointer-height = height;
 }
 
+void spiceqxl_tablet_position(int x, int y, uint32_t buttons_state)
+{
+// TODO: don't ignore buttons_state
+xf86PostMotionEvent(g_xspice_pointer-pInfo-dev, 1, 0, 2, x, y);
+}
+
 static void tablet_position(SpiceTabletInstance* sin, int x, int y,
 uint32_t buttons_state)
 {
-XSpicePointer *spice_pointer = container_of(sin, XSpicePointer, tablet);
-
-// TODO: don't ignore buttons_state
-xf86PostMotionEvent(spice_pointer-pInfo-dev, 1, 0, 2, x, y);
+spiceqxl_tablet_position(x, y, buttons_state);
 }
 
-static void tablet_buttons(SpiceTabletInstance *sin,
-   uint32_t buttons_state)
+void spiceqxl_tablet_buttons(uint32_t buttons_state)
 {
-XSpicePointer *spice_pointer = container_of(sin, XSpicePointer, tablet);
 static uint32_t old_buttons_state = 0;
 int i;
 
+for (i = 0; i  BUTTONS; i++) {
+if ((buttons_state ^ old_buttons_state)  (1  i)) {
+int action = (buttons_state  (1  i));
+xf86PostButtonEvent(g_xspice_pointer-pInfo-dev, 0, i + 1, 
action, 0, 0);
+}
+}
+old_buttons_state = buttons_state;
+}
+
+static void tablet_buttons(SpiceTabletInstance *sin,
+   uint32_t buttons_state)
+{
 // For some reason spice switches the second and third button, undo that.
 // basically undo RED_MOUSE_STATE_TO_LOCAL
 buttons_state = (buttons_state  SPICE_MOUSE_BUTTON_MASK_LEFT) |
@@ -327,14 +342,7 @@ static void tablet_buttons(SpiceTabletInstance *sin,
 ((buttons_state  SPICE_MOUSE_BUTTON_MASK_RIGHT)  1) |
 (buttons_state  ~(SPICE_MOUSE_BUTTON_MASK_LEFT | 
SPICE_MOUSE_BUTTON_MASK_MIDDLE
   |SPICE_MOUSE_BUTTON_MASK_RIGHT));
-
-for (i = 0; i  BUTTONS; i++) {
-if ((buttons_state ^ old_buttons_state)  (1  i)) {
-int action = (buttons_state  (1  i));
-xf86PostButtonEvent(spice_pointer-pInfo-dev, 0, i + 1, action, 
0, 0);
-}
-}
-old_buttons_state = buttons_state;
+spiceqxl_tablet_buttons(buttons_state);
 }
 
 static void tablet_wheel(SpiceTabletInstance* sin, int wheel,
@@ -358,6 +366,7 @@ static const SpiceTabletInterface tablet_interface = {
 };
 
 static char unknown_type_string[] = UNKNOWN;
+
 static int
 XSpiceKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
@@ -382,7 +391,7 @@ XSpicePointerPreInit(InputDriverPtr drv, InputInfoPtr 
pInfo, int flags)
 {
 XSpicePointer *spice_pointer;
 
-spice_pointer = calloc(sizeof(*spice_pointer), 1);
+g_xspice_pointer = spice_pointer = calloc(sizeof(*spice_pointer), 1);
 spice_pointer-mouse.base.sif  = mouse_interface.base;
 spice_pointer-tablet.base.sif = tablet_interface.base;
 spice_pointer-absolute = TRUE;
diff --git a/src/spiceqxl_inputs.h b/src/spiceqxl_inputs.h
index 8b2c815..9ff78cf 100644
--- a/src/spiceqxl_inputs.h
+++ b/src/spiceqxl_inputs.h
@@ -26,5 +26,7 @@
 #include qxl.h
 
 void xspice_add_input_drivers(pointer module);
+void spiceqxl_tablet_buttons(uint32_t buttons_state);
+void spiceqxl_tablet_position(int x, int y, uint32_t buttons_state);
 
 #endif // QXL_SPICE_INPUTS_H
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 08/11] Xspice: use subprocess.Popen, nicer cleanup of files/processes

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 scripts/Xspice | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index bfa9197..b50ea46 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -22,6 +22,7 @@ import sys
 import tempfile
 import atexit
 import time
+from subprocess import Popen
 
 def which(x):
 for p in os.environ['PATH'].split(':'):
@@ -124,13 +125,28 @@ def error(msg, exit_code=1):
 if not args.xorg:
 error(Xorg missing)
 
+cleanup_files = []
+cleanup_processes = []
+
 def cleanup():
-if os.path.isfile(cf.name + .log):
-os.remove(cf.name + .log)
+for f in cleanup_files:
+if os.path.isfile(f):
+os.remove(f)
+for p in cleanup_processes:
+p.kill()
+for p in cleanup_processes:
+p.wait()
+
+def launch(*args, **kw):
+p = Popen(*args, **kw)
+cleanup_processes.append(p)
+return p
+
+atexit.register(cleanup)
 
 if args.auto:
-atexit.register(cleanup)   
 cf = tempfile.NamedTemporaryFile(prefix=Xspice-, delete=True)
+cleanup_files.append(cf.name + .log)
 args.config = cf.name
 xorg_args = [ '-logfile', cf.name + .log ] + xorg_args
 cf.write(
@@ -206,10 +222,10 @@ if cgdb and args.cgdb:
 # This is currently mandatory; the driver cannot survive a reset
 xorg_args = [ '-noreset' ] + xorg_args
 
-xpid = os.spawnv(os.P_NOWAIT, args.xorg, exec_args + xorg_args)
+xorg = launch(executable=args.xorg, args=exec_args + xorg_args)
 time.sleep(2)
 
-retpid,rc = os.waitpid(xpid, os.WNOHANG)
+retpid,rc = os.waitpid(xorg.pid, os.WNOHANG)
 if retpid != 0:
 print Error: X server is not running
 else:
@@ -219,7 +235,7 @@ else:
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
 
 try:
-os.waitpid(xpid, 0)
+xorg.wait()
 except KeyboardInterrupt:
 # Catch Ctrl-C as that is the common way of ending this script
 print Keyboard Interrupt
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 07/11] xspice: add uinput support to vdagent support

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 src/Makefile.am|   2 +
 src/qxl.h  |   1 +
 src/qxl_driver.c   |   3 ++
 src/spiceqxl_uinput.c  | 124 +
 src/spiceqxl_uinput.h  |   8 
 src/spiceqxl_vdagent.c |   2 +
 6 files changed, 140 insertions(+)
 create mode 100644 src/spiceqxl_uinput.c
 create mode 100644 src/spiceqxl_uinput.h

diff --git a/src/Makefile.am b/src/Makefile.am
index c6e6dcd..edc2f0b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,8 @@ spiceqxl_drv_la_SOURCES = \
spiceqxl_display.h  \
spiceqxl_vdagent.c  \
spiceqxl_vdagent.h  \
+   spiceqxl_uinput.c   \
+   spiceqxl_uinput.h   \
spiceqxl_audio.c\
spiceqxl_audio.h\
spiceqxl_inputs.c   \
diff --git a/src/qxl.h b/src/qxl.h
index b1ba2e9..2d3a6ee 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -136,6 +136,7 @@ enum {
 OPTION_SPICE_PLAYBACK_FIFO_DIR,
 OPTION_SPICE_VDAGENT_ENABLED,
 OPTION_SPICE_VDAGENT_VIRTIO_PATH,
+OPTION_SPICE_VDAGENT_UINPUT_PATH,
 #endif
 OPTION_COUNT,
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 00736a2..a27d4fa 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -69,6 +69,7 @@ static char filter_str[] = filter;
 static char auto_str[]   = auto;
 static char auto_glz_str[]   = auto_glz;
 static char spice_vdagent_virtio_path_default[] = /tmp/xspice-virtio;
+static char spice_vdagent_uinput_path_default[] = /tmp/xspice-uinput;
 #endif
 static char driver_name[] = QXL_DRIVER_NAME;
 const OptionInfoRec DefaultOptions[] =
@@ -139,6 +140,8 @@ const OptionInfoRec DefaultOptions[] =
   SpiceVdagentEnabled,  OPTV_BOOLEAN,   {0}, FALSE},
 { OPTION_SPICE_VDAGENT_VIRTIO_PATH,
   SpiceVdagentVirtioPath,   OPTV_STRING,{.str = 
spice_vdagent_virtio_path_default}, FALSE},
+{ OPTION_SPICE_VDAGENT_UINPUT_PATH,
+  SpiceVdagentUinputPath,   OPTV_STRING,{.str = 
spice_vdagent_uinput_path_default}, FALSE},
 #endif
 
 { -1, NULL, OPTV_NONE, {0}, FALSE }
diff --git a/src/spiceqxl_uinput.c b/src/spiceqxl_uinput.c
new file mode 100644
index 000..443f931
--- /dev/null
+++ b/src/spiceqxl_uinput.c
@@ -0,0 +1,124 @@
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include unistd.h
+#include errno.h
+#include stdio.h
+
+#include linux/input.h
+#include linux/uinput.h
+
+#include qxl_option_helpers.h
+#include spiceqxl_inputs.h
+
+#include spiceqxl_uinput.h
+
+static const char *uinput_filename;
+static int uinput_fd;
+static struct input_event inp_event;
+static int offset;
+
+static void spiceqxl_uinput_read_cb(int fd, int event, void *opaque)
+{
+int n;
+static int x = -1;
+static int y = -1;
+static int buttons_state = 0;
+int button = -1;
+
+n = read(uinput_fd, (char *)inp_event + offset, sizeof(inp_event) - 
offset);
+if (n == -1) {
+if (errno != EAGAIN  errno != EINTR  errno != EWOULDBLOCK) {
+fprintf(stderr, spice: uinput read failed: %s\n, 
strerror(errno));
+}
+return;
+}
+offset += n;
+if (offset  sizeof(inp_event)) {
+return;
+}
+offset = 0;
+switch (inp_event.type) {
+case EV_KEY:
+/*  XXX Here we hardcode vdagent-uinput.c mapping since we don't 
support ioctls.
+ *  We could replace the ioctls with additional non uinput messages
+ *  used in vdagentd fake uinput mode. */
+switch (inp_event.code) {
+case BTN_LEFT:
+button = 1  0;
+break;
+case BTN_MIDDLE:
+button = 1  1;
+break;
+case BTN_RIGHT:
+button = 1  2;
+break;
+}
+if (inp_event.value  0) {
+buttons_state |= button;
+} else {
+buttons_state = ~button;
+}
+spiceqxl_tablet_buttons(buttons_state);
+break;
+case EV_REL:
+button = 1;
+if (inp_event.value == 1) {
+button = 1  3;
+} else {
+button = 1  4;
+}
+buttons_state |= button;
+spiceqxl_tablet_buttons(buttons_state);
+buttons_state = ~button;
+spiceqxl_tablet_buttons(buttons_state);
+break;
+case EV_ABS:
+switch (inp_event.code) {
+case ABS_X:
+x = inp_event.value;
+break;
+case ABS_Y:
+y = inp_event.value;
+break;
+default:
+fprintf(stderr, %s: unknown axis %d, ignoring\n, __func__, 
inp_event.code);
+return;
+break;
+}
+spiceqxl_tablet_position(x, y, buttons_state);
+break;
+}
+}
+
+void 

[Spice-devel] [PATCH xf86-video-qxl v2 10/11] Xspice: require display parameter, and set if earlier in environment

2013-09-08 Thread Alon Levy
Signed-off-by: Alon Levy al...@redhat.com
---
 scripts/Xspice | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index 5375624..ba04951 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -213,6 +213,10 @@ display=
 for arg in xorg_args:
 if arg.startswith(:):
 display = arg
+if not display:
+print Error: missing display on line (i.e. :3)
+raise SystemExit
+os.environ ['DISPLAY'] = display
 
 exec_args = [args.xorg, '-config', args.config]
 if cgdb and args.cgdb:
@@ -231,7 +235,6 @@ if retpid != 0:
 else:
 if args.xsession:
 environ = os.environ
-environ ['DISPLAY'] = display
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
 
 try:
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v2 11/11] Xspice: vdagent{, d} launching support

2013-09-08 Thread Alon Levy
It checks for a new enough vdagentd/vdagent via the new -S command line
parameter available via vdagentd -h and vdagent -h.

Signed-off-by: Alon Levy al...@redhat.com
---
 scripts/Xspice | 43 +--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/scripts/Xspice b/scripts/Xspice
index ba04951..5baa5c3 100755
--- a/scripts/Xspice
+++ b/scripts/Xspice
@@ -22,9 +22,11 @@ import sys
 import tempfile
 import atexit
 import time
-from subprocess import Popen
+from subprocess import Popen, PIPE
 
 def which(x):
+if os.path.exists(x):
+return x
 for p in os.environ['PATH'].split(':'):
 candidate = os.path.join(p, x)
 if os.path.exists(candidate):
@@ -82,6 +84,12 @@ parser.add_argument('--streaming-video', choices=['off', 
'all', 'filter'],
 default='filter', help='filter by default')
 add_boolean('--ipv4-only')
 add_boolean('--ipv6-only')
+parser.add_argument('--vdagent', action='store_true', dest='vdagent_enabled', 
default=False, help='disable vdagent launching')
+parser.add_argument('--vdagent-virtio-path', default='/tmp/xspice-virtio', 
help='virtio socket path')
+parser.add_argument('--vdagent-uinput-path', default='/tmp/xspice-uinput', 
help='uinput socket path')
+parser.add_argument('--vdagentd-exec', default='spice-vdagentd')
+parser.add_argument('--vdagent-exec', default='spice-vdagent')
+parser.add_argument('--vdagent-no-launch', default=True, action='store_false', 
dest='vdagent_launch')
 
 #TODO
 #Option SpiceAddr 
@@ -98,6 +106,20 @@ if cgdb:
 
 args, xorg_args = parser.parse_known_args(sys.argv[1:])
 
+def agents_new_enough(args):
+if not os.path.exists(args.vdagent_exec) or not 
os.path.exists(args.vdagentd_exec):
+return False
+for f in [args.vdagent_exec, args.vdagentd_exec]:
+if Popen(args=[f, '-h'], stdout=PIPE).stdout.read().find('-S') == -1:
+return False
+return True
+
+if args.vdagent_enabled:
+args.vdagent_exec = which(args.vdagent_exec)
+args.vdagentd_exec = which(args.vdagentd_exec)
+if not agents_new_enough(args):
+args.vdagent_enabled = False
+
 def tls_files(args):
 if args.tls_port == 0:
 return {}
@@ -196,7 +218,9 @@ var_args = ['port', 'tls_port', 'disable_ticketing',
 'x509_key_file', 'x509_key_password',
 'tls_ciphers', 'dh_file', 'password', 'image_compression',
 'jpeg_wan_compression', 'zlib_glz_wan_compression',
-'streaming_video', 'deferred_fps', 'exit_on_disconnect']
+'streaming_video', 'deferred_fps', 'exit_on_disconnect',
+'vdagent_enabled', 'vdagent_virtio_path', 'vdagent_uinput_path']
+
 for arg in var_args:
 if getattr(args, arg):
 # The Qxl code doesn't respect booleans, so pass them as 0/1
@@ -226,6 +250,13 @@ if cgdb and args.cgdb:
 # This is currently mandatory; the driver cannot survive a reset
 xorg_args = [ '-noreset' ] + xorg_args
 
+
+# TODO /tmp/xspice-vdagent - replace with temporary file in temporary directory
+vdagentd_uds = '/tmp/xspice-vdagent'
+if args.vdagent_enabled:
+for f in [vdagentd_uds, args.vdagent_virtio_path, 
args.vdagent_uinput_path]:
+if os.path.exists(f):
+os.unlink(f)
 xorg = launch(executable=args.xorg, args=exec_args + xorg_args)
 time.sleep(2)
 
@@ -233,6 +264,14 @@ retpid,rc = os.waitpid(xorg.pid, os.WNOHANG)
 if retpid != 0:
 print Error: X server is not running
 else:
+if args.vdagent_enabled and args.vdagent_launch:
+# XXX use systemd --user for this?
+vdagentd = launch(args=[args.vdagentd_exec, '-x', '-S', vdagentd_uds,
+  '-s', args.vdagent_virtio_path, '-u', 
args.vdagent_uinput_path])
+time.sleep(1)
+# TODO wait for uinput pipe open for write
+vdagent = launch(args=[args.vdagent_exec, '-x', '-s', 
args.vdagent_virtio_path, '-S',
+ vdagentd_uds])
 if args.xsession:
 environ = os.environ
 os.spawnlpe(os.P_NOWAIT, args.xsession, environ)
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server] Fix _FORTIFY_SOURCE redefine error

2013-09-08 Thread Uri Lublin

On 09/06/2013 10:57 PM, Dunrong Huang wrote:

If the _FORTIFY_SOURCE has been already defined, we shouldn't redefine
it, or it will raise a build error as below:

In file included from agent-msg-filter.c:21:0:
../config.h:17:0: error: _FORTIFY_SOURCE redefined [-Werror]
agent-msg-filter.c:1:0: note: this is the location of the previous definition

Suggested-by: Christophe Fergeau cferg...@redhat.com
Signed-off-by: Dunrong Huang riegama...@gmail.com
---
  m4/spice-compile-warnings.m4 | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/m4/spice-compile-warnings.m4 b/m4/spice-compile-warnings.m4
index 959971a..31f2a9c 100644
--- a/m4/spice-compile-warnings.m4
+++ b/m4/spice-compile-warnings.m4
@@ -113,7 +113,7 @@ AC_DEFUN([SPICE_COMPILE_WARNINGS],[
  # Use improved glibc headers
  AH_VERBATIM([FORTIFY_SOURCE],
  [/* Enable compile-time and run-time bounds-checking, and some warnings. 
*/
-#if __OPTIMIZE__
+#if !defined _FORTIFY_SOURCE   defined __OPTIMIZE__  __OPTIMIZE__
  # define _FORTIFY_SOURCE 2
  #endif
  ])


Ack.
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk] Fix _FORTIFY_SOURCE redefine error

2013-09-08 Thread Uri Lublin

On 09/06/2013 10:59 PM, Dunrong Huang wrote:

If the _FORTIFY_SOURCE has been already defined, we shouldn't redefine
it, or it will raise a build error as below:

In file included from spice-audio.c:36:0:
../config.h:12:0: error: _FORTIFY_SOURCE redefined [-Werror]
spice-audio.c:1:0: note: this is the location of the previous definition

Suggested-by: Christophe Fergeau cferg...@redhat.com
Signed-off-by: Dunrong Huang riegama...@gmail.com
---
  m4/spice-compile-warnings.m4 | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/m4/spice-compile-warnings.m4 b/m4/spice-compile-warnings.m4
index 31fc0fc..533bac6 100644
--- a/m4/spice-compile-warnings.m4
+++ b/m4/spice-compile-warnings.m4
@@ -104,7 +104,7 @@ AC_DEFUN([SPICE_COMPILE_WARNINGS],[
  # Use improved glibc headers
  AH_VERBATIM([FORTIFY_SOURCE],
  [/* Enable compile-time and run-time bounds-checking, and some warnings. 
*/
- #if defined __OPTIMIZE__  __OPTIMIZE__
+ #if !defined _FORTIFY_SOURCE   defined __OPTIMIZE__  __OPTIMIZE__
   # define _FORTIFY_SOURCE 2
   #endif
  ])


Ack.
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] 回复: Sync of audio in android

2013-09-08 Thread jojo
Hi,
Is someone maintaining the playback channel of gstaudio  ?

it looks like behind pulseaudio  with some feature :(  

Thanks,

- Jojo


在 2013年9月6日星期五,上午11:00,jojo 写道:

 Hi,  
 I use gstaudio to enable the audio output in android platform,
  
 but there is the sync issue with this approach, it looks like the pulse audio 
 is  
  
 the better choice.
  
 I research some pulse audio porting in android, some ugly problem looks like 
 bellow which i think about :
  
 * much more device(driver) maybe can not used by PA, they implement with HAL 
 layer with AudioFlinger
  
 * can not use PA as the regular NDK app in NDK, this will be done by OEM in 
 their device
  
 am i right ?  
  
 Thanks,
  
 - Jojo
  

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 00/10] clean-ups and performance (hopefully)

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

Hi,

Some profiling results show rather obvious bottlenecks that I try to
optimize.  In general, the patch series is mostly clean-ups, and the
performance difference is mostly the change in the coroutine loop,
which will now treat all incoming messages before returning to main
coroutine, to avoid GMainLoop overhead.

Please don't ask exacts results, there is no reliable measurements
tools. We are getting there eventually. But in the meantime, the whole
series improves by ~10% cpu usage according to my tests using the
development version of Alon replay tool. Either we consider those
patches good clean-ups, or I'll keep them in a branch until we have
better tools, but that might take a while.

Obvious slowdowns are now mostly in spice-common canvas: quic decode,
spice_pixman_copy_rect, glyphs.

Marc-André Lureau (10):
  display: use bitfields for surface flags
  Add SPICE_DISABLE_CHANNELS
  display: replace ring with hashtable
  display: make the hashtable to destroy the surface
  display: keep a reference to the primary surface
  util: avoid calling getenv for every SPICE_DEBUG
  channel: do not reenter the mainloop at every iteration
  gtk: use GHashTable in display_cache
  gtk: use slices for frequently allocated objects
  gtk: simplify spice_channel_recv_msg

 gtk/channel-base.c |   1 +
 gtk/channel-cursor.c   |  56 +--
 gtk/channel-display-priv.h |   1 -
 gtk/channel-display.c  | 175 +
 gtk/spice-channel-cache.h  | 111 +++-
 gtk/spice-channel-priv.h   |   5 +-
 gtk/spice-channel.c| 107 +--
 gtk/spice-session-priv.h   |   4 +-
 gtk/spice-session.c|  58 +--
 gtk/spice-util.c   |  13 +++-
 spice-common   |   2 +-
 11 files changed, 204 insertions(+), 329 deletions(-)

--
1.8.3.1
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 01/10] display: use bitfields for surface flags

2013-09-08 Thread Marc-André Lureau
Checking by value make the flag fields useless.Uunfortunately, when
adding more flags, the server will have to ensure it can safely send it,
by checking some of new client caps.
---
 gtk/channel-display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 75fa8c2..704d5a7 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -1741,7 +1741,8 @@ static void display_handle_surface_create(SpiceChannel 
*channel, SpiceMsgIn *in)
 surface-stride = create-width * 4;
 surface-size   = surface-height * surface-stride;
 
-if (create-flags == SPICE_SURFACE_FLAGS_PRIMARY) {
+if (create-flags  SPICE_SURFACE_FLAGS_PRIMARY) {
+SPICE_DEBUG(primary flags: %d, create-flags);
 surface-primary = true;
 create_canvas(channel, surface);
 if (c-mark_false_event_id != 0) {
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 02/10] Add SPICE_DISABLE_CHANNELS

2013-09-08 Thread Marc-André Lureau
Allow to disable selectively channels, mainly used for testing,
ex: SPICE_DISABLE_CHANNELS=display spicy-stats -p 12345
---
 gtk/channel-display.c|  4 ++--
 gtk/spice-channel-priv.h |  2 ++
 gtk/spice-channel.c  | 14 --
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 704d5a7..eab1742 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -1889,9 +1889,9 @@ static void spice_display_handle_msg(SpiceChannel 
*channel, SpiceMsgIn *msg)
 
 parent_class = SPICE_CHANNEL_CLASS(spice_display_channel_parent_class);
 
-if (display_handlers[type] != NULL)
+if (display_handlers[type] != NULL) {
 display_handlers[type](channel, msg);
-else if (parent_class-handle_msg)
+} else if (parent_class-handle_msg)
 parent_class-handle_msg(channel, msg);
 else
 g_return_if_reached();
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index be061c5..9e70ff2 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -134,6 +134,8 @@ struct _SpiceChannelPrivate {
 gsize   total_read_bytes;
 uint64_tlast_message_serial;
 GSList  *flushing;
+
+gbooleandisable_channel_msg;
 };
 
 SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel);
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 093b292..778a90b 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -126,6 +126,10 @@ static void spice_channel_constructed(GObject *gobject)
  desc ? desc : unknown, c-channel_type, c-channel_id);
 CHANNEL_DEBUG(channel, %s, __FUNCTION__);
 
+const char *disabled  = g_getenv(SPICE_DISABLE_CHANNELS);
+if (disabled  strstr(disabled, desc))
+c-disable_channel_msg = TRUE;
+
 c-connection_id = spice_session_get_connection_id(c-session);
 spice_session_channel_new(c-session, channel);
 
@@ -2075,10 +2079,13 @@ static void spice_channel_iterate_write(SpiceChannel 
*channel)
 static void spice_channel_iterate_read(SpiceChannel *channel)
 {
 SpiceChannelPrivate *c = channel-priv;
+handler_msg_in handler;
+
 g_return_if_fail(c-state != SPICE_CHANNEL_STATE_MIGRATING);
 
-spice_channel_recv_msg(channel,
-(handler_msg_in)SPICE_CHANNEL_GET_CLASS(channel)-handle_msg, NULL);
+handler = (handler_msg_in) (c-disable_channel_msg ?
+spice_channel_handle_msg : 
SPICE_CHANNEL_GET_CLASS(channel)-handle_msg);
+spice_channel_recv_msg(channel, handler, NULL);
 }
 
 static gboolean wait_migration(gpointer data)
@@ -2777,6 +2784,9 @@ static void spice_channel_handle_msg(SpiceChannel 
*channel, SpiceMsgIn *msg)
 {
 int type = spice_msg_in_type(msg);
 
+if (type  SPICE_N_ELEMENTS(base_handlers)  
channel-priv-disable_channel_msg)
+return;
+
 g_return_if_fail(type  SPICE_N_ELEMENTS(base_handlers));
 g_return_if_fail(base_handlers[type] != NULL);
 
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 03/10] display: replace ring with hashtable

2013-09-08 Thread Marc-André Lureau
With a Spice replay (a tool not yet merged, but available in dev
branches), the following commit improves a little bit performance by not
spending so much CPU time in looking up surfaces. I found initially
hotspot with perf, and get a consistant ~200ms speedup with time
spicy-stats after replacing the ring.

before:
real 0m5.147s
user 0m3.506s
sys  0m1.949s

after:
real 0m5.008s
user 0m3.253s
sys  0m2.015s
---
 gtk/channel-display-priv.h |  1 -
 gtk/channel-display.c  | 33 -
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/gtk/channel-display-priv.h b/gtk/channel-display-priv.h
index 09683be..92cd231 100644
--- a/gtk/channel-display-priv.h
+++ b/gtk/channel-display-priv.h
@@ -37,7 +37,6 @@ G_BEGIN_DECLS
 
 
 typedef struct display_surface {
-RingItemlink;
 guint32 surface_id;
 boolprimary;
 enum SpiceSurfaceFmtformat;
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index eab1742..7a66558 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -66,7 +66,7 @@
 #define MONITORS_MAX 256
 
 struct _SpiceDisplayChannelPrivate {
-Ringsurfaces;
+GHashTable  *surfaces;
 display_cache   *images;
 display_cache   *palettes;
 SpiceImageCache image_cache;
@@ -141,6 +141,7 @@ static void spice_display_channel_finalize(GObject *object)
 
 g_clear_pointer(c-monitors, g_array_unref);
 clear_surfaces(SPICE_CHANNEL(object), FALSE);
+g_hash_table_unref(c-surfaces);
 clear_streams(SPICE_CHANNEL(object));
 
 if (G_OBJECT_CLASS(spice_display_channel_parent_class)-finalize)
@@ -705,7 +706,7 @@ static void spice_display_channel_init(SpiceDisplayChannel 
*channel)
 
 c = channel-priv = SPICE_DISPLAY_CHANNEL_GET_PRIVATE(channel);
 
-ring_init(c-surfaces);
+c-surfaces = g_hash_table_new(NULL, NULL);
 c-image_cache.ops = image_cache_ops;
 c-palette_cache.ops = palette_cache_ops;
 c-image_surfaces.ops = image_surfaces_ops;
@@ -740,7 +741,8 @@ static int create_canvas(SpiceChannel *channel, 
display_surface *surface)
 }
 
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
-ring_remove(primary-link);
+
+g_hash_table_remove(c-surfaces, 0);
 destroy_canvas(primary);
 free(primary);
 }
@@ -792,7 +794,7 @@ static int create_canvas(SpiceChannel *channel, 
display_surface *surface)
  surface-zlib_decoder);
 
 g_return_val_if_fail(surface-canvas != NULL, 0);
-ring_add(c-surfaces, surface-link);
+g_hash_table_insert(c-surfaces, GINT_TO_POINTER(surface-surface_id), 
surface);
 
 if (surface-primary) {
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_CREATE,
@@ -839,35 +841,24 @@ static void destroy_canvas(display_surface *surface)
 
 static display_surface *find_surface(SpiceDisplayChannelPrivate *c, guint32 
surface_id)
 {
-display_surface *surface;
-RingItem *item;
-
-for (item = ring_get_head(c-surfaces);
- item != NULL;
- item = ring_next(c-surfaces, item)) {
-surface = SPICE_CONTAINEROF(item, display_surface, link);
-if (surface-surface_id == surface_id)
-return surface;
-}
-return NULL;
+return g_hash_table_lookup(c-surfaces, GINT_TO_POINTER(surface_id));
 }
 
 static void clear_surfaces(SpiceChannel *channel, gboolean keep_primary)
 {
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)-priv;
+GHashTableIter iter;
 display_surface *surface;
-RingItem *item;
 
-for (item = ring_get_head(c-surfaces); item != NULL; ) {
-surface = SPICE_CONTAINEROF(item, display_surface, link);
-item = ring_next(c-surfaces, item);
+g_hash_table_iter_init(iter, c-surfaces);
+while (g_hash_table_iter_next(iter, NULL, (gpointer*)surface)) {
 
 if (keep_primary  surface-primary) {
 CHANNEL_DEBUG(channel, keeping exisiting primary surface, 
migration or reset);
 continue;
 }
 
-ring_remove(surface-link);
+g_hash_table_iter_remove(iter);
 destroy_canvas(surface);
 free(surface);
 }
@@ -1792,7 +1783,7 @@ static void display_handle_surface_destroy(SpiceChannel 
*channel, SpiceMsgIn *in
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
 }
 
-ring_remove(surface-link);
+g_hash_table_remove(c-surfaces, GINT_TO_POINTER(surface-surface_id));
 destroy_canvas(surface);
 free(surface);
 }
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 05/10] display: keep a reference to the primary surface

2013-09-08 Thread Marc-André Lureau
Avoid hard-coding surface 0 as being primary, although in practice it
always is so far. Also a lot of lookups are primary, so add a shortcut
for this special case (~30% apparently), it shows some small lookup
speedup.

before:
real 0m5.008s
user 0m3.253s
sys  0m2.015s

after:
real0m4.930s
user0m3.133s
sys 0m2.027s
---
 gtk/channel-display.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 979ce7b..03ae535 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -67,6 +67,7 @@
 
 struct _SpiceDisplayChannelPrivate {
 GHashTable  *surfaces;
+display_surface *primary;
 display_cache   *images;
 display_cache   *palettes;
 SpiceImageCache image_cache;
@@ -180,13 +181,11 @@ static void spice_display_get_property(GObject*object,
 
 switch (prop_id) {
 case PROP_WIDTH: {
-display_surface *surface = find_surface(c, 0);
-g_value_set_uint(value, surface ? surface-width : 0);
+g_value_set_uint(value, c-primary ? c-primary-width : 0);
 break;
 }
 case PROP_HEIGHT: {
-display_surface *surface = find_surface(c, 0);
-g_value_set_uint(value, surface ? surface-height : 0);
+g_value_set_uint(value, c-primary ? c-primary-height : 0);
 break;
 }
 case PROP_MONITORS: {
@@ -739,18 +738,16 @@ static int create_canvas(SpiceChannel *channel, 
display_surface *surface)
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)-priv;
 
 if (surface-primary) {
-display_surface *primary = find_surface(c, 0);
-
-if (primary) {
-if (primary-width == surface-width 
-primary-height == surface-height) {
+if (c-primary) {
+if (c-primary-width == surface-width 
+c-primary-height == surface-height) {
 CHANNEL_DEBUG(channel, Reusing existing primary surface);
 return 0;
 }
 
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
 
-g_hash_table_remove(c-surfaces, 0);
+g_hash_table_remove(c-surfaces, 
GINT_TO_POINTER(c-primary-surface_id));
 }
 
 CHANNEL_DEBUG(channel, Create primary canvas);
@@ -803,6 +800,8 @@ static int create_canvas(SpiceChannel *channel, 
display_surface *surface)
 g_hash_table_insert(c-surfaces, GINT_TO_POINTER(surface-surface_id), 
surface);
 
 if (surface-primary) {
+g_warn_if_fail(c-primary == NULL);
+c-primary = surface;
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_CREATE,
   surface-format, surface-width, surface-height,
   surface-stride, surface-shmid, surface-data);
@@ -847,6 +846,9 @@ static void destroy_canvas(display_surface *surface)
 
 static display_surface *find_surface(SpiceDisplayChannelPrivate *c, guint32 
surface_id)
 {
+if (c-primary  c-primary-surface_id == surface_id)
+return c-primary;
+
 return g_hash_table_lookup(c-surfaces, GINT_TO_POINTER(surface_id));
 }
 
@@ -944,10 +946,9 @@ static void display_handle_mode(SpiceChannel *channel, 
SpiceMsgIn *in)
 static void display_handle_mark(SpiceChannel *channel, SpiceMsgIn *in)
 {
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)-priv;
-display_surface *surface = find_surface(c, 0);
 
 CHANNEL_DEBUG(channel, %s, __FUNCTION__);
-g_return_if_fail(surface != NULL);
+g_return_if_fail(c-primary != NULL);
 #ifdef EXTRA_CHECKS
 g_warn_if_fail(c-mark == FALSE);
 #endif
@@ -960,7 +961,7 @@ static void display_handle_mark(SpiceChannel *channel, 
SpiceMsgIn *in)
 static void display_handle_reset(SpiceChannel *channel, SpiceMsgIn *in)
 {
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)-priv;
-display_surface *surface = find_surface(c, 0);
+display_surface *surface = c-primary;
 
 CHANNEL_DEBUG(channel, %s: TODO detach_from_screen, __FUNCTION__);
 
@@ -1784,6 +1785,7 @@ static void display_handle_surface_destroy(SpiceChannel 
*channel, SpiceMsgIn *in
 if (id != 0  c-mark_false_event_id == 0) {
 c-mark_false_event_id = g_timeout_add_seconds(1, 
display_mark_false, channel);
 }
+c-primary = NULL;
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
 }
 
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 04/10] display: make the hashtable to destroy the surface

2013-09-08 Thread Marc-André Lureau
Improve a bit the code by using hashtable ownership.
---
 gtk/channel-display.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 7a66558..979ce7b 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -700,13 +700,21 @@ static void 
spice_display_channel_reset_capabilities(SpiceChannel *channel)
 }
 }
 
+static void destroy_surface(gpointer data)
+{
+display_surface *surface = data;
+
+destroy_canvas(surface);
+free(surface);
+}
+
 static void spice_display_channel_init(SpiceDisplayChannel *channel)
 {
 SpiceDisplayChannelPrivate *c;
 
 c = channel-priv = SPICE_DISPLAY_CHANNEL_GET_PRIVATE(channel);
 
-c-surfaces = g_hash_table_new(NULL, NULL);
+c-surfaces = g_hash_table_new_full(NULL, NULL, NULL, destroy_surface);
 c-image_cache.ops = image_cache_ops;
 c-palette_cache.ops = palette_cache_ops;
 c-image_surfaces.ops = image_surfaces_ops;
@@ -743,8 +751,6 @@ static int create_canvas(SpiceChannel *channel, 
display_surface *surface)
 emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
 
 g_hash_table_remove(c-surfaces, 0);
-destroy_canvas(primary);
-free(primary);
 }
 
 CHANNEL_DEBUG(channel, Create primary canvas);
@@ -859,8 +865,6 @@ static void clear_surfaces(SpiceChannel *channel, gboolean 
keep_primary)
 }
 
 g_hash_table_iter_remove(iter);
-destroy_canvas(surface);
-free(surface);
 }
 }
 
@@ -1784,8 +1788,6 @@ static void display_handle_surface_destroy(SpiceChannel 
*channel, SpiceMsgIn *in
 }
 
 g_hash_table_remove(c-surfaces, GINT_TO_POINTER(surface-surface_id));
-destroy_canvas(surface);
-free(surface);
 }
 
 #define CLAMP_CHECK(x, low, high)  (((x)  (high)) ? TRUE : (((x)  (low)) ? 
TRUE : FALSE))
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 06/10] util: avoid calling getenv for every SPICE_DEBUG

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

That doesn't seem to really improve performance so much,
but that' s what we should do probably.
---
 gtk/spice-util.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index e02fc4d..4372f28 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -39,7 +39,7 @@
  * Various functions for debugging and informational purposes.
  */
 
-static gboolean debugFlag = FALSE;
+static GOnce debug_once = G_ONCE_INIT;
 
 /**
  * spice_util_set_debug:
@@ -61,12 +61,19 @@ void spice_util_set_debug(gboolean enabled)
 }
 }
 #endif
-debugFlag = enabled;
+debug_once.retval = GINT_TO_POINTER(enabled);
+}
+
+static gpointer getenv_debug(gpointer data)
+{
+return GINT_TO_POINTER(g_getenv(SPICE_DEBUG) != NULL);
 }
 
 gboolean spice_util_get_debug(void)
 {
-return debugFlag || g_getenv(SPICE_DEBUG) != NULL;
+g_once(debug_once, getenv_debug, NULL);
+
+return GPOINTER_TO_INT(debug_once.retval);
 }
 
 /**
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 07/10] channel: do not reenter the mainloop at every iteration

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

The current coroutine channel_iterate() creates a GSource for the socket
reenters the mainloop waiting for IO condition. This is really heavy
usage of mainloop showing up in system time and user space
profiling (10% of CPU time spent in mainloop overhead). Instead flush
all pending input messages before switching context and reentering main
loop.
---
 gtk/spice-channel.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 778a90b..9fb3b0c 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2107,35 +2107,34 @@ static gboolean spice_channel_iterate(SpiceChannel 
*channel)
 SpiceChannelPrivate *c = channel-priv;
 GIOCondition ret;
 
-do {
-if (c-state == SPICE_CHANNEL_STATE_MIGRATING 
-!g_coroutine_condition_wait(c-coroutine, wait_migration, 
channel))
-CHANNEL_DEBUG(channel, migration wait cancelled);
+if (c-state == SPICE_CHANNEL_STATE_MIGRATING 
+!g_coroutine_condition_wait(c-coroutine, wait_migration, channel))
+CHANNEL_DEBUG(channel, migration wait cancelled);
 
-if (c-has_error) {
-CHANNEL_DEBUG(channel, channel has error, breaking loop);
-return FALSE;
-}
-
-SPICE_CHANNEL_GET_CLASS(channel)-iterate_write(channel);
+if (c-has_error) {
+CHANNEL_DEBUG(channel, channel has error, breaking loop);
+return FALSE;
+}
 
-ret = g_coroutine_socket_wait(c-coroutine, c-sock,
-c-state != SPICE_CHANNEL_STATE_MIGRATING ? G_IO_IN : 0);
+/* flush any pending write */
+SPICE_CHANNEL_GET_CLASS(channel)-iterate_write(channel);
+/* go back to main loop, wait for an event or incoming data */
+ret = g_coroutine_socket_wait(c-coroutine, c-sock, G_IO_IN);
 
-#ifdef WIN32
-/* FIXME: windows gsocket is buggy, it doesn't return correct 
condition... */
-ret = g_socket_condition_check(c-sock, G_IO_IN);
-#endif
-} while (ret == 0); /* ret == 0 means no IO condition, but woken up */
+/* treat all incoming data (block on message completion) */
+while (!c-has_error  (ret  G_IO_IN)) {
+if (c-state == SPICE_CHANNEL_STATE_MIGRATING)
+break;
 
-if (ret  G_IO_IN) {
 do
 SPICE_CHANNEL_GET_CLASS(channel)-iterate_read(channel);
 #if HAVE_SASL
+/* flush the sasl buffer too */
 while (c-sasl_decoded != NULL);
 #else
 while (FALSE);
 #endif
+ret = g_socket_condition_check(c-sock, G_IO_IN | G_IO_ERR | G_IO_HUP);
 }
 
 if (c-state  SPICE_CHANNEL_STATE_CONNECTING 
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 08/10] gtk: use GHashTable in display_cache

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

The cache code isn't very quick, it shows up in profilers.  Using
GHashTable allows to simplify the code while making it faster.
---
 gtk/channel-cursor.c  |  56 +++
 gtk/channel-display.c |  93 +++---
 gtk/spice-channel-cache.h | 111 +-
 gtk/spice-session-priv.h  |   4 +-
 gtk/spice-session.c   |  58 +++-
 spice-common  |   2 +-
 6 files changed, 103 insertions(+), 221 deletions(-)

diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index e4a996b..eb53843 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -51,7 +51,7 @@ struct display_cursor {
 };
 
 struct _SpiceCursorChannelPrivate {
-display_cache   cursors;
+display_cache   *cursors;
 gbooleaninit_done;
 };
 
@@ -67,7 +67,6 @@ enum {
 static guint signals[SPICE_CURSOR_LAST_SIGNAL];
 
 static void spice_cursor_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg);
-static void delete_cursor_all(SpiceChannel *channel);
 static display_cursor * display_cursor_ref(display_cursor *cursor);
 static void display_cursor_unref(display_cursor *cursor);
 
@@ -81,12 +80,14 @@ static void spice_cursor_channel_init(SpiceCursorChannel 
*channel)
 
 c = channel-priv = SPICE_CURSOR_CHANNEL_GET_PRIVATE(channel);
 
-cache_init(c-cursors, cursor);
+c-cursors = cache_new((GDestroyNotify)display_cursor_unref);
 }
 
 static void spice_cursor_channel_finalize(GObject *obj)
 {
-delete_cursor_all(SPICE_CHANNEL(obj));
+SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL_GET_PRIVATE(obj);
+
+g_clear_pointer(c-cursors, cache_unref);
 
 if (G_OBJECT_CLASS(spice_cursor_channel_parent_class)-finalize)
 G_OBJECT_CLASS(spice_cursor_channel_parent_class)-finalize(obj);
@@ -97,7 +98,7 @@ static void spice_cursor_channel_reset(SpiceChannel *channel, 
gboolean migrating
 {
 SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)-priv;
 
-delete_cursor_all(channel);
+cache_clear(c-cursors);
 c-init_done = FALSE;
 
 
SPICE_CHANNEL_CLASS(spice_cursor_channel_parent_class)-channel_reset(channel, 
migrating);
@@ -359,7 +360,6 @@ static display_cursor *set_cursor(SpiceChannel *channel, 
SpiceCursor *scursor)
 {
 SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)-priv;
 SpiceCursorHeader *hdr = scursor-header;
-display_cache_item *item;
 display_cursor *cursor;
 size_t size;
 gint i, pix_mask, pix;
@@ -378,9 +378,9 @@ static display_cursor *set_cursor(SpiceChannel *channel, 
SpiceCursor *scursor)
   hdr-width, hdr-height);
 
 if (scursor-flags  SPICE_CURSOR_FLAGS_FROM_CACHE) {
-item = cache_find(c-cursors, hdr-unique);
-g_return_val_if_fail(item != NULL, NULL);
-return display_cursor_ref(item-ptr);
+cursor = cache_find(c-cursors, hdr-unique);
+g_return_val_if_fail(cursor != NULL, NULL);
+return display_cursor_ref(cursor);
 }
 
 g_return_val_if_fail(scursor-data_size != 0, NULL);
@@ -453,36 +453,12 @@ static display_cursor *set_cursor(SpiceChannel *channel, 
SpiceCursor *scursor)
 
 cache_add:
 if (cursor  (scursor-flags  SPICE_CURSOR_FLAGS_CACHE_ME)) {
-display_cursor_ref(cursor);
-item = cache_add(c-cursors, hdr-unique);
-item-ptr = cursor;
+cache_add(c-cursors, hdr-unique, display_cursor_ref(cursor));
 }
 
 return cursor;
 }
 
-static void delete_cursor_one(SpiceChannel *channel, display_cache_item *item)
-{
-SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)-priv;
-
-display_cursor_unref((display_cursor*)item-ptr);
-cache_del(c-cursors, item);
-}
-
-static void delete_cursor_all(SpiceChannel *channel)
-{
-SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)-priv;
-display_cache_item *item;
-
-for (;;) {
-item = cache_get_lru(c-cursors);
-if (item == NULL) {
-return;
-}
-delete_cursor_one(channel, item);
-}
-}
-
 /* coroutine context */
 static void emit_cursor_set(SpiceChannel *channel, display_cursor *cursor)
 {
@@ -502,7 +478,7 @@ static void cursor_handle_init(SpiceChannel *channel, 
SpiceMsgIn *in)
 
 g_return_if_fail(c-init_done == FALSE);
 
-delete_cursor_all(channel);
+cache_clear(c-cursors);
 cursor = set_cursor(channel, init-cursor);
 c-init_done = TRUE;
 if (cursor)
@@ -520,7 +496,7 @@ static void cursor_handle_reset(SpiceChannel *channel, 
SpiceMsgIn *in)
 
 CHANNEL_DEBUG(channel, %s, init_done: %d, __FUNCTION__, c-init_done);
 
-delete_cursor_all(channel);
+cache_clear(c-cursors);
 emit_main_context(channel, SPICE_CURSOR_RESET);
 c-init_done = FALSE;
 }
@@ -584,18 +560,18 @@ static void cursor_handle_inval_one(SpiceChannel 
*channel, SpiceMsgIn *in)
 {
 

[Spice-devel] [PATCH spice-gtk 09/10] gtk: use slices for frequently allocated objects

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

---
 gtk/channel-display.c | 4 ++--
 gtk/spice-channel.c   | 8 
 spice-common  | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index a69f14f..8629eee 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -657,7 +657,7 @@ static void destroy_surface(gpointer data)
 display_surface *surface = data;
 
 destroy_canvas(surface);
-free(surface);
+g_slice_free(display_surface, surface);
 }
 
 static void spice_display_channel_init(SpiceDisplayChannel *channel)
@@ -1687,7 +1687,7 @@ static void display_handle_surface_create(SpiceChannel 
*channel, SpiceMsgIn *in)
 {
 SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)-priv;
 SpiceMsgSurfaceCreate *create = spice_msg_in_parsed(in);
-display_surface *surface = spice_new0(display_surface, 1);
+display_surface *surface = g_slice_new0(display_surface);
 
 surface-surface_id = create-surface_id;
 surface-format = create-format;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 9fb3b0c..4b80029 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -462,7 +462,7 @@ SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel)
 
 g_return_val_if_fail(channel != NULL, NULL);
 
-in = spice_new0(SpiceMsgIn, 1);
+in = g_slice_new0(SpiceMsgIn);
 in-refcount = 1;
 in-channel  = channel;
 
@@ -510,7 +510,7 @@ void spice_msg_in_unref(SpiceMsgIn *in)
 } else {
 free(in-data);
 }
-free(in);
+g_slice_free(SpiceMsgIn, in);
 }
 
 G_GNUC_INTERNAL
@@ -615,7 +615,7 @@ SpiceMsgOut *spice_msg_out_new(SpiceChannel *channel, int 
type)
 
 g_return_val_if_fail(c != NULL, NULL);
 
-out = spice_new0(SpiceMsgOut, 1);
+out = g_slice_new0(SpiceMsgOut);
 out-refcount = 1;
 out-channel  = channel;
 out-ro_check = msg_check_read_only(c-channel_type, type);
@@ -651,7 +651,7 @@ void spice_msg_out_unref(SpiceMsgOut *out)
 if (out-refcount  0)
 return;
 spice_marshaller_destroy(out-marshaller);
-free(out);
+g_slice_free(SpiceMsgOut, out);
 }
 
 /* system context */
diff --git a/spice-common b/spice-common
index 7aef065..ab6fb3c 16
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 7aef06577e47965bbe93e0a054857a562d2fde5a
+Subproject commit ab6fb3c176b090cffedeb53d9b03f8399bd51ace
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk 10/10] gtk: simplify spice_channel_recv_msg

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

Use of coroutines allow to simplify spice_channel_recv_msg(), it doesn't
need to keep current reading state, it can rely on the coroutine stack
for that.
---
 gtk/channel-base.c   |  1 +
 gtk/spice-channel-priv.h |  3 +--
 gtk/spice-channel.c  | 50 +++-
 3 files changed, 17 insertions(+), 37 deletions(-)

diff --git a/gtk/channel-base.c b/gtk/channel-base.c
index dff3024..6bfce3d 100644
--- a/gtk/channel-base.c
+++ b/gtk/channel-base.c
@@ -187,5 +187,6 @@ void spice_channel_handle_migrate(SpiceChannel *channel, 
SpiceMsgIn *in)
 spice_marshaller_add(out-marshaller, data-data,
  spice_header_get_msg_size(data-header, 
c-use_mini_header));
 spice_msg_out_send_internal(out);
+/* FIXME: who unref in? */
 }
 }
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 9e70ff2..53830a8 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -59,7 +59,7 @@ struct _SpiceMsgIn {
 SpiceChannel  *channel;
 uint8_t   header[MAX_SPICE_DATA_HEADER_SIZE];
 uint8_t   *data;
-int   hpos,dpos;
+int   dpos;
 uint8_t   *parsed;
 size_tpsize;
 message_destructor_t  pfree;
@@ -122,7 +122,6 @@ struct _SpiceChannelPrivate {
 SpiceLinkReply* peer_msg;
 int peer_pos;
 
-SpiceMsgIn  *msg_in;
 int message_ack_window;
 int message_ack_count;
 
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 4b80029..00e544b 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1770,43 +1770,26 @@ void spice_channel_recv_msg(SpiceChannel *channel,
 {
 SpiceChannelPrivate *c = channel-priv;
 SpiceMsgIn *in;
-int header_size;
 int msg_size;
 int msg_type;
 int sub_list_offset = 0;
-int rc;
 
-if (!c-msg_in) {
-c-msg_in = spice_msg_in_new(channel);
-}
-in = c-msg_in;
-header_size = spice_header_get_header_size(c-use_mini_header);
+in = spice_msg_in_new(channel);
 
 /* receive message */
-if (in-hpos  header_size) {
-rc = spice_channel_read(channel, in-header + in-hpos,
-header_size - in-hpos);
-if (rc  0) {
-g_critical(recv hdr: %s, strerror(errno));
-return;
-}
-in-hpos += rc;
-if (in-hpos  header_size)
-return;
-in-data = spice_malloc(spice_header_get_msg_size(in-header, 
c-use_mini_header));
-}
+spice_channel_read(channel, in-header,
+   spice_header_get_header_size(c-use_mini_header));
+if (c-has_error)
+goto end;
+
 msg_size = spice_header_get_msg_size(in-header, c-use_mini_header);
-if (in-dpos  msg_size) {
-rc = spice_channel_read(channel, in-data + in-dpos,
-msg_size - in-dpos);
-if (rc  0) {
-g_critical(recv msg: %s, strerror(errno));
-return;
-}
-in-dpos += rc;
-if (in-dpos  msg_size)
-return;
-}
+/* FIXME: do not allow others to take ref on in, and use realloc here?
+ * this would avoid malloc/free on each message?
+ */
+in-data = spice_malloc(msg_size);
+spice_channel_read(channel, in-data, msg_size);
+if (c-has_error)
+goto end;
 
 msg_type = spice_header_get_msg_type(in-header, c-use_mini_header);
 sub_list_offset = spice_header_get_msg_sub_list(in-header, 
c-use_mini_header);
@@ -1829,7 +1812,7 @@ void spice_channel_recv_msg(SpiceChannel *channel,
 if (sub_in-parsed == NULL) {
 g_critical(failed to parse sub-message: %s type %d,
c-name, spice_header_get_msg_type(sub_in-header, 
c-use_mini_header));
-return;
+goto end;
 }
 msg_handler(channel, sub_in, data);
 spice_msg_in_unref(sub_in);
@@ -1851,7 +1834,7 @@ void spice_channel_recv_msg(SpiceChannel *channel,
 }
 
 /* parse message */
-in-parsed = c-parser(in-data, in-data + in-dpos, msg_type,
+in-parsed = c-parser(in-data, in-data + msg_size, msg_type,
c-peer_hdr.minor_version, in-psize, in-pfree);
 if (in-parsed == NULL) {
 g_critical(failed to parse message: %s type %d,
@@ -1860,7 +1843,6 @@ void spice_channel_recv_msg(SpiceChannel *channel,
 }
 
 /* process message */
-c-msg_in = NULL; /* the function is reentrant, reset state */
 /* spice_msg_in_hexdump(in); */
 msg_handler(channel, in, data);
 
@@ -1869,8 +1851,6 @@ end:
  * to c-in_serial (the server can sometimes skip serials) */
 c-last_message_serial = spice_header_get_in_msg_serial(in);
 c-in_serial++;
-  

[Spice-devel] [PATCH common 1/3] quic: compile with constant bpp, to help compiler

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

---
 common/quic_family_tmpl.c |  4 ++--
 common/quic_rgb_tmpl.c|  6 +++---
 common/quic_tmpl.c| 16 
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/common/quic_family_tmpl.c b/common/quic_family_tmpl.c
index cca2c05..287ff6d 100644
--- a/common/quic_family_tmpl.c
+++ b/common/quic_family_tmpl.c
@@ -74,13 +74,13 @@ static unsigned int FNAME(golomb_decoding)(const unsigned 
int l, const unsigned
 
 /* update the bucket using just encoded curval */
 static void FNAME(update_model)(CommonState *state, s_bucket * const bucket,
-const BYTE curval, unsigned int bpp)
+const BYTE curval)
 {
+const unsigned int bpp = BPC;
 COUNTER * const pcounters = bucket-pcounters;
 unsigned int i;
 unsigned int bestcode;
 unsigned int bestcodelen;
-//unsigned int bpp = encoder-bpp;
 
 /* update counters, find minimum */
 
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index 37c908c..19cc348 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -178,11 +178,11 @@
 
 #define UPDATE_MODEL(index)
 \
 update_model(encoder-rgb_state, find_bucket(channel_r, 
correlate_row_r[index - 1]),   \
-correlate_row_r[index], bpc);  
 \
+correlate_row_r[index]);   
\
 update_model(encoder-rgb_state, find_bucket(channel_g, 
correlate_row_g[index - 1]),   \
-correlate_row_g[index], bpc);  
 \
+correlate_row_g[index]);   
\
 update_model(encoder-rgb_state, find_bucket(channel_b, 
correlate_row_b[index - 1]),   \
-correlate_row_b[index], bpc);
+correlate_row_b[index]);
 
 
 #ifdef RLE_PRED_1
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index b625daf..75f2ff0 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -173,7 +173,7 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, 
Channel *channel, int i,
 } else {
 channel-state.waitcnt = (tabrand(channel-state.tabrand_seed)  
waitmask);
 update_model(channel-state, find_bucket(channel, 
decorelate_drow[-1]),
- decorelate_drow[i], bpc);
+ decorelate_drow[i]);
 }
 stopidx = ++i + channel-state.waitcnt;
 } else {
@@ -191,7 +191,7 @@ static void FNAME(compress_row0_seg)(Encoder *encoder, 
Channel *channel, int i,
 }
 
 update_model(channel-state, find_bucket(channel, 
decorelate_drow[stopidx - 1]),
- decorelate_drow[stopidx], bpc);
+ decorelate_drow[stopidx]);
 stopidx = i + (tabrand(channel-state.tabrand_seed)  waitmask);
 }
 
@@ -272,7 +272,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, 
Channel *channel, int i,
 } else {
 channel-state.waitcnt = (tabrand(channel-state.tabrand_seed)  
waitmask);
 update_model(channel-state, find_bucket(channel, 
decorelate_drow[-1]),
- decorelate_drow[0], bpc);
+ decorelate_drow[0]);
 }
 stopidx = ++i + channel-state.waitcnt;
 } else {
@@ -295,7 +295,7 @@ static void FNAME(compress_row_seg)(Encoder *encoder, 
Channel *channel, int i,
 }
 
 update_model(channel-state, find_bucket(channel, 
decorelate_drow[stopidx - 1]),
- decorelate_drow[stopidx], bpc);
+ decorelate_drow[stopidx]);
 stopidx = i + (tabrand(channel-state.tabrand_seed)  waitmask);
 }
 
@@ -406,7 +406,7 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, 
Channel *channel, int i
 } else {
 channel-state.waitcnt = (tabrand(channel-state.tabrand_seed)  
waitmask);
 update_model(channel-state, find_bucket(channel, 
correlate_row[-1]),
- correlate_row[0], bpc);
+ correlate_row[0]);
 }
 stopidx = ++i + channel-state.waitcnt;
 } else {
@@ -426,7 +426,7 @@ static void FNAME(uncompress_row0_seg)(Encoder *encoder, 
Channel *channel, int i
 decode_eatbits(encoder, codewordlen);
 }
 
-update_model(channel-state, pbucket, correlate_row[stopidx], bpc);
+update_model(channel-state, pbucket, correlate_row[stopidx]);
 
 stopidx = i + (tabrand(channel-state.tabrand_seed)  waitmask);
 }
@@ -511,7 +511,7 @@ static void FNAME(uncompress_row_seg)(Encoder *encoder, 
Channel *channel,
 } else {
 channel-state.waitcnt = (tabrand(channel-state.tabrand_seed)  
waitmask);
 update_model(channel-state, 

[Spice-devel] [PATCH common 3/3] canvas: use precompiled revers_bits

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

Thos function shows up in some profiling results, it seems we can
trivially replace it with a precompiled array.
---
 common/canvas_base.c | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 38a8497..6764b70 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -1329,6 +1329,8 @@ static pixman_image_t* 
canvas_get_image_from_self(SpiceCanvas *canvas,
 return surface;
 }
 
+
+#ifdef REVERS_BITS_SLOW
 static inline uint8_t revers_bits(uint8_t byte)
 {
 uint8_t ret = 0;
@@ -1341,6 +1343,47 @@ static inline uint8_t revers_bits(uint8_t byte)
 }
 return ret;
 }
+#else
+static inline uint8_t revers_bits(uint8_t byte)
+{
+static const uint8_t revers[] = {
+0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+0x8, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+0x4, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+0xc, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+0x2, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+0xa, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+0x6, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+0xe, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+0x1, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+0x9, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+0x5, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+0xd, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+0x3, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+0xb, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+0x7, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+0xf, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f
+};
+
+return revers[byte];
+}
+#endif
 
 static pixman_image_t *canvas_get_bitmap_mask(CanvasBase *canvas, SpiceBitmap* 
bitmap, int invers)
 {
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH common 2/3] quic: precompile golomb codes

2013-09-08 Thread Marc-André Lureau
From: Marc-André Lureau marcandre.lur...@gmail.com

---
 common/quic.c | 25 -
 common/quic_family_tmpl.c | 22 +-
 2 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/common/quic.c b/common/quic.c
index 3e7c802..c9c3624 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -75,6 +75,9 @@ typedef struct QuicFamily {
 unsigned int notGRsuffixlen[MAXNUMCODES];/* indexed by code number, 
contains suffix
 length of the not-GR 
codeword */
 
+unsigned int golomb_code_len[256][MAXNUMCODES];
+unsigned int golomb_code[256][MAXNUMCODES];
+
 /* array for translating distribution U to L for depths up to 8 bpp,
 initialized by decorelateinit() */
 BYTE xlatU2L[256];
@@ -360,9 +363,22 @@ static void corelate_init(QuicFamily *family, int bpc)
 }
 }
 
+static void golomb_coding_slow(QuicFamily *family, const BYTE n, const 
unsigned int l,
+   unsigned int * const codeword,
+   unsigned int * const codewordlen)
+{
+if (n  family-nGRcodewords[l]) {
+(*codeword) = bitat[l] | (n  bppmask[l]);
+(*codewordlen) = (n  l) + l + 1;
+} else {
+(*codeword) = n - family-nGRcodewords[l];
+(*codewordlen) = family-notGRcwlen[l];
+}
+}
+
 static void family_init(QuicFamily *family, int bpc, int limit)
 {
-int l;
+int l, b;
 
 for (l = 0; l  bpc; l++) { /* fill arrays indexed by code number */
 int altprefixlen, altcodewords;
@@ -378,6 +394,13 @@ static void family_init(QuicFamily *family, int bpc, int 
limit)
 family-notGRcwlen[l] = altprefixlen + ceil_log_2(altcodewords);
 family-notGRprefixmask[l] = bppmask[32 - altprefixlen]; /* needed for 
decoding only */
 family-notGRsuffixlen[l] = ceil_log_2(altcodewords); /* needed for 
decoding only */
+
+for (b = 0; b  256; b++) {
+unsigned int code, len;
+golomb_coding_slow(family, b, l, code, len);
+family-golomb_code[b][l] = code;
+family-golomb_code_len[b][l] = len;
+}
 }
 
 decorelate_init(family, bpc);
diff --git a/common/quic_family_tmpl.c b/common/quic_family_tmpl.c
index 287ff6d..12ef62f 100644
--- a/common/quic_family_tmpl.c
+++ b/common/quic_family_tmpl.c
@@ -34,26 +34,21 @@
 #define BPC 5
 #endif
 
+static inline unsigned int FNAME(golomb_code)(const BYTE n, const unsigned int 
l)
+{
+return VNAME(family).golomb_code[n][l];
+}
 
-static unsigned int FNAME(golomb_code_len)(const BYTE n, const unsigned int l)
+static inline unsigned int FNAME(golomb_code_len)(const BYTE n, const unsigned 
int l)
 {
-if (n  VNAME(family).nGRcodewords[l]) {
-return (n  l) + 1 + l;
-} else {
-return VNAME(family).notGRcwlen[l];
-}
+return VNAME(family).golomb_code_len[n][l];
 }
 
 static void FNAME(golomb_coding)(const BYTE n, const unsigned int l, unsigned 
int * const codeword,
  unsigned int * const codewordlen)
 {
-if (n  VNAME(family).nGRcodewords[l]) {
-(*codeword) = bitat[l] | (n  bppmask[l]);
-(*codewordlen) = (n  l) + l + 1;
-} else {
-(*codeword) = n - VNAME(family).nGRcodewords[l];
-(*codewordlen) = VNAME(family).notGRcwlen[l];
-}
+*codeword = FNAME(golomb_code)(n, l);
+*codewordlen = FNAME(golomb_code_len)(n, l);
 }
 
 static unsigned int FNAME(golomb_decoding)(const unsigned int l, const 
unsigned int bits,
@@ -76,6 +71,7 @@ static unsigned int FNAME(golomb_decoding)(const unsigned int 
l, const unsigned
 static void FNAME(update_model)(CommonState *state, s_bucket * const bucket,
 const BYTE curval)
 {
+spice_static_assert(BPC = 1);
 const unsigned int bpp = BPC;
 COUNTER * const pcounters = bucket-pcounters;
 unsigned int i;
-- 
1.8.3.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH common 3/3] canvas: use precompiled revers_bits

2013-09-08 Thread Marc-André Lureau
On Sun, Sep 8, 2013 at 9:07 PM, Marc-André Lureau
marcandre.lur...@gmail.com wrote:
 0x3f, 0xbf, 0x7f


oops, I removed the last value by mistake, 0xff, fixed.

-- 
Marc-André Lureau
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel