The RedChannel argument is not used by pipe_item_init. Removing it will make code simpler in places where we don't have a RedChannel directly available. This is acting on a PipeItem object so correct name is pipe_item_init. --- server/cache-item.tmpl.c | 3 +-- server/cursor-channel.c | 2 +- server/dcc.c | 26 +++++++++----------------- server/inputs-channel.c | 6 ++---- server/main-channel.c | 26 +++++++++----------------- server/red-channel.c | 6 +++--- server/red-channel.h | 2 +- server/red-worker.h | 2 +- server/smartcard.c | 6 ++---- server/spicevmc.c | 7 +++---- server/stream.c | 12 ++++-------- 11 files changed, 36 insertions(+), 62 deletions(-) diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c index efc26c3..23b0bc1 100644 --- a/server/cache-item.tmpl.c +++ b/server/cache-item.tmpl.c @@ -66,7 +66,6 @@ static CacheItem *FUNC_NAME(find)(CHANNELCLIENT *channel_client, uint64_t id) static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, CacheItem *item) { CacheItem **now; - CHANNEL *channel = CHANNEL_FROM_RCC(&channel_client->common.base); spice_assert(item); now = &channel_client->CACHE_NAME[CACHE_HASH_KEY(item->id)]; @@ -82,7 +81,7 @@ static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, CacheItem *item) channel_client->VAR_NAME(items)--; channel_client->VAR_NAME(available) += item->size; - red_channel_pipe_item_init(&channel->common.base, &item->u.pipe_data, PIPE_ITEM_TYPE_INVAL_ONE); + pipe_item_init(&item->u.pipe_data, PIPE_ITEM_TYPE_INVAL_ONE); red_channel_client_pipe_add_tail_and_push(&channel_client->common.base, &item->u.pipe_data); // for now } diff --git a/server/cursor-channel.c b/server/cursor-channel.c index f5cb5ee..a904cff 100644 --- a/server/cursor-channel.c +++ b/server/cursor-channel.c @@ -136,7 +136,7 @@ static PipeItem *new_cursor_pipe_item(RedChannelClient *rcc, void *data, int num { CursorPipeItem *item = spice_malloc0(sizeof(CursorPipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_CURSOR); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_CURSOR); item->refs = 1; item->cursor_item = data; item->cursor_item->refs++; diff --git a/server/dcc.c b/server/dcc.c index 1f71423..c952042 100644 --- a/server/dcc.c +++ b/server/dcc.c @@ -38,8 +38,7 @@ static SurfaceCreateItem *surface_create_item_new(RedChannel* channel, create->surface_create.flags = flags; create->surface_create.format = format; - red_channel_pipe_item_init(channel, - &create->pipe_item, PIPE_ITEM_TYPE_CREATE_SURFACE); + pipe_item_init(&create->pipe_item, PIPE_ITEM_TYPE_CREATE_SURFACE); return create; } @@ -167,7 +166,6 @@ ImageItem *dcc_add_surface_area_image(DisplayChannelClient *dcc, int surface_id, SpiceRect *area, PipeItem *pos, int can_lossy) { DisplayChannel *display = DCC_TO_DC(dcc); - RedChannel *channel = RED_CHANNEL(display); RedSurface *surface = &display->surfaces[surface_id]; SpiceCanvas *canvas = surface->context.canvas; ImageItem *item; @@ -186,7 +184,7 @@ ImageItem *dcc_add_surface_area_image(DisplayChannelClient *dcc, int surface_id, item = (ImageItem *)spice_malloc_n_m(height, stride, sizeof(ImageItem)); - red_channel_pipe_item_init(channel, &item->link, PIPE_ITEM_TYPE_IMAGE); + pipe_item_init(&item->link, PIPE_ITEM_TYPE_IMAGE); item->refs = 1; item->surface_id = surface_id; @@ -305,8 +303,7 @@ static DrawablePipeItem *drawable_pipe_item_new(DisplayChannelClient *dcc, Drawa dpi->dcc = dcc; ring_item_init(&dpi->base); ring_add(&drawable->pipes, &dpi->base); - red_channel_pipe_item_init(RED_CHANNEL_CLIENT(dcc)->channel, - &dpi->dpi_pipe_item, PIPE_ITEM_TYPE_DRAW); + pipe_item_init(&dpi->dpi_pipe_item, PIPE_ITEM_TYPE_DRAW); dpi->refs++; drawable->refs++; return dpi; @@ -340,15 +337,14 @@ static void dcc_init_stream_agents(DisplayChannelClient *dcc) { int i; DisplayChannel *display = DCC_TO_DC(dcc); - RedChannel *channel = RED_CHANNEL_CLIENT(dcc)->channel; for (i = 0; i < NUM_STREAMS; i++) { StreamAgent *agent = &dcc->stream_agents[i]; agent->stream = &display->streams_buf[i]; region_init(&agent->vis_region); region_init(&agent->clip); - red_channel_pipe_item_init(channel, &agent->create_item, PIPE_ITEM_TYPE_STREAM_CREATE); - red_channel_pipe_item_init(channel, &agent->destroy_item, PIPE_ITEM_TYPE_STREAM_DESTROY); + pipe_item_init(&agent->create_item, PIPE_ITEM_TYPE_STREAM_CREATE); + pipe_item_init(&agent->destroy_item, PIPE_ITEM_TYPE_STREAM_DESTROY); } dcc->use_mjpeg_encoder_rate_control = red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(dcc), SPICE_DISPLAY_CAP_STREAM_REPORT); @@ -529,8 +525,7 @@ static MonitorsConfigItem *monitors_config_item_new(RedChannel* channel, mci = (MonitorsConfigItem *)spice_malloc(sizeof(*mci)); mci->monitors_config = monitors_config; - red_channel_pipe_item_init(channel, - &mci->pipe_item, PIPE_ITEM_TYPE_MONITORS_CONFIG); + pipe_item_init(&mci->pipe_item, PIPE_ITEM_TYPE_MONITORS_CONFIG); return mci; } @@ -563,8 +558,7 @@ static SurfaceDestroyItem *surface_destroy_item_new(RedChannel *channel, destroy = spice_malloc(sizeof(SurfaceDestroyItem)); destroy->surface_destroy.surface_id = surface_id; - red_channel_pipe_item_init(channel, &destroy->pipe_item, - PIPE_ITEM_TYPE_DESTROY_SURFACE); + pipe_item_init(&destroy->pipe_item, PIPE_ITEM_TYPE_DESTROY_SURFACE); return destroy; } @@ -582,8 +576,7 @@ PipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc, void *data, int num) return NULL; } - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_GL_SCANOUT); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_GL_SCANOUT); return &item->base; } @@ -603,8 +596,7 @@ PipeItem *dcc_gl_draw_item_new(RedChannelClient *rcc, void *data, int num) dcc->gl_draw_ongoing = TRUE; item->draw = *draw; - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_GL_DRAW); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_GL_DRAW); return &item->base; } diff --git a/server/inputs-channel.c b/server/inputs-channel.c index 6533526..ca8166d 100644 --- a/server/inputs-channel.c +++ b/server/inputs-channel.c @@ -234,8 +234,7 @@ static PipeItem *inputs_key_modifiers_item_new( { KeyModifiersPipeItem *item = spice_malloc(sizeof(KeyModifiersPipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_KEY_MODIFIERS); + pipe_item_init(&item->base, PIPE_ITEM_KEY_MODIFIERS); item->modifiers = *(uint8_t *)data; return &item->base; } @@ -504,8 +503,7 @@ static void inputs_pipe_add_init(RedChannelClient *rcc) InputsInitPipeItem *item = spice_malloc(sizeof(InputsInitPipeItem)); InputsChannel *inputs = SPICE_CONTAINEROF(rcc->channel, InputsChannel, base); - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_INPUTS_INIT); + pipe_item_init(&item->base, PIPE_ITEM_INPUTS_INIT); item->modifiers = kbd_get_leds(inputs_channel_get_keyboard(inputs)); red_channel_client_pipe_add_push(rcc, &item->base); } diff --git a/server/main-channel.c b/server/main-channel.c index c72d7d5..9901135 100644 --- a/server/main-channel.c +++ b/server/main-channel.c @@ -226,8 +226,7 @@ static PipeItem *main_mouse_mode_item_new(RedChannelClient *rcc, void *data, int MouseModePipeItem *item = spice_malloc(sizeof(MouseModePipeItem)); MainMouseModeItemInfo *info = data; - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_MAIN_MOUSE_MODE); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_MOUSE_MODE); item->current_mode = info->current_mode; item->is_client_mouse_allowed = info->is_client_mouse_allowed; return &item->base; @@ -237,7 +236,7 @@ static PipeItem *main_ping_item_new(MainChannelClient *mcc, int size) { PingPipeItem *item = spice_malloc(sizeof(PingPipeItem)); - red_channel_pipe_item_init(mcc->base.channel, &item->base, PIPE_ITEM_TYPE_MAIN_PING); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_PING); item->size = size; return &item->base; } @@ -246,8 +245,7 @@ static PipeItem *main_agent_tokens_item_new(RedChannelClient *rcc, uint32_t num_ { TokensPipeItem *item = spice_malloc(sizeof(TokensPipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_MAIN_AGENT_TOKEN); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_AGENT_TOKEN); item->tokens = num_tokens; return &item->base; } @@ -258,8 +256,7 @@ static PipeItem *main_agent_data_item_new(RedChannelClient *rcc, uint8_t* data, { AgentDataPipeItem *item = spice_malloc(sizeof(AgentDataPipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_MAIN_AGENT_DATA); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_AGENT_DATA); item->data = data; item->len = len; item->free_data = free_data; @@ -274,8 +271,7 @@ static PipeItem *main_init_item_new(MainChannelClient *mcc, { InitPipeItem *item = spice_malloc(sizeof(InitPipeItem)); - red_channel_pipe_item_init(mcc->base.channel, &item->base, - PIPE_ITEM_TYPE_MAIN_INIT); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_INIT); item->connection_id = connection_id; item->display_channels_hint = display_channels_hint; item->current_mouse_mode = current_mouse_mode; @@ -289,8 +285,7 @@ static PipeItem *main_name_item_new(MainChannelClient *mcc, const char *name) { NamePipeItem *item = spice_malloc(sizeof(NamePipeItem) + strlen(name) + 1); - red_channel_pipe_item_init(mcc->base.channel, &item->base, - PIPE_ITEM_TYPE_MAIN_NAME); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_NAME); item->msg.name_len = strlen(name) + 1; memcpy(&item->msg.name, name, item->msg.name_len); @@ -301,8 +296,7 @@ static PipeItem *main_uuid_item_new(MainChannelClient *mcc, const uint8_t uuid[1 { UuidPipeItem *item = spice_malloc(sizeof(UuidPipeItem)); - red_channel_pipe_item_init(mcc->base.channel, &item->base, - PIPE_ITEM_TYPE_MAIN_UUID); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_UUID); memcpy(item->msg.uuid, uuid, sizeof(item->msg.uuid)); return &item->base; @@ -313,8 +307,7 @@ static PipeItem *main_notify_item_new(RedChannelClient *rcc, void *data, int num NotifyPipeItem *item = spice_malloc(sizeof(NotifyPipeItem)); const char *msg = data; - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_MAIN_NOTIFY); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_NOTIFY); item->msg = spice_strdup(msg); return &item->base; } @@ -325,8 +318,7 @@ static PipeItem *main_multi_media_time_item_new( MultiMediaTimePipeItem *item, *info = data; item = spice_malloc(sizeof(MultiMediaTimePipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, - PIPE_ITEM_TYPE_MAIN_MULTI_MEDIA_TIME); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_MAIN_MULTI_MEDIA_TIME); item->time = info->time; return &item->base; } diff --git a/server/red-channel.c b/server/red-channel.c index 3ee6192..3909c63 100644 --- a/server/red-channel.c +++ b/server/red-channel.c @@ -1663,7 +1663,7 @@ void red_channel_client_set_message_serial(RedChannelClient *rcc, uint64_t seria rcc->send_data.serial = serial; } -void red_channel_pipe_item_init(RedChannel *channel, PipeItem *item, int type) +void pipe_item_init(PipeItem *item, int type) { ring_item_init(&item->link); item->type = type; @@ -1729,7 +1729,7 @@ void red_channel_client_pipe_add_type(RedChannelClient *rcc, int pipe_item_type) { PipeItem *item = spice_new(PipeItem, 1); - red_channel_pipe_item_init(rcc->channel, item, pipe_item_type); + pipe_item_init(item, pipe_item_type); red_channel_client_pipe_add(rcc, item); red_channel_client_push(rcc); } @@ -1749,7 +1749,7 @@ void red_channel_client_pipe_add_empty_msg(RedChannelClient *rcc, int msg_type) { EmptyMsgPipeItem *item = spice_new(EmptyMsgPipeItem, 1); - red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_EMPTY_MSG); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_EMPTY_MSG); item->msg = msg_type; red_channel_client_pipe_add(rcc, &item->base); red_channel_client_push(rcc); diff --git a/server/red-channel.h b/server/red-channel.h index 2d61bc5..7c1c95d 100644 --- a/server/red-channel.h +++ b/server/red-channel.h @@ -476,7 +476,7 @@ int red_channel_client_get_roundtrip_ms(RedChannelClient *rcc); */ void red_channel_client_start_connectivity_monitoring(RedChannelClient *rcc, uint32_t timeout_ms); -void red_channel_pipe_item_init(RedChannel *channel, PipeItem *item, int type); +void pipe_item_init(PipeItem *item, int type); // TODO: add back the channel_pipe_add functionality - by adding reference counting // to the PipeItem. diff --git a/server/red-worker.h b/server/red-worker.h index c93f66c..7faf0b3 100644 --- a/server/red-worker.h +++ b/server/red-worker.h @@ -70,7 +70,7 @@ static inline void red_pipe_add_verb(RedChannelClient* rcc, uint16_t verb) { VerbItem *item = spice_new(VerbItem, 1); - red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_VERB); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_VERB); item->verb = verb; red_channel_client_pipe_add(rcc, &item->base); } diff --git a/server/smartcard.c b/server/smartcard.c index 6071f59..97462df 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -576,8 +576,7 @@ static void smartcard_push_error(RedChannelClient *rcc, uint32_t reader_id, VSCE { ErrorItem *error_item = spice_new0(ErrorItem, 1); - red_channel_pipe_item_init(rcc->channel, &error_item->base, - PIPE_ITEM_TYPE_ERROR); + pipe_item_init(&error_item->base, PIPE_ITEM_TYPE_ERROR); error_item->base.type = PIPE_ITEM_TYPE_ERROR; error_item->vheader.reader_id = reader_id; @@ -591,8 +590,7 @@ static MsgItem *smartcard_get_vsc_msg_item(RedChannelClient *rcc, VSCMsgHeader * { MsgItem *msg_item = spice_new0(MsgItem, 1); - red_channel_pipe_item_init(rcc->channel, &msg_item->base, - PIPE_ITEM_TYPE_SMARTCARD_DATA); + pipe_item_init(&msg_item->base, PIPE_ITEM_TYPE_SMARTCARD_DATA); msg_item->refs = 1; msg_item->vheader = vheader; return msg_item; diff --git a/server/spicevmc.c b/server/spicevmc.c index 929ec0e..1050fde 100644 --- a/server/spicevmc.c +++ b/server/spicevmc.c @@ -121,8 +121,7 @@ static SpiceCharDeviceMsgToClient *spicevmc_chardev_read_msg_from_dev(SpiceCharD if (!state->pipe_item) { msg_item = spice_new0(SpiceVmcPipeItem, 1); msg_item->refs = 1; - red_channel_pipe_item_init(&state->channel, - &msg_item->base, PIPE_ITEM_TYPE_SPICEVMC_DATA); + pipe_item_init(&msg_item->base, PIPE_ITEM_TYPE_SPICEVMC_DATA); } else { spice_assert(state->pipe_item->buf_used == 0); msg_item = state->pipe_item; @@ -159,7 +158,7 @@ static void spicevmc_port_send_init(RedChannelClient *rcc) SpiceCharDeviceInstance *sin = state->chardev_sin; PortInitPipeItem *item = spice_malloc(sizeof(PortInitPipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_PORT_INIT); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_PORT_INIT); item->name = strdup(sin->portname); item->opened = state->port_opened; red_channel_client_pipe_add_push(rcc, &item->base); @@ -169,7 +168,7 @@ static void spicevmc_port_send_event(RedChannelClient *rcc, uint8_t event) { PortEventPipeItem *item = spice_malloc(sizeof(PortEventPipeItem)); - red_channel_pipe_item_init(rcc->channel, &item->base, PIPE_ITEM_TYPE_PORT_EVENT); + pipe_item_init(&item->base, PIPE_ITEM_TYPE_PORT_EVENT); item->event = event; red_channel_client_pipe_add_push(rcc, &item->base); } diff --git a/server/stream.c b/server/stream.c index e98ed69..548c4c7 100644 --- a/server/stream.c +++ b/server/stream.c @@ -136,8 +136,7 @@ void stream_agent_unref(DisplayChannel *display, StreamAgent *agent) StreamClipItem *stream_clip_item_new(DisplayChannelClient* dcc, StreamAgent *agent) { StreamClipItem *item = spice_new(StreamClipItem, 1); - red_channel_pipe_item_init(RED_CHANNEL_CLIENT(dcc)->channel, - (PipeItem *)item, PIPE_ITEM_TYPE_STREAM_CLIP); + pipe_item_init((PipeItem *)item, PIPE_ITEM_TYPE_STREAM_CLIP); item->stream_agent = agent; agent->stream->refs++; @@ -735,8 +734,8 @@ void dcc_create_stream(DisplayChannelClient *dcc, Stream *stream) StreamActivateReportItem *report_pipe_item = spice_malloc0(sizeof(*report_pipe_item)); agent->report_id = rand(); - red_channel_pipe_item_init(RED_CHANNEL_CLIENT(dcc)->channel, &report_pipe_item->pipe_item, - PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT); + pipe_item_init(&report_pipe_item->pipe_item, + PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT); report_pipe_item->stream_id = get_stream_id(DCC_TO_DC(dcc), stream); red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &report_pipe_item->pipe_item); } @@ -782,7 +781,6 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc, if (stream->current && region_contains(&stream->current->tree_item.base.rgn, &agent->vis_region)) { - RedChannel *channel; RedChannelClient *rcc; UpgradeItem *upgrade_item; int n_rects; @@ -799,11 +797,9 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc, stream_id, stream->current->sized_stream != NULL); rect_debug(&stream->current->red_drawable->bbox); rcc = RED_CHANNEL_CLIENT(dcc); - channel = rcc->channel; upgrade_item = spice_new(UpgradeItem, 1); upgrade_item->refs = 1; - red_channel_pipe_item_init(channel, - &upgrade_item->base, PIPE_ITEM_TYPE_UPGRADE); + pipe_item_init(&upgrade_item->base, PIPE_ITEM_TYPE_UPGRADE); upgrade_item->drawable = stream->current; upgrade_item->drawable->refs++; n_rects = pixman_region32_n_rects(&upgrade_item->drawable->tree_item.base.rgn); -- 2.5.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel