[Spice-devel] [PATCH v2 spice 02/11] server/red_worker: dump_bitmap: add surface_id to the bitmap file name
Yonit Halperin
yhalperi at redhat.com
Tue Apr 17 03:12:27 PDT 2012
Also replaced sprintf with snprintf
---
server/red_worker.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index 5350195..99a8948 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -1014,7 +1014,7 @@ static void cursor_channel_client_release_item_after_push(CursorChannelClient *c
static void red_wait_pipe_item_sent(RedChannelClient *rcc, PipeItem *item);
#ifdef DUMP_BITMAP
-static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id);
+static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id, int surface_id);
#endif
/*
@@ -6368,7 +6368,9 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
case SPICE_IMAGE_TYPE_BITMAP: {
SpiceBitmap *bitmap = &image.u.bitmap;
#ifdef DUMP_BITMAP
- dump_bitmap(display_channel->common.worker, &simage->u.bitmap, drawable->group_id);
+ dump_bitmap(display_channel->common.worker, &simage->u.bitmap,
+ drawable->group_id,
+ drawable->surface_id);
#endif
/* Images must be added to the cache only after they are compressed
in order to prevent starvation in the client between pixmap_cache and
@@ -11235,12 +11237,12 @@ static void dump_line(FILE *f, uint8_t* line, uint16_t n_pixel_bits, int width,
}
#define RAM_PATH "/tmp/tmpfs"
-
-static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id)
+#define DUMP_BITMAP_FILE_NAME_LEN 200
+static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_id, int surface_id)
{
static uint32_t file_id = 0;
+ static char file_str[DUMP_BITMAP_FILE_NAME_LEN];
- char file_str[200];
int rgb = TRUE;
uint16_t n_pixel_bits;
SpicePalette *plt = NULL;
@@ -11303,7 +11305,7 @@ static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_i
file_size = bitmap_data_offset + (bitmap->y * row_size);
id = ++file_id;
- sprintf(file_str, "%s/%u.bmp", RAM_PATH, id);
+ sprintf(file_str, DUMP_BITMAP_FILE_NAME_LEN, "%s/%u-%d.bmp", RAM_PATH, id, surface_id);
f = fopen(file_str, "wb");
if (!f) {
--
1.7.7.6
More information about the Spice-devel
mailing list