[Spice-devel] [PATCH 09/19] worker: move dcc_send & marshallers to dcc-send.c

Frediano Ziglio fziglio at redhat.com
Thu Nov 26 01:58:36 PST 2015


> 
> This patch is freaking huge :-\
> Is there some automated way to check whether a function move is just a
> move or something else changed?
> 

Do you mean something like this?


--- before.c	2015-11-26 09:57:02.327008820 +0000
+++ after.c	2015-11-26 09:19:38.642524996 +0000
@@ -34,20 +34,22 @@
 #define DISPLAY_CLIENT_TIMEOUT 30000000000ULL //nano
 #define DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT 10000000000ULL //nano, 10 sec
 #define DISPLAY_CLIENT_RETRY_INTERVAL 10000 //micro
 
 /* Each drawable can refer to at most 3 images: src, brush and mask */
 #define MAX_DRAWABLE_PIXMAP_CACHE_ITEMS 3
 
 #define WIDE_CLIENT_ACK_WINDOW 40
 #define NARROW_CLIENT_ACK_WINDOW 20
 
+#define MAX_PIPE_SIZE 50
+
 typedef struct WaitForChannels {
     SpiceMsgWaitForChannels header;
     SpiceWaitForChannel buf[MAX_CACHE_CLIENTS];
 } WaitForChannels;
 
 typedef struct FreeList {
     int res_size;
     SpiceResourceList *res;
     uint64_t sync[MAX_CACHE_CLIENTS];
     WaitForChannels wait;
@@ -367,20 +369,21 @@
 	pixmap-cache.c				\
 	tree.h				\
 	tree.c				\
 	spice-bitmap-utils.h			\
 	spice-bitmap-utils.c			\
 	utils.c					\
 	utils.h					\
 	stream.c					\
 	stream.h					\
 	dcc.c					\
+	dcc-send.c					\
 	dcc.h					\
 	display-limits.h			\
 	dcc-encoders.c					\
 	dcc-encoders.h					\
 	$(NULL)
 
 if HAVE_SMARTCARD
 libspice_server_la_SOURCES +=	\
 	smartcard.c		\
 	smartcard.h		\
@@ -516,24 +519,20 @@
         out_lossy_area->top = lossy_region.extents.y1;
         out_lossy_area->right = lossy_region.extents.x2;
         out_lossy_area->bottom = lossy_region.extents.y2;
         region_destroy(&lossy_region);
         return TRUE;
     } else {
         return FALSE;
     }
 }
 
-/* returns if the bitmap was already sent lossy to the client. If the bitmap hasn't been sent yet
-   to the client, returns false. "area" is for surfaces. If area = NULL,
-   all the surface is considered. out_lossy_data will hold info about the bitmap, and its lossy
-   area in case it is lossy and part of a surface. */
 static int is_bitmap_lossy(RedChannelClient *rcc, SpiceImage *image, SpiceRect *area,
                            Drawable *drawable, BitmapData *out_data)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
 
     if (image == NULL) {
         // self bitmap
         out_data->type = BITMAP_DATA_TYPE_BITMAP;
         return FALSE;
     }
@@ -608,73 +607,73 @@
                 stat_inc_counter(display_channel->add_to_cache_counter, 1);
             }
         }
     }
 
     if (!(io_image->descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME)) {
         stat_inc_counter(display_channel->non_cache_counter, 1);
     }
 }
 
