From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx> Rename and lightly refactor the function that creates new common channels for RedWorker (essentially Cursor and Display channels). Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> --- server/cursor-channel.c | 25 ++++++++++----------- server/red_worker.c | 59 ++++++++++++++++++++++--------------------------- server/red_worker.h | 14 ++++-------- 3 files changed, 42 insertions(+), 56 deletions(-) diff --git a/server/cursor-channel.c b/server/cursor-channel.c index 24b7362..9c4bf1e 100644 --- a/server/cursor-channel.c +++ b/server/cursor-channel.c @@ -364,22 +364,21 @@ static void cursor_channel_release_item(RedChannelClient *rcc, PipeItem *item, i CursorChannel* cursor_channel_new(RedWorker *worker) { - CursorChannel* cursor; + CursorChannel *cursor; + RedChannel *channel = NULL; + ChannelCbs cbs = { + .on_disconnect = cursor_channel_client_on_disconnect, + .send_item = cursor_channel_send_item, + .hold_item = cursor_channel_hold_pipe_item, + .release_item = cursor_channel_release_item + }; spice_info("create cursor channel"); - cursor = (CursorChannel *)__new_channel( - worker, sizeof(CursorChannel), - SPICE_CHANNEL_CURSOR, - 0, - cursor_channel_client_on_disconnect, - cursor_channel_send_item, - cursor_channel_hold_pipe_item, - cursor_channel_release_item, - red_channel_client_handle_message, - NULL, - NULL, - NULL); + channel = red_worker_new_channel(worker, sizeof(CursorChannel), + SPICE_CHANNEL_CURSOR, 0, + &cbs, red_channel_client_handle_message); + cursor = (CursorChannel *)channel; cursor->cursor_visible = TRUE; cursor->mouse_mode = SPICE_MOUSE_MODE_SERVER; diff --git a/server/red_worker.c b/server/red_worker.c index 0c8ba4c..52fe132 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -9558,38 +9558,30 @@ DisplayChannelClient *display_channel_client_create(CommonChannel *common, return dcc; } -RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_type, - int migration_flags, - channel_disconnect_proc on_disconnect, - channel_send_pipe_item_proc send_item, - channel_hold_pipe_item_proc hold_item, - channel_release_pipe_item_proc release_item, - channel_handle_parsed_proc handle_parsed, - channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark, - channel_handle_migrate_data_proc handle_migrate_data, - channel_handle_migrate_data_get_serial_proc migrate_get_serial) +RedChannel *red_worker_new_channel(RedWorker *worker, int size, + uint32_t channel_type, int migration_flags, + ChannelCbs *channel_cbs, + channel_handle_parsed_proc handle_parsed) { RedChannel *channel = NULL; CommonChannel *common; - ChannelCbs channel_cbs = { NULL, }; - - channel_cbs.config_socket = common_channel_config_socket; - channel_cbs.on_disconnect = on_disconnect; - channel_cbs.send_item = send_item; - channel_cbs.hold_item = hold_item; - channel_cbs.release_item = release_item; - channel_cbs.alloc_recv_buf = common_alloc_recv_buf; - channel_cbs.release_recv_buf = common_release_recv_buf; - channel_cbs.handle_migrate_flush_mark = handle_migrate_flush_mark; - channel_cbs.handle_migrate_data = handle_migrate_data; - channel_cbs.handle_migrate_data_get_serial = migrate_get_serial; + + spice_return_val_if_fail(worker, NULL); + spice_return_val_if_fail(channel_cbs, NULL); + spice_return_val_if_fail(!channel_cbs->config_socket, NULL); + spice_return_val_if_fail(!channel_cbs->alloc_recv_buf, NULL); + spice_return_val_if_fail(!channel_cbs->release_recv_buf, NULL); + + channel_cbs->config_socket = common_channel_config_socket; + channel_cbs->alloc_recv_buf = common_alloc_recv_buf; + channel_cbs->release_recv_buf = common_release_recv_buf; channel = red_channel_create_parser(size, &worker_core, channel_type, worker->qxl->id, TRUE /* handle_acks */, spice_get_client_channel_parser(channel_type, NULL), handle_parsed, - &channel_cbs, + channel_cbs, migration_flags); common = (CommonChannel *)channel; if (!channel) { @@ -9738,25 +9730,26 @@ static void display_channel_release_item(RedChannelClient *rcc, PipeItem *item, static void display_channel_create(RedWorker *worker, int migrate) { DisplayChannel *display_channel; + ChannelCbs cbs = { + .on_disconnect = display_channel_client_on_disconnect, + .send_item = display_channel_send_item, + .hold_item = display_channel_hold_pipe_item, + .release_item = display_channel_release_item, + .handle_migrate_flush_mark = display_channel_handle_migrate_mark, + .handle_migrate_data = display_channel_handle_migrate_data, + .handle_migrate_data_get_serial = display_channel_handle_migrate_data_get_serial + }; if (worker->display_channel) { return; } spice_info("create display channel"); - if (!(worker->display_channel = (DisplayChannel *)__new_channel( + if (!(worker->display_channel = (DisplayChannel *)red_worker_new_channel( worker, sizeof(*display_channel), SPICE_CHANNEL_DISPLAY, SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER, - display_channel_client_on_disconnect, - display_channel_send_item, - display_channel_hold_pipe_item, - display_channel_release_item, - display_channel_handle_message, - display_channel_handle_migrate_mark, - display_channel_handle_migrate_data, - display_channel_handle_migrate_data_get_serial - ))) { + &cbs, display_channel_handle_message))) { spice_warning("failed to create display channel"); return; } diff --git a/server/red_worker.h b/server/red_worker.h index 795959d..76502b6 100644 --- a/server/red_worker.h +++ b/server/red_worker.h @@ -118,16 +118,10 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher); bool red_worker_run(RedWorker *worker); QXLInstance* red_worker_get_qxl(RedWorker *worker); -RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_type, - int migration_flags, - channel_disconnect_proc on_disconnect, - channel_send_pipe_item_proc send_item, - channel_hold_pipe_item_proc hold_item, - channel_release_pipe_item_proc release_item, - channel_handle_parsed_proc handle_parsed, - channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark, - channel_handle_migrate_data_proc handle_migrate_data, - channel_handle_migrate_data_get_serial_proc migrate_get_serial); +RedChannel *red_worker_new_channel(RedWorker *worker, int size, + uint32_t channel_type, int migration_flags, + ChannelCbs *channel_cbs, + channel_handle_parsed_proc handle_parsed); CommonChannelClient *common_channel_new_client(CommonChannel *common, int size, -- 2.4.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel