diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp index 36917e25..b084ef72 100644 --- a/server/cursor-channel.cpp +++ b/server/cursor-channel.cpp @@ -269,11 +269,11 @@ void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd) return; } - if (red_channel_is_connected(cursor) && + if (cursor->is_connected() && (cursor->mouse_mode == SPICE_MOUSE_MODE_SERVER || cursor_cmd->type != QXL_CURSOR_MOVE || cursor_show)) { - red_channel_pipes_add(cursor, &cursor_pipe_item->base); + cursor->pipes_add(&cursor_pipe_item->base); } else { red_pipe_item_unref(&cursor_pipe_item->base); } @@ -288,12 +288,12 @@ void cursor_channel_reset(CursorChannel *cursor) cursor->cursor_position.x = cursor->cursor_position.y = 0; cursor->cursor_trail_length = cursor->cursor_trail_frequency = 0; - if (red_channel_is_connected(cursor)) { - red_channel_pipes_add_type(cursor, RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE); + if (cursor->is_connected()) { + cursor->pipes_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE); if (!common_graphics_channel_get_during_target_migrate(cursor)) { - red_channel_pipes_add_empty_msg(cursor, SPICE_MSG_CURSOR_RESET); + cursor->pipes_add_empty_msg(SPICE_MSG_CURSOR_RESET); } - red_channel_wait_all_sent(cursor, COMMON_CLIENT_TIMEOUT); + cursor->wait_all_sent(COMMON_CLIENT_TIMEOUT); } } @@ -301,7 +301,7 @@ static void cursor_channel_init_client(CursorChannel *cursor, CursorChannelClien { spice_return_if_fail(cursor); - if (!red_channel_is_connected(cursor) + if (!cursor->is_connected() || common_graphics_channel_get_during_target_migrate(cursor)) { spice_debug("during_target_migrate: skip init"); return; @@ -310,7 +310,7 @@ static void cursor_channel_init_client(CursorChannel *cursor, CursorChannelClien if (client) client->pipe_add_type(RED_PIPE_ITEM_TYPE_CURSOR_INIT); else - red_channel_pipes_add_type(cursor, RED_PIPE_ITEM_TYPE_CURSOR_INIT); + cursor->pipes_add_type(RED_PIPE_ITEM_TYPE_CURSOR_INIT); } void cursor_channel_do_init(CursorChannel *cursor) @@ -366,7 +366,7 @@ static void cursor_channel_constructed(GObject *object) { RedChannel *red_channel = RED_CHANNEL(object); - RedsState *reds = red_channel_get_server(red_channel); + RedsState *reds = red_channel->get_server(); G_OBJECT_CLASS(cursor_channel_parent_class)->constructed(object); diff --git a/server/display-channel-private.h b/server/display-channel-private.h index d32273b7..c3170e54 100644 --- a/server/display-channel-private.h +++ b/server/display-channel-private.h @@ -134,7 +134,7 @@ struct DisplayChannelPrivate }; #define FOREACH_DCC(_channel, _data) \ - GLIST_FOREACH((_channel ? red_channel_get_clients(_channel) : NULL), \ + GLIST_FOREACH((_channel ? _channel->get_clients() : NULL), \ DisplayChannelClient, _data) typedef struct RedMonitorsConfigItem { diff --git a/server/display-channel.cpp b/server/display-channel.cpp index a35f1a6a..0bdda034 100644 --- a/server/display-channel.cpp +++ b/server/display-channel.cpp @@ -336,7 +336,7 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra RingItem *item; DisplayChannelClient *dcc; - if (!red_channel_is_connected(display)) { + if (!display->is_connected()) { return; } @@ -399,7 +399,7 @@ static void pipes_add_drawable_after(DisplayChannel *display, pipes_add_drawable(display, drawable); return; } - if (num_other_linked != red_channel_get_n_clients(display)) { + if (num_other_linked != display->get_n_clients()) { spice_debug("TODO: not O(n^2)"); FOREACH_DCC(display, dcc) { int sent = 0; @@ -1465,9 +1465,9 @@ bool display_channel_wait_for_migrate_data(DisplayChannel *display) uint64_t end_time = spice_get_monotonic_time_ns() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT; RedChannelClient *rcc; int ret = FALSE; - GList *clients = red_channel_get_clients(display); + GList *clients = display->get_clients(); - if (!red_channel_is_waiting_for_migrate_data(display)) { + if (!display->is_waiting_for_migrate_data()) { return FALSE; } @@ -2111,11 +2111,9 @@ void display_channel_destroy_surfaces(DisplayChannel *display) } spice_warn_if_fail(ring_is_empty(&display->priv->streams)); - if (red_channel_is_connected(display)) { - red_channel_pipes_add_type(display, - RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE); - red_channel_pipes_add_empty_msg(display, - SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL); + if (display->is_connected()) { + display->pipes_add_type(RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE); + display->pipes_add_empty_msg(SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL); } display_channel_free_glz_drawables(display); @@ -2184,7 +2182,7 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id if (display->priv->renderer == RED_RENDERER_INVALID) { int i; - RedsState *reds = red_channel_get_server(display); + RedsState *reds = display->get_server(); GArray *renderers = reds_get_renderers(reds); for (i = 0; i < renderers->len; i++) { uint32_t renderer = g_array_index(renderers, uint32_t, i); @@ -2207,7 +2205,7 @@ static bool handle_migrate_flush_mark(RedChannelClient *rcc) { RedChannel *channel = rcc->get_channel(); - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_MIGRATE_DATA); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_MIGRATE_DATA); return TRUE; } @@ -2304,8 +2302,8 @@ display_channel_constructed(GObject *object) stat_init(&self->priv->add_stat, "add", CLOCK_THREAD_CPUTIME_ID); stat_init(&self->priv->exclude_stat, "exclude", CLOCK_THREAD_CPUTIME_ID); stat_init(&self->priv->__exclude_stat, "__exclude", CLOCK_THREAD_CPUTIME_ID); - RedsState *reds = red_channel_get_server(self); - const RedStatNode *stat = red_channel_get_stat_node(channel); + RedsState *reds = self->get_server(); + const RedStatNode *stat = channel->get_stat_node(); stat_init_counter(&self->priv->cache_hits_counter, reds, stat, "cache_hits", TRUE); stat_init_counter(&self->priv->add_to_cache_counter, reds, stat, @@ -2313,10 +2311,10 @@ display_channel_constructed(GObject *object) stat_init_counter(&self->priv->non_cache_counter, reds, stat, "non_cache", TRUE); - 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_PREF_VIDEO_CODEC_TYPE); - red_channel_set_cap(channel, SPICE_DISPLAY_CAP_STREAM_REPORT); + channel->set_cap(SPICE_DISPLAY_CAP_MONITORS_CONFIG); + channel->set_cap(SPICE_DISPLAY_CAP_PREF_COMPRESSION); + channel->set_cap(SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE); + channel->set_cap(SPICE_DISPLAY_CAP_STREAM_REPORT); reds_register_channel(reds, channel); } @@ -2393,7 +2391,7 @@ static void display_channel_update_compression(DisplayChannel *display, DisplayC void display_channel_gl_scanout(DisplayChannel *display) { - red_channel_pipes_new_add(display, dcc_gl_scanout_item_new, NULL); + display->pipes_new_add(dcc_gl_scanout_item_new, NULL); } static void set_gl_draw_async_count(DisplayChannel *display, int num) @@ -2411,7 +2409,7 @@ void display_channel_gl_draw(DisplayChannel *display, SpiceMsgDisplayGlDraw *dra spice_return_if_fail(display->priv->gl_draw_async_count == 0); - num = red_channel_pipes_new_add(display, dcc_gl_draw_item_new, draw); + num = display->pipes_new_add(dcc_gl_draw_item_new, draw); set_gl_draw_async_count(display, num); } @@ -2551,7 +2549,7 @@ void display_channel_debug_oom(DisplayChannel *display, const char *msg) display->priv->drawable_count, display->priv->encoder_shared_data.glz_drawable_count, ring_get_length(&display->priv->current_list), - red_channel_sum_pipes_size(display)); + display->sum_pipes_size()); } static void guest_set_client_capabilities(DisplayChannel *display) @@ -2579,7 +2577,7 @@ static void guest_set_client_capabilities(DisplayChannel *display) #define CLEAR_CAP(a,c) \ ((a)[(c) / 8] &= ~(1 << ((c) % 8))) - if ((red_channel_get_n_clients(display) == 0)) { + if ((display->get_n_clients() == 0)) { red_qxl_set_client_capabilities(display->priv->qxl, FALSE, caps); } else { // Take least common denominator @@ -2613,7 +2611,7 @@ display_channel_connect(RedChannel *channel, RedClient *client, spice_debug("connect new client"); - SpiceServer *reds = red_channel_get_server(channel); + SpiceServer *reds = channel->get_server(); dcc = dcc_new(display, client, stream, migration, caps, display->priv->image_compression, reds_get_jpeg_state(reds), reds_get_zlib_glz_state(reds)); diff --git a/server/inputs-channel.cpp b/server/inputs-channel.cpp index 7f1e63f0..67ead1db 100644 --- a/server/inputs-channel.cpp +++ b/server/inputs-channel.cpp @@ -275,7 +275,7 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type, InputsChannel *inputs_channel = INPUTS_CHANNEL(rcc->get_channel()); InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc); uint32_t i; - RedsState *reds = red_channel_get_server(inputs_channel); + RedsState *reds = inputs_channel->get_server(); switch (type) { case SPICE_MSGC_INPUTS_KEY_DOWN: { @@ -499,12 +499,11 @@ static void inputs_migrate(RedChannelClient *rcc) static void inputs_channel_push_keyboard_modifiers(InputsChannel *inputs, uint8_t modifiers) { - if (!inputs || !red_channel_is_connected(inputs) || + if (!inputs || !inputs->is_connected() || inputs->src_during_migrate) { return; } - red_channel_pipes_add(inputs, - red_inputs_key_modifiers_item_new(modifiers)); + inputs->pipes_add(red_inputs_key_modifiers_item_new(modifiers)); } SPICE_GNUC_VISIBLE int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds) @@ -574,12 +573,12 @@ static void inputs_channel_constructed(GObject *object) { InputsChannel *self = INPUTS_CHANNEL(object); - RedsState *reds = red_channel_get_server(self); - SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(self); + RedsState *reds = self->get_server(); + SpiceCoreInterfaceInternal *core = self->get_core_interface(); G_OBJECT_CLASS(inputs_channel_parent_class)->constructed(object); - red_channel_set_cap(self, SPICE_INPUTS_CAP_KEY_SCANCODE); + self->set_cap(SPICE_INPUTS_CAP_KEY_SCANCODE); reds_register_channel(reds, self); self->key_modifiers_timer = core->timer_add(core, key_modifiers_sender, self); @@ -671,7 +670,7 @@ int inputs_channel_set_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet return -1; } inputs->tablet = tablet; - inputs->tablet->st = spice_tablet_state_new(red_channel_get_server(inputs)); + inputs->tablet->st = spice_tablet_state_new(inputs->get_server()); return 0; } diff --git a/server/main-channel-client.cpp b/server/main-channel-client.cpp index f2ee2632..f5e7c643 100644 --- a/server/main-channel-client.cpp +++ b/server/main-channel-client.cpp @@ -172,7 +172,7 @@ main_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc, if (type == SPICE_MSGC_MAIN_AGENT_DATA) { RedChannel *channel = rcc->get_channel(); - return reds_get_agent_data_buffer(red_channel_get_server(channel), mcc, size); + return reds_get_agent_data_buffer(channel->get_server(), mcc, size); } else if (size > sizeof(mcc->priv->recv_buf)) { /* message too large, caller will log a message and close the connection */ return NULL; @@ -187,7 +187,7 @@ main_channel_client_release_msg_rcv_buf(RedChannelClient *rcc, { if (type == SPICE_MSGC_MAIN_AGENT_DATA) { RedChannel *channel = rcc->get_channel(); - reds_release_agent_data_buffer(red_channel_get_server(channel), msg); + reds_release_agent_data_buffer(channel->get_server(), msg); } } @@ -196,7 +196,7 @@ main_channel_client_release_msg_rcv_buf(RedChannelClient *rcc, */ static void main_channel_client_on_disconnect(RedChannelClient *rcc) { - RedsState *reds = red_channel_get_server(rcc->get_channel()); + RedsState *reds = rcc->get_channel()->get_server(); main_dispatcher_client_disconnect(reds_get_main_dispatcher(reds), rcc->get_client()); } @@ -472,7 +472,7 @@ void main_channel_client_handle_migrate_dst_do_seamless(MainChannelClient *mcc, uint32_t src_version) { RedChannel *channel = mcc->get_channel(); - if (reds_on_migrate_dst_set_seamless(red_channel_get_server(channel), mcc, src_version)) { + if (reds_on_migrate_dst_set_seamless(channel->get_server(), mcc, src_version)) { mcc->priv->seamless_mig_dst = TRUE; mcc->pipe_add_empty_msg(SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK); } else { @@ -569,7 +569,7 @@ void main_channel_client_migrate_dst_complete(MainChannelClient *mcc) if (mcc->priv->mig_wait_prev_complete) { if (mcc->priv->mig_wait_prev_try_seamless) { RedChannel *channel = mcc->get_channel(); - spice_assert(red_channel_get_n_clients(channel) == 1); + spice_assert(channel->get_n_clients() == 1); mcc->pipe_add_type(RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_BEGIN_SEAMLESS); } else { mcc->pipe_add_type(RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_BEGIN); @@ -645,7 +645,7 @@ uint64_t main_channel_client_get_roundtrip_ms(MainChannelClient *mcc) void main_channel_client_migrate(RedChannelClient *rcc) { RedChannel *channel = rcc->get_channel(); - reds_on_main_channel_migrate(red_channel_get_server(channel), + reds_on_main_channel_migrate(channel->get_server(), MAIN_CHANNEL_CLIENT(rcc)); RedChannelClient::default_migrate(rcc); } @@ -699,7 +699,7 @@ static void main_channel_marshall_channels(RedChannelClient *rcc, RedChannel *channel = rcc->get_channel(); rcc->init_send_data(SPICE_MSG_MAIN_CHANNELS_LIST); - channels_info = reds_msg_channels_new(red_channel_get_server(channel)); + channels_info = reds_msg_channels_new(channel->get_server()); spice_marshall_msg_main_channels_list(m, channels_info); g_free(channels_info); } @@ -777,7 +777,7 @@ static void main_channel_marshall_migrate_data_item(RedChannelClient *rcc, RedChannel *channel = rcc->get_channel(); rcc->init_send_data(SPICE_MSG_MIGRATE_DATA); // TODO: from reds split. ugly separation. - reds_marshall_migrate_data(red_channel_get_server(channel), m); + reds_marshall_migrate_data(channel->get_server(), m); } static void main_channel_marshall_init(RedChannelClient *rcc, @@ -795,7 +795,7 @@ static void main_channel_marshall_init(RedChannelClient *rcc, if (item->is_client_mouse_allowed) { init.supported_mouse_modes |= SPICE_MOUSE_MODE_CLIENT; } - init.agent_connected = reds_has_vdagent(red_channel_get_server(channel)); + init.agent_connected = reds_has_vdagent(channel->get_server()); init.agent_tokens = REDS_AGENT_WINDOW_SIZE; init.multi_media_time = item->multi_media_time; init.ram_hint = item->ram_hint; diff --git a/server/main-channel.cpp b/server/main-channel.cpp index 20a93fe4..f867254f 100644 --- a/server/main-channel.cpp +++ b/server/main-channel.cpp @@ -42,7 +42,7 @@ G_DEFINE_TYPE(MainChannel, main_channel, RED_TYPE_CHANNEL) int main_channel_is_connected(MainChannel *main_chan) { - return red_channel_is_connected(main_chan); + return main_chan && main_chan->is_connected(); } RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t connection_id) @@ -72,8 +72,7 @@ static void main_channel_push_channels(MainChannelClient *mcc) void main_channel_push_mouse_mode(MainChannel *main_chan, SpiceMouseMode current_mode, int is_client_mouse_allowed) { - red_channel_pipes_add(main_chan, - main_mouse_mode_item_new(current_mode, is_client_mouse_allowed)); + main_chan->pipes_add(main_mouse_mode_item_new(current_mode, is_client_mouse_allowed)); } void main_channel_push_agent_connected(MainChannel *main_chan) @@ -90,14 +89,12 @@ void main_channel_push_agent_connected(MainChannel *main_chan) void main_channel_push_agent_disconnected(MainChannel *main_chan) { - red_channel_pipes_add_type(main_chan, - RED_PIPE_ITEM_TYPE_MAIN_AGENT_DISCONNECTED); + main_chan->pipes_add_type(RED_PIPE_ITEM_TYPE_MAIN_AGENT_DISCONNECTED); } static void main_channel_push_migrate_data_item(MainChannel *main_chan) { - red_channel_pipes_add_type(main_chan, - RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_DATA); + main_chan->pipes_add_type(RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_DATA); } static bool main_channel_handle_migrate_data(RedChannelClient *rcc, @@ -108,7 +105,7 @@ static bool main_channel_handle_migrate_data(RedChannelClient *rcc, SpiceMigrateDataHeader *header = (SpiceMigrateDataHeader *)message; /* not supported with multi-clients */ - spice_assert(red_channel_get_n_clients(channel) == 1); + spice_assert(channel->get_n_clients() == 1); if (size < sizeof(SpiceMigrateDataHeader) + sizeof(SpiceMigrateDataMain)) { red_channel_warning(rcc->get_channel(), @@ -121,14 +118,14 @@ static bool main_channel_handle_migrate_data(RedChannelClient *rcc, spice_error("bad header"); return FALSE; } - return reds_handle_migrate_data(red_channel_get_server(channel), mcc, + return reds_handle_migrate_data(channel->get_server(), mcc, (SpiceMigrateDataMain *)(header + 1), size); } void main_channel_push_multi_media_time(MainChannel *main_chan, uint32_t time) { - red_channel_pipes_add(main_chan, main_multi_media_time_item_new(time)); + main_chan->pipes_add(main_multi_media_time_item_new(time)); } static void main_channel_fill_mig_target(MainChannel *main_channel, RedsMigSpice *mig_target) @@ -149,14 +146,13 @@ static void main_channel_fill_mig_target(MainChannel *main_channel, RedsMigSpice void main_channel_registered_new_channel(MainChannel *main_chan, RedChannel *channel) { - red_channel_pipes_add(main_chan, registered_channel_item_new(channel)); + main_chan->pipes_add(registered_channel_item_new(channel)); } void main_channel_migrate_switch(MainChannel *main_chan, RedsMigSpice *mig_target) { main_channel_fill_mig_target(main_chan, mig_target); - red_channel_pipes_add_type(main_chan, - RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_SWITCH_HOST); + main_chan->pipes_add_type(RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_SWITCH_HOST); } static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type, @@ -164,7 +160,7 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type, { RedChannel *channel = rcc->get_channel(); MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc); - RedsState *reds = red_channel_get_server(channel); + RedsState *reds = channel->get_server(); switch (type) { case SPICE_MSGC_MAIN_AGENT_START: { @@ -262,8 +258,8 @@ main_channel_constructed(GObject *object) G_OBJECT_CLASS(main_channel_parent_class)->constructed(object); - red_channel_set_cap(self, SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE); - red_channel_set_cap(self, SPICE_MAIN_CAP_SEAMLESS_MIGRATE); + self->set_cap(SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE); + self->set_cap(SPICE_MAIN_CAP_SEAMLESS_MIGRATE); } static void @@ -307,7 +303,7 @@ static int main_channel_connect_seamless(MainChannel *main_channel) { RedChannelClient *rcc; - spice_assert(red_channel_get_n_clients(main_channel) == 1); + spice_assert(main_channel->get_n_clients() == 1); FOREACH_CLIENT(main_channel, rcc) { MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc); @@ -331,7 +327,7 @@ int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_ta return main_channel_connect_semi_seamless(main_channel); } else { RedChannelClient *rcc; - GList *clients = red_channel_get_clients(main_channel); + GList *clients = main_channel->get_clients(); /* just test the first one */ rcc = (RedChannelClient*) g_list_nth_data(clients, 0); @@ -361,7 +357,7 @@ int main_channel_migrate_src_complete(MainChannel *main_chan, int success) int semi_seamless_count = 0; RedChannelClient *rcc; - if (!red_channel_get_clients(main_chan)) { + if (!main_chan->get_clients()) { red_channel_warning(main_chan, "no peer connected"); return 0; } @@ -380,7 +376,7 @@ void main_channel_on_migrate_connected(MainChannel *main_channel, spice_assert(main_channel->num_clients_mig_wait); spice_assert(!seamless || main_channel->num_clients_mig_wait == 1); if (!--main_channel->num_clients_mig_wait) { - reds_on_main_migrate_connected(red_channel_get_server(main_channel), + reds_on_main_migrate_connected(main_channel->get_server(), seamless && success); } } diff --git a/server/red-channel-client.cpp b/server/red-channel-client.cpp index b0c71cac..77d8c090 100644 --- a/server/red-channel-client.cpp +++ b/server/red-channel-client.cpp @@ -406,8 +406,8 @@ static void red_channel_client_constructed(GObject *object) self->priv->incoming.header.data = self->priv->incoming.header_buf; RedChannel *channel = self->priv->channel; - RedsState* reds = red_channel_get_server(channel); - const RedStatNode *node = red_channel_get_stat_node(channel); + RedsState* reds = channel->get_server(); + const RedStatNode *node = channel->get_stat_node(); stat_init_counter(&self->priv->out_messages, reds, node, "out_messages", TRUE); stat_init_counter(&self->priv->out_bytes, reds, node, "out_bytes", TRUE); } @@ -626,7 +626,7 @@ static void red_channel_client_send_item(RedChannelClient *rcc, RedPipeItem *ite SPICE_UPCAST(MarkerPipeItem, item)->item_sent = true; break; default: - red_channel_send_item(rcc->priv->channel, rcc, item); + rcc->priv->channel->send_item(rcc, item); break; } red_pipe_item_unref(item); @@ -803,7 +803,7 @@ static void red_channel_client_connectivity_timer(void *opaque) void RedChannelClient::start_connectivity_monitoring(uint32_t timeout_ms) { - SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(priv->channel); + SpiceCoreInterfaceInternal *core = priv->channel->get_core_interface(); if (!is_connected()) { return; } @@ -936,7 +936,7 @@ static gboolean red_channel_client_initable_init(GInitable *initable, goto cleanup; } - core = red_channel_get_core_interface(self->priv->channel); + core = self->priv->channel->get_core_interface(); red_stream_set_core_interface(self->priv->stream, core); self->priv->stream->watch = core->watch_add(core, self->priv->stream->socket, @@ -957,9 +957,9 @@ static gboolean red_channel_client_initable_init(GInitable *initable, self->priv->monitor_latency ? PING_TEST_TIMEOUT_MS : PING_TEST_LONG_TIMEOUT_MS; } - red_channel_add_client(self->priv->channel, self); + self->priv->channel->add_client(self); if (!red_client_add_channel(self->priv->client, self, &local_error)) { - red_channel_remove_client(self->priv->channel, self); + self->priv->channel->remove_client(self); } cleanup: @@ -1012,7 +1012,7 @@ static void red_channel_client_seamless_migration_done(RedChannelClient *rcc) red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS); if (rcc->priv->connectivity_monitor.timer) { red_timer_start(rcc->priv->connectivity_monitor.timer, - rcc->priv->connectivity_monitor.timeout); + rcc->priv->connectivity_monitor.timeout); } } } @@ -1671,7 +1671,7 @@ bool RedChannelClient::is_mini_header() gboolean RedChannelClient::is_connected() { return priv->channel - && (g_list_find(red_channel_get_clients(priv->channel), this) != NULL); + && (g_list_find(priv->channel->get_clients(), this) != NULL); } static void red_channel_client_clear_sent_item(RedChannelClient *rcc) @@ -1737,7 +1737,7 @@ void RedChannelClient::disconnect() red_timer_remove(priv->connectivity_monitor.timer); priv->connectivity_monitor.timer = NULL; - red_channel_remove_client(channel, this); + channel->remove_client(this); red_channel_client_on_disconnect(this); // remove client from RedClient // NOTE this may trigger the free of the object, if we are in a watch/timer diff --git a/server/red-channel.cpp b/server/red-channel.cpp index c057ebe9..4c50fbe1 100644 --- a/server/red-channel.cpp +++ b/server/red-channel.cpp @@ -310,8 +310,8 @@ red_channel_init(RedChannel *self) { self->priv = (RedChannelPrivate*) red_channel_get_instance_private(self); - red_channel_set_common_cap(self, SPICE_COMMON_CAP_MINI_HEADER); - red_channel_set_common_cap(self, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION); + self->set_common_cap(SPICE_COMMON_CAP_MINI_HEADER); + self->set_common_cap(SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION); self->priv->thread_id = pthread_self(); } @@ -325,22 +325,22 @@ red_channel_foreach_client(RedChannel *channel, void (RedChannelClient::*func)() } } -void red_channel_receive(RedChannel *channel) +void RedChannel::receive() { - red_channel_foreach_client(channel, &RedChannelClient::receive); + red_channel_foreach_client(this, &RedChannelClient::receive); } -void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc) +void RedChannel::add_client(RedChannelClient *rcc) { spice_assert(rcc); - channel->priv->clients = g_list_prepend(channel->priv->clients, rcc); + priv->clients = g_list_prepend(priv->clients, rcc); } -bool red_channel_test_remote_cap(RedChannel *channel, uint32_t cap) +bool RedChannel::test_remote_cap(uint32_t cap) { RedChannelClient *rcc; - FOREACH_CLIENT(channel, rcc) { + FOREACH_CLIENT(this, rcc) { if (!rcc->test_remote_cap(cap)) { return FALSE; } @@ -348,12 +348,12 @@ bool red_channel_test_remote_cap(RedChannel *channel, uint32_t cap) return TRUE; } -bool red_channel_is_waiting_for_migrate_data(RedChannel *channel) +bool RedChannel::is_waiting_for_migrate_data() { RedChannelClient *rcc; - guint n_clients = g_list_length(channel->priv->clients); + guint n_clients = g_list_length(priv->clients); - if (!red_channel_is_connected(channel)) { + if (!is_connected()) { return FALSE; } @@ -361,21 +361,19 @@ bool red_channel_is_waiting_for_migrate_data(RedChannel *channel) return FALSE; } spice_assert(n_clients == 1); - rcc = (RedChannelClient*) g_list_nth_data(channel->priv->clients, 0); + rcc = (RedChannelClient*) g_list_nth_data(priv->clients, 0); return rcc->is_waiting_for_migrate_data(); } -void red_channel_init_stat_node(RedChannel *channel, const RedStatNode *parent, const char *name) +void RedChannel::init_stat_node(const RedStatNode *parent, const char *name) { - spice_return_if_fail(channel != NULL); - // TODO check not already initialized - stat_init_node(&channel->priv->stat, channel->priv->reds, parent, name, TRUE); + stat_init_node(&priv->stat, priv->reds, parent, name, TRUE); } -const RedStatNode *red_channel_get_stat_node(RedChannel *channel) +const RedStatNode *RedChannel::get_stat_node() { - return &channel->priv->stat; + return &priv->stat; } static void add_capability(uint32_t **caps, int *num_caps, uint32_t cap) @@ -390,49 +388,41 @@ static void add_capability(uint32_t **caps, int *num_caps, uint32_t cap) (*caps)[n] |= (1 << (cap % 32)); } -void red_channel_set_common_cap(RedChannel *channel, uint32_t cap) +void RedChannel::set_common_cap(uint32_t cap) { - add_capability(&channel->priv->local_caps.common_caps, - &channel->priv->local_caps.num_common_caps, cap); + add_capability(&priv->local_caps.common_caps, + &priv->local_caps.num_common_caps, cap); } -void red_channel_set_cap(RedChannel *channel, uint32_t cap) +void RedChannel::set_cap(uint32_t cap) { - add_capability(&channel->priv->local_caps.caps, &channel->priv->local_caps.num_caps, cap); + add_capability(&priv->local_caps.caps, &priv->local_caps.num_caps, cap); } -void red_channel_destroy(RedChannel *channel) +void RedChannel::destroy() { - if (!channel) { - return; - } - // prevent future connection - reds_unregister_channel(channel->priv->reds, channel); + reds_unregister_channel(priv->reds, this); - red_channel_foreach_client(channel, &RedChannelClient::disconnect); - g_object_unref(channel); + red_channel_foreach_client(this, &RedChannelClient::disconnect); + g_object_unref(this); } -void red_channel_send(RedChannel *channel) +void RedChannel::send() { - red_channel_foreach_client(channel, &RedChannelClient::send); + red_channel_foreach_client(this, &RedChannelClient::send); } -void red_channel_push(RedChannel *channel) +void RedChannel::push() { - if (!channel) { - return; - } - - red_channel_foreach_client(channel, &RedChannelClient::push); + red_channel_foreach_client(this, &RedChannelClient::push); } -void red_channel_pipes_add(RedChannel *channel, RedPipeItem *item) +void RedChannel::pipes_add(RedPipeItem *item) { RedChannelClient *rcc; - FOREACH_CLIENT(channel, rcc) { + FOREACH_CLIENT(this, rcc) { red_pipe_item_ref(item); rcc->pipe_add(item); } @@ -440,54 +430,53 @@ void red_channel_pipes_add(RedChannel *channel, RedPipeItem *item) red_pipe_item_unref(item); } -void red_channel_pipes_add_type(RedChannel *channel, int pipe_item_type) +void RedChannel::pipes_add_type(int pipe_item_type) { RedPipeItem *item = g_new(RedPipeItem, 1); red_pipe_item_init(item, pipe_item_type); - red_channel_pipes_add(channel, item); + pipes_add(item); } -void red_channel_pipes_add_empty_msg(RedChannel *channel, int msg_type) +void RedChannel::pipes_add_empty_msg(int msg_type) { - red_channel_pipes_add(channel, RedChannelClient::new_empty_msg(msg_type)); + pipes_add(RedChannelClient::new_empty_msg(msg_type)); } -int red_channel_is_connected(RedChannel *channel) +int RedChannel::is_connected() { - return channel && channel->priv->clients; + return priv->clients != NULL; } -const char *red_channel_get_name(RedChannel *channel) +const char *RedChannel::get_name() { - return red_channel_type_to_str(channel->priv->type); + return red_channel_type_to_str(priv->type); } -void red_channel_remove_client(RedChannel *channel, RedChannelClient *rcc) +void RedChannel::remove_client(RedChannelClient *rcc) { GList *link; - g_return_if_fail(channel == rcc->get_channel()); + g_return_if_fail(this == rcc->get_channel()); - if (!pthread_equal(pthread_self(), channel->priv->thread_id)) { - red_channel_warning(channel, + if (!pthread_equal(pthread_self(), priv->thread_id)) { + red_channel_warning(this, "channel->thread_id (%p) != " "pthread_self (%p)." "If one of the threads is != io-thread && != vcpu-thread, " "this might be a BUG", - (void*) channel->priv->thread_id, (void*) pthread_self()); + (void*) priv->thread_id, (void*) pthread_self()); } - spice_return_if_fail(channel); - link = g_list_find(channel->priv->clients, rcc); + link = g_list_find(priv->clients, rcc); spice_return_if_fail(link != NULL); - channel->priv->clients = g_list_delete_link(channel->priv->clients, link); + priv->clients = g_list_delete_link(priv->clients, link); // TODO: should we set rcc->channel to NULL??? } -void red_channel_disconnect(RedChannel *channel) +void RedChannel::disconnect() { - red_channel_foreach_client(channel, &RedChannelClient::disconnect); + red_channel_foreach_client(this, &RedChannelClient::disconnect); } typedef struct RedMessageConnect { @@ -509,23 +498,22 @@ static void handle_dispatcher_connect(void *opaque, void *payload) red_channel_capabilities_reset(&msg->caps); } -void red_channel_connect(RedChannel *channel, RedClient *client, - RedStream *stream, int migration, +void RedChannel::connect(RedClient *client, RedStream *stream, int migration, RedChannelCapabilities *caps) { - if (channel->priv->dispatcher == NULL || - pthread_equal(pthread_self(), channel->priv->thread_id)) { - RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel); - klass->connect(channel, client, stream, migration, caps); + if (priv->dispatcher == NULL || + pthread_equal(pthread_self(), priv->thread_id)) { + RedChannelClass *klass = RED_CHANNEL_GET_CLASS(this); + klass->connect(this, client, stream, migration, caps); return; } - Dispatcher *dispatcher = channel->priv->dispatcher; + Dispatcher *dispatcher = priv->dispatcher; // get a reference potentially the main channel can be destroyed in // the main thread causing RedClient to be destroyed before using it RedMessageConnect payload = { - .channel = channel, + .channel = this, .client = (RedClient*) g_object_ref(client), .stream = stream, .migration = migration @@ -536,23 +524,23 @@ void red_channel_connect(RedChannel *channel, RedClient *client, &payload, sizeof(payload), false); } -GList *red_channel_get_clients(RedChannel *channel) +GList *RedChannel::get_clients() { - return channel->priv->clients; + return priv->clients; } -guint red_channel_get_n_clients(RedChannel *channel) +guint RedChannel::get_n_clients() { - return g_list_length(channel->priv->clients); + return g_list_length(priv->clients); } -bool red_channel_all_blocked(RedChannel *channel) +bool RedChannel::all_blocked() { RedChannelClient *rcc; - if (!channel || !channel->priv->clients) { + if (!priv->clients) { return FALSE; } - FOREACH_CLIENT(channel, rcc) { + FOREACH_CLIENT(this, rcc) { if (!rcc->is_blocked()) { return FALSE; } @@ -604,8 +592,7 @@ static bool red_channel_no_item_being_sent(RedChannel *channel) * * Returns: the number of added items **/ -int red_channel_pipes_new_add(RedChannel *channel, - new_pipe_item_t creator, void *data) +int RedChannel::pipes_new_add(new_pipe_item_t creator, void *data) { RedChannelClient *rcc; RedPipeItem *item; @@ -613,7 +600,7 @@ int red_channel_pipes_new_add(RedChannel *channel, spice_assert(creator != NULL); - FOREACH_CLIENT(channel, rcc) { + FOREACH_CLIENT(this, rcc) { item = (*creator)(rcc, data, num++); if (item) { rcc->pipe_add(item); @@ -624,12 +611,12 @@ int red_channel_pipes_new_add(RedChannel *channel, return n; } -uint32_t red_channel_max_pipe_size(RedChannel *channel) +uint32_t RedChannel::max_pipe_size() { RedChannelClient *rcc; uint32_t pipe_size = 0; - FOREACH_CLIENT(channel, rcc) { + FOREACH_CLIENT(this, rcc) { uint32_t new_size; new_size = rcc->get_pipe_size(); pipe_size = MAX(pipe_size, new_size); @@ -637,12 +624,12 @@ uint32_t red_channel_max_pipe_size(RedChannel *channel) return pipe_size; } -uint32_t red_channel_sum_pipes_size(RedChannel *channel) +uint32_t RedChannel::sum_pipes_size() { RedChannelClient *rcc; uint32_t sum = 0; - FOREACH_CLIENT(channel, rcc) { + FOREACH_CLIENT(this, rcc) { sum += rcc->get_pipe_size(); } return sum; @@ -661,8 +648,7 @@ static void red_channel_disconnect_if_pending_send(RedChannel *channel) } } -bool red_channel_wait_all_sent(RedChannel *channel, - int64_t timeout) +bool RedChannel::wait_all_sent(int64_t timeout) { uint64_t end_time; uint32_t max_pipe_size; @@ -674,54 +660,54 @@ bool red_channel_wait_all_sent(RedChannel *channel, end_time = UINT64_MAX; } - red_channel_push(channel); - while (((max_pipe_size = red_channel_max_pipe_size(channel)) || - (blocked = red_channel_any_blocked(channel))) && + push(); + while (((max_pipe_size = this->max_pipe_size()) || + (blocked = red_channel_any_blocked(this))) && (timeout == -1 || spice_get_monotonic_time_ns() < end_time)) { spice_debug("pipe-size %u blocked %d", max_pipe_size, blocked); usleep(CHANNEL_BLOCKED_SLEEP_DURATION); - red_channel_receive(channel); - red_channel_send(channel); - red_channel_push(channel); + receive(); + send(); + push(); } if (max_pipe_size || blocked) { spice_warning("timeout: pending out messages exist (pipe-size %u, blocked %d)", max_pipe_size, blocked); - red_channel_disconnect_if_pending_send(channel); + red_channel_disconnect_if_pending_send(this); return FALSE; } else { - spice_assert(red_channel_no_item_being_sent(channel)); + spice_assert(red_channel_no_item_being_sent(this)); return TRUE; } } -RedsState* red_channel_get_server(RedChannel *channel) +RedsState* RedChannel::get_server() { - return channel->priv->reds; + return priv->reds; } -SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel) +SpiceCoreInterfaceInternal* RedChannel::get_core_interface() { - return channel->priv->core; + return priv->core; } -void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item) +void RedChannel::send_item(RedChannelClient *rcc, RedPipeItem *item) { - RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self); + RedChannelClass *klass = RED_CHANNEL_GET_CLASS(this); g_return_if_fail(klass->send_item); klass->send_item(rcc, item); } -void red_channel_reset_thread_id(RedChannel *self) +void RedChannel::reset_thread_id() { - self->priv->thread_id = pthread_self(); + priv->thread_id = pthread_self(); } -const RedChannelCapabilities* red_channel_get_local_capabilities(RedChannel *self) +const RedChannelCapabilities* RedChannel::get_local_capabilities() { - return &self->priv->local_caps; + return &priv->local_caps; } typedef struct RedMessageMigrate { @@ -738,17 +724,17 @@ static void handle_dispatcher_migrate(void *opaque, void *payload) g_object_unref(msg->rcc); } -void red_channel_migrate_client(RedChannel *channel, RedChannelClient *rcc) +void RedChannel::migrate_client(RedChannelClient *rcc) { - if (channel->priv->dispatcher == NULL || - pthread_equal(pthread_self(), channel->priv->thread_id)) { - RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel); + if (priv->dispatcher == NULL || + pthread_equal(pthread_self(), priv->thread_id)) { + RedChannelClass *klass = RED_CHANNEL_GET_CLASS(this); klass->migrate(rcc); return; } RedMessageMigrate payload = { .rcc = (RedChannelClient *) g_object_ref(rcc) }; - dispatcher_send_message_custom(channel->priv->dispatcher, handle_dispatcher_migrate, + dispatcher_send_message_custom(priv->dispatcher, handle_dispatcher_migrate, &payload, sizeof(payload), false); } @@ -765,11 +751,11 @@ static void handle_dispatcher_disconnect(void *opaque, void *payload) klass->disconnect(msg->rcc); } -void red_channel_disconnect_client(RedChannel *channel, RedChannelClient *rcc) +void RedChannel::disconnect_client(RedChannelClient *rcc) { - if (channel->priv->dispatcher == NULL || - pthread_equal(pthread_self(), channel->priv->thread_id)) { - RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel); + if (priv->dispatcher == NULL || + pthread_equal(pthread_self(), priv->thread_id)) { + RedChannelClass *klass = RED_CHANNEL_GET_CLASS(this); klass->disconnect(rcc); return; } @@ -777,6 +763,6 @@ void red_channel_disconnect_client(RedChannel *channel, RedChannelClient *rcc) // TODO: we turned it to be sync, due to client_destroy . Should we support async? - for this we will need ref count // for channels RedMessageDisconnect payload = { .rcc = rcc }; - dispatcher_send_message_custom(channel->priv->dispatcher, handle_dispatcher_disconnect, + dispatcher_send_message_custom(priv->dispatcher, handle_dispatcher_disconnect, &payload, sizeof(payload), true); } diff --git a/server/red-channel.h b/server/red-channel.h index d53c951a..ae86fdd3 100644 --- a/server/red-channel.h +++ b/server/red-channel.h @@ -66,12 +66,8 @@ static inline gboolean test_capability(const uint32_t *caps, int num_caps, uint3 return VD_AGENT_HAS_CAPABILITY(caps, num_caps, cap); } -struct RedChannel: public GObject -{ - RedChannelPrivate *priv; -}; - struct RedChannelClass + { GObjectClass parent_class; @@ -104,113 +100,116 @@ struct RedChannelClass }; #define FOREACH_CLIENT(_channel, _data) \ - GLIST_FOREACH((_channel ? red_channel_get_clients(_channel) : NULL), \ - RedChannelClient, _data) + GLIST_FOREACH(_channel->get_clients(), RedChannelClient, _data) /* Red Channel interface */ -const char *red_channel_get_name(RedChannel *channel); +struct RedChannel: public GObject +{ + const char *get_name(); -void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc); -void red_channel_remove_client(RedChannel *channel, RedChannelClient *rcc); + void add_client(RedChannelClient *rcc); + void remove_client(RedChannelClient *rcc); -void red_channel_init_stat_node(RedChannel *channel, const RedStatNode *parent, const char *name); + void init_stat_node(const RedStatNode *parent, const char *name); -// caps are freed when the channel is destroyed -void red_channel_set_common_cap(RedChannel *channel, uint32_t cap); -void red_channel_set_cap(RedChannel *channel, uint32_t cap); + // caps are freed when the channel is destroyed + void set_common_cap(uint32_t cap); + void set_cap(uint32_t cap); -int red_channel_is_connected(RedChannel *channel); + int is_connected(); -/* seamless migration is supported for only one client. This routine - * checks if the only channel client associated with channel is - * waiting for migration data */ -bool red_channel_is_waiting_for_migrate_data(RedChannel *channel); + /* seamless migration is supported for only one client. This routine + * checks if the only channel client associated with channel is + * waiting for migration data */ + bool is_waiting_for_migrate_data(); -/* - * the disconnect callback is called from the channel's thread, - * i.e., for display channels - red worker thread, for all the other - from the main thread. - * RedChannel::destroy can be called only from channel thread. - */ -void red_channel_destroy(RedChannel *channel); + /* + * the disconnect callback is called from the channel's thread, + * i.e., for display channels - red worker thread, for all the other - from the main thread. + * RedChannel::destroy can be called only from channel thread. + */ -/* return true if all the channel clients support the cap */ -bool red_channel_test_remote_cap(RedChannel *channel, uint32_t cap); + void destroy(); -// helper to push a new item to all channels -typedef RedPipeItem *(*new_pipe_item_t)(RedChannelClient *rcc, void *data, int num); -int red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator, void *data); + /* return true if all the channel clients support the cap */ + bool test_remote_cap(uint32_t cap); -void red_channel_pipes_add_type(RedChannel *channel, int pipe_item_type); + // helper to push a new item to all channels + typedef RedPipeItem *(*new_pipe_item_t)(RedChannelClient *rcc, void *data, int num); + int pipes_new_add(new_pipe_item_t creator, void *data); -void red_channel_pipes_add_empty_msg(RedChannel *channel, int msg_type); + void pipes_add_type(int pipe_item_type); -/* Add an item to all the clients connected. - * The same item is shared between all clients. - * Function will take ownership of the item. - */ -void red_channel_pipes_add(RedChannel *channel, RedPipeItem *item); + void pipes_add_empty_msg(int msg_type); -/* return TRUE if all of the connected clients to this channel are blocked */ -bool red_channel_all_blocked(RedChannel *channel); + /* Add an item to all the clients connected. + * The same item is shared between all clients. + * Function will take ownership of the item. + */ + void pipes_add(RedPipeItem *item); -// TODO: unstaticed for display/cursor channels. they do some specific pushes not through -// adding elements or on events. but not sure if this is actually required (only result -// should be that they ""try"" a little harder, but if the event system is correct it -// should not make any difference. -void red_channel_push(RedChannel *channel); -// Again, used in various places outside of event handler context (or in other event handler -// contexts): -// flush_display_commands/flush_cursor_commands -// display_channel_wait_for_init -// red_wait_outgoing_item -// red_wait_pipe_item_sent -// handle_channel_events - this is the only one that was used before, and was in red-channel.c -void red_channel_receive(RedChannel *channel); -// For red_worker -void red_channel_send(RedChannel *channel); -// For red_worker -void red_channel_disconnect(RedChannel *channel); -void red_channel_connect(RedChannel *channel, RedClient *client, - RedStream *stream, int migration, - RedChannelCapabilities *caps); + /* return TRUE if all of the connected clients to this channel are blocked */ + bool all_blocked(); -/* return the sum of all the rcc pipe size */ -uint32_t red_channel_max_pipe_size(RedChannel *channel); -/* return the max size of all the rcc pipe */ -uint32_t red_channel_sum_pipes_size(RedChannel *channel); + // TODO: unstaticed for display/cursor channels. they do some specific pushes not through + // adding elements or on events. but not sure if this is actually required (only result + // should be that they ""try"" a little harder, but if the event system is correct it + // should not make any difference. + void push(); + // Again, used in various places outside of event handler context (or in other event handler + // contexts): + // flush_display_commands/flush_cursor_commands + // display_channel_wait_for_init + // red_wait_outgoing_item + // red_wait_pipe_item_sent + // handle_channel_events - this is the only one that was used before, and was in red-channel.c + void receive(); + // For red_worker + void send(); + // For red_worker + void disconnect(); + void connect(RedClient *client, RedStream *stream, int migration, + RedChannelCapabilities *caps); -GList *red_channel_get_clients(RedChannel *channel); -guint red_channel_get_n_clients(RedChannel *channel); -struct RedsState* red_channel_get_server(RedChannel *channel); -SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel); + /* return the sum of all the rcc pipe size */ + uint32_t max_pipe_size(); + /* return the max size of all the rcc pipe */ + uint32_t sum_pipes_size(); -/* channel callback function */ -void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item); -void red_channel_reset_thread_id(RedChannel *self); -const RedStatNode *red_channel_get_stat_node(RedChannel *channel); + GList *get_clients(); + guint get_n_clients(); + struct RedsState* get_server(); + SpiceCoreInterfaceInternal* get_core_interface(); -const RedChannelCapabilities* red_channel_get_local_capabilities(RedChannel *self); + /* channel callback function */ + void send_item(RedChannelClient *rcc, RedPipeItem *item); + void reset_thread_id(); + const RedStatNode *get_stat_node(); -/* - * blocking functions. - * - * timeout is in nano sec. -1 for no timeout. - * - * This method tries for up to @timeout nanoseconds to send all the - * items which are currently queued. If the timeout elapses, - * the RedChannelClient which are too slow (those which still have pending - * items) will be disconnected. - * - * Return: TRUE if waiting succeeded. FALSE if timeout expired. - */ + const RedChannelCapabilities* get_local_capabilities(); -bool red_channel_wait_all_sent(RedChannel *channel, - int64_t timeout); + /* + * blocking functions. + * + * timeout is in nano sec. -1 for no timeout. + * + * This method tries for up to @timeout nanoseconds to send all the + * items which are currently queued. If the timeout elapses, + * the RedChannelClient which are too slow (those which still have pending + * items) will be disconnected. + * + * Return: TRUE if waiting succeeded. FALSE if timeout expired. + */ -/* wrappers for client callbacks */ -void red_channel_migrate_client(RedChannel *channel, RedChannelClient *rcc); -void red_channel_disconnect_client(RedChannel *channel, RedChannelClient *rcc); + bool wait_all_sent(int64_t timeout); + + /* wrappers for client callbacks */ + void migrate_client(RedChannelClient *rcc); + void disconnect_client(RedChannelClient *rcc); + + RedChannelPrivate *priv; +}; #define CHANNEL_BLOCKED_SLEEP_DURATION 10000 //micro @@ -219,7 +218,7 @@ void red_channel_disconnect_client(RedChannel *channel, RedChannelClient *rcc); uint32_t id_; \ RedChannel *channel_ = (channel); \ g_object_get(channel_, "id", &id_, NULL); \ - log_cb("%s:%u (%p): " format, red_channel_get_name(channel_), \ + log_cb("%s:%u (%p): " format, channel_->get_name(), \ id_, channel_, ## __VA_ARGS__); \ } while (0) diff --git a/server/red-client.cpp b/server/red-client.cpp index 42228cc9..bccea554 100644 --- a/server/red-client.cpp +++ b/server/red-client.cpp @@ -184,7 +184,7 @@ void red_client_migrate(RedClient *client) FOREACH_CHANNEL_CLIENT(client, rcc) { if (rcc->is_connected()) { channel = rcc->get_channel(); - red_channel_migrate_client(channel, rcc); + channel->migrate_client(rcc); } } } @@ -228,7 +228,7 @@ void red_client_destroy(RedClient *client) // to wait for disconnection) // TODO: should we go back to async. For this we need to use // ref count for channel clients. - red_channel_disconnect_client(channel, rcc); + channel->disconnect_client(rcc); spice_assert(rcc->pipe_is_empty()); spice_assert(rcc->no_item_being_sent()); diff --git a/server/red-stream-device.cpp b/server/red-stream-device.cpp index bcb9d5f0..a99f1d58 100644 --- a/server/red-stream-device.cpp +++ b/server/red-stream-device.cpp @@ -638,12 +638,12 @@ stream_device_dispose(GObject *object) if (dev->stream_channel) { // close all current connections and drop the reference - red_channel_destroy(RED_CHANNEL(dev->stream_channel)); + RED_CHANNEL(dev->stream_channel)->destroy(); dev->stream_channel = NULL; } if (dev->cursor_channel) { // close all current connections and drop the reference - red_channel_destroy(RED_CHANNEL(dev->cursor_channel)); + RED_CHANNEL(dev->cursor_channel)->destroy(); dev->cursor_channel = NULL; } diff --git a/server/red-worker.cpp b/server/red-worker.cpp index d308f82c..43d62c50 100644 --- a/server/red-worker.cpp +++ b/server/red-worker.cpp @@ -116,7 +116,7 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty) } *ring_is_empty = FALSE; - while (red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) { + while (RED_CHANNEL(worker->cursor_channel)->max_pipe_size() <= MAX_PIPE_SIZE) { if (!red_qxl_get_cursor_command(worker->qxl, &ext_cmd)) { *ring_is_empty = TRUE; if (worker->cursor_poll_tries < CMD_RING_POLL_RETRIES) { @@ -177,7 +177,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty) worker->process_display_generation++; *ring_is_empty = FALSE; - while (red_channel_max_pipe_size(worker->display_channel) <= MAX_PIPE_SIZE) { + while (worker->display_channel->max_pipe_size() <= MAX_PIPE_SIZE) { if (!red_qxl_get_command(worker->qxl, &ext_cmd)) { *ring_is_empty = TRUE; if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) { @@ -249,7 +249,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty) spice_error("bad command type"); } n++; - if (red_channel_all_blocked(worker->display_channel) + if (worker->display_channel->all_blocked() || spice_get_monotonic_time_ns() - start > NSEC_PER_SEC / 100) { worker->event_timeout = 0; return n; @@ -262,8 +262,8 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty) static bool red_process_is_blocked(RedWorker *worker) { - return red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) > MAX_PIPE_SIZE || - red_channel_max_pipe_size(worker->display_channel) > MAX_PIPE_SIZE; + return RED_CHANNEL(worker->cursor_channel)->max_pipe_size() > MAX_PIPE_SIZE || + worker->display_channel->max_pipe_size() > MAX_PIPE_SIZE; } typedef int (*red_process_t)(RedWorker *worker, int *ring_is_empty); @@ -280,7 +280,7 @@ static void flush_commands(RedWorker *worker, RedChannel *red_channel, } while (process(worker, &ring_is_empty)) { - red_channel_push(red_channel); + red_channel->push(); } if (ring_is_empty) { @@ -288,12 +288,12 @@ static void flush_commands(RedWorker *worker, RedChannel *red_channel, } end_time = spice_get_monotonic_time_ns() + COMMON_CLIENT_TIMEOUT; for (;;) { - red_channel_push(red_channel); - if (red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) { + red_channel->push(); + if (red_channel->max_pipe_size() <= MAX_PIPE_SIZE) { break; } - red_channel_receive(red_channel); - red_channel_send(red_channel); + red_channel->receive(); + red_channel->send(); // TODO: MC: the whole timeout will break since it takes lowest timeout, should // do it client by client. if (spice_get_monotonic_time_ns() >= end_time) { @@ -301,7 +301,7 @@ static void flush_commands(RedWorker *worker, RedChannel *red_channel, // So we need to check the locations of the various pipe heads when counting, // and disconnect only those/that. spice_warning("flush timeout"); - red_channel_disconnect(red_channel); + red_channel->disconnect(); } else { usleep(DISPLAY_CLIENT_RETRY_INTERVAL); } @@ -437,15 +437,15 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id, display_channel_set_monitors_config_to_primary(display); CommonGraphicsChannel *common = display; - if (red_channel_is_connected(display) && + if (display->is_connected() && !common_graphics_channel_get_during_target_migrate(common)) { /* guest created primary, so it will (hopefully) send a monitors_config * now, don't send our own temporary one */ if (!worker->driver_cap_monitors_config) { display_channel_push_monitors_config(display); } - red_channel_pipes_add_empty_msg(display, SPICE_MSG_DISPLAY_MARK); - red_channel_push(display); + display->pipes_add_empty_msg(SPICE_MSG_DISPLAY_MARK); + display->push(); } cursor_channel_do_init(worker->cursor_channel); @@ -529,8 +529,8 @@ static void handle_dev_stop(void *opaque, void *payload) * purge the pipe, send destroy_all_surfaces * to the client (there is no such message right now), and start * from scratch on the destination side */ - red_channel_wait_all_sent(worker->display_channel, COMMON_CLIENT_TIMEOUT); - red_channel_wait_all_sent(RED_CHANNEL(worker->cursor_channel), COMMON_CLIENT_TIMEOUT); + worker->display_channel->wait_all_sent(COMMON_CLIENT_TIMEOUT); + RED_CHANNEL(worker->cursor_channel)->wait_all_sent(COMMON_CLIENT_TIMEOUT); } static void handle_dev_start(void *opaque, void *payload) @@ -571,7 +571,7 @@ static void handle_dev_oom(void *opaque, void *payload) // streams? but without streams also leak display_channel_debug_oom(display, "OOM1"); while (red_process_display(worker, &ring_is_empty)) { - red_channel_push(display); + display->push(); } if (red_qxl_flush_resources(worker->qxl) == 0) { display_channel_free_some(worker->display_channel); @@ -1097,7 +1097,7 @@ RedWorker* red_worker_new(QXLInstance *qxl) worker->cursor_channel = cursor_channel_new(reds, qxl->id, &worker->core, dispatcher); channel = RED_CHANNEL(worker->cursor_channel); - red_channel_init_stat_node(channel, &worker->stat, "cursor_channel"); + channel->init_stat_node(&worker->stat, "cursor_channel"); // TODO: handle seamless migration. Temp, setting migrate to FALSE worker->display_channel = display_channel_new(reds, qxl, &worker->core, dispatcher, @@ -1106,7 +1106,7 @@ RedWorker* red_worker_new(QXLInstance *qxl) reds_get_video_codecs(reds), init_info.n_surfaces); channel = worker->display_channel; - red_channel_init_stat_node(channel, &worker->stat, "display_channel"); + channel->init_stat_node(&worker->stat, "display_channel"); display_channel_set_image_compression(worker->display_channel, spice_server_get_image_compression(reds)); @@ -1121,8 +1121,8 @@ static void *red_worker_main(void *arg) SPICE_VERIFY(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW && MAX_PIPE_SIZE > NARROW_CLIENT_ACK_WINDOW); //ensure wakeup by ack message - red_channel_reset_thread_id(RED_CHANNEL(worker->cursor_channel)); - red_channel_reset_thread_id(worker->display_channel); + RED_CHANNEL(worker->cursor_channel)->reset_thread_id(); + worker->display_channel->reset_thread_id(); GMainLoop *loop = g_main_loop_new(worker->core.main_context, FALSE); worker->loop = loop; @@ -1164,8 +1164,8 @@ bool red_worker_run(RedWorker *worker) static void red_worker_close_channel(RedChannel *channel) { - red_channel_reset_thread_id(channel); - red_channel_destroy(channel); + channel->reset_thread_id(); + channel->destroy(); } /* diff --git a/server/reds.cpp b/server/reds.cpp index 9bacfa49..65b184a8 100644 --- a/server/reds.cpp +++ b/server/reds.cpp @@ -678,7 +678,7 @@ static void reds_agent_remove(RedsState *reds) reds->vdagent = NULL; reds_update_mouse_mode(reds); if (reds_main_channel_connected(reds) && - !red_channel_is_waiting_for_migrate_data(RED_CHANNEL(reds->main_channel))) { + !RED_CHANNEL(reds->main_channel)->is_waiting_for_migrate_data()) { main_channel_push_agent_disconnected(reds->main_channel); } } @@ -1558,9 +1558,9 @@ static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel) { RedsState *reds = link->reds; if (reds->config->sasl_enabled && !link->skip_auth) { - red_channel_set_common_cap(channel, SPICE_COMMON_CAP_AUTH_SASL); + channel->set_common_cap(SPICE_COMMON_CAP_AUTH_SASL); } else { - red_channel_set_common_cap(channel, SPICE_COMMON_CAP_AUTH_SPICE); + channel->set_common_cap(SPICE_COMMON_CAP_AUTH_SPICE); } } @@ -1615,7 +1615,7 @@ static bool reds_send_link_ack(RedsState *reds, RedLinkInfo *link) reds_channel_init_auth_caps(link, channel); /* make sure common caps are set */ - channel_caps = red_channel_get_local_capabilities(channel); + channel_caps = channel->get_local_capabilities(); msg.ack.num_common_caps = GUINT32_TO_LE(channel_caps->num_common_caps); msg.ack.num_channel_caps = GUINT32_TO_LE(channel_caps->num_caps); hdr_size += channel_caps->num_common_caps * sizeof(uint32_t); @@ -1955,9 +1955,8 @@ static void reds_channel_do_link(RedChannel *channel, RedClient *client, spice_assert(stream); red_channel_capabilities_init_from_link_message(&caps, link_msg); - red_channel_connect(channel, client, stream, - red_client_during_migrate_at_target(client), - &caps); + channel->connect(client, stream, + red_client_during_migrate_at_target(client), &caps); red_channel_capabilities_reset(&caps); } @@ -3140,7 +3139,7 @@ static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan dev->priv->plug_generation++; if (dev->priv->mig_data || - red_channel_is_waiting_for_migrate_data(RED_CHANNEL(reds->main_channel))) { + RED_CHANNEL(reds->main_channel)->is_waiting_for_migrate_data()) { /* Migration in progress (code is running on the destination host): * 1. Add the client to spice char device, if it was not already added. * 2.a If this (qemu-kvm state load side of migration) happens first @@ -3837,10 +3836,10 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds) g_list_free_full(reds->qxl_instances, (GDestroyNotify)red_qxl_destroy); if (reds->inputs_channel) { - red_channel_destroy(RED_CHANNEL(reds->inputs_channel)); + RED_CHANNEL(reds->inputs_channel)->destroy(); } if (reds->main_channel) { - red_channel_destroy(RED_CHANNEL(reds->main_channel)); + RED_CHANNEL(reds->main_channel)->destroy(); } red_timer_remove(reds->mig_timer); @@ -4274,8 +4273,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_connect(SpiceServer *reds, const cha * be valid (see reds_reset_vdp for more details). */ try_seamless = reds->seamless_migration_enabled && - red_channel_test_remote_cap(RED_CHANNEL(reds->main_channel), - SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS); + RED_CHANNEL(reds->main_channel)->test_remote_cap(SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS); /* main channel will take care of clients that are still during migration (at target)*/ if (main_channel_migrate_connect(reds->main_channel, reds->config->mig_spice, try_seamless)) { diff --git a/server/smartcard.cpp b/server/smartcard.cpp index eb3ca7a7..3e0fa6ae 100644 --- a/server/smartcard.cpp +++ b/server/smartcard.cpp @@ -541,7 +541,7 @@ static void red_smartcard_channel_constructed(GObject *object) { RedSmartcardChannel *self = RED_SMARTCARD_CHANNEL(object); - RedsState *reds = red_channel_get_server(self); + RedsState *reds = self->get_server(); G_OBJECT_CLASS(red_smartcard_channel_parent_class)->constructed(object); diff --git a/server/sound.cpp b/server/sound.cpp index aa6f064b..51deb0da 100644 --- a/server/sound.cpp +++ b/server/sound.cpp @@ -253,7 +253,7 @@ static void snd_send(SndChannelClient * client); /* sound channels only support a single client */ static SndChannelClient *snd_channel_get_client(SndChannel *channel) { - GList *clients = red_channel_get_clients(channel); + GList *clients = channel->get_clients(); if (clients == NULL) { return NULL; } @@ -264,7 +264,7 @@ static SndChannelClient *snd_channel_get_client(SndChannel *channel) static RedsState* snd_channel_get_server(SndChannelClient *client) { g_return_val_if_fail(client != NULL, NULL); - return red_channel_get_server(client->get_channel()); + return client->get_channel()->get_server(); } static void snd_playback_free_frame(PlaybackChannelClient *playback_client, AudioFrame *frame) @@ -1068,7 +1068,7 @@ playback_channel_client_constructed(GObject *object) bool client_can_opus = rcc->test_remote_cap(SPICE_PLAYBACK_CAP_OPUS); bool playback_compression = - reds_config_get_playback_compression(red_channel_get_server(red_channel)); + reds_config_get_playback_compression(red_channel->get_server()); int desired_mode = snd_desired_audio_mode(playback_compression, channel->frequency, client_can_opus); if (desired_mode != SPICE_AUDIO_DATA_MODE_RAW) { if (snd_codec_create(&playback_client->codec, desired_mode, channel->frequency, @@ -1239,7 +1239,7 @@ static void snd_set_rate(SndChannel *channel, uint32_t frequency, uint32_t cap_o { channel->frequency = frequency; if (channel && snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, frequency)) { - red_channel_set_cap(channel, cap_opus); + channel->set_cap(cap_opus); } } @@ -1362,11 +1362,11 @@ static void playback_channel_constructed(GObject *object) { SndChannel *self = SND_CHANNEL(object); - RedsState *reds = red_channel_get_server(self); + RedsState *reds = self->get_server(); G_OBJECT_CLASS(playback_channel_parent_class)->constructed(object); - red_channel_set_cap(self, SPICE_PLAYBACK_CAP_VOLUME); + self->set_cap(SPICE_PLAYBACK_CAP_VOLUME); add_channel(self); reds_register_channel(reds, self); @@ -1408,11 +1408,11 @@ static void record_channel_constructed(GObject *object) { SndChannel *self = SND_CHANNEL(object); - RedsState *reds = red_channel_get_server(self); + RedsState *reds = self->get_server(); G_OBJECT_CLASS(record_channel_parent_class)->constructed(object); - red_channel_set_cap(self, SPICE_RECORD_CAP_VOLUME); + self->set_cap(SPICE_RECORD_CAP_VOLUME); add_channel(self); reds_register_channel(reds, self); @@ -1451,7 +1451,7 @@ static void snd_detach_common(SndChannel *channel) return; } - red_channel_destroy(channel); + channel->destroy(); } void snd_detach_playback(SpicePlaybackInstance *sin) diff --git a/server/spicevmc.cpp b/server/spicevmc.cpp index 5e92bd61..20afd28a 100644 --- a/server/spicevmc.cpp +++ b/server/spicevmc.cpp @@ -180,12 +180,12 @@ static void red_vmc_channel_constructed(GObject *object) { RedVmcChannel *self = RED_VMC_CHANNEL(object); - RedsState *reds = red_channel_get_server(self); + RedsState *reds = self->get_server(); G_OBJECT_CLASS(red_vmc_channel_parent_class)->constructed(object); - red_channel_init_stat_node(self, NULL, "spicevmc"); - const RedStatNode *stat = red_channel_get_stat_node(self); + self->init_stat_node(NULL, "spicevmc"); + const RedStatNode *stat = self->get_stat_node(); stat_init_counter(&self->in_data, reds, stat, "in_data", TRUE); stat_init_counter(&self->in_compressed, reds, stat, "in_compressed", TRUE); stat_init_counter(&self->in_decompressed, reds, stat, "in_decompressed", TRUE); @@ -194,7 +194,7 @@ red_vmc_channel_constructed(GObject *object) stat_init_counter(&self->out_uncompressed, reds, stat, "out_uncompressed", TRUE); #ifdef USE_LZ4 - red_channel_set_cap(self, SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4); + self->set_cap(SPICE_SPICEVMC_CAP_DATA_COMPRESS_LZ4); #endif reds_register_channel(reds, self); @@ -852,7 +852,7 @@ red_char_device_spicevmc_dispose(GObject *object) self->channel->chardev = NULL; // close all current connections and drop the reference - red_channel_destroy(self->channel); + self->channel->destroy(); self->channel = NULL; } G_OBJECT_CLASS(red_char_device_spicevmc_parent_class)->dispose(object); diff --git a/server/stream-channel.cpp b/server/stream-channel.cpp index afbb7ddf..46f73089 100644 --- a/server/stream-channel.cpp +++ b/server/stream-channel.cpp @@ -162,7 +162,7 @@ stream_channel_client_on_disconnect(RedChannelClient *rcc) // if there are still some client connected keep streaming // TODO, maybe would be worth sending new codecs if they are better - if (red_channel_is_connected(channel)) { + if (channel->is_connected()) { return; } @@ -477,13 +477,13 @@ static void stream_channel_constructed(GObject *object) { RedChannel *red_channel = RED_CHANNEL(object); - RedsState *reds = red_channel_get_server(red_channel); + RedsState *reds = red_channel->get_server(); G_OBJECT_CLASS(stream_channel_parent_class)->constructed(object); - red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG); - red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_STREAM_REPORT); - red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE); + red_channel->set_cap(SPICE_DISPLAY_CAP_MONITORS_CONFIG); + red_channel->set_cap(SPICE_DISPLAY_CAP_STREAM_REPORT); + red_channel->set_cap(SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE); reds_register_channel(reds, red_channel); } @@ -515,19 +515,19 @@ void stream_channel_change_format(StreamChannel *channel, const StreamMsgFormat *fmt) { // send destroy old stream - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_STREAM_DESTROY); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_STREAM_DESTROY); // send new create surface if required if (channel->width != fmt->width || channel->height != fmt->height) { if (channel->width != 0 && channel->height != 0) { - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_SURFACE_DESTROY); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_SURFACE_DESTROY); } channel->width = fmt->width; channel->height = fmt->height; - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_SURFACE_CREATE); - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_MONITORS_CONFIG); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_SURFACE_CREATE); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_MONITORS_CONFIG); // TODO monitors config ?? - red_channel_pipes_add_empty_msg(channel, SPICE_MSG_DISPLAY_MARK); + channel->pipes_add_empty_msg(SPICE_MSG_DISPLAY_MARK); } // allocate a new stream id @@ -545,10 +545,10 @@ stream_channel_change_format(StreamChannel *channel, const StreamMsgFormat *fmt) item->stream_create.src_height = fmt->height; item->stream_create.dest = (SpiceRect) { 0, 0, fmt->width, fmt->height }; item->stream_create.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, NULL }; - red_channel_pipes_add(channel, &item->base); + channel->pipes_add(&item->base); // activate stream report if possible - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT); } static inline void @@ -592,7 +592,7 @@ stream_channel_send_data(StreamChannel *channel, const void *data, size_t size, stream_channel_update_queue_stat(channel, 1, size); // TODO try to optimize avoiding the copy memcpy(item->data.data, data, size); - red_channel_pipes_add(channel, &item->base); + channel->pipes_add(&item->base); } void @@ -621,18 +621,18 @@ stream_channel_reset(StreamChannel *channel) StreamMsgStartStop *const start = &start_msg.base; // send destroy old stream - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_STREAM_DESTROY); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_STREAM_DESTROY); // destroy display surface if (channel->width != 0 && channel->height != 0) { - red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_SURFACE_DESTROY); + channel->pipes_add_type(RED_PIPE_ITEM_TYPE_SURFACE_DESTROY); } channel->stream_id = -1; channel->width = 0; channel->height = 0; - if (!red_channel_is_connected(channel)) { + if (!channel->is_connected()) { return; } diff --git a/server/tests/test-channel.cpp b/server/tests/test-channel.cpp index 73556971..ed083f1a 100644 --- a/server/tests/test-channel.cpp +++ b/server/tests/test-channel.cpp @@ -295,8 +295,8 @@ static void channel_loop(void) server_core->watch_add = watch_add_inject; // create our testing RedChannelClient - red_channel_connect(channel, client, create_dummy_stream(server, &client_socket), - FALSE, &caps); + channel->connect(client, create_dummy_stream(server, &client_socket), + FALSE, &caps); red_channel_capabilities_reset(&caps); // remove code to inject code during RedChannelClient watch, we set it diff --git a/server/tests/test-smartcard.cpp b/server/tests/test-smartcard.cpp index a4d56892..9beaa0f4 100644 --- a/server/tests/test-smartcard.cpp +++ b/server/tests/test-smartcard.cpp @@ -359,8 +359,7 @@ static void test_smartcard(TestFixture *fixture, gconstpointer user_data) g_assert_nonnull(mcc); // create our testing RedChannelClient - red_channel_connect(channel, client, create_dummy_stream(server, &client_socket), - FALSE, &caps); + channel->connect(client, create_dummy_stream(server, &client_socket), FALSE, &caps); red_channel_capabilities_reset(&caps); // push data to device diff --git a/server/video-stream.cpp b/server/video-stream.cpp index 8d8f2b33..22742eee 100644 --- a/server/video-stream.cpp +++ b/server/video-stream.cpp @@ -348,7 +348,7 @@ static void before_reattach_stream(DisplayChannel *display, spice_return_if_fail(stream->current); - if (!red_channel_is_connected(display)) { + if (!display->is_connected()) { return; } @@ -925,7 +925,7 @@ void video_stream_detach_behind(DisplayChannel *display, Ring *ring = &display->priv->streams; RingItem *item = ring_get_head(ring); DisplayChannelClient *dcc; - bool is_connected = red_channel_is_connected(display); + bool is_connected = display->is_connected(); while (item) { VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);