-static inline void display_marshal_sub_msg_inval_list(SpiceMarshaller *m,
+static void marshal_sub_msg_inval_list(SpiceMarshaller *m,
                                                        FreeList *free_list)
 {
     /* type + size + submessage */
     spice_marshaller_add_uint16(m, SPICE_MSG_DISPLAY_INVAL_LIST);
     spice_marshaller_add_uint32(m, sizeof(*free_list->res) +
                                 free_list->res->count * sizeof(free_list->res->resources[0]));
     spice_marshall_msg_display_inval_list(m, free_list->res);
 }
 
-static inline void display_marshal_sub_msg_inval_list_wait(SpiceMarshaller *m,
+static void marshal_sub_msg_inval_list_wait(SpiceMarshaller *m,
                                                             FreeList *free_list)
 {
     /* type + size + submessage */
     spice_marshaller_add_uint16(m, SPICE_MSG_WAIT_FOR_CHANNELS);
     spice_marshaller_add_uint32(m, sizeof(free_list->wait.header) +
                                 free_list->wait.header.wait_count * sizeof(free_list->wait.buf[0]));
     spice_marshall_msg_wait_for_channels(m, &free_list->wait.header);
 }
 
 /* use legacy SpiceDataHeader (with sub_list) */
-static inline void display_channel_send_free_list_legacy(RedChannelClient *rcc)
+static void send_free_list_legacy(RedChannelClient *rcc)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     FreeList *free_list = &dcc->send_data.free_list;
     SpiceMarshaller *marshaller;
     int sub_list_len = 1;
     SpiceMarshaller *wait_m = NULL;
     SpiceMarshaller *inval_m;
     SpiceMarshaller *sub_list_m;
 
     marshaller = red_channel_client_get_marshaller(rcc);
     inval_m = spice_marshaller_get_submarshaller(marshaller);
 
-    display_marshal_sub_msg_inval_list(inval_m, free_list);
+    marshal_sub_msg_inval_list(inval_m, free_list);
 
     if (free_list->wait.header.wait_count) {
         wait_m = spice_marshaller_get_submarshaller(marshaller);
-        display_marshal_sub_msg_inval_list_wait(wait_m, free_list);
+        marshal_sub_msg_inval_list_wait(wait_m, free_list);
         sub_list_len++;
     }
 
     sub_list_m = spice_marshaller_get_submarshaller(marshaller);
     spice_marshaller_add_uint16(sub_list_m, sub_list_len);
     if (wait_m) {
         spice_marshaller_add_uint32(sub_list_m, spice_marshaller_get_offset(wait_m));
     }
     spice_marshaller_add_uint32(sub_list_m, spice_marshaller_get_offset(inval_m));
     red_channel_client_set_header_sub_list(rcc, spice_marshaller_get_offset(sub_list_m));
 }
 
 /* use mini header and SPICE_MSG_LIST */
-static inline void display_channel_send_free_list(RedChannelClient *rcc)
+static void send_free_list(RedChannelClient *rcc)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     FreeList *free_list = &dcc->send_data.free_list;
     int sub_list_len = 1;
     SpiceMarshaller *urgent_marshaller;
     SpiceMarshaller *wait_m = NULL;
     SpiceMarshaller *inval_m;
     uint32_t sub_arr_offset;
     uint32_t wait_offset = 0;
     uint32_t inval_offset = 0;
@@ -693,25 +692,25 @@
 
     if (free_list->wait.header.wait_count) {
         red_channel_client_init_send_data(rcc, SPICE_MSG_LIST, NULL);
     } else { /* only one message, no need for a list */
         red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_LIST, NULL);
         spice_marshall_msg_display_inval_list(urgent_marshaller, free_list->res);
         return;
     }
 
     inval_m = spice_marshaller_get_submarshaller(urgent_marshaller);
-    display_marshal_sub_msg_inval_list(inval_m, free_list);
+    marshal_sub_msg_inval_list(inval_m, free_list);
 
     if (free_list->wait.header.wait_count) {
         wait_m = spice_marshaller_get_submarshaller(urgent_marshaller);
-        display_marshal_sub_msg_inval_list_wait(wait_m, free_list);
+        marshal_sub_msg_inval_list_wait(wait_m, free_list);
         sub_list_len++;
     }
 
     sub_arr_offset = sub_list_len * sizeof(uint32_t);
 
     spice_marshaller_add_uint16(urgent_marshaller, sub_list_len);
     inval_offset = spice_marshaller_get_offset(inval_m); // calc the offset before
                                                          // adding the sub list
                                                          // offsets array to the marshaller
     /* adding the array of offsets */
@@ -903,21 +902,21 @@
 {
     int i;
 
     if (m && attr->style_nseg) {
         for (i = 0 ; i < attr->style_nseg; i++) {
             spice_marshaller_add_uint32(m, attr->style[i]);
         }
     }
 }
 
-static void red_marshall_qxl_draw_fill(RedChannelClient *rcc,
+static void marshall_qxl_draw_fill(RedChannelClient *rcc,
                                        SpiceMarshaller *base_marshaller,
                                        DrawablePipeItem *dpi)
 {
     Drawable *item = dpi->drawable;
     RedDrawable *drawable = item->red_drawable;
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     SpiceMarshaller *brush_pat_out;
     SpiceMarshaller *mask_bitmap_out;
     SpiceFill fill;
 
@@ -929,20 +928,24 @@
                         &brush_pat_out,
                         &mask_bitmap_out);
 
     if (brush_pat_out) {
         fill_bits(dcc, brush_pat_out, fill.brush.u.pattern.pat, item, FALSE);
     }
 
     fill_mask(rcc, mask_bitmap_out, fill.mask.bitmap, item);
 }
 
