summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/red-replay-qxl.cpp25
-rw-r--r--server/tests/replay.c39
2 files changed, 64 insertions, 0 deletions
diff --git a/server/red-replay-qxl.cpp b/server/red-replay-qxl.cpp
index 05818295..c4182b09 100644
--- a/server/red-replay-qxl.cpp
+++ b/server/red-replay-qxl.cpp
@@ -367,6 +367,8 @@ static void red_replay_data_chunks_free(SpiceReplay *replay, void *data, size_t
auto cur = reinterpret_cast<QXLDataChunk *>(static_cast<uint8_t *>(data) +
(base_size ? base_size - sizeof(QXLDataChunk) : 0));
+ if (!base_size && !cur) return;
+
cur = QXLPHYSICAL_TO_PTR<QXLDataChunk>(cur->next_chunk);
while (cur) {
auto next = QXLPHYSICAL_TO_PTR<QXLDataChunk>(cur->next_chunk);
@@ -918,6 +920,26 @@ static void red_replay_composite_free(SpiceReplay *replay, QXLComposite *qxl, ui
}
+static int dr_count = 0;
+static int type_counts[256];
+
+static void add_count(SpiceReplay *replay, int type, int inc)
+{
+ int i;
+ pthread_mutex_lock(&replay->mutex);
+ dr_count += inc;
+ printf("DRAWABLE COUNT %d\n", dr_count);
+ assert(type >= 0 && type < 256);
+ type_counts[type] += inc;
+ for (i = 0; i < 256; ++i) {
+ if (type_counts[i])
+ printf(" %d=%d", i, type_counts[i]);
+ }
+ printf("\n");
+ pthread_mutex_unlock(&replay->mutex);
+}
+#define add_count(t,i) add_count(replay,t,i)
+
static QXLDrawable *red_replay_native_drawable(SpiceReplay *replay, uint32_t flags)
{
auto qxl = static_cast<QXLDrawable *>(
@@ -950,6 +972,7 @@ static QXLDrawable *red_replay_native_drawable(SpiceReplay *replay, uint32_t fla
if (replay->error) {
return nullptr;
}
+add_count(qxl->type, 1);
switch (qxl->type) {
case QXL_DRAW_ALPHA_BLEND:
red_replay_alpha_blend_ptr(replay, &qxl->u.alpha_blend, flags);
@@ -1006,6 +1029,8 @@ static void red_replay_native_drawable_free(SpiceReplay *replay, QXLDrawable *qx
{
red_replay_clip_free(replay, &qxl->clip);
+add_count(qxl->type, -1);
+
switch (qxl->type) {
case QXL_DRAW_ALPHA_BLEND:
red_replay_alpha_blend_free(replay, &qxl->u.alpha_blend, flags);
diff --git a/server/tests/replay.c b/server/tests/replay.c
index 420aca1d..f539f991 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -207,6 +207,9 @@ static int get_command_from(QXLInstance *qin, QXLCommandExt *ext, GAsyncQueue *q
{
QXLCommandExt *cmd;
+ if (!queue)
+ return FALSE;
+
if (g_async_queue_length(queue) == 0) {
/* could use a gcondition ? */
fill_queue();
@@ -367,6 +370,8 @@ static void free_queue(GAsyncQueue *queue)
g_async_queue_unref(queue);
}
+QXLCommandExt *cmd;
+
int main(int argc, char **argv)
{
GError *error = NULL;
@@ -468,6 +473,7 @@ int main(int argc, char **argv)
fseek(fd, 0L, SEEK_SET);
if (total_size > 0)
g_timeout_add_seconds(1, progress_timer, fd);
+ fd->_offset = 0;
replay = spice_replay_new(fd, MAX_SURFACE_NUM);
if (replay == NULL) {
g_printerr("Error initializing replay\n");
@@ -519,6 +525,29 @@ int main(int argc, char **argv)
spice_replay_set_playback(replay, &playback_sin);
}
+#if 1
+int n = 0;
+ for (;;) {
+ printf("cmd %d pos %ld\n", n, ftell(fd));
+ cmd = spice_replay_next_cmd(replay, &display_sin);
+ if (!cmd)
+ break;
+//if (++n == 5813) abort();
+ spice_replay_free_cmd(replay, cmd);
+if (++n == 5812) break;
+#if 0
+if (++n == 5812) {
+//asm("int3");
+printf("stop here\n");
+printf("stop here\n");
+printf("stop here\n");
+}
+#endif
+ }
+ spice_replay_free(replay);
+
+return 0;
+#endif
if (client) {
start_client(client, &error);
wait = TRUE;
@@ -537,6 +566,16 @@ int main(int argc, char **argv)
if (print_count)
g_print("Counted %d commands\n", ncommands);
+ g_async_queue_unref(display_queue);
+ display_queue = NULL;
+ g_async_queue_unref(cursor_queue);
+ cursor_queue = NULL;
+ spice_qxl_wakeup(&display_sin);
+ spice_qxl_wakeup(&display_sin);
+ spice_qxl_wakeup(&display_sin);
+ spice_qxl_wakeup(&display_sin);
+sleep(2);
+printf("XXXX\n");
spice_server_destroy(server);
free_queue(display_queue);
free_queue(cursor_queue);