mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-30 17:49:02 +00:00
Avoid useless downcast to RedChannelClient or RedChannel
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
3720e5a686
commit
08fab74cd7
@ -117,12 +117,11 @@ static void red_marshall_cursor_init(CursorChannelClient *ccc, SpiceMarshaller *
|
||||
spice_assert(ccc);
|
||||
|
||||
CursorChannel *cursor_channel;
|
||||
RedChannelClient *rcc = ccc;
|
||||
SpiceMsgCursorInit msg;
|
||||
|
||||
cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(ccc));
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT);
|
||||
red_channel_client_init_send_data(ccc, SPICE_MSG_CURSOR_INIT);
|
||||
msg.visible = cursor_channel->cursor_visible;
|
||||
msg.position = cursor_channel->cursor_position;
|
||||
msg.trail_length = cursor_channel->cursor_trail_length;
|
||||
@ -136,8 +135,7 @@ static void red_marshall_cursor(CursorChannelClient *ccc,
|
||||
SpiceMarshaller *m,
|
||||
RedCursorPipeItem *cursor_pipe_item)
|
||||
{
|
||||
RedChannelClient *rcc = ccc;
|
||||
CursorChannel *cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
CursorChannel *cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(ccc));
|
||||
RedCursorPipeItem *item = cursor_pipe_item;
|
||||
RedCursorCmd *cmd;
|
||||
|
||||
@ -148,7 +146,7 @@ static void red_marshall_cursor(CursorChannelClient *ccc,
|
||||
case QXL_CURSOR_MOVE:
|
||||
{
|
||||
SpiceMsgCursorMove cursor_move;
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_MOVE);
|
||||
red_channel_client_init_send_data(ccc, SPICE_MSG_CURSOR_MOVE);
|
||||
cursor_move.position = cmd->u.position;
|
||||
spice_marshall_msg_cursor_move(m, &cursor_move);
|
||||
break;
|
||||
@ -157,7 +155,7 @@ static void red_marshall_cursor(CursorChannelClient *ccc,
|
||||
{
|
||||
SpiceMsgCursorSet cursor_set;
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_SET);
|
||||
red_channel_client_init_send_data(ccc, SPICE_MSG_CURSOR_SET);
|
||||
cursor_set.position = cmd->u.set.position;
|
||||
cursor_set.visible = cursor_channel->cursor_visible;
|
||||
|
||||
@ -166,13 +164,13 @@ static void red_marshall_cursor(CursorChannelClient *ccc,
|
||||
break;
|
||||
}
|
||||
case QXL_CURSOR_HIDE:
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_HIDE);
|
||||
red_channel_client_init_send_data(ccc, SPICE_MSG_CURSOR_HIDE);
|
||||
break;
|
||||
case QXL_CURSOR_TRAIL:
|
||||
{
|
||||
SpiceMsgCursorTrail cursor_trail;
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_TRAIL);
|
||||
red_channel_client_init_send_data(ccc, SPICE_MSG_CURSOR_TRAIL);
|
||||
cursor_trail.length = cmd->u.trail.length;
|
||||
cursor_trail.frequency = cmd->u.trail.frequency;
|
||||
spice_marshall_msg_cursor_trail(m, &cursor_trail);
|
||||
@ -283,8 +281,6 @@ void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd)
|
||||
|
||||
void cursor_channel_reset(CursorChannel *cursor)
|
||||
{
|
||||
RedChannel *channel = cursor;
|
||||
|
||||
spice_return_if_fail(cursor);
|
||||
|
||||
cursor_channel_set_item(cursor, NULL);
|
||||
@ -292,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(channel)) {
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
|
||||
if (red_channel_is_connected(cursor)) {
|
||||
red_channel_pipes_add_type(cursor, RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
|
||||
if (!common_graphics_channel_get_during_target_migrate(COMMON_GRAPHICS_CHANNEL(cursor))) {
|
||||
red_channel_pipes_add_empty_msg(channel, SPICE_MSG_CURSOR_RESET);
|
||||
red_channel_pipes_add_empty_msg(cursor, SPICE_MSG_CURSOR_RESET);
|
||||
}
|
||||
red_channel_wait_all_sent(channel, COMMON_CLIENT_TIMEOUT);
|
||||
red_channel_wait_all_sent(cursor, COMMON_CLIENT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,9 +345,8 @@ cursor_channel_connect(CursorChannel *cursor, RedClient *client, RedStream *stre
|
||||
return;
|
||||
}
|
||||
|
||||
RedChannelClient *rcc = ccc;
|
||||
red_channel_client_ack_zero_messages_window(rcc);
|
||||
red_channel_client_push_set_ack(rcc);
|
||||
red_channel_client_ack_zero_messages_window(ccc);
|
||||
red_channel_client_push_set_ack(ccc);
|
||||
|
||||
cursor_channel_init_client(cursor, ccc);
|
||||
}
|
||||
|
||||
@ -356,7 +356,6 @@ static void marshaller_unref_drawable(uint8_t *data, void *opaque)
|
||||
static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
|
||||
SpiceImage *simage, Drawable *drawable, int can_lossy)
|
||||
{
|
||||
RedChannelClient *rcc = dcc;
|
||||
DisplayChannel *display = DCC_TO_DC(dcc);
|
||||
SpiceImage image;
|
||||
compress_send_data_t comp_send_data = {0};
|
||||
@ -437,12 +436,12 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
|
||||
/* Images must be added to the cache only after they are compressed
|
||||
in order to prevent starvation in the client between pixmap_cache and
|
||||
global dictionary (in cases of multiple monitors) */
|
||||
if (red_stream_get_family(red_channel_client_get_stream(rcc)) == AF_UNIX ||
|
||||
if (red_stream_get_family(red_channel_client_get_stream(dcc)) == AF_UNIX ||
|
||||
!dcc_compress_image(dcc, &image, &simage->u.bitmap,
|
||||
drawable, can_lossy, &comp_send_data)) {
|
||||
SpicePalette *palette;
|
||||
|
||||
red_display_add_image_to_pixmap_cache(rcc, simage, &image, FALSE);
|
||||
red_display_add_image_to_pixmap_cache(dcc, simage, &image, FALSE);
|
||||
|
||||
*bitmap = simage->u.bitmap;
|
||||
bitmap->flags = bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN;
|
||||
@ -468,7 +467,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
|
||||
pthread_mutex_unlock(&dcc->priv->pixmap_cache->lock);
|
||||
return FILL_BITS_TYPE_BITMAP;
|
||||
} else {
|
||||
red_display_add_image_to_pixmap_cache(rcc, simage, &image,
|
||||
red_display_add_image_to_pixmap_cache(dcc, simage, &image,
|
||||
comp_send_data.is_lossy);
|
||||
|
||||
spice_marshall_Image(m, &image,
|
||||
@ -490,7 +489,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
|
||||
break;
|
||||
}
|
||||
case SPICE_IMAGE_TYPE_QUIC:
|
||||
red_display_add_image_to_pixmap_cache(rcc, simage, &image, FALSE);
|
||||
red_display_add_image_to_pixmap_cache(dcc, simage, &image, FALSE);
|
||||
image.u.quic = simage->u.quic;
|
||||
spice_marshall_Image(m, &image,
|
||||
&bitmap_palette_out, &lzplt_palette_out);
|
||||
|
||||
@ -228,14 +228,12 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
|
||||
{
|
||||
GList *l;
|
||||
int x;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
spice_return_val_if_fail(dcc != NULL, TRUE);
|
||||
/* removing the newest drawables that their destination is surface_id and
|
||||
no other drawable depends on them */
|
||||
|
||||
rcc = dcc;
|
||||
for (l = red_channel_client_get_pipe(rcc)->head; l != NULL; ) {
|
||||
for (l = red_channel_client_get_pipe(dcc)->head; l != NULL; ) {
|
||||
Drawable *drawable;
|
||||
RedDrawablePipeItem *dpi = NULL;
|
||||
int depend_found = FALSE;
|
||||
@ -253,7 +251,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
|
||||
}
|
||||
|
||||
if (drawable->surface_id == surface_id) {
|
||||
red_channel_client_pipe_remove_and_release_pos(rcc, item_pos);
|
||||
red_channel_client_pipe_remove_and_release_pos(dcc, item_pos);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -269,7 +267,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
|
||||
if (!wait_if_used) {
|
||||
return TRUE;
|
||||
}
|
||||
return red_channel_client_wait_pipe_item_sent(rcc, item_pos,
|
||||
return red_channel_client_wait_pipe_item_sent(dcc, item_pos,
|
||||
COMMON_CLIENT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
@ -282,7 +280,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
|
||||
* in case that the pipe didn't contain any item that is dependent on the surface, but
|
||||
* there is one during sending. Use a shorter timeout, since it is just one item
|
||||
*/
|
||||
return red_channel_client_wait_outgoing_item(rcc, DISPLAY_CLIENT_SHORT_TIMEOUT);
|
||||
return red_channel_client_wait_outgoing_item(dcc, DISPLAY_CLIENT_SHORT_TIMEOUT);
|
||||
}
|
||||
|
||||
void dcc_create_surface(DisplayChannelClient *dcc, int surface_id)
|
||||
@ -565,31 +563,30 @@ static bool display_channel_client_wait_for_init(DisplayChannelClient *dcc)
|
||||
void dcc_start(DisplayChannelClient *dcc)
|
||||
{
|
||||
DisplayChannel *display = DCC_TO_DC(dcc);
|
||||
RedChannelClient *rcc = dcc;
|
||||
|
||||
red_channel_client_push_set_ack(rcc);
|
||||
red_channel_client_push_set_ack(dcc);
|
||||
|
||||
if (red_channel_client_is_waiting_for_migrate_data(rcc))
|
||||
if (red_channel_client_is_waiting_for_migrate_data(dcc))
|
||||
return;
|
||||
|
||||
if (!display_channel_client_wait_for_init(dcc))
|
||||
return;
|
||||
|
||||
g_object_ref(dcc);
|
||||
red_channel_client_ack_zero_messages_window(rcc);
|
||||
red_channel_client_ack_zero_messages_window(dcc);
|
||||
if (display->priv->surfaces[0].context.canvas) {
|
||||
display_channel_current_flush(display, 0);
|
||||
red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
|
||||
red_channel_client_pipe_add_type(dcc, RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
|
||||
dcc_create_surface(dcc, 0);
|
||||
dcc_push_surface_image(dcc, 0);
|
||||
dcc_push_monitors_config(dcc);
|
||||
red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_MARK);
|
||||
red_channel_client_pipe_add_empty_msg(dcc, SPICE_MSG_DISPLAY_MARK);
|
||||
dcc_create_all_streams(dcc);
|
||||
}
|
||||
|
||||
if (red_stream_is_plain_unix(red_channel_client_get_stream(rcc)) &&
|
||||
red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_GL_SCANOUT)) {
|
||||
red_channel_client_pipe_add(rcc, dcc_gl_scanout_item_new(rcc, NULL, 0));
|
||||
if (red_stream_is_plain_unix(red_channel_client_get_stream(dcc)) &&
|
||||
red_channel_client_test_remote_cap(dcc, SPICE_DISPLAY_CAP_GL_SCANOUT)) {
|
||||
red_channel_client_pipe_add(dcc, dcc_gl_scanout_item_new(dcc, NULL, 0));
|
||||
dcc_push_monitors_config(dcc);
|
||||
}
|
||||
g_object_unref(dcc);
|
||||
|
||||
@ -92,7 +92,7 @@ typedef struct FreeList {
|
||||
WaitForChannels wait;
|
||||
} FreeList;
|
||||
|
||||
#define DCC_TO_DC(dcc) ((DisplayChannel*)red_channel_client_get_channel((RedChannelClient*)dcc))
|
||||
#define DCC_TO_DC(dcc) ((DisplayChannel*)red_channel_client_get_channel(dcc))
|
||||
|
||||
typedef struct RedSurfaceCreateItem {
|
||||
RedPipeItem base;
|
||||
|
||||
@ -2546,14 +2546,12 @@ display_channel_class_init(DisplayChannelClass *klass)
|
||||
|
||||
void display_channel_debug_oom(DisplayChannel *display, const char *msg)
|
||||
{
|
||||
RedChannel *channel = display;
|
||||
|
||||
spice_debug("%s #draw=%u, #glz_draw=%u current %u pipes %u",
|
||||
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(channel));
|
||||
red_channel_sum_pipes_size(display));
|
||||
}
|
||||
|
||||
static void guest_set_client_capabilities(DisplayChannel *display)
|
||||
|
||||
@ -488,7 +488,6 @@ void main_channel_client_handle_migrate_dst_do_seamless(MainChannelClient *mcc,
|
||||
void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping, uint32_t size)
|
||||
{
|
||||
uint64_t roundtrip;
|
||||
RedChannelClient* rcc = mcc;
|
||||
|
||||
roundtrip = spice_get_monotonic_time_ns() / NSEC_PER_MICROSEC - ping->timestamp;
|
||||
|
||||
@ -496,7 +495,7 @@ void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping,
|
||||
/*
|
||||
* channel client monitors the connectivity using ping-pong messages
|
||||
*/
|
||||
red_channel_client_handle_message(rcc, SPICE_MSGC_PONG, size, ping);
|
||||
red_channel_client_handle_message(mcc, SPICE_MSGC_PONG, size, ping);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -515,30 +514,30 @@ void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping,
|
||||
mcc->priv->net_test_id = 0;
|
||||
if (roundtrip <= mcc->priv->latency) {
|
||||
// probably high load on client or server result with incorrect values
|
||||
red_channel_debug(red_channel_client_get_channel(rcc),
|
||||
red_channel_debug(red_channel_client_get_channel(mcc),
|
||||
"net test: invalid values, latency %" G_GUINT64_FORMAT
|
||||
" roundtrip %" G_GUINT64_FORMAT ". assuming high"
|
||||
"bandwidth", mcc->priv->latency, roundtrip);
|
||||
mcc->priv->latency = 0;
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_INVALID;
|
||||
red_channel_client_start_connectivity_monitoring(rcc,
|
||||
red_channel_client_start_connectivity_monitoring(mcc,
|
||||
CLIENT_CONNECTIVITY_TIMEOUT);
|
||||
break;
|
||||
}
|
||||
mcc->priv->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
|
||||
/ (roundtrip - mcc->priv->latency);
|
||||
mcc->priv->net_test_stage = NET_TEST_STAGE_COMPLETE;
|
||||
red_channel_debug(red_channel_client_get_channel(rcc),
|
||||
red_channel_debug(red_channel_client_get_channel(mcc),
|
||||
"net test: latency %f ms, bitrate %" G_GUINT64_FORMAT " bps (%f Mbps)%s",
|
||||
(double)mcc->priv->latency / 1000,
|
||||
mcc->priv->bitrate_per_sec,
|
||||
(double)mcc->priv->bitrate_per_sec / 1024 / 1024,
|
||||
main_channel_client_is_low_bandwidth(mcc) ? " LOW BANDWIDTH" : "");
|
||||
red_channel_client_start_connectivity_monitoring(rcc,
|
||||
red_channel_client_start_connectivity_monitoring(mcc,
|
||||
CLIENT_CONNECTIVITY_TIMEOUT);
|
||||
break;
|
||||
default:
|
||||
red_channel_warning(red_channel_client_get_channel(rcc),
|
||||
red_channel_warning(red_channel_client_get_channel(mcc),
|
||||
"invalid net test stage, ping id %d test id %d stage %d",
|
||||
ping->id,
|
||||
mcc->priv->net_test_id,
|
||||
@ -595,21 +594,20 @@ gboolean main_channel_client_migrate_src_complete(MainChannelClient *mcc,
|
||||
gboolean success)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
RedChannelClient *rcc = mcc;
|
||||
bool semi_seamless_support = red_channel_client_test_remote_cap(rcc,
|
||||
bool semi_seamless_support = red_channel_client_test_remote_cap(mcc,
|
||||
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE);
|
||||
if (semi_seamless_support && mcc->priv->mig_connect_ok) {
|
||||
if (success) {
|
||||
red_channel_client_pipe_add_empty_msg(rcc,
|
||||
red_channel_client_pipe_add_empty_msg(mcc,
|
||||
SPICE_MSG_MAIN_MIGRATE_END);
|
||||
ret = TRUE;
|
||||
} else {
|
||||
red_channel_client_pipe_add_empty_msg(rcc,
|
||||
red_channel_client_pipe_add_empty_msg(mcc,
|
||||
SPICE_MSG_MAIN_MIGRATE_CANCEL);
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
red_channel_client_pipe_add_type(rcc,
|
||||
red_channel_client_pipe_add_type(mcc,
|
||||
RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_SWITCH_HOST);
|
||||
}
|
||||
}
|
||||
@ -669,15 +667,14 @@ void main_channel_client_migrate(RedChannelClient *rcc)
|
||||
|
||||
gboolean main_channel_client_connect_semi_seamless(MainChannelClient *mcc)
|
||||
{
|
||||
RedChannelClient *rcc = mcc;
|
||||
if (red_channel_client_test_remote_cap(rcc,
|
||||
if (red_channel_client_test_remote_cap(mcc,
|
||||
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE)) {
|
||||
RedClient *client = red_channel_client_get_client(rcc);
|
||||
RedClient *client = red_channel_client_get_client(mcc);
|
||||
if (red_client_during_migrate_at_target(client)) {
|
||||
mcc->priv->mig_wait_prev_complete = TRUE;
|
||||
mcc->priv->mig_wait_prev_try_seamless = FALSE;
|
||||
} else {
|
||||
red_channel_client_pipe_add_type(rcc,
|
||||
red_channel_client_pipe_add_type(mcc,
|
||||
RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_BEGIN);
|
||||
mcc->priv->mig_wait_connect = TRUE;
|
||||
}
|
||||
@ -689,15 +686,14 @@ gboolean main_channel_client_connect_semi_seamless(MainChannelClient *mcc)
|
||||
|
||||
void main_channel_client_connect_seamless(MainChannelClient *mcc)
|
||||
{
|
||||
RedChannelClient *rcc = mcc;
|
||||
RedClient *client = red_channel_client_get_client(rcc);
|
||||
spice_assert(red_channel_client_test_remote_cap(rcc,
|
||||
RedClient *client = red_channel_client_get_client(mcc);
|
||||
spice_assert(red_channel_client_test_remote_cap(mcc,
|
||||
SPICE_MAIN_CAP_SEAMLESS_MIGRATE));
|
||||
if (red_client_during_migrate_at_target(client)) {
|
||||
mcc->priv->mig_wait_prev_complete = TRUE;
|
||||
mcc->priv->mig_wait_prev_try_seamless = TRUE;
|
||||
} else {
|
||||
red_channel_client_pipe_add_type(rcc,
|
||||
red_channel_client_pipe_add_type(mcc,
|
||||
RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_BEGIN_SEAMLESS);
|
||||
mcc->priv->mig_wait_connect = TRUE;
|
||||
}
|
||||
|
||||
@ -60,14 +60,13 @@ RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t c
|
||||
|
||||
static void main_channel_push_channels(MainChannelClient *mcc)
|
||||
{
|
||||
RedChannelClient *rcc = mcc;
|
||||
if (red_client_during_migrate_at_target(red_channel_client_get_client(rcc))) {
|
||||
red_channel_warning(red_channel_client_get_channel(rcc),
|
||||
if (red_client_during_migrate_at_target(red_channel_client_get_client(mcc))) {
|
||||
red_channel_warning(red_channel_client_get_channel(mcc),
|
||||
"warning: ignoring unexpected SPICE_MSGC_MAIN_ATTACH_CHANNELS"
|
||||
"during migration");
|
||||
return;
|
||||
}
|
||||
red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_MAIN_CHANNELS_LIST);
|
||||
red_channel_client_pipe_add_type(mcc, RED_PIPE_ITEM_TYPE_MAIN_CHANNELS_LIST);
|
||||
}
|
||||
|
||||
void main_channel_push_mouse_mode(MainChannel *main_chan, SpiceMouseMode current_mode,
|
||||
|
||||
@ -437,16 +437,15 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
|
||||
display_channel_set_monitors_config_to_primary(display);
|
||||
|
||||
CommonGraphicsChannel *common = COMMON_GRAPHICS_CHANNEL(display);
|
||||
RedChannel *channel = display;
|
||||
if (red_channel_is_connected(channel) &&
|
||||
if (red_channel_is_connected(display) &&
|
||||
!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(channel, SPICE_MSG_DISPLAY_MARK);
|
||||
red_channel_push(channel);
|
||||
red_channel_pipes_add_empty_msg(display, SPICE_MSG_DISPLAY_MARK);
|
||||
red_channel_push(display);
|
||||
}
|
||||
|
||||
cursor_channel_do_init(worker->cursor_channel);
|
||||
@ -566,14 +565,13 @@ static void handle_dev_oom(void *opaque, void *payload)
|
||||
RedWorker *worker = (RedWorker*) opaque;
|
||||
DisplayChannel *display = worker->display_channel;
|
||||
|
||||
RedChannel *display_red_channel = display;
|
||||
int ring_is_empty;
|
||||
|
||||
spice_return_if_fail(red_qxl_is_running(worker->qxl));
|
||||
// streams? but without streams also leak
|
||||
display_channel_debug_oom(display, "OOM1");
|
||||
while (red_process_display(worker, &ring_is_empty)) {
|
||||
red_channel_push(display_red_channel);
|
||||
red_channel_push(display);
|
||||
}
|
||||
if (red_qxl_flush_resources(worker->qxl) == 0) {
|
||||
display_channel_free_some(worker->display_channel);
|
||||
|
||||
@ -1080,15 +1080,13 @@ SpiceMsgChannels *reds_msg_channels_new(RedsState *reds)
|
||||
void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens)
|
||||
{
|
||||
RedCharDevice *dev_state = RED_CHAR_DEVICE(reds->agent_dev);
|
||||
RedChannelClient *rcc;
|
||||
RedClient *client;
|
||||
|
||||
if (!reds->vdagent) {
|
||||
return;
|
||||
}
|
||||
spice_assert(reds->vdagent->st && reds->vdagent->st == dev_state);
|
||||
rcc = mcc;
|
||||
client = red_channel_client_get_client(rcc);
|
||||
client = red_channel_client_get_client(mcc);
|
||||
reds->agent_dev->priv->client_agent_started = true;
|
||||
/*
|
||||
* Note that in older releases, send_tokens were set to ~0 on both client
|
||||
@ -1106,11 +1104,11 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
|
||||
REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
|
||||
REDS_AGENT_WINDOW_SIZE,
|
||||
num_tokens,
|
||||
red_channel_client_is_waiting_for_migrate_data(rcc));
|
||||
red_channel_client_is_waiting_for_migrate_data(mcc));
|
||||
|
||||
if (!client_added) {
|
||||
spice_warning("failed to add client to agent");
|
||||
red_channel_client_shutdown(rcc);
|
||||
red_channel_client_shutdown(mcc);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -2012,8 +2010,7 @@ int reds_on_migrate_dst_set_seamless(RedsState *reds, MainChannelClient *mcc, ui
|
||||
if (reds->allow_multiple_clients || src_version > SPICE_MIGRATION_PROTOCOL_VERSION) {
|
||||
reds->dst_do_seamless_migrate = FALSE;
|
||||
} else {
|
||||
RedChannelClient *rcc = mcc;
|
||||
RedClient *client = red_channel_client_get_client(rcc);
|
||||
RedClient *client = red_channel_client_get_client(mcc);
|
||||
|
||||
red_client_set_migration_seamless(client);
|
||||
/* linking all the channels that have been connected before migration handshake */
|
||||
|
||||
@ -1239,10 +1239,9 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
|
||||
|
||||
static void snd_set_rate(SndChannel *channel, uint32_t frequency, uint32_t cap_opus)
|
||||
{
|
||||
RedChannel *red_channel = channel;
|
||||
channel->frequency = frequency;
|
||||
if (red_channel && snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, frequency)) {
|
||||
red_channel_set_cap(red_channel, cap_opus);
|
||||
if (channel && snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, frequency)) {
|
||||
red_channel_set_cap(channel, cap_opus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -158,15 +158,14 @@ request_new_stream(StreamChannel *channel, StreamMsgStartStop *start)
|
||||
static void
|
||||
stream_channel_client_on_disconnect(RedChannelClient *rcc)
|
||||
{
|
||||
RedChannel *red_channel = red_channel_client_get_channel(rcc);
|
||||
StreamChannel *channel = STREAM_CHANNEL(red_channel_client_get_channel(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(red_channel)) {
|
||||
if (red_channel_is_connected(channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
StreamChannel *channel = STREAM_CHANNEL(red_channel);
|
||||
channel->stream_id = -1;
|
||||
channel->width = 0;
|
||||
channel->height = 0;
|
||||
@ -515,22 +514,20 @@ stream_channel_init(StreamChannel *channel)
|
||||
void
|
||||
stream_channel_change_format(StreamChannel *channel, const StreamMsgFormat *fmt)
|
||||
{
|
||||
RedChannel *red_channel = channel;
|
||||
|
||||
// send destroy old stream
|
||||
red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_STREAM_DESTROY);
|
||||
red_channel_pipes_add_type(channel, 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(red_channel, RED_PIPE_ITEM_TYPE_SURFACE_DESTROY);
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_SURFACE_DESTROY);
|
||||
}
|
||||
channel->width = fmt->width;
|
||||
channel->height = fmt->height;
|
||||
red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_SURFACE_CREATE);
|
||||
red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_MONITORS_CONFIG);
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_SURFACE_CREATE);
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_MONITORS_CONFIG);
|
||||
// TODO monitors config ??
|
||||
red_channel_pipes_add_empty_msg(red_channel, SPICE_MSG_DISPLAY_MARK);
|
||||
red_channel_pipes_add_empty_msg(channel, SPICE_MSG_DISPLAY_MARK);
|
||||
}
|
||||
|
||||
// allocate a new stream id
|
||||
@ -548,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(red_channel, &item->base);
|
||||
red_channel_pipes_add(channel, &item->base);
|
||||
|
||||
// activate stream report if possible
|
||||
red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT);
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -585,8 +582,6 @@ stream_channel_send_data(StreamChannel *channel, const void *data, size_t size,
|
||||
return;
|
||||
}
|
||||
|
||||
RedChannel *red_channel = channel;
|
||||
|
||||
StreamDataItem *item = (StreamDataItem*) g_malloc(sizeof(*item) + size);
|
||||
red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_STREAM_DATA,
|
||||
data_item_free);
|
||||
@ -597,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(red_channel, &item->base);
|
||||
red_channel_pipes_add(channel, &item->base);
|
||||
}
|
||||
|
||||
void
|
||||
@ -624,21 +619,20 @@ stream_channel_reset(StreamChannel *channel)
|
||||
uint8_t codecs_buffer[MAX_SUPPORTED_CODECS];
|
||||
} start_msg;
|
||||
StreamMsgStartStop *const start = &start_msg.base;
|
||||
RedChannel *red_channel = channel;
|
||||
|
||||
// send destroy old stream
|
||||
red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_STREAM_DESTROY);
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_STREAM_DESTROY);
|
||||
|
||||
// destroy display surface
|
||||
if (channel->width != 0 && channel->height != 0) {
|
||||
red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_SURFACE_DESTROY);
|
||||
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_SURFACE_DESTROY);
|
||||
}
|
||||
|
||||
channel->stream_id = -1;
|
||||
channel->width = 0;
|
||||
channel->height = 0;
|
||||
|
||||
if (!red_channel_is_connected(red_channel)) {
|
||||
if (!red_channel_is_connected(channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -731,8 +731,7 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
|
||||
uint64_t starting_bit_rate,
|
||||
VideoEncoderRateControlCbs *cbs)
|
||||
{
|
||||
RedChannelClient *rcc = dcc;
|
||||
bool client_has_multi_codec = red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_MULTI_CODEC);
|
||||
bool client_has_multi_codec = red_channel_client_test_remote_cap(dcc, SPICE_DISPLAY_CAP_MULTI_CODEC);
|
||||
int i;
|
||||
GArray *video_codecs;
|
||||
|
||||
@ -746,7 +745,7 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
|
||||
continue;
|
||||
}
|
||||
if (client_has_multi_codec &&
|
||||
!red_channel_client_test_remote_cap(rcc, video_codec->cap)) {
|
||||
!red_channel_client_test_remote_cap(dcc, video_codec->cap)) {
|
||||
/* The client is recent but does not support this codec */
|
||||
continue;
|
||||
}
|
||||
@ -758,7 +757,7 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
|
||||
}
|
||||
|
||||
/* Try to use the builtin MJPEG video encoder as a fallback */
|
||||
if (!client_has_multi_codec || red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_CODEC_MJPEG)) {
|
||||
if (!client_has_multi_codec || red_channel_client_test_remote_cap(dcc, SPICE_DISPLAY_CAP_CODEC_MJPEG)) {
|
||||
return mjpeg_encoder_new(SPICE_VIDEO_CODEC_TYPE_MJPEG, starting_bit_rate, cbs, bitmap_ref, bitmap_unref);
|
||||
}
|
||||
|
||||
@ -854,7 +853,6 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
|
||||
|
||||
if (stream->current &&
|
||||
region_contains(&stream->current->tree_item.base.rgn, &agent->vis_region)) {
|
||||
RedChannelClient *rcc;
|
||||
RedUpgradeItem *upgrade_item;
|
||||
int n_rects;
|
||||
|
||||
@ -868,7 +866,6 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
|
||||
}
|
||||
spice_debug("stream %d: upgrade by drawable. box ==>", stream_id);
|
||||
rect_debug(&stream->current->red_drawable->bbox);
|
||||
rcc = dcc;
|
||||
upgrade_item = g_new(RedUpgradeItem, 1);
|
||||
red_pipe_item_init_full(&upgrade_item->base, RED_PIPE_ITEM_TYPE_UPGRADE,
|
||||
red_upgrade_item_free);
|
||||
@ -879,7 +876,7 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
|
||||
upgrade_item->rects->num_rects = n_rects;
|
||||
region_ret_rects(&upgrade_item->drawable->tree_item.base.rgn,
|
||||
upgrade_item->rects->rects, n_rects);
|
||||
red_channel_client_pipe_add(rcc, &upgrade_item->base);
|
||||
red_channel_client_pipe_add(dcc, &upgrade_item->base);
|
||||
|
||||
} else {
|
||||
SpiceRect upgrade_area;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user