mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-25 22:18:58 +00:00
red-channel-client: Move migrate as virtual method
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
2b04f644f6
commit
28a4fc5a10
@ -60,12 +60,10 @@ void CursorChannelClient::on_disconnect()
|
||||
cursor_channel_client_reset_cursor_cache(this);
|
||||
}
|
||||
|
||||
void cursor_channel_client_migrate(RedChannelClient *rcc)
|
||||
void CursorChannelClient::migrate()
|
||||
{
|
||||
spice_return_if_fail(rcc);
|
||||
|
||||
rcc->pipe_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
|
||||
RedChannelClient::default_migrate(rcc);
|
||||
pipe_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
|
||||
RedChannelClient::migrate();
|
||||
}
|
||||
|
||||
CursorChannelClient::CursorChannelClient(RedChannel *channel,
|
||||
|
||||
@ -40,6 +40,11 @@ public:
|
||||
protected:
|
||||
virtual void on_disconnect() override;
|
||||
void send_item(RedPipeItem *pipe_item) override;
|
||||
/**
|
||||
* Migrate a client channel from a CursorChannel.
|
||||
* This is the equivalent of RedChannel client migrate callback.
|
||||
*/
|
||||
virtual void migrate() override;
|
||||
|
||||
public:
|
||||
red::unique_link<CursorChannelClientPrivate> priv;
|
||||
@ -61,12 +66,6 @@ enum {
|
||||
RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
|
||||
};
|
||||
|
||||
/**
|
||||
* Migrate a client channel from a CursorChannel.
|
||||
* This is the equivalent of RedChannel client migrate callback.
|
||||
*/
|
||||
void cursor_channel_client_migrate(RedChannelClient *client);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* CURSOR_CHANNEL_CLIENT_H_ */
|
||||
|
||||
@ -386,7 +386,6 @@ cursor_channel_class_init(CursorChannelClass *klass)
|
||||
|
||||
// client callbacks
|
||||
channel_class->connect = (channel_client_connect_proc) cursor_channel_connect;
|
||||
channel_class->migrate = cursor_channel_client_migrate;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -50,6 +50,7 @@ protected:
|
||||
virtual void on_disconnect() override;
|
||||
virtual void send_item(RedPipeItem *item) override;
|
||||
virtual bool handle_migrate_data(uint32_t size, void *message) override;
|
||||
virtual void migrate() override;
|
||||
|
||||
public:
|
||||
red::unique_link<DisplayChannelClientPrivate> priv;
|
||||
|
||||
@ -27,7 +27,6 @@ static void display_channel_connect(RedChannel *channel, RedClient *client,
|
||||
RedStream *stream, int migration,
|
||||
RedChannelCapabilities *caps);
|
||||
static void display_channel_disconnect(RedChannelClient *rcc);
|
||||
static void display_channel_migrate(RedChannelClient *rcc);
|
||||
|
||||
enum {
|
||||
PROP0,
|
||||
@ -2508,7 +2507,6 @@ display_channel_class_init(DisplayChannelClass *klass)
|
||||
// client callbacks
|
||||
channel_class->connect = display_channel_connect;
|
||||
channel_class->disconnect = display_channel_disconnect;
|
||||
channel_class->migrate = display_channel_migrate;
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_N_SURFACES,
|
||||
@ -2629,9 +2627,9 @@ static void display_channel_disconnect(RedChannelClient *rcc)
|
||||
rcc->disconnect();
|
||||
}
|
||||
|
||||
static void display_channel_migrate(RedChannelClient *rcc)
|
||||
void DisplayChannelClient::migrate()
|
||||
{
|
||||
DisplayChannel *display = DISPLAY_CHANNEL(rcc->get_channel());
|
||||
DisplayChannel *display = DISPLAY_CHANNEL(get_channel());
|
||||
|
||||
/* We need to stop the streams, and to send upgrade_items to the client.
|
||||
* Otherwise, (1) the client might display lossy regions that we don't track
|
||||
@ -2644,8 +2642,8 @@ static void display_channel_migrate(RedChannelClient *rcc)
|
||||
* handle_dev_stop already took care of releasing all the dev ram resources.
|
||||
*/
|
||||
video_stream_detach_and_stop(display);
|
||||
if (rcc->is_connected()) {
|
||||
RedChannelClient::default_migrate(rcc);
|
||||
if (is_connected()) {
|
||||
RedChannelClient::migrate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ protected:
|
||||
virtual void on_disconnect() override;
|
||||
virtual void send_item(RedPipeItem *base) override;
|
||||
virtual bool handle_migrate_data(uint32_t size, void *message) override;
|
||||
virtual void migrate() override;
|
||||
};
|
||||
|
||||
RedChannelClient* inputs_channel_client_create(RedChannel *channel,
|
||||
|
||||
@ -488,11 +488,11 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
|
||||
inputs_pipe_add_init(rcc);
|
||||
}
|
||||
|
||||
static void inputs_migrate(RedChannelClient *rcc)
|
||||
void InputsChannelClient::migrate()
|
||||
{
|
||||
InputsChannel *inputs = INPUTS_CHANNEL(rcc->get_channel());
|
||||
InputsChannel *inputs = INPUTS_CHANNEL(get_channel());
|
||||
inputs->src_during_migrate = TRUE;
|
||||
RedChannelClient::default_migrate(rcc);
|
||||
RedChannelClient::migrate();
|
||||
}
|
||||
|
||||
static void inputs_channel_push_keyboard_modifiers(InputsChannel *inputs, uint8_t modifiers)
|
||||
@ -615,7 +615,6 @@ inputs_channel_class_init(InputsChannelClass *klass)
|
||||
|
||||
// client callbacks
|
||||
channel_class->connect = inputs_connect;
|
||||
channel_class->migrate = inputs_migrate;
|
||||
}
|
||||
|
||||
static SpiceKbdInstance* inputs_channel_get_keyboard(InputsChannel *inputs)
|
||||
|
||||
@ -570,14 +570,11 @@ uint64_t main_channel_client_get_roundtrip_ms(MainChannelClient *mcc)
|
||||
return mcc->priv->latency / 1000;
|
||||
}
|
||||
|
||||
XXX_CAST(RedChannelClient, MainChannelClient, MAIN_CHANNEL_CLIENT);
|
||||
|
||||
void main_channel_client_migrate(RedChannelClient *rcc)
|
||||
void MainChannelClient::migrate()
|
||||
{
|
||||
RedChannel *channel = rcc->get_channel();
|
||||
reds_on_main_channel_migrate(channel->get_server(),
|
||||
MAIN_CHANNEL_CLIENT(rcc));
|
||||
RedChannelClient::default_migrate(rcc);
|
||||
RedChannel *channel = get_channel();
|
||||
reds_on_main_channel_migrate(channel->get_server(), this);
|
||||
RedChannelClient::migrate();
|
||||
}
|
||||
|
||||
gboolean main_channel_client_connect_semi_seamless(MainChannelClient *mcc)
|
||||
|
||||
@ -44,6 +44,7 @@ protected:
|
||||
virtual bool handle_message(uint16_t type, uint32_t size, void *message) override;
|
||||
virtual void send_item(RedPipeItem *item) override;
|
||||
virtual bool handle_migrate_data(uint32_t size, void *message) override;
|
||||
virtual void migrate() override;
|
||||
|
||||
public:
|
||||
red::unique_link<MainChannelClientPrivate> priv;
|
||||
@ -66,7 +67,6 @@ void main_channel_client_push_init(MainChannelClient *mcc,
|
||||
int multi_media_time,
|
||||
int ram_hint);
|
||||
void main_channel_client_push_notify(MainChannelClient *mcc, const char *msg);
|
||||
void main_channel_client_migrate(RedChannelClient *rcc);
|
||||
gboolean main_channel_client_connect_semi_seamless(MainChannelClient *mcc);
|
||||
void main_channel_client_connect_seamless(MainChannelClient *mcc);
|
||||
void main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
|
||||
|
||||
@ -277,9 +277,6 @@ main_channel_class_init(MainChannelClass *klass)
|
||||
|
||||
/* channel callbacks */
|
||||
channel_class->handle_migrate_flush_mark = main_channel_handle_migrate_flush_mark;
|
||||
|
||||
// client callbacks
|
||||
channel_class->migrate = main_channel_client_migrate;
|
||||
}
|
||||
|
||||
static int main_channel_connect_semi_seamless(MainChannel *main_channel)
|
||||
|
||||
@ -912,16 +912,16 @@ bool RedChannelClient::is_waiting_for_migrate_data() const
|
||||
return priv->wait_migrate_data;
|
||||
}
|
||||
|
||||
void RedChannelClient::default_migrate(RedChannelClient *rcc)
|
||||
void RedChannelClient::migrate()
|
||||
{
|
||||
rcc->priv->cancel_ping_timer();
|
||||
red_timer_remove(rcc->priv->latency_monitor.timer);
|
||||
rcc->priv->latency_monitor.timer = NULL;
|
||||
priv->cancel_ping_timer();
|
||||
red_timer_remove(priv->latency_monitor.timer);
|
||||
priv->latency_monitor.timer = NULL;
|
||||
|
||||
red_timer_remove(rcc->priv->connectivity_monitor.timer);
|
||||
rcc->priv->connectivity_monitor.timer = NULL;
|
||||
red_timer_remove(priv->connectivity_monitor.timer);
|
||||
priv->connectivity_monitor.timer = NULL;
|
||||
|
||||
rcc->pipe_add_type(RED_PIPE_ITEM_TYPE_MIGRATE);
|
||||
pipe_add_type(RED_PIPE_ITEM_TYPE_MIGRATE);
|
||||
}
|
||||
|
||||
void RedChannelClient::shutdown()
|
||||
|
||||
@ -48,7 +48,6 @@ public:
|
||||
virtual bool init();
|
||||
|
||||
bool is_connected() const;
|
||||
static void default_migrate(RedChannelClient *rcc);
|
||||
bool is_waiting_for_migrate_data() const;
|
||||
bool test_remote_common_cap(uint32_t cap) const;
|
||||
bool test_remote_cap(uint32_t cap) const;
|
||||
@ -152,6 +151,9 @@ public:
|
||||
void ref() { g_atomic_int_inc(&_ref); }
|
||||
void unref() { if (g_atomic_int_dec_and_test(&_ref)) delete this; }
|
||||
|
||||
// callback from client
|
||||
virtual void migrate();
|
||||
|
||||
/* configure socket connected to the client */
|
||||
virtual bool config_socket() { return true; }
|
||||
virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size)=0;
|
||||
|
||||
@ -301,7 +301,6 @@ red_channel_class_init(RedChannelClass *klass)
|
||||
|
||||
klass->connect = red_channel_client_default_connect;
|
||||
klass->disconnect = red_channel_client_default_disconnect;
|
||||
klass->migrate = RedChannelClient::default_migrate;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -708,10 +707,8 @@ typedef struct RedMessageMigrate {
|
||||
static void handle_dispatcher_migrate(void *opaque, void *payload)
|
||||
{
|
||||
RedMessageMigrate *msg = (RedMessageMigrate*) payload;
|
||||
RedChannel *channel = msg->rcc->get_channel();
|
||||
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel);
|
||||
|
||||
klass->migrate(msg->rcc);
|
||||
msg->rcc->migrate();
|
||||
msg->rcc->unref();
|
||||
}
|
||||
|
||||
@ -719,8 +716,7 @@ void RedChannel::migrate_client(RedChannelClient *rcc)
|
||||
{
|
||||
if (priv->dispatcher == NULL ||
|
||||
pthread_equal(pthread_self(), priv->thread_id)) {
|
||||
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(this);
|
||||
klass->migrate(rcc);
|
||||
rcc->migrate();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,6 @@ typedef uint64_t (*channel_handle_migrate_data_get_serial_proc)(RedChannelClient
|
||||
typedef void (*channel_client_connect_proc)(RedChannel *channel, RedClient *client, RedStream *stream,
|
||||
int migration, RedChannelCapabilities *caps);
|
||||
typedef void (*channel_client_disconnect_proc)(RedChannelClient *base);
|
||||
typedef void (*channel_client_migrate_proc)(RedChannelClient *base);
|
||||
|
||||
|
||||
static inline gboolean test_capability(const uint32_t *caps, int num_caps, uint32_t cap)
|
||||
@ -82,7 +81,6 @@ struct RedChannelClass
|
||||
*/
|
||||
channel_client_connect_proc connect;
|
||||
channel_client_disconnect_proc disconnect;
|
||||
channel_client_migrate_proc migrate;
|
||||
};
|
||||
|
||||
#define FOREACH_CLIENT(_channel, _data) \
|
||||
|
||||
@ -105,6 +105,7 @@ public:
|
||||
virtual bool config_socket() override;
|
||||
virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
|
||||
virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
|
||||
virtual void migrate() override;
|
||||
};
|
||||
|
||||
static void snd_playback_alloc_frames(PlaybackChannelClient *playback);
|
||||
@ -1101,12 +1102,10 @@ static void snd_set_playback_peer(RedChannel *red_channel, RedClient *client, Re
|
||||
}
|
||||
}
|
||||
|
||||
XXX_CAST(RedChannelClient, SndChannelClient, SND_CHANNEL_CLIENT)
|
||||
|
||||
static void snd_migrate_channel_client(RedChannelClient *rcc)
|
||||
void SndChannelClient::migrate()
|
||||
{
|
||||
snd_set_command(SND_CHANNEL_CLIENT(rcc), SND_MIGRATE_MASK);
|
||||
snd_send(SND_CHANNEL_CLIENT(rcc));
|
||||
snd_set_command(this, SND_MIGRATE_MASK);
|
||||
snd_send(this);
|
||||
}
|
||||
|
||||
SPICE_GNUC_VISIBLE void spice_server_record_set_volume(SpiceRecordInstance *sin,
|
||||
@ -1320,7 +1319,6 @@ playback_channel_class_init(PlaybackChannelClass *klass)
|
||||
|
||||
// client callbacks
|
||||
channel_class->connect = snd_set_playback_peer;
|
||||
channel_class->migrate = snd_migrate_channel_client;
|
||||
}
|
||||
|
||||
void snd_attach_playback(RedsState *reds, SpicePlaybackInstance *sin)
|
||||
@ -1364,7 +1362,6 @@ record_channel_class_init(RecordChannelClass *klass)
|
||||
|
||||
// client callbacks
|
||||
channel_class->connect = snd_set_record_peer;
|
||||
channel_class->migrate = snd_migrate_channel_client;
|
||||
}
|
||||
|
||||
void snd_attach_record(RedsState *reds, SpiceRecordInstance *sin)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user