[Spice-devel] [spice-server 1/8] Remove red_channel_set_data()
Jonathon Jongsma
jjongsma at redhat.com
Thu Mar 17 18:32:44 UTC 2016
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
On Mon, 2016-03-14 at 18:10 +0100, Christophe Fergeau wrote:
> It's always called at the same time as red_channel_register_client_cbs()
> and the data is used by the callbacks, so we can pass the data as an
> argument to red_channel_register_client_cbs().
> ---
> server/inputs-channel.c | 2 +-
> server/main-channel.c | 2 +-
> server/red-channel.c | 13 ++++---------
> server/red-channel.h | 3 +--
> server/red-qxl.c | 6 ++----
> server/smartcard.c | 2 +-
> server/sound.c | 6 ++----
> server/spicevmc.c | 2 +-
> 8 files changed, 13 insertions(+), 23 deletions(-)
>
> diff --git a/server/inputs-channel.c b/server/inputs-channel.c
> index ca8166d..45e0a8f 100644
> --- a/server/inputs-channel.c
> +++ b/server/inputs-channel.c
> @@ -650,7 +650,7 @@ InputsChannel* inputs_channel_new(RedsState *reds)
>
> client_cbs.connect = inputs_connect;
> client_cbs.migrate = inputs_migrate;
> - red_channel_register_client_cbs(&inputs->base, &client_cbs);
> + red_channel_register_client_cbs(&inputs->base, &client_cbs, NULL);
>
> red_channel_set_cap(&inputs->base, SPICE_INPUTS_CAP_KEY_SCANCODE);
> reds_register_channel(reds, &inputs->base);
> diff --git a/server/main-channel.c b/server/main-channel.c
> index 9901135..a9d0ce1 100644
> --- a/server/main-channel.c
> +++ b/server/main-channel.c
> @@ -1184,7 +1184,7 @@ MainChannel* main_channel_new(RedsState *reds)
> red_channel_set_cap(channel, SPICE_MAIN_CAP_SEAMLESS_MIGRATE);
>
> client_cbs.migrate = main_channel_client_migrate;
> - red_channel_register_client_cbs(channel, &client_cbs);
> + red_channel_register_client_cbs(channel, &client_cbs, NULL);
>
> return (MainChannel *)channel;
> }
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 3909c63..d8f1d27 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -1064,7 +1064,7 @@ RedChannel *red_channel_create(int size,
> client_cbs.disconnect = red_channel_client_default_disconnect;
> client_cbs.migrate = red_channel_client_default_migrate;
>
> - red_channel_register_client_cbs(channel, &client_cbs);
> + red_channel_register_client_cbs(channel, &client_cbs, NULL);
> red_channel_set_common_cap(channel, SPICE_COMMON_CAP_MINI_HEADER);
>
> channel->thread_id = pthread_self();
> @@ -1115,7 +1115,7 @@ RedChannel *red_channel_create_dummy(int size, RedsState
> *reds, uint32_t type, u
> client_cbs.disconnect = red_channel_client_default_disconnect;
> client_cbs.migrate = red_channel_client_default_migrate;
>
> - red_channel_register_client_cbs(channel, &client_cbs);
> + red_channel_register_client_cbs(channel, &client_cbs, NULL);
> red_channel_set_common_cap(channel, SPICE_COMMON_CAP_MINI_HEADER);
>
> channel->thread_id = pthread_self();
> @@ -1171,7 +1171,7 @@ void red_channel_set_stat_node(RedChannel *channel,
> StatNodeRef stat)
> #endif
> }
>
> -void red_channel_register_client_cbs(RedChannel *channel, const ClientCbs
> *client_cbs)
> +void red_channel_register_client_cbs(RedChannel *channel, const ClientCbs
> *client_cbs, gpointer cbs_data)
> {
> spice_assert(client_cbs->connect || channel->type == SPICE_CHANNEL_MAIN);
> channel->client_cbs.connect = client_cbs->connect;
> @@ -1183,6 +1183,7 @@ void red_channel_register_client_cbs(RedChannel
> *channel, const ClientCbs *clien
> if (client_cbs->migrate) {
> channel->client_cbs.migrate = client_cbs->migrate;
> }
> + channel->data = cbs_data;
> }
>
> int test_capability(const uint32_t *caps, int num_caps, uint32_t cap)
> @@ -1217,12 +1218,6 @@ void red_channel_set_cap(RedChannel *channel, uint32_t
> cap)
> add_capability(&channel->local_caps.caps, &channel->local_caps.num_caps,
> cap);
> }
>
> -void red_channel_set_data(RedChannel *channel, void *data)
> -{
> - spice_assert(channel);
> - channel->data = data;
> -}
> -
> static void red_channel_ref(RedChannel *channel)
> {
> channel->refs++;
> diff --git a/server/red-channel.h b/server/red-channel.h
> index 7c1c95d..26304bf 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -383,11 +383,10 @@ RedChannel *red_channel_create_parser(int size,
> uint32_t migration_flags);
> void red_channel_set_stat_node(RedChannel *channel, StatNodeRef stat);
>
> -void red_channel_register_client_cbs(RedChannel *channel, const ClientCbs
> *client_cbs);
> +void red_channel_register_client_cbs(RedChannel *channel, const ClientCbs
> *client_cbs, gpointer cbs_data);
> // 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);
> -void red_channel_set_data(RedChannel *channel, void *data);
>
> RedChannelClient *red_channel_client_create(int size, RedChannel *channel,
> RedClient *client,
> RedsStream *stream,
> diff --git a/server/red-qxl.c b/server/red-qxl.c
> index 491046f..ee3cab0 100644
> --- a/server/red-qxl.c
> +++ b/server/red-qxl.c
> @@ -985,16 +985,14 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
> client_cbs.connect = red_qxl_set_cursor_peer;
> client_cbs.disconnect = red_qxl_disconnect_cursor_peer;
> client_cbs.migrate = red_qxl_cursor_migrate;
> - red_channel_register_client_cbs(channel, &client_cbs);
> - red_channel_set_data(channel, qxl_state);
> + red_channel_register_client_cbs(channel, &client_cbs, qxl_state);
> reds_register_channel(reds, channel);
>
> channel = red_worker_get_display_channel(worker);
> client_cbs.connect = red_qxl_set_display_peer;
> client_cbs.disconnect = red_qxl_disconnect_display_peer;
> client_cbs.migrate = red_qxl_display_migrate;
> - red_channel_register_client_cbs(channel, &client_cbs);
> - red_channel_set_data(channel, qxl_state);
> + red_channel_register_client_cbs(channel, &client_cbs, qxl_state);
> red_channel_set_cap(channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
> red_channel_set_cap(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION);
> red_channel_set_cap(channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
> diff --git a/server/smartcard.c b/server/smartcard.c
> index 55382e2..2b25bac 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -863,7 +863,7 @@ static void smartcard_init(void)
> }
>
> client_cbs.connect = smartcard_connect_client;
> - red_channel_register_client_cbs(&g_smartcard_channel->base, &client_cbs);
> + red_channel_register_client_cbs(&g_smartcard_channel->base, &client_cbs,
> NULL);
>
> reds_register_channel(reds, &g_smartcard_channel->base);
> }
> diff --git a/server/sound.c b/server/sound.c
> index 1aa3a74..82c14f7 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -1534,8 +1534,7 @@ void snd_attach_playback(RedsState *reds,
> SpicePlaybackInstance *sin)
> client_cbs.connect = snd_set_playback_peer;
> client_cbs.disconnect = snd_disconnect_channel_client;
> client_cbs.migrate = snd_playback_migrate_channel_client;
> - red_channel_register_client_cbs(channel, &client_cbs);
> - red_channel_set_data(channel, playback_worker);
> + red_channel_register_client_cbs(channel, &client_cbs, playback_worker);
>
> if (snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_CELT_0_5_1,
> SND_CODEC_ANY_FREQUENCY))
> red_channel_set_cap(channel, SPICE_PLAYBACK_CAP_CELT_0_5_1);
> @@ -1564,8 +1563,7 @@ void snd_attach_record(RedsState *reds,
> SpiceRecordInstance *sin)
> client_cbs.connect = snd_set_record_peer;
> client_cbs.disconnect = snd_disconnect_channel_client;
> client_cbs.migrate = snd_record_migrate_channel_client;
> - red_channel_register_client_cbs(channel, &client_cbs);
> - red_channel_set_data(channel, record_worker);
> + red_channel_register_client_cbs(channel, &client_cbs, record_worker);
> if (snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_CELT_0_5_1,
> SND_CODEC_ANY_FREQUENCY))
> red_channel_set_cap(channel, SPICE_RECORD_CAP_CELT_0_5_1);
> red_channel_set_cap(channel, SPICE_RECORD_CAP_VOLUME);
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 1050fde..f745fdb 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -528,7 +528,7 @@ SpiceCharDeviceState *spicevmc_device_connect(RedsState
> *reds,
> red_channel_init_outgoing_messages_window(&state->channel);
>
> client_cbs.connect = spicevmc_connect;
> - red_channel_register_client_cbs(&state->channel, &client_cbs);
> + red_channel_register_client_cbs(&state->channel, &client_cbs, NULL);
>
> char_dev_cbs.read_one_msg_from_device =
> spicevmc_chardev_read_msg_from_dev;
> char_dev_cbs.ref_msg_to_client = spicevmc_chardev_ref_msg_to_client;
More information about the Spice-devel
mailing list