+/* returns if the bitmap was already sent lossy to the client. If the bitmap hasn't been sent yet
+   to the client, returns false. "area" is for surfaces. If area = NULL,
+   all the surface is considered. out_lossy_data will hold info about the bitmap, and its lossy
+   area in case it is lossy and part of a surface. */
 static void surface_lossy_region_update(DisplayChannelClient *dcc,
                                         Drawable *item, int has_mask, int lossy)
 {
     QRegion *surface_lossy_region;
     RedDrawable *drawable;
 
     if (has_mask && !lossy) {
         return;
     }
 
@@ -967,21 +970,21 @@
         region_destroy(&draw_region);
     } else { /* no clip */
         if (!lossy) {
             region_remove(surface_lossy_region, &drawable->bbox);
         } else {
             region_add(surface_lossy_region, &drawable->bbox);
         }
     }
 }
 
-static inline int drawable_intersects_with_areas(Drawable *drawable, int surface_ids[],
+static int drawable_intersects_with_areas(Drawable *drawable, int surface_ids[],
                                                  SpiceRect *surface_areas[],
                                                  int num_surfaces)
 {
     int i;
     for (i = 0; i < num_surfaces; i++) {
         if (surface_ids[i] == drawable->red_drawable->surface_id) {
             if (rect_intersects(surface_areas[i], &drawable->red_drawable->bbox)) {
                 return TRUE;
             }
         }
@@ -1014,24 +1017,22 @@
             continue; // item hasn't been rendered
 
         if (drawable_intersects_with_areas(drawable, surface_ids, surface_areas, num_surfaces)) {
             return TRUE;
         }
     }
 
     return FALSE;
 }
 
-static inline int drawable_depends_on_areas(Drawable *drawable,
-                                            int surface_ids[],
-                                            SpiceRect surface_areas[],
-                                            int num_surfaces)
+static int drawable_depends_on_areas(Drawable *drawable, int surface_ids[],
+                                     SpiceRect surface_areas[], int num_surfaces)
 {
     int i;
     RedDrawable *red_drawable;
     int drawable_has_shadow;
     SpiceRect shadow_rect = {0, 0, 0, 0};
 
     red_drawable = drawable->red_drawable;
     drawable_has_shadow = has_shadow(red_drawable);
 
     if (drawable_has_shadow) {
@@ -1227,21 +1228,21 @@
                                     &brush_bitmap_data);
     if (!dest_allowed_lossy) {
         dest_is_lossy = is_surface_area_lossy(dcc, item->surface_id, &drawable->bbox,
                                               &dest_lossy_area);
     }
 
     if (!dest_is_lossy &&
         !(brush_is_lossy && (brush_bitmap_data.type == BITMAP_DATA_TYPE_SURFACE))) {
         int has_mask = !!drawable->u.fill.mask.bitmap;
 
-        red_marshall_qxl_draw_fill(rcc, m, dpi);
+        marshall_qxl_draw_fill(rcc, m, dpi);
         // either the brush operation is opaque, or the dest is not lossy
         surface_lossy_region_update(dcc, item, has_mask, FALSE);
     } else {
         int resend_surface_ids[2];
         SpiceRect *resend_areas[2];
         int num_resend = 0;
 
         if (dest_is_lossy) {
             resend_surface_ids[num_resend] = item->surface_id;
             resend_areas[num_resend] = &dest_lossy_area;
@@ -2161,21 +2162,21 @@
     agent->last_send_time = time_now;
 #ifdef STREAM_STATS
     agent->stats.num_frames_sent++;
     agent->stats.size_sent += n;
     agent->stats.end = frame_mm_time;
 #endif
 
     return TRUE;
 }
 
-static inline void red_marshall_inval_palette(RedChannelClient *rcc,
+static inline void marshall_inval_palette(RedChannelClient *rcc,
                                               SpiceMarshaller *base_marshaller,
                                               CacheItem *cache_item)
 {
     SpiceMsgDisplayInvalOne inval_one;
 
     red_channel_client_init_send_data(rcc, cache_item->inval_type, NULL);
     inval_one.id = *(uint64_t *)&cache_item->id;
 
     spice_marshall_msg_display_inval_palette(base_marshaller, &inval_one);
 
@@ -2394,41 +2395,39 @@
             if (grad_level == BITMAP_GRADUAL_HIGH) {
                 // if we use lz for alpha, the stride can't be extra
                 lossy_comp = display->enable_jpeg && item->can_lossy;
                 quic_comp = TRUE;
             }
         }
     } else if (comp_mode == SPICE_IMAGE_COMPRESSION_QUIC) {
         quic_comp = TRUE;
     }
 
+    uint32_t groupid = red_worker_get_memslot(worker)->internal_groupslot_id;
+
     if (lossy_comp) {
-        comp_succeeded = dcc_compress_image_jpeg(dcc, &red_image,
-                                                 &bitmap, &comp_send_data,
-                                                 worker->mem_slots.internal_groupslot_id);
+        comp_succeeded = dcc_compress_image_jpeg(dcc, &red_image, &bitmap, &comp_send_data, groupid);
     } else if (quic_comp) {
-        comp_succeeded = dcc_compress_image_quic(dcc, &red_image, &bitmap,
-                                                 &comp_send_data,
-                                                 worker->mem_slots.internal_groupslot_id);
+        comp_succeeded = dcc_compress_image_quic(dcc, &red_image, &bitmap, &comp_send_data, groupid);
 #ifdef USE_LZ4
     } else 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)) {
         comp_succeeded = dcc_compress_image_lz4(dcc, &red_image, &bitmap,
                                                 &comp_send_data,
-                                                worker->mem_slots.internal_groupslot_id);
+                                                groupid);
 #endif
     } else if (comp_mode != SPICE_IMAGE_COMPRESSION_OFF) {
         comp_succeeded = dcc_compress_image_lz(dcc, &red_image, &bitmap,
                                                &comp_send_data,
-                                               worker->mem_slots.internal_groupslot_id);
+                                               groupid);
     }
 
     surface_lossy_region = &dcc->surface_client_lossy_region[item->surface_id];
     if (comp_succeeded) {
         spice_marshall_Image(src_bitmap_out, &red_image,
                              &bitmap_palette_out, &lzplt_palette_out);
 
         marshaller_add_compressed(src_bitmap_out,
                                   comp_send_data.comp_buf, comp_send_data.comp_buf_size);
 
@@ -2447,21 +2446,21 @@
 
         spice_marshall_Image(src_bitmap_out, &red_image,
                              &bitmap_palette_out, &lzplt_palette_out);
         spice_marshaller_add_ref(src_bitmap_out, item->data,
                                  bitmap.y * bitmap.stride);
         region_remove(surface_lossy_region, &copy.base.box);
     }
     spice_chunks_destroy(chunks);
 }
 
