summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorJeremy White <jwhite@codeweavers.com>2016-06-20 15:53:50 -0500
committerJeremy White <jwhite@codeweavers.com>2016-06-20 15:53:50 -0500
commit8969fe0669ddf5b3e288470b7fbf37da38f6f2ad (patch)
tree9cb1b67b4ee98c90c2e08792137519bac62dd86d /src/session.c
parentee26c4a6c6f0d5c78f14cc956452f1b33bee9a89 (diff)
Revisions to improve session creation/tear down.
This is part of an effort to nail down invalid access and memory leaks. We move the spice surface creation / destruction into the spice code, and the fullscreen display to the display logic.
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/session.c b/src/session.c
index 8093861..ccfe7ee 100644
--- a/src/session.c
+++ b/src/session.c
@@ -42,11 +42,17 @@ void free_draw_queue_item(gpointer data)
void *session_pop_draw(session_t *session)
{
+ if (! session || ! session->running)
+ return NULL;
+
return g_async_queue_try_pop(session->draw_queue);
}
int session_draw_waiting(session_t *session)
{
+ if (! session || ! session->running)
+ return 0;
+
return g_async_queue_length(session->draw_queue);
}
@@ -110,17 +116,11 @@ void session_handle_mouse_buttons(session_t *session, uint32_t buttons_state)
int session_start(session_t *s)
{
int rc = 0;
- shm_image_t *f;
s->spice.session = s;
s->display.session = s;
s->scanner.session = s;
- rc = display_create_fullscreen(&s->display);
- if (rc)
- return rc;
- f = s->display.fullscreen;
-
rc = scanner_create(&s->scanner);
if (rc)
goto end;
@@ -129,9 +129,7 @@ int session_start(session_t *s)
if (rc)
return rc;
- rc = spice_create_primary(&s->spice, f->w, f->h, f->bytes_per_line, f->shmaddr);
- if (rc)
- goto end;
+ s->running = 1;
end:
if (rc)
@@ -141,8 +139,7 @@ end:
void session_end(session_t *s)
{
- // FIXME - can't always destroy...
- spice_destroy_primary(&s->spice);
+ s->running = 0;
scanner_destroy(&s->scanner);
@@ -166,3 +163,8 @@ void session_destroy(session_t *s)
s->cursor_queue = NULL;
s->draw_queue = NULL;
}
+
+int session_alive(session_t *s)
+{
+ return s->running;
+}