[Spice-commits] server/red-qxl.c server/red-worker.c server/red-worker.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Mar 29 08:27:01 UTC 2016


 server/red-qxl.c    |   34 +++++++++++++---------------------
 server/red-worker.c |   30 +++++++++++++++---------------
 server/red-worker.h |    6 +++---
 3 files changed, 31 insertions(+), 39 deletions(-)

New commits:
commit 4c5c9f6b6954fdf82ee2158cc9e945103ce784ae
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Dec 18 12:02:31 2015 +0000

    dispatcher: move channel final initialization to red-worker
    
    CursorChannel and DisplayChannel was initialized half in red_worker_new
    and half in red_dispatcher_init using some accessor for RedWorker
    (red_worker_get_cursor_channel and red_worker_get_display_channel).
    Moving directly into red_worker_new make easier to follow code path.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-qxl.c b/server/red-qxl.c
index 8ba6fd6..7015144 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -950,8 +950,8 @@ void red_qxl_gl_draw_async_complete(QXLInstance *qxl)
 void red_qxl_init(RedsState *reds, QXLInstance *qxl)
 {
     QXLState *qxl_state;
-    RedChannel *channel;
-    ClientCbs client_cbs = { NULL, };
+    ClientCbs client_cursor_cbs = { NULL, };
+    ClientCbs client_display_cbs = { NULL, };
 
     spice_return_if_fail(qxl != NULL);
 
@@ -983,26 +983,18 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
     qxl_state->max_monitors = UINT_MAX;
     qxl->st = qxl_state;
 
-    // TODO: reference and free
-    RedWorker *worker = red_worker_new(qxl);
-
     // TODO: move to their respective channel files
-    channel = red_worker_get_cursor_channel(worker);
-    client_cbs.connect = red_qxl_set_cursor_peer;
-    client_cbs.disconnect = red_qxl_disconnect_cursor_peer;
-    client_cbs.migrate = red_qxl_cursor_migrate;
-    red_channel_register_client_cbs(channel, &client_cbs, &qxl_state->dispatcher);
-    reds_register_channel(reds, channel);
-
-    channel = red_worker_get_display_channel(worker);
-    client_cbs.connect = red_qxl_set_display_peer;
-    client_cbs.disconnect = red_qxl_disconnect_display_peer;
-    client_cbs.migrate = red_qxl_display_migrate;
-    red_channel_register_client_cbs(channel, &client_cbs, &qxl_state->dispatcher);
-    red_channel_set_cap(channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
-    red_channel_set_cap(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION);
-    red_channel_set_cap(channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
-    reds_register_channel(reds, channel);
+    client_cursor_cbs.connect = red_qxl_set_cursor_peer;
+    client_cursor_cbs.disconnect = red_qxl_disconnect_cursor_peer;
+    client_cursor_cbs.migrate = red_qxl_cursor_migrate;
+
+    client_display_cbs.connect = red_qxl_set_display_peer;
+    client_display_cbs.disconnect = red_qxl_disconnect_display_peer;
+    client_display_cbs.migrate = red_qxl_display_migrate;
+
+    // TODO: reference and free
+    RedWorker *worker = red_worker_new(qxl, &client_cursor_cbs,
+                                       &client_display_cbs);
 
     red_worker_run(worker);
 }
diff --git a/server/red-worker.c b/server/red-worker.c
index 8dacc87..241c300 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1464,13 +1464,16 @@ static GSourceFuncs worker_source_funcs = {
     .dispatch = worker_source_dispatch,
 };
 
-RedWorker* red_worker_new(QXLInstance *qxl)
+RedWorker* red_worker_new(QXLInstance *qxl,
+                          const ClientCbs *client_cursor_cbs,
+                          const ClientCbs *client_display_cbs)
 {
     QXLDevInitInfo init_info;
     RedWorker *worker;
     Dispatcher *dispatcher;
     const char *record_filename;
     RedsState *reds = red_qxl_get_server(qxl->st);
+    RedChannel *channel;
 
     red_qxl_get_init_info(qxl, &init_info);
 
@@ -1533,10 +1536,21 @@ RedWorker* red_worker_new(QXLInstance *qxl)
     worker->event_timeout = INF_EVENT_WAIT;
 
     worker->cursor_channel = cursor_channel_new(worker);
+    channel = RED_CHANNEL(worker->cursor_channel);
+    red_channel_register_client_cbs(channel, client_cursor_cbs, dispatcher);
+    reds_register_channel(reds, channel);
+
     // TODO: handle seemless migration. Temp, setting migrate to FALSE
     worker->display_channel = display_channel_new(reds, worker, FALSE, reds_get_streaming_video(reds),
                                                   init_info.n_surfaces);
 
+    channel = RED_CHANNEL(worker->display_channel);
+    red_channel_register_client_cbs(channel, client_display_cbs, dispatcher);
+    red_channel_set_cap(channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
+    red_channel_set_cap(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION);
+    red_channel_set_cap(channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
+    reds_register_channel(reds, channel);
+
     return worker;
 }
 
@@ -1581,20 +1595,6 @@ bool red_worker_run(RedWorker *worker)
     return r == 0;
 }
 
-RedChannel* red_worker_get_cursor_channel(RedWorker *worker)
-{
-    spice_return_val_if_fail(worker, NULL);
-
-    return RED_CHANNEL(worker->cursor_channel);
-}
-
-RedChannel* red_worker_get_display_channel(RedWorker *worker)
-{
-    spice_return_val_if_fail(worker, NULL);
-
-    return RED_CHANNEL(worker->display_channel);
-}
-
 static RedsState* red_worker_get_server(RedWorker *worker)
 {
     return red_qxl_get_server(worker->qxl->st);
diff --git a/server/red-worker.h b/server/red-worker.h
index 7faf0b3..15cceb8 100644
--- a/server/red-worker.h
+++ b/server/red-worker.h
@@ -90,10 +90,10 @@ static inline void red_pipes_add_verb(RedChannel *channel, uint16_t verb)
     }
 }
 
-RedWorker* red_worker_new(QXLInstance *qxl);
+RedWorker* red_worker_new(QXLInstance *qxl,
+                          const ClientCbs *client_cursor_cbs,
+                          const ClientCbs *client_display_cbs);
 bool       red_worker_run(RedWorker *worker);
-RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
-RedChannel* red_worker_get_display_channel(RedWorker *worker);
 
 void red_drawable_unref(RedDrawable *red_drawable);
 


More information about the Spice-commits mailing list