-static void red_lossy_marshall_qxl_drawable(RedChannelClient *rcc,
+static void marshall_lossy_qxl_drawable(RedChannelClient *rcc,
                                             SpiceMarshaller *base_marshaller,
                                             DrawablePipeItem *dpi)
 {
     Drawable *item = dpi->drawable;
     switch (item->red_drawable->type) {
     case QXL_DRAW_FILL:
         red_lossy_marshall_qxl_draw_fill(rcc, base_marshaller, dpi);
         break;
     case QXL_DRAW_OPAQUE:
         red_lossy_marshall_qxl_draw_opaque(rcc, base_marshaller, dpi);
@@ -2496,33 +2495,33 @@
     case QXL_DRAW_COMPOSITE:
         red_lossy_marshall_qxl_draw_composite(rcc, base_marshaller, dpi);
         break;
     case QXL_DRAW_STROKE:
         red_lossy_marshall_qxl_draw_stroke(rcc, base_marshaller, dpi);
         break;
     case QXL_DRAW_TEXT:
         red_lossy_marshall_qxl_draw_text(rcc, base_marshaller, dpi);
         break;
     default:
-        spice_error("invalid type");
+        spice_warn_if_reached();
     }
 }
 
-static inline void red_marshall_qxl_drawable(RedChannelClient *rcc,
+static void marshall_lossless_qxl_drawable(RedChannelClient *rcc,
                                              SpiceMarshaller *m, DrawablePipeItem *dpi)
 {
     Drawable *item = dpi->drawable;
     RedDrawable *drawable = item->red_drawable;
 
     switch (drawable->type) {
     case QXL_DRAW_FILL:
-        red_marshall_qxl_draw_fill(rcc, m, dpi);
+        marshall_qxl_draw_fill(rcc, m, dpi);
         break;
     case QXL_DRAW_OPAQUE:
         red_marshall_qxl_draw_opaque(rcc, m, dpi, FALSE);
         break;
     case QXL_DRAW_COPY:
         red_marshall_qxl_draw_copy(rcc, m, dpi, FALSE);
         break;
     case QXL_DRAW_TRANSPARENT:
         red_marshall_qxl_draw_transparent(rcc, m, dpi);
         break;
@@ -2550,43 +2549,44 @@
     case QXL_DRAW_STROKE:
         red_marshall_qxl_draw_stroke(rcc, m, dpi);
         break;
     case QXL_DRAW_COMPOSITE:
         red_marshall_qxl_draw_composite(rcc, m, dpi);
         break;
     case QXL_DRAW_TEXT:
         red_marshall_qxl_draw_text(rcc, m, dpi);
         break;
     default:
-        spice_error("invalid type");
+        spice_warn_if_reached();
     }
 }
 
-static inline void marshall_qxl_drawable(RedChannelClient *rcc,
+static void marshall_qxl_drawable(RedChannelClient *rcc,
     SpiceMarshaller *m, DrawablePipeItem *dpi)
 {
     Drawable *item = dpi->drawable;
     DisplayChannel *display = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
 
-    spice_assert(display && rcc);
+    spice_return_if_fail(display);
+    spice_return_if_fail(rcc);
     /* allow sized frames to be streamed, even if they where replaced by another frame, since
      * newer frames might not cover sized frames completely if they are bigger */
     if ((item->stream || item->sized_stream) && red_marshall_stream_data(rcc, m, item)) {
         return;
     }
-    if (!display->enable_jpeg)
-        red_marshall_qxl_drawable(rcc, m, dpi);
+    if (display->enable_jpeg)
+        marshall_lossy_qxl_drawable(rcc, m, dpi);
     else
-        red_lossy_marshall_qxl_drawable(rcc, m, dpi);
+        marshall_lossless_qxl_drawable(rcc, m, dpi);
 }
 
-static void red_display_marshall_stream_start(RedChannelClient *rcc,
+static void marshall_stream_start(RedChannelClient *rcc,
                      SpiceMarshaller *base_marshaller, StreamAgent *agent)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     Stream *stream = agent->stream;
 
     agent->last_send_time = 0;
     spice_assert(stream);
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CREATE, NULL);
     SpiceMsgDisplayStreamCreate stream_create;
     SpiceClipRects clip_rects;
@@ -2609,52 +2609,52 @@
         stream_create.clip.type = SPICE_CLIP_TYPE_RECTS;
         clip_rects.num_rects = 0;
         stream_create.clip.rects = &clip_rects;
     }
 
     stream_create.stamp = 0;
 
     spice_marshall_msg_display_stream_create(base_marshaller, &stream_create);
 }
 
-static void red_display_marshall_stream_clip(RedChannelClient *rcc,
+static void marshall_stream_clip(RedChannelClient *rcc,
                                          SpiceMarshaller *base_marshaller,
                                          StreamClipItem *item)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     StreamAgent *agent = item->stream_agent;
 
-    spice_assert(agent->stream);
+    spice_return_if_fail(agent->stream);
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP, &item->base);
     SpiceMsgDisplayStreamClip stream_clip;
 
     stream_clip.id = get_stream_id(DCC_TO_DC(dcc), agent->stream);
     stream_clip.clip.type = item->clip_type;
     stream_clip.clip.rects = item->rects;
 
     spice_marshall_msg_display_stream_clip(base_marshaller, &stream_clip);
 }
 
-static void red_display_marshall_stream_end(RedChannelClient *rcc,
+static void marshall_stream_end(RedChannelClient *rcc,
                    SpiceMarshaller *base_marshaller, StreamAgent* agent)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     SpiceMsgDisplayStreamDestroy destroy;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DESTROY, NULL);
     destroy.id = get_stream_id(DCC_TO_DC(dcc), agent->stream);
     stream_agent_stop(agent);
     spice_marshall_msg_display_stream_destroy(base_marshaller, &destroy);
 }
 
-static void red_display_marshall_upgrade(RedChannelClient *rcc, SpiceMarshaller *m,
+static void marshall_upgrade(RedChannelClient *rcc, SpiceMarshaller *m,
                                          UpgradeItem *item)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     RedDrawable *red_drawable;
     SpiceMsgDisplayDrawCopy copy;
     SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
 
     spice_assert(rcc && rcc->channel && item && item->drawable);
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, &item->base);
 
@@ -2668,46 +2668,47 @@
     copy.base.clip.type = SPICE_CLIP_TYPE_RECTS;
     copy.base.clip.rects = item->rects;
     copy.data = red_drawable->u.copy;
 
     spice_marshall_msg_display_draw_copy(m, &copy,
                                          &src_bitmap_out, &mask_bitmap_out);
 
     fill_bits(dcc, src_bitmap_out, copy.data.src_bitmap, item->drawable, FALSE);
 }
 
-static void red_marshall_surface_create(RedChannelClient *rcc,
-    SpiceMarshaller *base_marshaller, SpiceMsgSurfaceCreate *surface_create)
+static void marshall_surface_create(RedChannelClient *rcc,
+                                    SpiceMarshaller *base_marshaller,
+                                    SpiceMsgSurfaceCreate *surface_create)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
 
     region_init(&dcc->surface_client_lossy_region[surface_create->surface_id]);
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_CREATE, NULL);
 
     spice_marshall_msg_display_surface_create(base_marshaller, surface_create);
 }
 
-static void red_marshall_surface_destroy(RedChannelClient *rcc,
+static void marshall_surface_destroy(RedChannelClient *rcc,
        SpiceMarshaller *base_marshaller, uint32_t surface_id)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     SpiceMsgSurfaceDestroy surface_destroy;
 
     region_destroy(&dcc->surface_client_lossy_region[surface_id]);
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_DESTROY, NULL);
 
     surface_destroy.surface_id = surface_id;
 
     spice_marshall_msg_display_surface_destroy(base_marshaller, &surface_destroy);
 }
 
-static void red_marshall_monitors_config(RedChannelClient *rcc, SpiceMarshaller *base_marshaller,
+static void marshall_monitors_config(RedChannelClient *rcc, SpiceMarshaller *base_marshaller,
                                          MonitorsConfig *monitors_config)
 {
     int heads_size = sizeof(SpiceHead) * monitors_config->count;
     int i;
     SpiceMsgDisplayMonitorsConfig *msg = spice_malloc0(sizeof(*msg) + heads_size);
     int count = 0; // ignore monitors_config->count, it may contain zero width monitors, remove them now
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_MONITORS_CONFIG, NULL);
     for (i = 0 ; i < monitors_config->count; ++i) {
         if (monitors_config->heads[i].width == 0 || monitors_config->heads[i].height == 0) {
@@ -2720,58 +2721,58 @@
         msg->heads[count].x = monitors_config->heads[i].x;
         msg->heads[count].y = monitors_config->heads[i].y;
         count++;
     }
     msg->count = count;
     msg->max_allowed = monitors_config->max_allowed;
     spice_marshall_msg_display_monitors_config(base_marshaller, msg);
     free(msg);
 }
 
-static void red_marshall_stream_activate_report(RedChannelClient *rcc,
+static void marshall_stream_activate_report(RedChannelClient *rcc,
                                                 SpiceMarshaller *base_marshaller,
                                                 uint32_t stream_id)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     StreamAgent *agent = &dcc->stream_agents[stream_id];
     SpiceMsgDisplayStreamActivateReport msg;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT, NULL);
     msg.stream_id = stream_id;
     msg.unique_id = agent->report_id;
     msg.max_window_size = RED_STREAM_CLIENT_REPORT_WINDOW;
     msg.timeout_ms = RED_STREAM_CLIENT_REPORT_TIMEOUT;
     spice_marshall_msg_display_stream_activate_report(base_marshaller, &msg);
 }
 
-static inline void display_begin_send_message(RedChannelClient *rcc)
+static void begin_send_message(RedChannelClient *rcc)
 {
     DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
     FreeList *free_list = &dcc->send_data.free_list;
 
     if (free_list->res->count) {
         int sync_count = 0;
         int i;
 
         for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
             if (i != dcc->common.id && free_list->sync[i] != 0) {
                 free_list->wait.header.wait_list[sync_count].channel_type = SPICE_CHANNEL_DISPLAY;
                 free_list->wait.header.wait_list[sync_count].channel_id = i;
                 free_list->wait.header.wait_list[sync_count++].message_serial = free_list->sync[i];
             }
         }
         free_list->wait.header.wait_count = sync_count;
 
         if (rcc->is_mini_header) {
-            display_channel_send_free_list(rcc);
+            send_free_list(rcc);
         } else {
-            display_channel_send_free_list_legacy(rcc);
+            send_free_list_legacy(rcc);
         }
     }
     red_channel_client_begin_send_message(rcc);
 }
 
 static void reset_send_data(DisplayChannelClient *dcc)
 {
     dcc->send_data.free_list.res->count = 0;
     dcc->send_data.num_pixmap_cache_items = 0;
     memset(dcc->send_data.free_list.sync, 0, sizeof(dcc->send_data.free_list.sync));
@@ -2783,39 +2784,39 @@
     SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
 
     reset_send_data(dcc);
     switch (pipe_item->type) {
     case PIPE_ITEM_TYPE_DRAW: {
         DrawablePipeItem *dpi = SPICE_CONTAINEROF(pipe_item, DrawablePipeItem, dpi_pipe_item);
         marshall_qxl_drawable(rcc, m, dpi);
         break;
     }
     case PIPE_ITEM_TYPE_INVAL_ONE:
-        red_marshall_inval_palette(rcc, m, (CacheItem *)pipe_item);
+        marshall_inval_palette(rcc, m, (CacheItem *)pipe_item);
         break;
     case PIPE_ITEM_TYPE_STREAM_CREATE: {
         StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, create_item);
-        red_display_marshall_stream_start(rcc, m, agent);
+        marshall_stream_start(rcc, m, agent);
         break;
     }
     case PIPE_ITEM_TYPE_STREAM_CLIP: {
         StreamClipItem* clip_item = (StreamClipItem *)pipe_item;
-        red_display_marshall_stream_clip(rcc, m, clip_item);
+        marshall_stream_clip(rcc, m, clip_item);
         break;
     }
     case PIPE_ITEM_TYPE_STREAM_DESTROY: {
         StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, destroy_item);
-        red_display_marshall_stream_end(rcc, m, agent);
+        marshall_stream_end(rcc, m, agent);
         break;
     }
     case PIPE_ITEM_TYPE_UPGRADE:
-        red_display_marshall_upgrade(rcc, m, (UpgradeItem *)pipe_item);
+        marshall_upgrade(rcc, m, (UpgradeItem *)pipe_item);
         break;
     case PIPE_ITEM_TYPE_VERB:
         red_marshall_verb(rcc, (VerbItem*)pipe_item);
         break;
     case PIPE_ITEM_TYPE_MIGRATE_DATA:
         display_channel_marshall_migrate_data(rcc, m);
         break;
     case PIPE_ITEM_TYPE_IMAGE:
         red_marshall_image(rcc, m, (ImageItem *)pipe_item);
         break;
@@ -2825,51 +2826,51 @@
     case PIPE_ITEM_TYPE_PIXMAP_RESET:
         display_channel_marshall_reset_cache(rcc, m);
         break;
     case PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE:
         dcc_palette_cache_reset(dcc);
         red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES, NULL);
         break;
     case PIPE_ITEM_TYPE_CREATE_SURFACE: {
         SurfaceCreateItem *surface_create = SPICE_CONTAINEROF(pipe_item, SurfaceCreateItem,
                                                               pipe_item);
-        red_marshall_surface_create(rcc, m, &surface_create->surface_create);
+        marshall_surface_create(rcc, m, &surface_create->surface_create);
         break;
     }
     case PIPE_ITEM_TYPE_DESTROY_SURFACE: {
         SurfaceDestroyItem *surface_destroy = SPICE_CONTAINEROF(pipe_item, SurfaceDestroyItem,
                                                                 pipe_item);
-        red_marshall_surface_destroy(rcc, m, surface_destroy->surface_destroy.surface_id);
+        marshall_surface_destroy(rcc, m, surface_destroy->surface_destroy.surface_id);
         break;
     }
     case PIPE_ITEM_TYPE_MONITORS_CONFIG: {
         MonitorsConfigItem *monconf_item = SPICE_CONTAINEROF(pipe_item,
                                                              MonitorsConfigItem, pipe_item);
-        red_marshall_monitors_config(rcc, m, monconf_item->monitors_config);
+        marshall_monitors_config(rcc, m, monconf_item->monitors_config);
         break;
     }
     case PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT: {
         StreamActivateReportItem *report_item = SPICE_CONTAINEROF(pipe_item,
                                                                   StreamActivateReportItem,
                                                                   pipe_item);
-        red_marshall_stream_activate_report(rcc, m, report_item->stream_id);
+        marshall_stream_activate_report(rcc, m, report_item->stream_id);
         break;
     }
     default:
-        spice_error("invalid pipe item type");
+        spice_warn_if_reached();
     }
 
     dcc_release_item(dcc, pipe_item, FALSE);
 
     // a message is pending
     if (red_channel_client_send_message_pending(rcc)) {
-        display_begin_send_message(rcc);
+        begin_send_message(rcc);
     }
 }
 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
    Copyright (C) 2009 Red Hat, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
@@ -2910,25 +2911,23 @@
 #include <poll.h>
 #include <pthread.h>
 #include <netinet/tcp.h>
 #include <openssl/ssl.h>
 #include <inttypes.h>
 #include <glib.h>
 
 #include <spice/protocol.h>
 #include <spice/qxl_dev.h>
 #include "common/lz.h"
-#include "common/marshaller.h"
 #include "common/rect.h"
 #include "common/region.h"
 #include "common/ring.h"
-#include "common/generated_server_marshallers.h"
 
 #include "display-channel.h"
 #include "stream.h"
 
 #include "spice.h"
 #include "red_worker.h"
 #include "spice_timer_queue.h"
 #include "cursor-channel.h"
 #include "tree.h"
 
@@ -2941,22 +2940,20 @@
 
 #define MAX_EVENT_SOURCES 20
 #define INF_EVENT_WAIT ~0
 
 struct SpiceWatch {
     struct RedWorker *worker;
     SpiceWatchFunc watch_func;
     void *watch_func_opaque;
 };
 
-#define MAX_PIPE_SIZE 50
-
 struct RedWorker {
     pthread_t thread;
     clockid_t clockid;
     QXLInstance *qxl;
     RedDispatcher *red_dispatcher;
     int running;
     struct pollfd poll_fds[MAX_EVENT_SOURCES];
     struct SpiceWatch watches[MAX_EVENT_SOURCES];
     unsigned int event_timeout;
 
@@ -2977,29 +2974,34 @@
     StatNodeRef stat;
     uint64_t *wakeup_counter;
     uint64_t *command_counter;
 #endif
 
     int driver_cap_monitors_config;
 
     FILE *record_fd;
 };
 
-static inline void display_begin_send_message(RedChannelClient *rcc);
-
 QXLInstance* red_worker_get_qxl(RedWorker *worker)
 {
     spice_return_val_if_fail(worker != NULL, NULL);
 
     return worker->qxl;
 }
 
+RedMemSlotInfo* red_worker_get_memslot(RedWorker *worker)
+{
+    spice_return_val_if_fail(worker != NULL, NULL);
+
+    return &worker->mem_slots;
+}
+
 static int display_is_connected(RedWorker *worker)
 {
     return (worker->display_channel && red_channel_is_connected(
         &worker->display_channel->common.base));
 }
 
 static int cursor_is_connected(RedWorker *worker)
 {
     return worker->cursor_channel &&
         red_channel_is_connected(RED_CHANNEL(worker->cursor_channel));
@@ -5085,20 +5087,22 @@
         red_pipe_add_verb(rcc, verb);
     }
 }
 
 RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher);
 bool       red_worker_run(RedWorker *worker);
 QXLInstance* red_worker_get_qxl(RedWorker *worker);
 RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
 RedChannel* red_worker_get_display_channel(RedWorker *worker);
 clockid_t red_worker_get_clockid(RedWorker *worker);
+RedMemSlotInfo* red_worker_get_memslot(RedWorker *worker);
+
 void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
                         uint32_t group_id);
 
 RedChannel *red_worker_new_channel(RedWorker *worker, int size,
                                    const char *name,
                                    uint32_t channel_type, int migration_flags,
                                    ChannelCbs *channel_cbs,
                                    channel_handle_parsed_proc handle_parsed);
 
 CommonChannelClient *common_channel_new_client(CommonChannel *common,


More information about the Spice-devel mailing list